db_Select("user", "*", "user_id=".$modID);
$row = $sql->db_Fetch();
$a_name = $row['user_name'];
$perm = "";
foreach($_POST['perms'] as $value)
{
$value = $tp->toDB($value);
if ($value == "0")
{
if (!getperms('0')) { $value = ""; break; }
$perm = "0"; break;
}
if ($value)
{
$perm .= $value.".";
}
}
admin_update($sql->db_Update("user", "user_perms='{$perm}' WHERE user_id='{$modID}' "), 'update', sprintf(ADMSLAN_2, $tp->toDB($_POST['ad_name'])), false, false);
$logMsg = str_replace(array('--ID--', '--NAME--'),array($modID, $a_name),ADMSLAN_72).$perm;
$admin_log->log_event('ADMIN_01',$logMsg,E_LOG_INFORMATIVE,'');
unset($modID, $ad_name, $a_perms);
}
if (isset($_POST['edit_admin']) || $action == "edit")
{
$edid = array_keys($_POST['edit_admin']);
$theid = intval(($sub_action < 0) ? $edid[0] : $sub_action);
if ((!$sql->db_Select("user", "*", "user_id=".$theid))
|| !($row = $sql->db_Fetch()))
{
$emessage->add("Couldn't find user ID: {$theid}, {$sub_action}, {$edid[0]}", E_MESSAGE_DEBUG); // Debug code - shouldn't be executed
}
}
if (isset($_POST['del_admin']) && count($_POST['del_admin']))
{
$delid = array_keys($_POST['del_admin']);
$aID = intval($delid[0]);
$sql->db_Select("user", "*", "user_id= ".$aID);
$row = $sql->db_Fetch();
if ($row['user_id'] == 1)
{ // Can't delete main admin
$text = $row['user_name']." ".ADMSLAN_6."
".ADMSLAN_4."";
$emessage->add($text, E_MESSAGE_ERROR);
$ns->tablerender(LAN_ERROR, $emessage->render());
require_once("footer.php");
exit;
}
admin_update($sql -> db_Update("user", "user_admin=0, user_perms='' WHERE user_id= ".$aID), 'update', ADMSLAN_61, LAN_DELETED_FAILED, false);
$logMsg = str_replace(array('--ID--', '--NAME--'),array($aID, $row['user_name']),ADMSLAN_73);
$admin_log->log_event('ADMIN_02',$logMsg,E_LOG_INFORMATIVE,'');
}
if(isset($_POST['edit_admin']) || $action == "edit")
{
edit_administrator($row);
}
else
{
show_admins();
}
function show_admins()
{
global $sql, $emessage, $e107, $frm;
$sql->db_Select("user", "*", "user_admin='1'");
$text = "