144 lines
4.2 KiB
PHP
144 lines
4.2 KiB
PHP
<?php
|
|
if(isset($_POST["admin"])){$admin="Y";} else{$admin="N";}
|
|
if(isset($_POST["fname"])){$fname=$_POST["fname"];}
|
|
if(isset($_POST["mi"])){$mi=$_POST["mi"];}
|
|
if(isset($_POST["lname"])){$lname=$_POST["lname"];}
|
|
if(isset($_POST["dept"])){$dept=$_POST["dept"];}
|
|
if(isset($_POST["title"])){$title=$_POST["title"];}
|
|
if(isset($_POST["telephone"])){$telephone=$_POST["telephone"];}
|
|
if(isset($_POST["cellphone"])){$cellphone=$_POST["cellphone"];}
|
|
if(isset($_POST["fax"])){$fax=$_POST["fax"];}
|
|
if(isset($_POST["email"])){$email=$_POST["email"];}
|
|
if(isset($_POST["username"])){$username=$_POST["username"];}
|
|
if(isset($_POST["pass"])){$pass=$_POST["pass"];}
|
|
if(isset($_POST["orig_admin"])){$orig_admin=$_POST["orig_admin"];}
|
|
if(isset($_POST["group_membership"])){$group=$_POST["group_membership"];}
|
|
if(isset($_POST["orig_group"])){$orig_group=$_POST["orig_group"];}
|
|
date_default_timezone_set('UTC');
|
|
$thedate=date("Y-m-d H:i:s");
|
|
|
|
if($_POST["orig_username"] != $username)
|
|
{
|
|
$sqldupuser="SELECT
|
|
count(`tobin_users`.`user`) AS CID
|
|
FROM
|
|
`tobin_users`
|
|
WHERE `tobin_users`.`user` = AES_DECRYPT('".$username."','".$_SESSION["tobin_akey"]."')";
|
|
$rsCheck = mysql_query($sqldupuser) or $em=$em.mysql_error();
|
|
$numrow = mysql_result($rsCheck,0);
|
|
}
|
|
else
|
|
{
|
|
$numrow=0;
|
|
}
|
|
|
|
if($em=="")
|
|
{
|
|
if($numrow == 0)
|
|
{
|
|
$thedate=date("Y-m-d H:i:s");
|
|
$sql = "UPDATE tobin_users SET firstname=".GetSQLValueString($fname, "text").",
|
|
lastname=AES_ENCRYPT(".GetSQLValueString($lname, "text").",'".$_SESSION["tobin_akey"]."'),
|
|
mi = ".GetSQLValueString($mi, "text").",
|
|
department = ".GetSQLValueString($dept, "text").",
|
|
title = ".GetSQLValueString($title, "text").",
|
|
email=AES_ENCRYPT(".GetSQLValueString($email, "text").",'".$_SESSION["tobin_akey"]."'),
|
|
phone = AES_ENCRYPT(".GetSQLValueString($telephone, "text").",'".$_SESSION["tobin_akey"]."'),
|
|
cellphone = AES_ENCRYPT(".GetSQLValueString($cellphone, "text").",'".$_SESSION["tobin_akey"]."'), fax = AES_ENCRYPT(".GetSQLValueString($fax, "text").",'".$_SESSION["tobin_akey"]."'),
|
|
user=AES_ENCRYPT(".GetSQLValueString($username, "text").",'".$_SESSION["tobin_akey"]."'),
|
|
pass=AES_ENCRYPT(".GetSQLValueString($pass, "text").",'".$_SESSION["tobin_akey"]."'),
|
|
admin = ".GetSQLValueString($admin, "text").",
|
|
updatedby = ".GetSQLValueString($_SESSION["admin_uid"], "int")."
|
|
WHERE uid = ".$_SESSION["euuid"];
|
|
$query=mysql_query($sql) or $em=$em.mysql_error();
|
|
if($em !="")
|
|
{
|
|
$posterror="Unable to update user. Please resubmit form. If the problem persists, please contact the site administrator.";
|
|
$posterror=$em."<br />".$posterror;
|
|
}
|
|
else
|
|
{
|
|
// change group if necessary
|
|
|
|
$therights=1;
|
|
$og=explode(",",$_POST["orig_group"]);
|
|
foreach ($_POST["group_membership"] as $value) {
|
|
$gexit=0;
|
|
foreach ($og as $cv) {
|
|
if($cv==$value)
|
|
{
|
|
$gexit=1;
|
|
}
|
|
}
|
|
if($gexit==0)
|
|
{
|
|
|
|
$sqlig=sprintf("INSERT INTO tobin_user_group (gid, uid, cdate, updatedby, rights)
|
|
VALUES (%s, %s, %s, %s, %s)",
|
|
GetSQLValueString($value, "int"),
|
|
GetSQLValueString($_SESSION["euuid"], "int"),
|
|
GetSQLValueString($thedate, "date"),
|
|
GetSQLValueString($_SESSION["tobin_uid"], "int"),
|
|
GetSQLValueString($therights, "int"));
|
|
$qig=mysql_query($sqlig) or $em=$em.mysql_error();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
foreach ($og as $value) {
|
|
$gexit=0;
|
|
foreach ($_POST["group_membership"] as $cv) {
|
|
if($cv==$value)
|
|
{
|
|
$gexit=1;
|
|
}
|
|
}
|
|
|
|
if($gexit==0)
|
|
{
|
|
|
|
$sqldg="DELETE FROM tobin_user_group WHERE gid = ".$value." AND uid = ".$_SESSION["euuid"];
|
|
$qdg=mysql_query($sqldg) or $em=$em.mysql_error();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$postsuccess="Account successuflly updated.";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$posterror="Duplicate username. Please select another username and resubmit form.";
|
|
$username=$_POST["orig_username"];
|
|
}
|
|
} // end if em after duplicate check
|
|
else
|
|
{
|
|
$posterror="Unable to update user. Please resubmit form. If the problem persists, please contact the site administrator.";
|
|
$posterror=$em."<br />".$posterror;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|