{
if(isset($_POST["adminuser"])&&isset($_POST["adminpwd1"])&&isset($_POST["adminpwd2"])){
if($_POST["adminpwd1"]==""){
print("Error: Cannot create user with empty password!<p>");
break;
}
if($_POST["adminpwd1"]!=$_POST["adminpwd2"]){
print("Error: Passwords do not match.<p>");
break;
}
$un=$_POST["adminuser"];
$usr=
$db->select(
"user",
"uname",
"uname=".
$db->escapeString($un));
if(count($usr)>0){
print("Error: User already exists.<p>");
break;
}
$pwd=$salt." ".sha1($salt.$_POST["adminpwd1"]);
$db->insert(
"user",array(
"uname"=>$un,
"passwd"=>$pwd,
"flags"=>
"admin"));
$db->insert(
"userrole",array(
"uname"=>$un,
"role"=>
"_admin"));
$db->insert(
"userhost",array(
"uname"=>$un,
"host"=>
"_any"));
}
}while(0)
$db
Definition: config.php:16
getSalt()
return a salt value for Customer::setPassword
Definition: random.php:65