protected function action()
 {
     $msg = new SysMsg();
     $plan = new Unilevel();
     $plan->setLevel(mysql_real_escape_string($_POST['level']));
     $plan->setDescription(mysql_real_escape_string($_POST['desc']));
     $mycomm = floatval(preg_replace("/[^-0-9\\.]/", ".", mysql_real_escape_string($_POST['comm'])));
     $plan->setCommission($mycomm);
     $redirect = 'user/fancymessage';
     if ($plan->getLevel() > 0 && $plan->getDescription() != '' && $plan->getCommission() > 0) {
         if ($plan->save()) {
             $redirect = 'user/addplanunilevel';
         } else {
             Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento piano Unilevel fallito.')->setType(SysMsg::MSG_CRITICAL));
         }
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Tutti i campi sono obbligatori. Inserimento piano Unilevel fallito.')->setType(SysMsg::MSG_CRITICAL));
     }
     //***
     $this->redirect = $redirect;
 }
Example #2
0
 protected function action()
 {
     //Autenticazione Utente
     $msg = new SysMsg();
     $user = new Utente();
     $user->setParent(mysql_real_escape_string($_POST['parent']));
     $user->setNome(mysql_real_escape_string(ucfirst($_POST['nome'])));
     $user->setCognome(mysql_real_escape_string(ucfirst($_POST['cognome'])));
     $user->setEmail(mysql_real_escape_string($_POST['email']));
     $user->setUsername(mysql_real_escape_string($_POST['username']));
     $user->setPassword(mysql_real_escape_string($_POST['password']));
     if ($user->getNome() != '' && $user->getCognome() != '' && $user->getEmail() != '' && $user->getUsername() != '' && $user->getPassword() != '') {
         if ($user->save()) {
             $user->login();
             //Pone in sessione user (se autenticato)e message
             if ($user->isAutenticated()) {
                 Session::setObj(Session::UTENTE, $user);
             }
             //***
             Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento utente avvenuto correttamente.')->setType(SysMsg::MSG_OK));
         } else {
             Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento utente fallito.')->setType(SysMsg::MSG_CRITICAL));
         }
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Tutti i campi sono obbligatori. Inserimento utente fallito.')->setType(SysMsg::MSG_ALERT));
     }
     //***
     $this->redirect = "user/fancymessage";
 }
Example #3
0
 protected function action()
 {
     $userMail = filter_var($_POST['email'], FILTER_SANITIZE_STRING);
     $msg = new SysMsg();
     if ($this->checkEmailAddress($userMail)) {
         $user = new Utente();
         $user->setEmail($userMail);
         $pwd = $user->getForgottenPassword();
         if ($pwd != '') {
             $msg = 'Salve, abbiamo recuperato la sua password: '******'Servizio');
             $mail->setCognome('Support');
             $mail->setEmailFrom('*****@*****.**');
             $mail->setEmailTo($userMail);
             $mail->setEmailReplyTo('*****@*****.**');
             $mail->setOggetto('Recupero password.');
             $mail->setMessaggio($msg);
             $mail->sendMail();
             Session::setObj(Session::SYSMSG, $msg->setMessage('La password &egrave stata inviata a: ' . $userMail)->setType(SysMsg::MSG_OK));
         } else {
             Session::setObj(Session::SYSMSG, $msg->setMessage('Spiacente, non siamo riusciti a recuperare la sua password.')->setType(SysMsg::MSG_CRITICAL));
         }
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Spiacente, email errata.')->setType(SysMsg::MSG_ALERT));
     }
     //***
     $this->redirect = "message";
 }
 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());
     }
 }
Example #5
0
 protected function action()
 {
     //Logout Utente
     $msg = new SysMsg();
     Session::destroyObj(Session::UTENTE);
     Session::setObj(Session::SYSMSG, $msg->setMessage("Logout eseguito correttamente.")->setType(SysMsg::MSG_OK));
     //***
     $this->redirect = "user/message";
 }
Example #6
0
 protected function action()
 {
     $this->showContentOnly = TRUE;
     try {
         $idntwrkr = $this->uriPath[count($this->uriPath) - 1];
     } catch (Exception $exc) {
         $idntwrkr = NULL_PARENT_ROOT;
     }
     Session::setObj(Session::NETWORKER, new Utente($idntwrkr));
     $this->pageToView = "loadntwrkr";
     parent::action();
 }
Example #7
0
 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()
 {
     $msg = new SysMsg();
     $sale = new Vendita();
     $sale->setNetworker(mysql_real_escape_string($_POST['idntwrkr']));
     $sale->setDateSale(mysql_real_escape_string($_POST['datepicker']));
     $myamount = floatval(preg_replace("/[^-0-9\\.]/", ".", mysql_real_escape_string($_POST['importo'])));
     $sale->setAmount($myamount);
     if ($sale->getNetworker() > 0 && $sale->getDateSale() != '' && $sale->getAmount() > 0) {
         $sale->save() ? Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento nuova vendita avvenuto correttamente.')->setType(SysMsg::MSG_OK)) : Session::setObj(Session::SYSMSG, $msg->setMessage('Inserimento nuova vendita fallito.')->setType(SysMsg::MSG_CRITICAL));
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Tutti i campi sono obbligatori. Inserimento nuova vendita fallito.')->setType(SysMsg::MSG_CRITICAL));
     }
     //***
     $this->redirect = "user/fancymessage";
 }
Example #9
0
 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";
 }
Example #10
0
 protected function action()
 {
     $msg = new SysMsg();
     $rdrct = "user/message";
     if ($_POST['username'] != "" && $_POST['password'] != "") {
         //Autenticazione Utente
         $user = new Utente();
         $user->setUsername(filter_var($_POST['username'], FILTER_SANITIZE_STRING));
         $user->setPassword(filter_var($_POST['password'], FILTER_SANITIZE_STRING));
         $user->login();
         //Pone in sessione user (se autenticato)e message
         if ($user->isAutenticated()) {
             Session::setObj(Session::UTENTE, $user);
             Session::setObj(Session::SYSMSG, $msg->setMessage('Benvenuto ' . $user->getNome() . ' ' . $user->getCognome())->setType(SysMsg::MSG_OK)->addParameter('useravatar', $user->getAvatarUrl()));
             $rdrct = "user/welcome";
         } else {
             Session::setObj(Session::SYSMSG, $msg->setMessage('Username/Password errati. Login fallito.')->setType(SysMsg::MSG_CRITICAL));
         }
     } else {
         Session::setObj(Session::SYSMSG, $msg->setMessage('Username/Password non inseriti. Login fallito.')->setType(SysMsg::MSG_ALERT));
     }
     //***
     $this->redirect = $rdrct;
 }
Example #11
0
 protected function action()
 {
     //Init app with app id and secret
     FacebookSession::setDefaultApplication('416201525206070', 'db946f783550299dcf77faf9f09a8f41');
     //Login helper with redirect_uri
     $helper = new FacebookRedirectLoginHelper('http://www.ituk.it/cinderella/fblogin');
     try {
         $session = $helper->getSessionFromRedirect();
     } catch (FacebookRequestException $ex) {
         //Facebook returns an error
         Session::setObj(Session::SYSMSG, 'Errore durante l\'autenticazione con Facebook, per favore riprovare più tardi.');
         $this->redirect = 'message';
         exit;
     } catch (Exception $ex) {
         //Validation fails or other local issues
         Session::setObj(Session::SYSMSG, 'Errore durante l\'autenticazione con Facebook, per favore riprovare più tardi.');
         $this->redirect = 'message';
         exit;
     }
     //See if we have a session
     if (isset($session)) {
         //Graph api request for user data
         $request = new FacebookRequest($session, 'GET', '/me');
         $response = $request->execute();
         //Get response
         $graphObject = $response->getGraphObject();
         $fbid = $graphObject->getProperty('id');
         // To Get Facebook ID
         $fbfullname = $graphObject->getProperty('name');
         // To Get Facebook full name
         $fbfirstname = $graphObject->getProperty('first_name');
         // To Get Facebook first name
         $fblastname = $graphObject->getProperty('last_name');
         // To Get Facebook last name
         $fbemail = $graphObject->getProperty('email');
         // To Get Facebook email ID
         //Check if already logged in with Facebook
         //Create new Facebook user
         $fb_user = new UtenteFb($fbid);
         if (!$fb_user->hereIam()) {
             //Save credentials as regular user
             $objDateTime = new DateTime('NOW');
             $fakepassw = md5($objDateTime->format('c'));
             $fakeemail = $fakepassw . '@facebook.com';
             $fb_user->setNome($fbfirstname);
             $fb_user->setCognome($fblastname);
             $fb_user->setEmail(isset($fbemail) && strlen($fbemail) > 0 ? $fbemail : $fakeemail);
             $fb_user->setUsername('FacebookUser');
             $fb_user->set_password($fakepassw);
             $fb_user->save();
             //Save as Facebook user
             $fb_user->setFbId($fbid);
             $fb_user->setAvatarUrl($fb_user->getAvatarUrl());
             //Save Facebook credentials
             $fb_user->saveAsFbUser();
         }
         //Login user
         Session::setObj(Session::UTENTE, $fb_user);
         Session::setObj(Session::SYSMSG, 'Benvenuto ' . $fb_user->getNome() . ' ' . $fb_user->getCognome());
         $this->redirect = 'message';
     } else {
         //Try Facebook Authentication
         $loginUrl = $helper->getLoginUrl();
         $this->redirect = $loginUrl;
     }
 }
Example #12
0
 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;
     }
 }