protected function action() { //Salvataggio nuovo avatar Utente $user = Session::getObj(Session::UTENTE); $msg = new SysMsg(); $avatar = new Avatar($_FILES["browse"]); $this->redirect = "user/adduseravatar"; $abort = 0; if (!($avatar->isValidType() && $avatar->isValidExtension())) { Session::setObj(Session::SYSMSG, $msg->setMessage('Formato file immagine non ammesso. [png - jpeg - gif]')->setType(SysMsg::MSG_ALERT)); $this->redirect = "user/fancymessage"; $abort = 1; } if (!$avatar->isValidSize()) { Session::setObj(Session::SYSMSG, $msg->setMessage('Dimensione file immagine non ammessa. [Max ' . Avatar::MAX_FILE_SIZE . ']')->setType(SysMsg::MSG_ALERT)); $this->redirect = "user/fancymessage"; $abort = 1; } if (!$avatar->noErrorDetected()) { Session::setObj(Session::SYSMSG, $msg->setMessage('Impossibile aprire il file immagine. Errore generico.')->setType(SysMsg::MSG_ALERT)); $this->redirect = "user/fancymessage"; $abort = 1; } if (!$abort) { $avatar->save($user->getId()); } }
protected function action() { //Autenticazione Utente $msg = new SysMsg(); $user = new Utente(Session::getObj(Session::NETWORKER)->getId()); $user->setNome(filter_var(ucfirst($_POST['nome']), FILTER_SANITIZE_STRING)); $user->setCognome(filter_var(ucfirst($_POST['cognome']), FILTER_SANITIZE_STRING)); $user->setEmail(filter_var($_POST['email'], FILTER_SANITIZE_STRING)); $user->setUsername(filter_var($_POST['username'], FILTER_SANITIZE_STRING)); $user->setPassword(filter_var($_POST['password'], FILTER_SANITIZE_STRING)); $user->update() ? Session::setObj(Session::SYSMSG, $msg->setMessage("Utente aggiornato correttamente.")->setType(SysMsg::MSG_OK)) : Session::setObj(Session::SYSMSG, $msg->setMessage("Aggiornamento utente fallito.")->setType(SysMsg::MSG_CRITICAL)); //*** Session::destroyObj(Session::NETWORKER); $this->redirect = "user/fancymessage"; }
protected function action() { //Autenticazione Utente $msg = new SysMsg(); $user = new Utente(Session::getObj(Session::UTENTE)->getId()); $user->setNome(filter_var($_POST['nome'], FILTER_SANITIZE_STRING)); $user->setCognome(filter_var($_POST['cognome'], FILTER_SANITIZE_STRING)); $user->setEmail(filter_var($_POST['email'], FILTER_SANITIZE_STRING)); $user->setUsername(filter_var($_POST['username'], FILTER_SANITIZE_STRING)); $user->setPassword(filter_var($_POST['password'], FILTER_SANITIZE_STRING)); if ($user->update()) { //Pone in sessione user Session::setObj(Session::UTENTE, $user); Session::setObj(Session::SYSMSG, $msg->setMessage("Utente aggiornato correttamente.")->setType(SysMsg::MSG_OK)); } else { Session::setObj(Session::SYSMSG, $msg->setMessage("Aggiornamento utente fallito.")->setType(SysMsg::MSG_CRITICAL)); } //*** $this->redirect = "user/fancymessage"; }
<?php $user = Session::getObj(Session::UTENTE); ?> <div class="boxcommonform"> <br/> <div class="boxtitle"> IMMAGINE DEL PROFILO </div> <div > <div class="boxaddavatar" > <img src="<?php echo $user->getAvatarUrl(); ?> " class="avatar img_200_200" /> </div> <div class="formlogin"> <form action="<?php echo UriDispatch::getFullUri("user/useravatarsave"); ?> " method="post" name="frmAddUserAvatar" enctype="multipart/form-data"> <input type="file" name="browse" title="Sfoglia" class="login required"/> <br /> <input type="submit" name="submit" value="Salva" class="button" onclick="return validateAll($('#frmAddUserAvatar'),'.login.required');"/> </form> </div> </div> </div>
<?php $utente = Session::getObj(Session::UTENTE); ?> <div class="boxlogin"> <br/> <div class="boxtitle"> AGGIORNA CONSULENTE </div> <div class="formlogin"> <form id="frmUpdUser" name="Login" action="userupdate" method="POST"> <p> * Nome:<br/> <input type="text" name="nome" value="<?php echo $utente->getNome(); ?> " size="40" class="login required"/> </p> <p> * Cognome:<br/> <input type="text" name="cognome" value="<?php echo $utente->getCognome(); ?> " size="40" class="login required"/> </p> <p> * Email:<br/> <input type="text" name="email" value="<?php echo $utente->getEmail();
<div class="menubar"> <?php $utente = Session::isSetObj(Session::UTENTE) ? Session::getObj(Session::UTENTE) : NULL; include Session::isSetObj(Session::UTENTE) ? 'menu/menusigned.php' : 'menu/menunotsigned.php'; ?> </div>
<?php $utente = Session::getObj(Session::NETWORKER); ?> <div class="boxlogin"> <br/> <div class="boxtitle"> AGGIORNA CONSULENTE </div> <div class="formlogin"> <form id="frmUpdUser" name="Login" action="<?php echo UriDispatch::getFullUri('user/ntwrkrupdate'); ?> " method="POST"> <p> * Nome:<br/> <input type="text" name="nome" value="<?php echo $utente->getNome(); ?> " size="40" class="login required"/> </p> <p> * Cognome:<br/> <input type="text" name="cognome" value="<?php echo $utente->getCognome(); ?> " size="40" class="login required"/> </p> <p> * Email:<br/>
protected function action() { $client = new Google_Client(); $client->setApplicationName('ITUK-Cinderella'); $client->setClientId('1047071962553-peio8aua5ac0a17s11a116thcr77ag4m.apps.googleusercontent.com'); $client->setClientSecret('d-XWxzPq11ZrDsh0RsbgFc9k'); $client->setRedirectUri('http://www.ituk.it/cinderella/it/gologin'); $client->setApprovalPrompt('auto'); $client->setAccessType('offline'); $oauth2 = new Google_Oauth2Service($client); //*** if (isset($_GET['code'])) { $client->authenticate($_GET['code']); Session::setObj(Session::TOKEN, $client->getAccessToken()); } //*** if (Session::isSetObj(Session::TOKEN)) { $client->setAccessToken(Session::getObj(Session::TOKEN)); } //*** if (isset($_REQUEST['error'])) { //Google returns an error Session::setObj(Session::SYSMSG, 'Errore durante l\'autenticazione con Google, per favore riprovare più tardi.'); $this->redirect = 'message'; exit; } //*** if ($client->getAccessToken()) { $user = $oauth2->userinfo->get(); //The access token may have been updated lazily. Session::setObj(Session::TOKEN, $client->getAccessToken()); //*** $goid = $user['id']; // To Get Google ID $gofullname = $user['name']; // To Get Google full name $gofirstname = $user['given_name']; // To Get Google first name $golastname = $user['family_name']; // To Get Google last name $goemail = filter_var($user['email'], FILTER_SANITIZE_EMAIL); // To Get Google email ID $goavatar = filter_var($user['picture'], FILTER_VALIDATE_URL); // To Get Google avatar //Check if already logged in with Google //Create new Google user $go_user = new UtenteGo($goid); if (!$go_user->hereIam()) { //Save as regular user $objDateTime = new DateTime('NOW'); $fakepassw = md5($objDateTime->format('c')); $fakeemail = $fakepassw . '@google.com'; $go_user->setNome($gofirstname); $go_user->setCognome($golastname); $go_user->setEmail(isset($goemail) && strlen($goemail) > 0 ? $goemail : $fakeemail); $go_user->setUsername('GoogleUser'); $go_user->set_password($fakepassw); $go_user->save(); //Save as Google user $go_user->setGoId($goid); $go_user->setAvatarUrl($goavatar); //Save Google credentials $go_user->saveAsGoUser(); } //Login user Session::setObj(Session::UTENTE, $go_user); Session::setObj(Session::SYSMSG, 'Benvenuto ' . $go_user->getNome() . ' ' . $go_user->getCognome()); $this->redirect = 'message'; } else { //Try Google Authentication $loginUrl = $client->createAuthUrl(); $this->redirect = $loginUrl; } }
<?php $sysMsg = Session::getObj(Session::SYSMSG); ?> <div class="boxmessage" > <div class="boxlogin shadow" > <div style="padding-top: 50px;"> <img src="<?php echo $sysMsg->getIconUrl(); ?> " class="img_48_48" /> <?php echo $sysMsg->getMessage(); ?> </div> <div style="padding:80px;"> <a href="./home" title="Entra"> <img src="<?php echo $sysMsg->getParameter('useravatar'); ?> " class="avatar img_60_60" /> </a> </div> </div> </div>