Create pagine per notizie in pending e rifiutate; Creati componenti grafici per mostrare Notizia, Commento e lista commenti; Bugfix e limature su amministrazione
121 lines
3.7 KiB
PHP
121 lines
3.7 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 26/gen/2016
|
|
*/
|
|
|
|
require_once(dirname(__FILE__)."/../load.php");
|
|
|
|
GUIHandler::generateHtmlHeaders(array(),true);
|
|
|
|
HTMLHelper::generateAdminHead();
|
|
|
|
try{
|
|
if (!array_key_exists("regcode",$_GET) || strcmp("regcode", "")==0 || !array_key_exists("email",$_GET) || strcmp("email", "")==0){
|
|
GUIHandler::redirect("admin/login.php");
|
|
}
|
|
$regCode = $_GET['regcode'];
|
|
$email = $_GET['email'];
|
|
|
|
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/",$email)){
|
|
GUIHandler::redirect("admin/login.php");
|
|
}
|
|
|
|
$giornalista = GlobalVariables::get("dao")->getFirst("AdminModel",array("id"=>$regCode,"email"=>$email,"active"=>false));
|
|
|
|
if (is_null($giornalista)){
|
|
GUIHandler::redirect("admin/login.php");
|
|
}
|
|
|
|
$action = PostHandler::get("action");
|
|
if (!is_null($action) && strcmp("", $action)!=0){
|
|
if (strcmp("confirm", $action)==0){
|
|
$err = false;
|
|
$exc = new GUIException(array());
|
|
|
|
$giornalista->nome = trim(PostHandler::get("nome"));
|
|
$giornalista->cognome = trim(PostHandler::get("cognome"));
|
|
$giornalista->username = trim(PostHandler::get("username"));
|
|
|
|
// Validate Username
|
|
if (strcmp($giornalista->username,"")==0){
|
|
$err = true;
|
|
$exc->addMessage("Inserire un nome utente per accedere all'applicazione");
|
|
}
|
|
if (GlobalVariables::get("dao")->count("AdminModel",array("username"=>$giornalista->username,"id"=>array('$ne'=>new MongoId($giornalista->id) ) ) ) > 0 ){
|
|
$err = true;
|
|
$exc->addMessage("Il nome utente '".$giornalista->username."' è già in uso");
|
|
}
|
|
|
|
// Validate Password
|
|
$pass = trim(PostHandler::get("password"));
|
|
if (strcmp($pass,"")==0){
|
|
$err = true;
|
|
$exc->addMessage("Inserire una password per accedere all'applicazione");
|
|
}
|
|
if (strcmp($pass,PostHandler::get("password_confirm"))!=0){
|
|
$err = true;
|
|
$exc->addMessage("Le password inserite non coincidono");
|
|
}
|
|
$giornalista->password = sha1($pass);
|
|
|
|
if ($err){
|
|
throw $exc;
|
|
}
|
|
|
|
$giornalista->active = true;
|
|
|
|
GlobalVariables::get("dao")->save($giornalista);
|
|
GUIHandler::redirect("admin/login.php");
|
|
}
|
|
}
|
|
}catch(GUIException $ex){
|
|
$error = $ex->getMessageMerged("<br/>");
|
|
}catch (Exception $exec){
|
|
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_ERROR, $exec->getMessage());
|
|
$error = "Si è verificato un errore inaspettato durante l'esecuzione della pagina. Se l'errore persiste contattare il supporto tecnico.";
|
|
}
|
|
|
|
?>
|
|
<div>
|
|
<?php
|
|
if(strcmp($error, "")!=0){
|
|
echo '<div style="font-size: 16px; color:red;">'.$error.'</div>';
|
|
}
|
|
?>
|
|
<form id="adminConfirmForm" method="POST" action="">
|
|
<input type="hidden" name="action" value="" />
|
|
<input type="hidden" name="id" value="<?php echo $id;?>" />
|
|
<div>
|
|
<span class="label">Nome</span>
|
|
<input type="text" name="nome" value="<?php echo $giornalista->nome; ?>" />
|
|
</div>
|
|
<div>
|
|
<span class="label">Cognome</span>
|
|
<input type="text" name="cognome" value="<?php echo $giornalista->cognome; ?>" />
|
|
</div>
|
|
<div>
|
|
<span class="label">Username</span>
|
|
<input type="text" name="username" value="<?php echo $giornalista->username; ?>" />
|
|
</div>
|
|
<div>
|
|
<span class="label">Password</span>
|
|
<input type="password" name="password" value="" />
|
|
</div>
|
|
<div>
|
|
<span class="label">Conferma Password</span>
|
|
<input type="password" name="password_confirm" value="" />
|
|
</div>
|
|
</form>
|
|
<div class="formBtns">
|
|
<a href="#" id="adminConfirmForm_salva" >Conferma</a>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(event){
|
|
$("#adminConfirmForm_salva").click(function(event){
|
|
$("form#adminConfirmForm input[type=hidden][name=action]").val("confirm");
|
|
$("form#adminConfirmForm").submit();
|
|
});
|
|
});
|
|
</script>
|