Beispiel #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!'));
     }
 }
Beispiel #2
0
 public function put_verification()
 {
     // get parameters and set to local variables
     $mycode = utility::post('code');
     $mymobile = utility::post('mobile', 'filter');
     $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"));
     }
 }
Beispiel #3
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"));
     }
 }
Beispiel #4
0
 public function mvc_construct()
 {
     // define default value for url
     $this->url->full = $this->url('full');
     // full url except get parameter with http[s]
     $this->url->path = $this->url('path');
     // full path except parameter and domain name
     $this->url->breadcrumb = $this->url('breadcrumb');
     // full path in array for using in breadcrumb
     $this->url->domain = $this->url('domain');
     // domain name like 'ermile'
     $this->url->base = $this->url('base');
     $this->url->tld = $this->url('tld');
     // domain ltd like 'com'
     $this->url->raw = Service;
     // domain name except subdomain like 'ermile.com'
     $this->url->root = $this->url('root');
     $this->url->static = $this->url->root . 'static/';
     $this->url->protocol = Protocol;
     $this->url->account = $this->url('account');
     $this->url->MainStatic = $this->url('MainService') . '/' . 'static/';
     $this->url->MainSite = $this->url('MainSite');
     $this->url->MainProtocol = $this->url('MainProtocol');
     $this->url->SubDomain = SubDomain ? SubDomain . '.' : null;
     // return all parameters and clean it
     $this->url->param = \lib\utility::get(null, true);
     $this->url->all = $this->url->full . $this->url->param;
     $this->data->site['title'] = T_("Saloos");
     $this->data->site['desc'] = T_("Another Project with Saloos");
     $this->data->site['slogan'] = T_("Saloos is an artichokes for PHP programming!!");
     if (defined('LangList') && constant('LangList')) {
         $this->data->site['langlist'] = unserialize(constant('LangList'));
     } else {
         $this->data->site['langlist'] = ['fa_IR' => 'فارسی', 'en_US' => 'English'];
     }
     $current_lang_cookie = \lib\utility\Cookie::read('lang');
     $current_lang_get = \lib\utility::get('lang');
     if (SubDomain && SubDomain !== 'cp' && SubDomain !== 'account' && SubDomain !== 'files') {
         $this->data->site['currentlang'] = SubDomain;
     } elseif (isset($current_lang_get)) {
         $this->data->site['currentlang'] = substr($current_lang_get, 0, 2);
     } elseif (isset($current_lang_cookie)) {
         $this->data->site['currentlang'] = substr($current_lang_cookie, 0, 2);
     } else {
         $this->data->site['currentlang'] = substr(\lib\router::get_storage('defaultLanguage'), 0, 2);
     }
     $this->data->page['title'] = null;
     $this->data->page['desc'] = null;
     $this->data->page['special'] = null;
     $this->data->bodyclass = null;
     $this->data->module = $this->module();
     $this->data->child = $this->child();
     $this->data->login = $this->login('all');
     $this->data->perm = $this->access(null, 'all');
     $this->data->permContent = $this->access('all');
     // define default value for global
     $this->global->title = null;
     $this->global->login = $this->login();
     $this->global->lang = \lib\router::get_storage('language');
     $this->global->direction = \lib\router::get_storage('direction');
     $this->global->id = $this->url('path', '_');
     // define default value for include
     $this->include->newline = PHP_EOL;
     $this->include->css_main = false;
     $this->include->css_ermile = true;
     $this->include->js_main = true;
     $this->include->css = true;
     $this->include->js = true;
     $this->include->fontawesome = null;
     $this->include->datatable = null;
     $this->include->telinput = null;
     $this->include->lightbox = null;
     $this->include->editor = null;
     if (method_exists($this, '_construct')) {
         $this->_construct();
     }
     if (isset($this->url->MainStatic) && $this->url->MainStatic) {
         $this->url->myStatic = $this->url->MainStatic;
     } elseif (isset($this->url->MainStatic)) {
         $this->url->myStatic = $this->url->static;
     }
     if (method_exists($this, 'config')) {
         $this->config();
     }
     if (method_exists($this, 'options')) {
         $this->options();
     }
     $this->set_title();
     if (defined('SaveAsCookie') && SaveAsCookie) {
         $mygetlist = \lib\utility::get(null, 'raw');
         if ($mygetlist) {
             // var_dump(7); exit();
             foreach ($mygetlist as $name => $value) {
                 if ($name === 'ssid') {
                     $_SESSION['ssid'] = $value;
                 } elseif (!($name === 'dev' || $name === 'lang')) {
                     \lib\utility\Cookie::write($name, $value);
                 }
             }
             // remove get parameter from url
             header('Location: ' . $this->url('full'));
         }
     }
     // check main  ********************************************* CHECK FOR ONLY IN FIRST PAGE IN RIGHT PLACE
     // in all page like ajax request must be run
     if (AccountService === MainService) {
         $this->model()->checkMainAccount();
         $this->controller()->checkSession();
     }
     // if logvisitor on set visitors
     if (defined('LogVisitors') && constant('LogVisitors')) {
         $this->model()->addVisitor();
     }
 }
Beispiel #5
0
 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);
     }
 }