149 lines
4.7 KiB
PHP
149 lines
4.7 KiB
PHP
<?php
|
|
$filters = array
|
|
(
|
|
"firstname" => array
|
|
(
|
|
"filter"=>FILTER_SANITIZE_STRING
|
|
),
|
|
"mi" => array
|
|
(
|
|
"filter"=>FILTER_SANITIZE_STRING
|
|
),
|
|
"lastname" => array
|
|
(
|
|
"filter"=>FILTER_SANITIZE_STRING
|
|
),
|
|
"pass" => array
|
|
(
|
|
"filter"=>FILTER_SANITIZE_STRING
|
|
),
|
|
"username" => array
|
|
(
|
|
"filter"=>FILTER_SANITIZE_STRING
|
|
),
|
|
);
|
|
//4414-2000-0073-1933 4/13 104 visa 80302
|
|
$result = filter_input_array(INPUT_POST, $filters);
|
|
|
|
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"];}
|
|
$sqldupuser="SELECT
|
|
count(`tobin_users`.`user`) AS CID, count(`tobin_users`.`email`) AS CEM
|
|
FROM
|
|
`tobin_users`
|
|
WHERE `tobin_users`.`user` = AES_ENCRYPT('".$username."','".$_SESSION["tobin_akey"]."') AND `tobin_users`.`email` = AES_ENCRYPT('".$email."','".$_SESSION["tobin_akey"]."')";
|
|
$rsCheck = mysql_query($sqldupuser) or $em=$em.mysql_error();
|
|
$cue=mysql_fetch_assoc($rsCheck);
|
|
$isdupemail=$cue["CID"];
|
|
$isdupuser=$cue["CEM"];
|
|
|
|
if($em=="")
|
|
{
|
|
|
|
|
|
if($isdupemail == 0 && $isdupuser==0)
|
|
{
|
|
$thedate=date("Y-m-d H:i:s");
|
|
$sql = sprintf("INSERT INTO tobin_users (
|
|
firstname,
|
|
mi,
|
|
lastname,
|
|
title,
|
|
department,
|
|
email,
|
|
phone,
|
|
cellphone,
|
|
fax,
|
|
user,
|
|
pass,
|
|
admin,
|
|
cdate,
|
|
updatedby) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
|
|
GetSQLValueString($fname, "text"),
|
|
GetSQLValueString($mi, "text"),
|
|
"AES_ENCRYPT(".GetSQLValueString($lname, "text").",'".$_SESSION["tobin_akey"]."')",
|
|
GetSQLValueString($title, "text"),
|
|
GetSQLValueString($dept, "text"),
|
|
"AES_ENCRYPT(".GetSQLValueString($email, "text").",'".$_SESSION["tobin_akey"]."')",
|
|
"AES_ENCRYPT(".GetSQLValueString($telephone, "text").",'".$_SESSION["tobin_akey"]."')",
|
|
"AES_ENCRYPT(".GetSQLValueString($cellphone, "text").",'".$_SESSION["tobin_akey"]."')",
|
|
"AES_ENCRYPT(".GetSQLValueString($fax, "text").",'".$_SESSION["tobin_akey"]."')",
|
|
"AES_ENCRYPT(".GetSQLValueString($username, "text").",'".$_SESSION["tobin_akey"]."')",
|
|
"AES_ENCRYPT(".GetSQLValueString($pass, "text").",'".$_SESSION["tobin_akey"]."')",
|
|
GetSQLValueString($admin, "text"),
|
|
GetSQLValueString($thedate, "date"),
|
|
GetSQLValueString($_SESSION["tobin_uid"], "int"));
|
|
|
|
$query=mysql_query($sql) or $em=$em.mysql_error();
|
|
|
|
if($em != "")
|
|
{
|
|
$posterror="Unable to add user. Please resubmit form. If the problem persists, please contact the site administrator.";
|
|
$posterror=$em."<br />".$posterror;
|
|
}
|
|
else
|
|
{
|
|
$userid=mysql_insert_id();
|
|
|
|
$sqlug=sprintf("INSERT INTO tobin_user_group (
|
|
gid,
|
|
uid,
|
|
rights,
|
|
cdate,
|
|
updatedby) VALUES (%s, %s, %s, %s, %s)",
|
|
0,
|
|
GetSQLValueString($userid, "int"),
|
|
0,
|
|
GetSQLValueString($thedate, "date"),
|
|
GetSQLValueString($_SESSION["tobin_uid"], "int"));
|
|
mysql_query($sqlug) or $em=$em.mysql_error();
|
|
|
|
if($em != "")
|
|
{
|
|
$sqlreverse="DELETE FROM tobin_users WHERE uid = ".$userid;
|
|
$qreverse=mysql_query($sqlreverse) or $em=$em.mysql_error();
|
|
$posterror="Unable to add user. Please resubmit form. If the problem persists, please contact the site administrator.<br />".$em;
|
|
}
|
|
else
|
|
{
|
|
$posterror="";
|
|
$postsuccess="New user, ".$fname." ".$lname.", added to database. If you want to edit or review account, <a href=\"edit_user.php?uid=".$userid."\">please click on this link</a>.";
|
|
$fname="";
|
|
$mi="";
|
|
$lname="";
|
|
$dept="";
|
|
$title="";
|
|
$telephone="";
|
|
$cellphone="";
|
|
$fax="";
|
|
$email="";
|
|
$username="";
|
|
$pass="";
|
|
$admin="N";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}//ed if numrows = 0
|
|
else
|
|
{
|
|
$posterror="Duplicate username or email. Please correct and resubmit form. If the problem persists, please contact the site administrator.";
|
|
}
|
|
}
|
|
else //end query chkdup
|
|
{
|
|
$posterror="Unable to add user. Please resubmit form. If the problem persists, please contact the site administrator.";
|
|
$posterror=$em."<br />".$posterror;
|
|
}
|
|
?>
|