public function post_login() { // get parameters and set to local variables $mymobile = utility::post('mobile', 'filter'); $mypass = utility::post('password'); // check for mobile exist $tmp_result = $this->sql()->tableUsers()->whereUser_mobile($mymobile)->and('user_status', 'active')->select(); // $tmp_result = $this->sql()->tableUsers()->select(); // if exist if ($tmp_result->num() == 1) { $tmp_result = $tmp_result->assoc(); $myhashedPassword = $tmp_result['user_pass']; // if password is correct. go for login:) if (isset($myhashedPassword) && utility::hasher($mypass, $myhashedPassword)) { // you can change the code way easily at any time! // $qry = $this->sql()->tableUsers () // ->setUser_logincounter ($tmp_result['user_logincounter'] +1) // ->whereId ($tmp_result['id']); // $sql = $qry->update(); $myfields = array('id', 'user_displayname', 'user_mobile', 'user_meta', 'user_status'); $this->setLoginSession($tmp_result, $myfields); // ====================================================== // 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 () { // $this->logger('login'); // create code for pass with get to service home page debug::true(T_("Login Successfully")); \lib\utility\session::save(); $referer = \lib\router::urlParser('referer', 'host'); // set redirect to homepage $this->redirector()->set_domain()->set_url(); if (\lib\utility\option::get('account', 'status')) { $_redirect_sub = \lib\utility\option::get('account', 'meta', 'redirect'); if ($_redirect_sub !== 'home') { if (\lib\utility\option::get('config', 'meta', 'fakeSub')) { $this->redirector()->set_url($_redirect_sub); } else { $this->redirector()->set_sub_domain($_redirect_sub); } } } // do not use pushstate and run link direct debug::msg('direct', true); }); $this->rollback(function () { debug::error(T_("Login failed!")); }); } else { debug::error(T_("Mobile or password is incorrect")); } } elseif ($tmp_result->num() == 0) { debug::error(T_("Mobile or password is incorrect")); } else { debug::error(T_("Please forward this message to administrator")); } // sleep(0.1); }
public function post_login() { // get parameters and set to local variables $mymobile = utility::post('mobile', 'filter'); $mypass = utility::post('password'); // check for mobile exist $tmp_result = $this->sql()->tableUsers()->whereUser_mobile($mymobile)->and('user_status', 'active')->select(); // $tmp_result = $this->sql()->tableUsers()->select(); // if exist if ($tmp_result->num() == 1) { $tmp_result = $tmp_result->assoc(); $myhashedPassword = $tmp_result['user_pass']; // if password is correct. go for login:) if (isset($myhashedPassword) && utility::hasher($mypass, $myhashedPassword)) { // you can change the code way easily at any time! // $qry = $this->sql()->tableUsers () // ->setUser_logincounter ($tmp_result['user_logincounter'] +1) // ->whereId ($tmp_result['id']); // $sql = $qry->update(); $myfields = array('id', 'user_displayname', 'user_mobile', 'user_status'); $this->setLoginSession($tmp_result, $myfields); // ====================================================== // 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 () { // $this->logger('login'); // create code for pass with get to service home page debug::true(T_("Login Successfully")); $referer = \lib\router::urlParser('referer', 'host'); /** * temporary: after fix permissions below line must be delete */ if ($referer == 'archiver.dev' || $referer == 'irancamera.ir') { $this->redirector()->set_domain()->set_sub_domain('files')->set_url(); } elseif (\lib\router::get_storage('CMS')) { $this->redirector()->set_domain()->set_sub_domain(\lib\router::get_storage('CMS'))->set_url(); } else { $this->redirector()->set_domain()->set_url(); } }); $this->rollback(function () { debug::error(T_("Login failed!")); }); } else { debug::error(T_("Mobile or password is incorrect")); } } elseif ($tmp_result->num() == 0) { debug::error(T_("Mobile or password is incorrect")); } else { debug::error(T_("Please forward this message to administrator")); } sleep(0.1); }
public function config() { // $this->data->list = $this->cpModlueList('all'); $this->data->bodyclass = 'fixed unselectable'; $this->include->css = false; $this->include->js = false; $this->include->fontawesome = true; $this->include->datatable = true; $this->include->chart = true; $this->include->introjs = true; $this->include->lightbox = true; $this->include->editor = true; $this->include->cp = true; $this->include->uploader = true; $this->global->js = array(); $this->data->display['cp_posts'] = "content_cp/posts/layout.html"; $this->data->saloos['version'] = \lib\saloos::getLastVersion(); $this->data->saloos['lastUpdate'] = \lib\saloos::getLastUpdate(); $this->data->saloos['langlist'] = ['fa_IR' => 'Persian - فارسی', 'en_US' => 'English', 'ar_SU' => 'Arabic - العربية']; $this->data->modules = $this->controller::$manifest['modules']->get_modules(); // $this->global->js = [$this->url->myStatic.'js/highcharts/highcharts.js']; // $this->data->page['desc'] = 'salam'; $mymodule = $this->module(); $this->data->page['desc'] = $this->controller::$manifest['modules']->get_modules($mymodule, "desc"); $this->data->page['title'] = $this->controller::$manifest['modules']->get_modules($mymodule, "title"); $this->data->page['haschild'] = $this->controller::$manifest['modules']->get_modules($mymodule, "childless") ? false : true; $this->data->page['title'] = T_(ucfirst(\lib\router::get_url(' '))); $this->data->cpModule = $this->cpModule(); $this->data->dir['right'] = $this->global->direction == 'rtl' ? 'left' : 'right'; $this->data->dir['left'] = $this->global->direction == 'rtl' ? 'right' : 'left'; switch ($mymodule) { case 'visitors': if (\lib\utility\option::get('config', 'meta', 'logVisitors')) { // create for chart $type = \lib\utility::get('type'); $utype = \lib\utility::get('utype'); $stype = \lib\utility::get('stype'); $atype = \lib\utility::get('atype'); $this->data->chart_type = $type ? $type : 'column'; $this->data->chart_unique_type = $utype ? $utype : 'areaspline'; $this->data->chart_signup_type = $stype ? $stype : 'areaspline'; $this->data->chart_answered_type = $atype ? $atype : 'column'; // $this->data->visitors = $this->model()->visitors(); // $this->data->visitors_unique = $this->model()->visitors(true); $this->data->visitors = \lib\utility\visitor::chart(); $this->data->visitors_unique = \lib\utility\visitor::chart(true); // get period of signup from user $this->data->period = \lib\utility::get('period'); switch ($this->data->period) { case 'year': $period = "%Y"; break; case 'month': $period = "%Y-%m"; break; case 'week': $period = "%Y " . T_('week') . "%V"; break; case 'day': default: $period = "%Y-%m-%d"; break; } $this->data->signup = \lib\db\chart\users::signup($period); if (class_exists('\\lib\\db\\chart\\polls')) { $this->data->answered = \lib\db\chart\polls::answeredCount($period); } if ($this->data->visitors <= 1) { $this->data->error = T_("Chart must be contain at least 2 column!"); } } break; case 'home': $this->data->countOf['posts'] = $this->model()->countOf('posts'); $this->data->countOf['pages'] = $this->model()->countOf('pages'); $this->data->countOf['attachments'] = $this->model()->countOf('attachments'); $this->data->countOf['books'] = $this->model()->countOf('books'); $this->data->countOf['tags'] = $this->model()->countOf('tags'); $this->data->countOf['categories'] = $this->model()->countOf('categories'); $this->data->countOf['users'] = $this->model()->countOf('users'); $this->data->bodyclass .= ' unselectable'; // check visitor is new or not $this->data->visitor_new = false; $ref = \lib\router::urlParser('referer', 'sub'); if ($ref !== 'cp' && $ref !== null) { $this->data->visitor_new = true; } if (\lib\utility\option::get('config', 'meta', 'logVisitors')) { // create for chart $this->data->chart_type = 'column'; $this->data->visitors = \lib\utility\visitor::chart(); $this->data->visitors_toppages = \lib\utility\visitor::top_pages(15); if ($this->data->visitors <= 1) { $this->data->error = T_("Chart must be contain at least 2 column!"); } } break; default: # code... break; } if ($this->data->page['haschild']) { // Check permission and if user can do this operation // allow to do it, else show related message in notify center $myResult = $this->access('cp', $mymodule, 'add'); $this->data->page['haschild'] = $myResult ? true : false; } // $f = array_keys($this->controller::modules_hasnot('disable')); // $feature = []; // foreach ($f as $key => $value) { // $feature[$value] = true; // } // $this->data->site['title'] = T_('Control Panel'). ' - ' . $this->data->site['title']; }
/** * 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; }
public function config() { // $this->data->list = $this->cpModlueList('all'); $this->data->bodyclass = 'fixed'; $this->include->css = false; $this->include->js = false; $this->include->fontawesome = true; $this->include->datatable = true; $this->include->chart = true; $this->include->introjs = true; $this->include->lightbox = true; $this->include->editor = true; $this->include->cp = true; $this->include->uploader = true; $this->global->js = array(); // $this->global->js = [$this->url->myStatic.'js/highcharts/highcharts.js']; // $this->data->page['desc'] = 'salam'; $this->data->page['haschild'] = true; $this->data->page['title'] = T_(ucfirst(\lib\router::get_url(' '))); $this->data->dir['right'] = $this->global->direction == 'rtl' ? 'left' : 'right'; $this->data->dir['left'] = $this->global->direction == 'rtl' ? 'right' : 'left'; $mymodule = $this->module(); switch ($mymodule) { case 'tags': $this->data->page['desc'] = T_('Assign keywords to your posts using tags'); break; case 'categories': $this->data->page['desc'] = T_('Use categories to define sections of your site and group related posts'); $this->data->page['title'] = T_('Categories'); break; case 'filecategories': $this->data->page['desc'] = T_('Use categories to define sections of your site and group related files'); $this->data->page['title'] = T_('File Categories'); break; case 'bookcategories': $this->data->page['desc'] = T_('Use categories to define sections of your site and group related books'); $this->data->page['title'] = T_('Book Categories'); break; case 'books': $this->data->page['desc'] = T_('Use book to define important parts to use in posts'); $this->data->page['title'] = T_('books'); break; case 'posts': $this->data->page['desc'] = T_('Use posts to share your news in specefic category'); break; case 'pages': $this->data->page['desc'] = T_('Use pages to share your static content'); break; case 'attachments': $this->data->page['desc'] = T_('Upload your media'); break; case 'socialnetwork': $this->data->page['desc'] = T_('Publish new post in social networks'); break; case 'options': $this->data->page['desc'] = T_('Edit your site general options'); $this->data->page['haschild'] = false; break; case 'visitors': if (LogVisitors) { // create for chart $type = \lib\utility::get('type'); $utype = \lib\utility::get('utype'); $this->data->chart_type = $type ? $type : 'column'; $this->data->chart_unique_type = $utype ? $utype : 'areaspline'; $this->data->visitors = $this->model()->visitors(); $this->data->visitors_unique = $this->model()->visitors(true); if ($this->data->visitors <= 1) { $this->data->error = T_("Chart must be contain at least 2 column!"); } } break; case 'home': $this->data->page['title'] = T_('Dashboard'); $this->data->countOf['posts'] = $this->model()->countOf('posts'); $this->data->countOf['pages'] = $this->model()->countOf('pages'); $this->data->countOf['attachments'] = $this->model()->countOf('attachments'); $this->data->countOf['books'] = $this->model()->countOf('books'); $this->data->countOf['tags'] = $this->model()->countOf('tags'); $this->data->countOf['categories'] = $this->model()->countOf('categories'); $this->data->countOf['users'] = $this->model()->countOf('users'); $this->data->bodyclass .= ' unselectable'; // check visitor is new or not $this->data->visitor_new = false; $ref = \lib\router::urlParser('referer', 'sub'); if ($ref !== 'cp' && $ref !== null) { $this->data->visitor_new = true; } if (LogVisitors) { // create for chart $this->data->chart_type = 'column'; $this->data->visitors = $this->model()->visitors(); $this->data->visitors_toppages = $this->model()->visitors_toppages(15); if ($this->data->visitors <= 1) { $this->data->error = T_("Chart must be contain at least 2 column!"); } } break; default: # code... break; } if ($this->data->page['haschild']) { // Check permission and if user can do this operation // allow to do it, else show related message in notify center $myResult = $this->access('cp', $mymodule, 'add'); $this->data->page['haschild'] = $myResult ? true : false; } // $this->data->site['title'] = T_('Control Panel'). ' - ' . $this->data->site['title']; }
/** * find best display for this page! * @return [type] [description] */ function cpFindDisplay() { $mymodule = $this->cpModule('table'); $cpModule = $this->cpModule('raw'); $mychild = $this->child(); $mypath = $this->url('path', '_'); if (is_file(addons . 'content_cp/' . $cpModule . '/model.php') && !$this->model_name) { $this->model_name = '\\addons\\content_cp\\' . $cpModule . '\\model'; } elseif (is_file(addons . 'content_cp/' . $mymodule . '/model.php') && !$this->model_name) { $this->model_name = '\\addons\\content_cp\\' . $mymodule . '\\model'; } switch ($cpModule) { case 'home': break; case 'profile': //allow put on profile $this->display_name = 'content_cp/templates/module_profile.html'; $this->get(null, 'datatable')->ALL($cpModule); $this->put('profile')->ALL($cpModule); break; // case 'permissions': // $this->display_name = 'content_cp/templates/module_permissions.html'; // $this->get(null, 'datatable')->ALL('/^[^\/]*$/'); // $this->put('permissions')->ALL(); // break; // case 'permissions': // $this->display_name = 'content_cp/templates/module_permissions.html'; // $this->get(null, 'datatable')->ALL('/^[^\/]*$/'); // $this->put('permissions')->ALL(); // break; case 'logout': $mydomain = AccountService ? AccountService . MainTld : null; $this->redirector(null, false)->set_domain($mydomain)->set_url('logout')->redirect(); break; default: if (is_file(addons . 'content_cp/templates/module_' . $mymodule . '.html')) { $this->display_name = 'content_cp/templates/module_' . $mymodule . '.html'; } else { $this->display_name = 'content_cp/templates/module_display.html'; } $this->get(null, 'datatable')->ALL('/^[^\\/]*$/'); // on each module except home and some special module with child like /post/add if ($mychild) { if (is_file(addons . 'content_cp/templates/child_' . $mymodule . '.html')) { $this->display_name = 'content_cp/templates/child_' . $mymodule . '.html'; } else { $this->display_name = 'content_cp/templates/child_display.html'; } //all("edit=.*") // $this->route_check_true = true; switch ($mychild) { case 'delete': $referrer = \lib\router::urlParser('referer', 'full'); $this->redirector($referrer); // $this->redirector()->set_url($this->cpModule('raw')); //->redirect(); // $this->delete($mychild)->ALL('/^[^\/]*\/[^\/]*$/'); $this->post($mychild)->ALL(["url" => [$cpModule, "/^delete=(\\d+)\$/"]]); $this->get($mychild)->ALL(["url" => [$cpModule, "/^delete=(\\d+)\$/"]]); // @hasan: regular? // $this->display_name = null; // $this->redirector()->set_url($cpModule);//->redirect(); return; break; case 'edit': $this->get(null, 'child')->ALL(["url" => [$cpModule, "/^edit=(\\d+)\$/"]]); $this->put($mychild)->ALL(["url" => [$cpModule, "/^edit=(\\d+)\$/"]]); break; case 'add': $this->get(null, 'child')->ALL(["url" => [$cpModule, "add"]]); $this->post($mychild)->ALL(["url" => [$cpModule, "add"]]); break; case 'list': // $this->route_check_true = false; $this->get($mychild)->ALL(["max" => 2]); $this->post($mychild)->ALL(["max" => 2]); break; case 'options': // $this->route_check_true = false; $this->get($mychild)->ALL(["max" => 2]); $this->post($mychild)->ALL(["max" => 2]); break; default: break; } } break; } if (is_file(addons . 'content_cp/templates/static_' . $mypath . '.html')) { $this->display_name = 'content_cp/templates/static_' . $mypath . '.html'; } }