<?php
/**
 * $Source: /home/cvs/nukescripts/admin/modules/promotion/upgradegod.php,v $
 * $Revision: 1.0.0-1 $
 * $Author: cyril $
 * $Date: 2007/01/17 11:26:34 $
 */
/************************************************************************/
/* 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                                 */
/************************************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}
if ($acces == 1) {
if($admintest && $adminsecu)  {

if (!defined('SECUR_MAX')) {
	die ();
}


if (!is_god($admin)) { redirect_url("".$admin_file.".php"); }
if (! defined('ADMIN_ALLOW') ) { redirect_url("".$admin_file.".php"); }
if (! defined('USER_ALLOW') ) { redirect_url("".$admin_file.".php"); }

if ( empty( $a_aid ) ) {  redirect_url("".$admin_file.".php?op=promotion"); }

$gfx_code  = $db->XMFnum($gfx_code);
$gfx_check = $db->XMFnum($gfx_check);

if ( empty($gfx_code) || ( $gfx_code != $gfx_check ) ) {

incoh();

mt_srand ((double)microtime()*1000000);
$maxran     = 1000000;
$random_num = mt_rand(0, $maxran);
$datekey    = date("F j");
$rcode      = hexdec(md5($_SERVER['HTTP_USER_AGENT'] . $sitekey . $random_num . $datekey));
$code       = substr($rcode, 2, 6);

title(""._ADMINGOD_DOWNGRADE1."");
Max_OpenTable();

if ( $a_aid == 1 ) {
	echo "<center>"._ADMIN_CODE_ERROR."<br/>";
	echo ""._GOBACK."</center><br/>";
Max_CloseTable();
incof();
}

if ( $a_aid == $cookie[1] ) {
echo ""._ADMINGOD_DOWNGRADE_IMPOSSIBLE."";
echo "<meta http-equiv=\"refresh\" content=\"5;url=".$admin_file.".php?op=promotion\">"
	."<meta http-equiv=\"Pragma\" content=\"no-cache\">";
Max_CloseTable();
incof();
}

echo ""._ADMINGOD_CONSEILDOWN."<br/>";
echo "<form action='".$admin_file.".php' method='post'>";
echo "<input type='hidden' name='a_aid2' value='$a_aid' />";
echo "<input type='hidden' name='a_aid' value='1' />";

if ( extension_loaded("gd") ) {
	echo "<p align='center'><b>"._ADMIN_CODE.":</b> <img src='?gfx=gfx&amp;random_num=$random_num' border='1' alt='"._ADMIN_CODE."' title='"._ADMIN_CODE."' />
    <input type='hidden' name='gfx_check' value=\"$code\" /> &nbsp; &nbsp;
 <b>"._ADMIN_CODE_TYPE.":</b> <input type='text' name='gfx_code' size='9' maxlenght='6' /> $ast</p>";
} else {
	echo "<p align='center'><b>"._ADMIN_CODE.":</b> <font color='blue'><b>$code</b></font>
    <input type='hidden' name='gfx_check' value=\"$code\" /> &nbsp; &nbsp;
 <b>"._ADMIN_CODE_TYPE.":</b> <input type='text' name='gfx_code' size='9' maxlenght='6' /> $ast</p>";
}

echo "<center><input type='hidden' name='op' value='downgradegod' /><input type='submit' onclick=\"this.form.submit();this.disabled=true;this.value='"._WAITING."'\" value=\""._ADMIN_CODE_SEND."\" /><br/><br/>"._GOBACK."</center></form>";
br('1');
Max_CloseTable();

incof();


} else {

incoh();
title(""._ADMINGOD_DOWNGRADE2."");
Max_OpenTable();

if ( ! empty($gfx_code) && ( $gfx_code == $gfx_check ) && ( $a_aid == 1 ) && ( !empty( $a_aid2 ) ) ) {
$a_aid2 = addslashes( $a_aid2 );

if ( $a_aid2 == $cookie[1] ) {
echo ""._ADMINGOD_DOWNGRADE_IMPOSSIBLE."";
echo "<meta http-equiv=\"refresh\" content=\"5;url=".$admin_file.".php?op=promotion\">"
	."<meta http-equiv=\"Pragma\" content=\"no-cache\">";
Max_CloseTable();
incof();
}




echo "<br/>"._ADMINGOD_DOWNGRADE_SUCCES."<br/>";
$db->sql_query("UPDATE `".TABLE_AUTHORS."` SET `name`='$a_aid2', `radminsuper`='0' WHERE `aid`='$a_aid2'");

		$subject      = ""._ADMINGOD_DOWNGRADE_MAIL_TITLE."";
		$mailheaders  = "From: $adminmail <$adminmail>\n";
		$mailheaders .= "Reply-To: $adminmail\n\n";
		$msg          = ""._ADMINGOD_DOWNGRADE_MAIL.": $a_aid2\n\n"._ADMINGOD_DOWNGRADE_MAIL2.": $cookie[1]\n\n$sitename\n$nukeurl";
		@mail($adminmail, $subject, $msg, $mailheaders);

} else {
	redirect_url("".$admin_file.".php?op=promotion");
}
echo "<meta http-equiv=\"refresh\" content=\"5;url=".$admin_file.".php?op=promotion\">"
	."<meta http-equiv=\"Pragma\" content=\"no-cache\">";
Max_CloseTable();
incof();
}

	}
}else {
	echo "Access Denied";
}