<?php
/**
 * $Source: /home/cvs/nukescripts/admin/modules/promotion/PromotionSave.php,v $
 * $Revision: 1.0.0-2 $
 * $Author: cyril $
 * $Date: 2007/01/17 14:11:24 $
 * Fix Bug 196
 */
/************************************************************************/
/* 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"); }

$auth_modules    = htmlentities(addslashes($_POST['auth_modules']), ENT_QUOTES);
$add_name        = htmlentities(addslashes($_POST['add_aid']), ENT_QUOTES);
$add_aid         = htmlentities(addslashes($_POST['add_aid']), ENT_QUOTES);
$add_url         = htmlentities(addslashes($_POST['add_url']), ENT_QUOTES);
$add_email       = htmlentities(addslashes($_POST['add_email']), ENT_QUOTES);
$add_pwd         = htmlentities(addslashes($_POST['add_pwd']), ENT_QUOTES);
$add_radminsuper = htmlentities(addslashes($_POST['add_radminsuper']), ENT_QUOTES);
$add_admlanguage = htmlentities(addslashes($_POST['add_admlanguage']), ENT_QUOTES);


for ($i=0; $i < sizeof($auth_modules); $i++) {
			$row = $db->sql_fetchrow($db->sql_query("SELECT `admins` FROM `".TABLE_MODULES."` WHERE `mid`='$auth_modules[$i]'"));
			$adm = "$row[admins]$add_name";
			$db->sql_query("UPDATE `".TABLE_MODULES."` SET `admin`='$adm,' WHERE `mid`='$auth_modules[$i]'");


}
$add_pwd = md5( $add_pwd );

$db->sql_query("INSERT INTO `".TABLE_AUTHORS."` values ('$add_aid', '$add_name', '$add_url', '$add_email', '$add_pwd', '0', '$add_radminsuper', '$add_admlanguage')");
$db->sql_query("INSERT INTO `".TABLE_NSNSECUREADMIN."` values ('','$add_aid', '', '')");

		$subject      = ""._ADMIN_CREATACCOUNT_MAIL_TITLE."";
		$mailheaders  = "From: $adminmail <$adminmail>\n";
		$mailheaders .= "Reply-To: $adminmail\n\n";
		$msg          = ""._ADMIN_CREATACCOUNT_MAIL.": $add_aid\n\n"._ADMIN_CREATACCOUNT_MAIL2.": $cookie[1]\n\n$sitename\n$nukeurl";
		@mail($adminmail, $subject, $msg, $mailheaders);

if (!$result) {
return;
}
redirect_url("".$admin_file.".php?op=promotion");

}
}else {
	echo "Access Denied";
}