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;
 }
Esempio n. 7
0
 /**
  * [mvc_construct description]
  * @return [type] [description]
  */
 public function mvc_construct()
 {
     array_push($this->twig_include_path, addons);
     // define default value for url
     $this->url->fakesub = $this->url('fakesub');
     // the $_SERVER[REQUEST_URI]
     $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!!");
     $this->data->site['langlist'] = \lib\utility\option::languages();
     $this->data->site['currentlang'] = \lib\define::get_language();
     $this->data->site['defaultLang'] = \lib\define::get_language('default');
     // if allow to use social then get social network account list
     if (\lib\utility\option::get('social', 'status')) {
         $this->data->social = \lib\utility\option::get('social', 'meta');
     }
     $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 = $this->data->site['currentlang'];
     $this->global->direction = \lib\define::get_language('direction');
     $this->global->id = $this->url('path', '_');
     // add special pages to display array to use without name
     $this->data->display['main'] = "content/main/layout.html";
     $this->data->display['home'] = "content/home/display.html";
     $this->data->display['account'] = "content_account/home/layout.html";
     $this->data->display['cp'] = "content_cp/home/layout.html";
     $this->data->display['pagination'] = "content_cp/templates/inc_pagination.html";
     // add special pages to template array to use without name
     $this->data->template['header'] = 'content/template/header.html';
     $this->data->template['sidebar'] = 'content/template/sidebar.html';
     $this->data->template['footer'] = 'content/template/footer.html';
     // 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 (isset($this->controller->pagnation)) {
         $this->data->pagnation = $this->controller->pagnation_get();
     }
     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, 'options')) {
         $this->options();
     }
     if (\lib\utility\option::get('config', 'meta', 'saveAsCookie')) {
         $mygetlist = \lib\utility::get(null, 'raw');
         if ($mygetlist) {
             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();
     }
 }