Esempio n. 1
0
 public function post_verificationsms()
 {
     $mymobile = utility\cookie::read('mobile');
     $tmp_result = $this->sql()->tableSmss()->whereSms_from($mymobile)->andSms_type('receive')->andSms_status('enable')->select();
     if ($tmp_result->num() == 1) {
         $this->put_changeSmsStatus($mymobile);
     } else {
         debug::warn(T_('we are waiting for your message!'));
     }
 }
Esempio n. 2
0
 /**
  * check referrer and redirect to specefic service
  * @param [type]  $_id       [description]
  * @param boolean $_redirect [description]
  */
 protected function setLogin($_id, $_redirect = true)
 {
     $tmp_domain = null;
     $mycode = $this->setLoginToken($_id);
     $this->checkMainAccount($_id);
     $myreferer = utility\cookie::read('referer');
     utility\cookie::delete('referer');
     if ($_redirect) {
         if ($myreferer === 'jibres' || $myreferer === 'talambar') {
             $tmp_domain = $myreferer . '.' . $this->url('tld');
         }
         $this->redirector()->set_domain($tmp_domain)->set_url('?ssid=' . $mycode);
     }
 }
Esempio n. 3
0
 public function put_verification()
 {
     // get parameters and set to local variables
     $mycode = utility::post('code');
     $mymobile = utility::post('mobile', 'filter');
     if ($mymobile == '' && isset($_SESSION['verification_mobile'])) {
         $mymobile = $_SESSION['verification_mobile'];
     }
     $myuserid = $this->sql()->table('users')->field('id')->where('user_mobile', $mymobile)->select()->assoc('id');
     // check for mobile exist
     $tmp_result = $this->sql()->table('logs')->where('user_id', $myuserid)->and('log_data', $mycode)->and('log_status', 'enable')->select();
     if ($tmp_result->num()) {
         // mobile and code exist update the record and verify
         $qry = $this->sql()->table('logs')->set('log_status', 'expire')->where('user_id', $myuserid)->and('log_data', $mycode)->and('log_status', 'enable');
         $sql = $qry->update();
         $sql_users = $this->sql()->table('users')->where('id', $myuserid)->set('user_status', 'active')->update();
         // ======================================================
         // you can manage next event with one of these variables,
         // commit for successfull and rollback for failed
         //
         // if query run without error means commit
         $this->commit(function ($_mobile, $_userid) {
             $myfrom = utility\cookie::read('from');
             if ($myfrom == 'signup') {
                 // login user to system
                 $this->model()->setLogin($_userid);
                 //Send SMS
                 \lib\utility\sms::send($_mobile, 'verification');
                 debug::true(T_("verify successfully."));
             } else {
                 // login user to system
                 $this->model()->setLogin($_userid, false);
                 $this->redirector()->set_url('changepass');
                 $myreferer = utility\cookie::write('mobile', $_mobile, 60 * 5);
                 $myreferer = utility\cookie::write('from', 'verification', 60 * 5);
                 debug::true(T_("verify successfully.") . ' ' . T_("please Input your new password"));
             }
         }, $mymobile, $myuserid);
         // if a query has error or any error occour in any part of codes, run roolback
         $this->rollback(function () {
             debug::error(T_("verify failed!"));
         });
     } elseif ($tmp_result->num() == 0) {
         debug::error(T_("this data is incorrect"));
     } else {
         debug::error(T_("please forward this message to administrator"));
     }
 }
Esempio n. 4
0
 function __construct($object = false)
 {
     parent::__construct($object);
     $settings = $this->option('account', null, false, $this);
     $mymodule = $this->module();
     $isValid = false;
     // // entire account part is disabled
     // if(isset($settings['status']) && !$settings['status'])
     // {
     // 	\lib\error::core('Disabled!');
     // }
     // check access permission to account
     // if user set passphrase for enter account
     if (isset($settings['meta']['passphrase']) && $settings['meta']['passphrase'] && $mymodule !== 'logout') {
         // if user set pass key
         if (isset($settings['meta']['passkey']) && $settings['meta']['passkey']) {
             // get pass key and save it in myphrase variable
             $myPassKey = $settings['meta']['passkey'];
             $myPassValue = \lib\utility::get($myPassKey);
             // if user not set pass value in get, then check cookie for it
             if ($myPassValue === null) {
                 $myPassValue = \lib\utility\cookie::read($myPassKey);
             }
             // if not set this passkey and incorrect
             if ($myPassValue === null) {
                 $isValid = false;
             } elseif (isset($settings['meta']['passvalue']) && $settings['meta']['passvalue']) {
                 // passvalue exist and equal
                 if ($settings['meta']['passvalue'] === $myPassValue) {
                     $isValid = true;
                 } else {
                     $isValid = false;
                 }
             } else {
                 $isValid = true;
             }
             // if can access set cookie
             if ($isValid) {
                 \lib\utility\cookie::write($myPassKey, $myPassValue, 60 * 60 * 24 * 7);
                 // allow 1week
             } else {
                 \lib\utility\cookie::delete($myPassKey);
                 \lib\error::login();
             }
         }
     }
 }
Esempio n. 5
0
 public function post_recovery()
 {
     // get parameters and set to local variables
     $mymobile = utility::post('mobile', 'filter');
     // check for mobile exist
     $tmp_result = $this->sql()->table('users')->where('user_mobile', $mymobile)->select();
     if ($tmp_result->num() == 1) {
         $myuserid = $tmp_result->assoc('id');
         $mylogitem = $this->sql()->table('logitems')->field('id')->where('logitem_title', 'account/recovery')->select()->assoc('id');
         if (!isset($mylogitem)) {
             return;
         }
         $mycode = utility::randomCode();
         $qry = $this->sql()->table('logs')->set('logitem_id', $mylogitem)->set('user_id', $myuserid)->set('log_data', $mycode)->set('log_status', 'enable')->set('log_createdate', date('Y-m-d H:i:s'));
         // var_dump($qry->insertString());
         // return;
         $sql = $qry->insert();
         // ======================================================
         // you can manage next event with one of these variables,
         // commit for successfull and rollback for failed
         //
         // if query run without error means commit
         $this->commit(function ($_mobile, $_code) {
             $myreferer = utility\cookie::read('referer');
             //Send SMS
             \lib\utility\sms::send($_mobile, 'recovery', $_code);
             debug::true(T_("we send a verification code for you"));
             $myreferer = utility\cookie::write('mobile', $_mobile, 60 * 5);
             $myreferer = utility\cookie::write('from', 'recovery', 60 * 5);
             $this->redirector()->set_url('verification?from=recovery&mobile=' . $_mobile . '&referer=' . $myreferer);
         }, $mymobile, $mycode);
         // if a query has error or any error occour in any part of codes, run roolback
         $this->rollback(function () {
             debug::error(T_("recovery failed!"));
         });
     } elseif ($tmp_result->num() == 0) {
         debug::error(T_("Mobile number is incorrect"));
     } else {
         debug::error(T_("please forward this message to administrator"));
     }
 }
Esempio n. 6
0
 /**
  * check route of account
  * @return [type] [description]
  */
 function _route()
 {
     // exit();
     // \lib\debug::true("check", 'hi');
     // var_dump();
     $mymodule = $this->module();
     $referer = \lib\router::urlParser('referer', 'domain');
     $from = \lib\utility\cookie::read('from');
     $from = $from ? $from : \lib\utility::get('from');
     $islogin = $this->login();
     // set referrer in cookie
     if ($referer !== Domain) {
         \lib\utility\cookie::write('referer', $referer, 60 * 15);
     }
     // check permission for changepass
     if ($mymodule === 'changepass' && $from !== 'verification' && !$islogin) {
         \lib\error::access(T_("you can't access to this page!"));
     }
     switch ($mymodule) {
         case 'home':
             $this->redirector()->set_url("login")->redirect();
             break;
         case 'verification':
         case 'verificationsms':
             if ($from && $from !== 'recovery' && $from !== 'signup' && $from !== 'verification') {
                 \lib\error::access(T_("you can't access to this page!"));
             }
             $this->model_name = '\\addons\\content_account\\' . $mymodule . '\\model';
             $this->display_name = 'content_account\\' . $mymodule . '\\display.html';
             $this->post($mymodule)->ALL($mymodule);
             $this->get()->ALL($mymodule);
             break;
         case 'signup':
             return;
             /**
             
             Fix it later, only access if posible
             */
         /**
         
         Fix it later, only access if posible
         */
         case 'login':
         case 'recovery':
             if ($islogin) {
                 \lib\debug::true(T_("you are logined to system!"));
                 $myreferer = \lib\router::urlParser('referer', 'host');
                 $myssid = isset($_SESSION['ssid']) ? '?ssid=' . $_SESSION['ssid'] : null;
                 if (\lib\router::get_storage('CMS')) {
                     $this->redirector()->set_domain()->set_sub_domain(\lib\router::get_storage('CMS'))->set_url()->redirect();
                 } else {
                     $this->redirector()->set_domain()->set_url()->redirect();
                 }
             }
         case 'changepass':
             $this->model_name = '\\addons\\content_account\\' . $mymodule . '\\model';
             $this->display_name = 'content_account\\' . $mymodule . '\\display.html';
             $this->post($mymodule)->ALL($mymodule);
             $this->get()->ALL($mymodule);
             break;
         case 'smsdelivery':
         case 'smscallback':
             $uid = 201500001;
             if (\lib\utility::get('uid') == $uid || \lib\utility\cookie::read('uid') == $uid) {
                 $this->model_name = '\\addons\\content_account\\sms\\model';
                 $this->display_name = 'content_account\\sms\\display.html';
                 $this->post($mymodule)->ALL($mymodule);
                 $this->get($mymodule)->ALL($mymodule);
             } else {
                 \lib\error::access("SMS");
             }
             break;
             // logout user from system then redirect to ermile
         // logout user from system then redirect to ermile
         case 'logout':
             $this->model_name = '\\lib\\mvc\\model';
             $this->model()->put_logout();
             $this->redirector()->set_domain()->set_url()->redirect();
             break;
         default:
             \lib\error::page();
             break;
     }
     // $this->route_check_true = true;
 }