<?php
/************************************************************************/
/* 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                                 */
/************************************************************************/
/********************************************************/
/* NukeSentinel(tm)                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright © 2000-2005 by NukeScripts Network         */
/********************************************************/

if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}

if(is_god($admin)) {
  $subject = _AB_ACCESSCHANGEDON." ".$nuke_config['sitename'];
  $message  = ""._AB_HTTPONLY."\n";
  $message .= ""._AB_LOGIN.": $xlogin\n";
  $message .= ""._AB_PASSWORD.": $xpassword\n";
  $message .= ""._AB_PROTECTED.": ";
  if($xprotected==0) { $message .= ""._AB_NO."\n"; } else { $message .= ""._AB_YES."\n"; }
  $xpassword_md5 = md5($xpassword);
  $xpassword_crypt = crypt($xpassword);
  if (!get_magic_quotes_runtime()) {
    $xlogin = addslashes($xlogin);
    $xpassword = addslashes($xpassword);
  }
  $db->sql_query("UPDATE `".TABLE_NSNST_ADMINS."` SET `login`='$xlogin', `password`='$xpassword', `password_md5`='$xpassword_md5', `password_crypt`='$xpassword_crypt', `protected`='$xprotected' WHERE `aid`='$a_aid'");
  list($amail) = $db->sql_fetchrow($db->sql_query("SELECT `email` FROM `".TABLE_AUTHORS."` WHERE `aid`='$a_aid'"));
  @mail($amail, $subject, $message,"From: ".$nuke_config['adminmail']."\r\nX-Mailer: "._AB_NUKESENTINEL."\r\n");
  if($ab_config['http_auth'] == 2 AND $ab_config['staccess_path'] > "") {
    $stwrite = "";
    $adminresult = $db->sql_query("SELECT * FROM `".TABLE_NSNST_ADMINS."` WHERE `password_crypt`>'' ORDER BY `aid`");
    while($adminrow = $db->sql_fetchrow($adminresult)) {
      $stwrite .= $adminrow['aid'].":".$adminrow['password_crypt']."\n";
      $doit = fopen($ab_config['staccess_path'], "w");
      fwrite($doit, $stwrite);
      fclose($doit);
    }
  }
  redirect_url("".$admin_file.".php?op=ABAuthList");
} else {
  redirect_url("".$admin_file.".php?op=ABMain");
}

?>