<?php
/**
 * $Source: /home/cvs/nukescripts/admin/modules/promotion/ModifyPromotion.php,v $
 * $Revision: 1.0.0-1 $
 * $Author: cyril $
 * $Date: 2007/01/08 11:35:06 $
 * 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"); }

		incoh();
		Max_OpenTable();
		echo "<center><font class='title'><b>" . _AUTHORSADMIN . "</b></font></center>";
		Max_CloseTable();
		br('1');
		Max_OpenTable();
		echo "<center><font class=\"option\"><b>" . _MODIFYINFO . "</b></font></center><br /><br />";
		$adm_aid = $chng_aid;
		$adm_aid = trim($adm_aid);
		$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `aid`, `name`, `url`, `email`, `radminsuper`, `admlanguage` FROM `".TABLE_AUTHORS."` WHERE `aid`='$chng_aid'"));
		$chng_aid         = stripslashes($row['aid']);
		$chng_name        = stripslashes($row['name']);
		$chng_url         = stripslashes($row['url']);
		$chng_email       = stripslashes($row['email']);
		$chng_radminsuper = $GLOBALS['db']->XMFbin($row['radminsuper']);
		$chng_admlanguage = $GLOBALS['db']->XMFlang($row['admlanguage']);
		$chng_aid = substr("$chng_aid", 0,25);
		$aid = $chng_aid;
		echo "<form action=\"".$admin_file.".php\" method=\"post\">"
		."<center><table align='center' border='0' cellpadding='2' cellspacing='2'>\n"
		."<tr><td>" . _NAME . ":</td>"
		."<td colspan=\"3\"><b>$chng_name</b> <input type=\"hidden\" name=\"chng_name\" value=\"$chng_name\"></td></tr>"
		."<tr><td>" . _NICKNAME . ":</td>"
		."<td colspan=\"3\"><b>$chng_aid</b>  <input type=\"hidden\" name=\"chng_aid\" value=\"$chng_aid\"></td></tr>"
	    ."<tr><td>" . _EMAIL . ":</td>"
		."<td colspan=\"3\"><input type=\"text\" name=\"chng_email\" value=\"$chng_email\" size=\"30\" maxlength=\"60\"></td></tr>"
		."<tr><td>" . _URL . ":</td>"
		."<td colspan=\"3\"><input type=\"text\" name=\"chng_url\" value=\"$chng_url\" size=\"30\" maxlength=\"60\"></td></tr>"
		."<td colspan=\"3\"><b>$chng_url</b> <input type=\"hidden\" name=\"chng_url\" value=\"$chng_url\"></td></tr>";
		if ($multilingual == 1) {
			echo "<tr><td>" . _LANGUAGE . ":</td><td colspan=\"3\">"
			."<select name=\"chng_admlanguage\">";
			$handle=opendir('language');
			while ($file = readdir($handle)) {
				if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
					$langFound = $matches[1];
					$languageslist .= "$langFound ";
				}
			}
			closedir($handle);
			$languageslist = explode(" ", $languageslist);
			sort($languageslist);
			for ($i=0; $i < sizeof($languageslist); $i++) {
				if($languageslist[$i]!="") {
					echo "<option value=\"$languageslist[$i]\" ";
					if($languageslist[$i]==$chng_admlanguage) echo "selected";
					echo ">".ucfirst($languageslist[$i])."</option>\n";
				}
			}
			if ($chng_admlanguage == "") {
				$allsel = "selected";
			} else {
				$allsel = "";
			}
			echo "<option value=\"\" $allsel>" . _ALL . "</option></select></td></tr>";
		} else {
			echo "<input type=\"hidden\" name=\"chng_admlanguage\" value=\"\">";
		}
		echo "<tr><td>" . _PERMISSIONS . ":</td>";
		if ($row['name'] != "God") {
			$result = $GLOBALS['db']->sql_query("SELECT `mid`, `title`, `admins` FROM `".TABLE_MODULES."` ORDER BY `title` ASC");
			while ($row = $GLOBALS['db']->sql_fetchrow($result)) {
				$title = ereg_replace("_", " ", $row[title]);
				if (file_exists("modules/$row[title]/admin/index.php") AND file_exists("modules/$row[title]/admin/links.php") AND file_exists("modules/$row[title]/admin/case.php")) {
					$admins = explode(",", $row[admins]);
					$sel = "";
					for ($i=0; $i < sizeof($admins); $i++) {
						if ($chng_name == "$admins[$i]") {
							$sel = "checked";
						}
					}
					echo "<td><input type=\"checkbox\" name=\"auth_modules[]\" value=\"$row[mid]\" $sel> $title</td>";
					$sel = "";
					if ($a == 2) {
						echo "</tr><tr><td>&nbsp;</td>";
						$a = 0;
					} else {
						$a++;
					}
				}
			}
			if ($chng_radminsuper == 1) {
				$sel1 = "checked";
			}
			echo "</tr><tr><td>&nbsp;</td>";
		} else {
			echo "<input type=\"hidden\" name=\"auth_modules[]\" value=\"\">";
			$sel1 = "checked";
		}
		echo "<td><input type=\"checkbox\" name=\"chng_radminsuper\" value=\"1\" $sel1> <b>" . _SUPERUSER . "</b></td>"
		."</tr><tr><td>&nbsp;</td>"
		."<td colspan=\"3\"><font class=\"tiny\"><i>" . _SUPERWARNING . "</i></font></td></tr><tr>"
        ."<tr><td>" . _PASSW . ":</td>"
		."<td colspan=\"3\"><input type=\"text\" name=\"chng_pwd2\"  size=\"30\" maxlength=\"60\">" . _INFOPASSE . "</td></tr>"
		."<input type=\"hidden\" name=\"adm_aid\" value=\"$adm_aid\">"
		."<input type=\"hidden\" name=\"op\" value=\"UpdatePromotion\">"
		."<tr><td><input type=\"submit\" value=\"" . _SAVE . "\"> " . _GOBACK . ""
		."</td></tr></table></form>";
		Max_CloseTable();
		incof();

}
}else {
	echo "Access Denied";
}