56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
require_once(dirname(__FILE__)."/load.php");
|
|
|
|
try {
|
|
$email = PostHandler::get("email");
|
|
$userName = PostHandler::get("username");
|
|
$pass = PostHandler::get("pass");
|
|
$confPass = PostHandler::get("passwordConfirm");
|
|
$newsletter = false;
|
|
if(array_key_exists("newsletter", $_POST)){
|
|
$newsletter = true;
|
|
}
|
|
|
|
|
|
$notEmail = GlobalVariables::get("dao")->getFirst("UserModel",array("email"=>$email));
|
|
$notUser = GlobalVariables::get("dao")->getFirst("UserModel",array("username"=>$userName));
|
|
|
|
if(is_null($notEmail) || strcmp($email, $notEmail)!=0){
|
|
if(is_null($notUser) || strcmp($userName, $notUser)!=0){
|
|
if(strcmp($pass, $confPass)==0){
|
|
|
|
// GlobalVariables::get("dao")->getFirst("UserModel",array("username"=>$userName));
|
|
// GlobalVariables::get("dao")->getFirst("UserModel",array("email"=>$email));
|
|
// GlobalVariables::get("dao")->getFirst("UserModel",array("username"=>$userName));
|
|
$user = new stdClass();
|
|
$user->email = $email;
|
|
$user->password = sha1($pass);
|
|
$user->username = $userName;
|
|
$user->newsletter = $newsletter;
|
|
|
|
|
|
$userModel = new UserModel($user);
|
|
// GlobalVariables::get("dao")->save($userModel);
|
|
echo 'Registrazione avvenuta con successo.A breve riceverai una mail per confermare la tua registrazione';
|
|
}
|
|
else{
|
|
// trigger_error("Le due password non coincidono (trigger)");
|
|
echo '<span style="color:red;">Le due password non coincidono</span>';
|
|
}
|
|
}
|
|
else{
|
|
|
|
echo '<span style="color:red;">Questo username è già in uso da un altro utente.</span>';
|
|
}
|
|
}
|
|
else{
|
|
echo '<span style="color:red;">Questa email risulta già in utilizzo.<span>';
|
|
}
|
|
|
|
}catch(Exception $exec){
|
|
$msg = LogModel::fromException($exec);
|
|
GlobalVariables::get("dao")->save($msg);
|
|
}
|
|
|
|
?>
|