From e8980911dcae5c18e4894c896b0cddeb97428cd0 Mon Sep 17 00:00:00 2001 From: Riccardo Di Dato Date: Thu, 17 Mar 2016 10:43:01 +0100 Subject: [PATCH] Sistema di login / logout / registrazione Modifiche allo stile --- private/lib/FDN_MailHelper.php | 11 +++++ private/lib/gui/GUIHandler.php | 18 +++++++- public/js/functions.js | 11 +++++ public/login.php | 44 ++++++++++-------- public/logout.php | 13 ++++++ public/passwordForgot.php | 84 ++++++++++++++++++++++++++++++++++ public/registration.php | 51 +++++++++++++-------- public/style/public.css | 35 ++++++++++++-- 8 files changed, 226 insertions(+), 41 deletions(-) create mode 100644 public/logout.php create mode 100644 public/passwordForgot.php diff --git a/private/lib/FDN_MailHelper.php b/private/lib/FDN_MailHelper.php index 1f21e5c..21c374e 100644 --- a/private/lib/FDN_MailHelper.php +++ b/private/lib/FDN_MailHelper.php @@ -22,6 +22,17 @@ class FDN_MailHelper { return new MailModel($tmp); } + public static function getAdminPasswordResetMail($admin){ + + } + + public static function getUserConfirmMail($user){ + + } + + public static function getUserPasswordResetMail($user){ + + } } ?> \ No newline at end of file diff --git a/private/lib/gui/GUIHandler.php b/private/lib/gui/GUIHandler.php index d9afe98..484ff8d 100644 --- a/private/lib/gui/GUIHandler.php +++ b/private/lib/gui/GUIHandler.php @@ -90,6 +90,13 @@ class GUIHandler { die(); } + public static function pageReload(){ + // $tmp = new JavaScriptElement("var index = window.location.href.indexOf('#');window.location.href='".$url."'+(index == -1 ? '' : window.location.href.substr(index));"); + // $tmp->render(); + echo ''; + die(); + } + public static function redirectPost($url,array $vals = array()){ // $tmp = new JavaScriptElement("var index = window.location.href.indexOf('#');window.location.href='".$url."'+(index == -1 ? '' : window.location.href.substr(index));"); // $tmp->render(); @@ -159,7 +166,16 @@ class GUIHandler {
- Aggiornato alle
-
nome." ".UserLoginManager::getLogged()->cognome:'LOGIN';?> | REGISTRATI
+
+ nome." ".UserLoginManager::getLogged()->cognome.' | LOGOUT'; + } + else { + echo 'LOGIN | REGISTRATI'; + } + ?> +
diff --git a/public/js/functions.js b/public/js/functions.js index 8caf811..1dc3558 100644 --- a/public/js/functions.js +++ b/public/js/functions.js @@ -42,6 +42,17 @@ function openLoginModal(){ }); } +function logout(){ + $.ajax({ + method:"POST", + url:'logout.php', + dataType:'html', + success: function(data){ + location.reload(); + } + }); +} + function bannerRoll(prev,pos){ $.ajax({ method:"POST", diff --git a/public/login.php b/public/login.php index 80e0a70..759ad7e 100644 --- a/public/login.php +++ b/public/login.php @@ -7,18 +7,17 @@ Creation Date: 11/mar/2016 require_once(dirname(__FILE__)."/load.php"); try { + $username = ""; $msg = ""; $action = PostHandler::get("action"); if (!is_null($action) && strcmp($action, "login")==0){ $username = PostHandler::get("username"); $pass = PostHandler::get("password"); + $msg = "Username o password errati"; if (!is_null($username) && strcmp($username,"")!=0 && !is_null($pass) && strcmp($pass,"")!=0){ - if (!UserLoginManager::login($username, $pass)){ - $msg = "Invalid Data"; - } - else { - GUIHandler::redirect("index.php"); + if (UserLoginManager::login($username, $pass)){ + GUIHandler::pageReload(); } } } @@ -30,20 +29,19 @@ try { $msg = LogModel::fromException($exec); GlobalVariables::get("dao")->save($msg); } -if ($saved){ - echo "Registrazione avvenuta con successo"; -} -else { - ?> - -
+ +?> +x
+
Inserisci i tuoi dati per accedere
+
-
Username:
-
Password:
- +
+
+
+
- \ No newline at end of file + \ No newline at end of file diff --git a/public/logout.php b/public/logout.php new file mode 100644 index 0000000..27a5b6f --- /dev/null +++ b/public/logout.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/public/passwordForgot.php b/public/passwordForgot.php new file mode 100644 index 0000000..d24477c --- /dev/null +++ b/public/passwordForgot.php @@ -0,0 +1,84 @@ +getFirst("UserModel",array("email"=>$email)); // WTF!?!?! + + if (is_null($user)){ + $msg = "Email non valida"; + } + else { + $sent = true; + $mail = FDN_MailHelper::getUserPasswordResetMail($user); +// GlobalVariables::get("dao")->save($mail); + } + + } + +}catch(GUIException $ex){ + $msg = $ex->getMessage(); + $err = true; +}catch (Exception $exec){ + $msg = LogModel::fromException($exec); + GlobalVariables::get("dao")->save($msg); +} + +if ($sent){ + ?> +
A breve riceverai una email per modificare la password!
+ + +x +
+
Inserisci la tua email per recuperare i dati
+
+
+ +
+ +
+
+ + \ No newline at end of file diff --git a/public/registration.php b/public/registration.php index 83b41e4..6fbdd33 100644 --- a/public/registration.php +++ b/public/registration.php @@ -12,16 +12,19 @@ try { $obj->nome = PostHandler::get("nome"); $obj->cognome = PostHandler::get("cognome"); + // ANTICIPATI PER NON PERDERLI IN CASO DI ERRORE $email = trim(PostHandler::get("email")); - if (is_null($email) || !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/",$email)){ - throw new GUIException("L'email inserita non è in un formato valido ($email)"); - } - if (GlobalVariables::get("dao")->count("AdminModel",array("email",$email)) > 0 ){ - throw new GUIException("L'email inserita è già in uso ($email)"); - } $obj->email = $email; $username = trim(PostHandler::get("username")); + $obj->username = $username; + + if (is_null($email) || !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/",$email)){ + throw new GUIException("L'email inserita non è in un formato valido ($email)"); + } + if (GlobalVariables::get("dao")->count("UserModel",array("email",$email)) > 0 ){ + throw new GUIException("L'email inserita è già in uso ($email)"); + } // Validate Username if (is_null($username) || strcmp($username,"")==0){ @@ -31,8 +34,6 @@ try { throw new GUIException("Il nome utente '".$username."' è già in uso"); } - $obj->username = $username; - $pass = trim(PostHandler::get("password")); $passConf = trim(PostHandler::get("password_confirm")); if (is_null($pass) || strcmp($pass,"")==0){ @@ -61,23 +62,30 @@ try { GlobalVariables::get("dao")->save($msg); } if ($saved){ - echo "Registrazione avvenuta con successo"; + ?> + x +
+

La tua registrazione è quasi completa!

+

A breve riceverai un'email all'indirizzo
email;?>
per completare la registrazione

+
+ - -
+x
+
Inserisci i tuoi dati per registrarti al sito.
+
-
Nome:
-
Cognome:
-
Email:
-
Username:
-
Password:
-
Conferma password:
+
+
+
+
+
+
Vuoi iscriverti alla newsletter?
- +
diff --git a/public/style/public.css b/public/style/public.css index b8a8c27..2393202 100644 --- a/public/style/public.css +++ b/public/style/public.css @@ -92,19 +92,48 @@ body{font-family:lato, arial;} */ #floating{ - background-color:#ceecf4; + background: rgb(206,236,244); /* Old browsers */ + background: -moz-linear-gradient(top, rgba(206,236,244,1) 65%, rgba(135,220,242,1) 100%); /* FF3.6-15 */ + background: -webkit-linear-gradient(top, rgba(206,236,244,1) 65%,rgba(135,220,242,1) 100%); /* Chrome10-25,Safari5.1-6 */ + background: linear-gradient(to bottom, rgba(206,236,244,1) 65%,rgba(135,220,242,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ceecf4', endColorstr='#87dcf2',GradientType=0 ); /* IE6-9 */ z-index:4; padding:5px 10px; + border: 2px solid white; + border-radius: 5px; + box-shadow: 3px 3px 5px -3px; } .topReg{text-align:right;} .topReg > div{display:inline-block;} .topReg > span,a{vertical-align:top;} -.close{vertical-align:top;color:black;} +.close{text-align: center;width: 1.1em;display: inline-block;height: 1.1em;border: 1px solid #666;line-height: .9em;border-radius: 1em;background-color: #dddddd;color: #666; float:right;} + -.modalBody{text-align:right;} .regMe{text-align:left;} .modalResponse{text-align:center;color:aqua;font-weight:bold;} +.modalBody form div{padding:3px 5px;} +.modalBody input[type=text], .modalBody input[type=password] {background-color: #D2D2D2;border: 1px solid white;border-radius: 3px;color: #727272;padding: 6px 9px; min-width: 300px;} + +.modalBody div.title{text-align: left;font-weight: lighter;color: rgb(64, 64, 64);padding: 5px;} + +.modalBody div.btn{text-align:center;padding: 11px 1px 7px;} +.modalBody a.btn{background: rgb(115,216,245); /* Old browsers */ +background: -moz-linear-gradient(top, rgba(115,216,245,1) 53%, rgba(66,196,239,1) 100%); /* FF3.6-15 */ +background: -webkit-linear-gradient(top, rgba(115,216,245,1) 53%,rgba(66,196,239,1) 100%); /* Chrome10-25,Safari5.1-6 */ +background: linear-gradient(to bottom, rgba(115,216,245,1) 53%,rgba(66,196,239,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ +filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#73d8f5', endColorstr='#42c4ef',GradientType=0 ); /* IE6-9 */ +padding: 5px 20px; +border-radius: 2px 2px 2px 2px; +color: rgb(0, 133, 185); +font-weight: bold; +box-shadow: 0px 0px 2px 0px; +text-transform: uppercase; +font-size: 12px; +display: inline-block; +} + +.modalBody p{text-align:center;} #modalBlock{}/* margin-left:auto; margin-right:auto;