Sistema di login / logout / registrazione
Modifiche allo stile
This commit is contained in:
@@ -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){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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 '<script type="text/javascript">location.reload();</script>';
|
||||
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 {
|
||||
<div class="headContainer">
|
||||
<div class="upperBar">
|
||||
<div class="dateBar"><?php echo $day." ".$mesi[date("n")]." ".date("Y"); ?> - Aggiornato alle <span style="color:#f68235;"><?php echo date("H:i");?></span></div>
|
||||
<div class="loginReg"><?php echo UserLoginManager::isLogged()?UserLoginManager::getLogged()->nome." ".UserLoginManager::getLogged()->cognome:'<a href="javascript:openLoginModal();">LOGIN</a>';?> | <a id="regButton" href="javascript:openRegistrationModal();">REGISTRATI</a></div>
|
||||
<div class="loginReg">
|
||||
<?php
|
||||
if (UserLoginManager::isLogged()){
|
||||
echo UserLoginManager::getLogged()->nome." ".UserLoginManager::getLogged()->cognome.' | <a href="javascript:logout();">LOGOUT</a>';
|
||||
}
|
||||
else {
|
||||
echo '<a href="javascript:openLoginModal();">LOGIN</a> | <a id="regButton" href="javascript:openRegistrationModal();">REGISTRATI</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="socialBar">
|
||||
<a class="socialLink" href="https://www.facebook.com/ifattidinapoli" target="_blank"><div style="background-image:url(images/fb.png);"></div></a>
|
||||
<a class="socialLink" href="https://twitter.com/fattidinapoli" target="_blank"><div style="background-image:url(images/twitter.png);"></div></a>
|
||||
|
||||
@@ -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",
|
||||
|
||||
+25
-19
@@ -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 {
|
||||
?>
|
||||
<div class="topReg"><span></span><div><a class="close" href="javascript:void(0);" onClick="$('#floating').hide();">x</a></div></div>
|
||||
<div style="color:red;"><?php echo $msg;?></div>
|
||||
|
||||
?>
|
||||
<a class="close" href="javascript:void(0);" onClick="$('#floating').hide();">x</a>
|
||||
<div class="modalBody">
|
||||
<div class="title">Inserisci i tuoi dati per accedere</div>
|
||||
<div style="color:red; text-align:center;"><?php echo $msg;?></div>
|
||||
<form id="logForm">
|
||||
<input type="hidden" name="action" value=""/>
|
||||
<div>Username: <input type="text" name="username" value=""/></div>
|
||||
<div>Password: <input type="password" name="password" value="" /></div>
|
||||
<div ><a id="loginBtn" href="javascript:void(0);">Accedi</a></div>
|
||||
<div><input placeholder="USERNAME" type="text" name="username" value="<?php echo $username;?>"/></div>
|
||||
<div><input placeholder="PASSWORD" type="password" name="password" value="" /></div>
|
||||
<div class="btn"><a class="btn" id="loginBtn" href="javascript:void(0);">Accedi</a></div>
|
||||
</form>
|
||||
<div style="text-align:center;font-size: 10pt;"><a id="passForgot" style="color:rgb(0, 133, 185);" href="javascript:void(0);">Password Dimenticata?</a></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
@@ -59,9 +57,17 @@ else {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#logForm input[name=password]').keypress(function(event) {
|
||||
if (event.which==13){
|
||||
$("#loginBtn").click();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$("#passForgot").click(function () {
|
||||
$("#floating").load("passwordForgot.php");
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</script>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 16/mar/2016
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__)."/load.php");
|
||||
|
||||
if (UserLoginManager::isLogged()){
|
||||
UserLoginManager::logout();
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 16/mar/2016
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__)."/load.php");
|
||||
|
||||
try {
|
||||
$sent = false;
|
||||
$msg = "";
|
||||
$action = PostHandler::get("action");
|
||||
$email = "";
|
||||
|
||||
if (!is_null($action) && strcmp($action, "recover")==0){
|
||||
$email = trim(PostHandler::get("email"));
|
||||
|
||||
$user = GlobalVariables::get("dao")->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){
|
||||
?>
|
||||
<div style="padding:2em;">A breve riceverai una email per modificare la password!</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<a class="close" href="javascript:void(0);" onClick="$('#floating').hide();">x</a>
|
||||
<div class="modalBody">
|
||||
<div class="title">Inserisci la tua email per recuperare i dati</div>
|
||||
<div style="color:red; text-align:center;"><?php echo $msg;?></div>
|
||||
<form id="recForm">
|
||||
<input type="hidden" name="action" value=""/>
|
||||
<div><input placeholder="EMAIL" type="text" name="email" value="<?php echo $email; ?>"/></div>
|
||||
<div class="btn"><a class="btn" id="recoverBtn" href="javascript:void(0);">RICHIEDI</a></div>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$("#recoverBtn").click(function () {
|
||||
$("#recForm input[name=action]").val("recover");
|
||||
$.ajax({
|
||||
method:"POST",
|
||||
url:'passwordForgot.php',
|
||||
data:$("#recForm").serialize(),
|
||||
success: function(data){
|
||||
$("#floating").html(data);
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#recForm input[name=email]').keypress(function(event) {
|
||||
if (event.which==13){
|
||||
$("#recoverBtn").click();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
+33
-18
@@ -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";
|
||||
?>
|
||||
<a class="close" href="javascript:void(0);" onClick="$('#floating').hide();">x</a>
|
||||
<div class="modalBody" style="width:273px;">
|
||||
<p>La tua registrazione è quasi completa!</p>
|
||||
<p>A breve riceverai un'email all'indirizzo <br/><span style="font-weight:bold;"><?php echo $user->email;?></span><br/> per completare la registrazione</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<div class="topReg"><span></span><div><a class="close" href="javascript:void(0);" onClick="$('#floating').hide();">x</a></div></div>
|
||||
<div style="color:red;"><?php echo $msg;?></div>
|
||||
<a class="close" href="javascript:void(0);" onClick="$('#floating').hide();">x</a>
|
||||
<div class="modalBody">
|
||||
<form id="regForm">
|
||||
<div class="title">Inserisci i tuoi dati per registrarti al sito.</div>
|
||||
<div style="color:red; text-align:center;"><?php echo $msg;?></div>
|
||||
<input type="hidden" name="action" value=""/>
|
||||
<div>Nome: <input type="text" name="nome" value="" /></div>
|
||||
<div>Cognome: <input type="text" name="cognome" value="" /></div>
|
||||
<div>Email: <input type="text" name="email" value="" /></div>
|
||||
<div>Username: <input type="text" name="username" value=""/></div>
|
||||
<div>Password: <input type="password" name="password" value="" /></div>
|
||||
<div>Conferma password: <input type="password" name="password_confirm" value="" /></div>
|
||||
<div><input placeholder="NOME" type="text" name="nome" value="<?php echo $obj->nome;?>" /></div>
|
||||
<div><input placeholder="COGNOME" type="text" name="cognome" value="<?php echo $obj->cognome;?>" /></div>
|
||||
<div><input placeholder="EMAIL" type="text" name="email" value="<?php echo $obj->email;?>" /></div>
|
||||
<div><input placeholder="USERNAME" type="text" name="username" value="<?php echo $obj->username;?>"/></div>
|
||||
<div><input placeholder="PASSWORD" type="password" name="password" value="" /></div>
|
||||
<div><input placeholder="CONFERMA PASSWORD" type="password" name="password_confirm" value="" /></div>
|
||||
<div>Vuoi iscriverti alla newsletter? <input type="checkbox" name="newsletter" value="true" checked /></div>
|
||||
<div ><a id="regMe" href="javascript:void(0);">Registrami</a></div>
|
||||
<div class="btn" ><a class="btn" id="regMe" href="javascript:void(0);">Registrami</a></div>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
@@ -94,6 +102,13 @@ else {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#regForm input[name=password_confirm]').keypress(function(event) {
|
||||
if (event.which==13){
|
||||
$("#regMe").click();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
+32
-3
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user