<?php
/**
 * $Source: /home/cvs/nukescripts/kernel/authors.php,v $
 * $Revision: 1.1.0a $
 * $Author: cyril $
 * $Date: 2006/06/19 21:03:12 $
 *
 */
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or die ('Access denied authors MAXIMUS directly...');

function is_god($admin) {
    if (empty($admin)) { return NULL; }
  if(!is_array($admin)) {
    $tmpadm = base64_decode($admin);
    $tmpadm = explode(":", $tmpadm);
    $aname  = $tmpadm[0];
    $apwd   = $tmpadm[1];
  } else {
    $aname = $admin[0];
    $apwd  = $admin[1];
  }
  if (!empty($aname) AND !empty($apwd)) {
    $aname = trim($aname);
    $apwd  = trim($apwd);
    $sql   = "SELECT `name`, `pwd` FROM `".TABLE_AUTHORS."` WHERE `aid`='$aname' ";
    if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain pwd authors', '', __LINE__, __FILE__, $sql);}
    $admrow = $GLOBALS['db']->sql_fetchrow($result);
    if(strtolower($admrow['name']) == 'god' AND $admrow['pwd']==$apwd) { return 1; }
  }
  return 0;
}

function is_admin($admin) {
    if (empty($admin)) { return NULL; }
    if (isset($adminSave)) return $adminSave;
    if (!is_array($admin)) {
        $admin = base64_decode($admin);
        $admin = addslashes($admin);
        $admin = explode(":", $admin);
    }
    $aid = $admin[0];
    $pwd = $admin[1];
    $aid = substr(addslashes($aid), 0, 25);
    if (!empty($aid) && !empty($pwd)) {
        $sql = "SELECT `pwd` FROM `".TABLE_AUTHORS."` WHERE `aid`='$aid' ";
	if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain pwd table authors', '', __LINE__, __FILE__, $sql);}
        $pass = $GLOBALS['db']->sql_fetchrow($result);
        $GLOBALS['db']->sql_freeresult($result);
        if ($pass[0] == $pwd && !empty($pass[0])) {
            static $adminSave;
        	return $adminSave = 1;
        }
    }
    static $adminSave;
    return $adminSave = 0;
}
if (is_admin($admin)) { define('ADMIN_ALLOW', true); }

function formatAidHeader($aid) {
  if (empty($aid)) { return NULL; }
  $AidHeader = get_author($aid);
  echo $AidHeader;
}

function adminblock($side="") {
 // global $admin, $admin_file;
  include(INCLUDE_PATH.'kernel/fly/adminblock.php');
}