public function pagnation_make($_total_records, $_length = null) { if (!$_length && !$this->pagnation_get('custom_length') && !$this->pagnation_get('length')) { \lib\error::internal("PAGENAMTION LENGTH NOTFOUND"); return; } else { $length = $this->pagnation_get('length') ? $this->pagnation_get('length') : intval($_length); } $total_pages = intval(ceil($_total_records / $length)); $current = $this->pagnation_get('current') ? $this->pagnation_get('current') : 1; $next = $current + 1; $prev = $current - 1; if ($current > $total_pages) { $this->pagnation_error(); } $this->pagnation_set('total_pages', $total_pages); $this->pagnation_set('current', $current); $this->pagnation_set('next', $next <= $total_pages ? $next : false); $this->pagnation_set('prev', $prev >= 1 ? $prev : false); $this->pagnation_set('count_link', 7); $path = \lib\router::get_url() ? '/' . \lib\router::get_url() : null; if ($path === null) { $path = preg_replace("/\\/page\\=\\d+/", "", $_SERVER['REQUEST_URI']); } $current_url = $this->url('base') . $path; $this->pagnation_set('current_url', $this->pagnation_get('custom_length') ? $current_url . "/length={$length}" : $current_url); $this->pagnation_set('length', $length); }
private function check($route) { if ($this->api->controller->method) { return; } $route_callback = call_user_func_array(array($this->api->controller, 'route'), func_get_args()); $api_callback = null; if ($route_callback->status) { $this->api->controller->method = $this->api_method; $args_object = object(array('method' => $this->api_method, 'match' => $route_callback->match)); if ($this->model_api_name) { $model_api_name = "api_" . $this->model_api_name; // $api_callback = $this->api->controller->model()->$model_api_name($args_object); $this->api->controller->model_api_processor = $object = object(array("method" => $model_api_name, "args" => $args_object)); // $this->api->controller->api_callback = $api_callback; } if ($this->view_api_name && !\lib\router::get_storage('api')) { $view_api_name = "view_" . $this->view_api_name; if ($this->model_api_name) { $args_object->api_callback = $api_callback; } // $api_callback = $this->api->controller->view()->$view_api_name($args_object); $this->api->controller->view_api_processor = $object = object(array("method" => $view_api_name, "args" => $args_object)); } } }
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); }
/** * if pass parameter return the property of it, else return value of child * @param [type] $_name [description] * @return [type] [description] */ public function childparam($_name = null) { if ($_name) { return router::get_url_property($_name); } else { return router::get_url_property($this->child()); } }
public function __construct($_repository_name = null) { $this->repository_name = $_repository_name === null ? \lib\router::get_repository_name() : $_repository_name; $include_path = $this->manifest_get_file_list(); foreach ($include_path as $key => $manifest_file) { $this->manifest_include_file($manifest_file); } }
function before__route() { if (!$this->access('cp', 'attachments', 'view')) { return; } $this->get('search_attachments', 'search_attachments')->ALL(['url' => [\lib\router::get_class(), 'attachments_data'], 'property' => ['attachments_search_q' => ['/^.*$/', true, 'search'], 'attachments_search_image' => ['/^(on|off)$/', true, 'image'], 'attachments_search_video' => ['/^(on|off)$/', true, 'video'], 'attachments_search_audio' => ['/^(on|off)$/', true, 'audio'], 'attachments_search_other' => ['/^(on|off)$/', true, 'other']], 'max' => 1], function () { $this->on_search_attachments = true; }); }
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 __construct($_protocol, $_url, $_title, $_desc) { $this->siteurl = $_protocol . $_url; $this->rssFeed = '<?xml version="1.0" encoding="utf-8"?>' . "\n\n"; $this->rssFeed .= '<rss version="2.0"' . "\n " . 'xmlns:content="http://purl.org/rss/1.0/modules/content/"' . "\n " . 'xmlns:wfw="http://wellformedweb.org/CommentAPI/"' . "\n " . 'xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n " . 'xmlns:atom="http://www.w3.org/2005/Atom"' . "\n " . 'xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"' . "\n " . 'xmlns:slash="http://purl.org/rss/1.0/modules/slash/"' . "\n" . '>' . "\n\n"; $this->rssFeed .= ' <channel>' . "\n\n"; $this->rssFeed .= ' <title>' . $_title . '</title>' . "\n"; $this->rssFeed .= ' <link>' . $_protocol . $_url . '</link>' . "\n"; $this->rssFeed .= ' <description>' . $_desc . '</description>' . "\n"; $this->rssFeed .= ' <language>' . str_replace('_', '-', \lib\router::get_storage('defaultLanguage')) . '</language>' . "\n"; $this->rssFeed .= ' <copyright>Copyright (C) ' . date("Y") . ' ' . $_url . '</copyright>' . "\n"; $this->rssFeed .= ' <generator>' . 'Saloos!' . '</generator>' . "\n"; }
function max($max) { $url = \lib\router::get_url(-1); if (count($url) > 0 && \lib\router::get_class() == $url[0]) { array_shift($url); } if (count($url) > 0 && \lib\router::get_method() == $url[0]) { array_shift($url); } if (count($url) > $max) { $this->status = false; } }
/** * get the list of pages * @param boolean $_select for use in select box * @return [type] return string or dattable */ public function sp_books_nav() { $myUrl = \lib\router::get_url(-1); $result = ['cats' => null, 'pages' => null]; $parent_search = null; switch (count($myUrl)) { // book/book1 case 2: $myUrl = $this->url('path'); $parent_search = 'id'; break; // book/book1/jeld1 // book/book1/jeld1 case 3: $myUrl = $this->url('path'); $parent_search = 'parent'; break; // book/book1/jeld1/page1 // book/book1/jeld1/page1 case 4: $myUrl = $myUrl[0] . '/' . $myUrl[1] . '/' . $myUrl[2]; $parent_search = 'parent'; break; // on other conditions return false // on other conditions return false default: return false; } // get id of current page $qry = $this->sql()->table('posts')->where('post_type', 'book')->and('post_url', $myUrl)->and('post_status', 'publish')->field('id', '#post_parent as parent')->select(); if ($qry->num() != 1) { return; } $datarow = $qry->assoc(); // get list of category or jeld $qry = $this->sql()->table('posts')->where('post_type', 'book')->and('post_status', 'publish')->and('post_parent', $datarow[$parent_search])->field('id', '#post_title as title', '#post_parent as parent', '#post_url as url')->select(); if ($qry->num() < 1) { return; } $result['cats'] = $qry->allassoc(); $catsid = $qry->allassoc('id'); $catsid = implode($catsid, ', '); // check has page on category or only in $qry2 = $this->sql()->table('posts')->where('post_type', 'book')->and('post_status', 'publish')->and('post_parent', 'IN', '(' . $catsid . ')')->field('id'); $qry2 = $qry2->select(); $result['pages'] = $qry2->num(); return $result; }
/** * [get_file_name description] * @param [type] $split_name [description] * @return [type] [description] */ static function get_file_name($split_name) { list($prefix, $sub_path, $exec_file) = self::ifile_splice($split_name); $prefix_file = null; if (preg_grep("/^{$prefix}\$/", self::$core_prefix)) { $file_addr = self::icheck_file($prefix, $sub_path, $exec_file); return $file_addr; } $prefix_file = \lib\router::get_repository(); $prefix_file = preg_replace("#\\/[^\\/]+\\/?\$#", '', $prefix_file); $file_addr = $prefix_file . '/' . $prefix . '/' . $sub_path . $exec_file; if (!file_exists($file_addr)) { $file_addr = false; } return $file_addr; }
static function get_file_name($split_name) { list($prefix, $sub_path, $exec_file) = self::ifile_splice($split_name); $prefix_file = null; $file_addr = parent::get_file_name($split_name); if (!preg_grep("/^{$prefix}\$/", self::$core_prefix)) { if (!$file_addr) { $prefix_file = \lib\router::get_repository(); $prefix_file = preg_replace("#\\/[^\\/]+\\/?\$#", '', $prefix_file); if (file_exists(addons . $prefix . '/' . $sub_path . $exec_file)) { $file_addr = addons . $prefix . '/' . $sub_path . $exec_file; } } } return $file_addr; }
/** * [find_url_from_shortURL description] * @param [type] $_shortURL [description] * @return [type] [description] */ public static function checkShortURL($_shortURL = null) { // set this shorturl, real url:) if (!\lib\utility\option::get('config', 'meta', 'shortURL')) { return null; } if (!$_shortURL) { $_shortURL = \lib\router::get_url(); } $table = null; $field = null; $urlPrefix = substr($_shortURL, 0, 3); switch ($urlPrefix) { case 'sp_': // if this is url of one post $table = 'post'; $field = "*"; break; case 'st_': // else if this is url of one term $table = 'term'; $field = 'term_url as url'; break; } // if prefix is not correct return false if (!$table) { return null; } // remove prefix from url $_shortURL = substr($_shortURL, 3); $id = \lib\utility\shortURL::decode($_shortURL); $table .= 's'; $qry = "SELECT {$field} FROM {$table} WHERE id = {$id}"; $result = \lib\db::get($qry, null, true); if (!is_array($result)) { return false; } if (!\lib\utility\option::get('config', 'meta', 'forceShortURL') && isset($result['post_url'])) { $post_url = $result['post_url']; // redirect to url of this post $myredirect = new \lib\redirector(); $myredirect->set_url($post_url)->redirect(); } // if not force simulate this url return $result; }
public function _processor($options = false) { if (is_array($options)) { $options = (object) $options; } $force_json = gettype($options) == 'object' && isset($options->force_json) && $options->force_json ? true : false; $force_stop = gettype($options) == 'object' && isset($options->force_stop) && $options->force_stop ? true : false; $not_redirect = gettype($options) == 'object' && isset($options->not_redirect) && $options->not_redirect ? true : false; if ($this->transaction && debug::$status) { if (isset($this->sql)) { $this->sql->commit(); } if (count($this->commit)) { call_user_func_array($this->commit[0], array_slice($this->commit, 1)); } } elseif ($this->transaction && !debug::$status) { if (isset($this->sql)) { $this->sql->rollback(); } if (count($this->rollback)) { call_user_func_array($this->rollback[0], array_slice($this->rollback, 1)); } } if ($not_redirect) { $this->controller()->redirector = false; } if (\saloos::is_json_accept() || $force_json) { header('Content-Type: application/json'); if (isset($this->controller()->redirector) && $this->controller()->redirector) { $_SESSION['debug'][md5(strtok($this->redirector()->redirect(true), '?'))] = debug::compile(); debug::msg("redirect", $this->redirector()->redirect(true)); } echo debug::compile(true); } elseif (!\lib\router::get_storage('api') && strtolower($_SERVER['REQUEST_METHOD']) == "post") { $this->redirector(); } if (isset($this->controller()->redirector) && $this->controller()->redirector && !\saloos::is_json_accept()) { $_SESSION['debug'][md5(strtok($this->redirector()->redirect(true), '?'))] = debug::compile(); $this->redirector()->redirect(); } if ($force_stop) { exit; } }
public static function send($_mobile, $_status = null, $_arg = null, $_service = MainService) { $_status = is_null($_status) ? \lib\router::get_url() : $_status; $mymessage = T_(ucfirst($_service)) . "\n"; switch ($_status) { case 'signup': $mymessage .= T_('your verification code is') . ' ' . $_arg; break; case 'recovery': $mymessage .= T_('your recovery code is') . ' ' . $_arg; break; case 'verification': $mymessage .= T_('you account is verified successfully'); break; case 'changepass': $mymessage .= T_('your password is changed successfully'); break; default: $mymessage .= T_('thanks for using our service') . "\n" . T_('made in iran'); break; } $mymessage .= "\n\n" . ucfirst($_service) . '.com'; if (substr($_mobile, 0, 2) == '98') { $iran = true; } else { $iran = null; } if ($iran) { $api = new \KavenegarApi(); $result = $api->send($_mobile, $mymessage, 0); // $result = $api->select(27657835); // $result = $api->cancel(27657835); // $result = $api->selectoutbox(1410570000); // $result = $api->account_info(); // var_dump($result);exit(); } else { \lib\debug::warn(T_('now we only support Iran!')); if (DEBUG) { \lib\debug::warn("Think sms is send to {$_mobile}!"); \lib\debug::true($mymessage); } } }
/** * return list of posts in custom term like cat or tag * @return [type] datarow */ public function sp_postsInTerm($_limit = null) { $url = $this->url('path'); if (substr($url, 0, 4) === 'tag/') { $url = substr($url, 4, $url); } if (substr($url, 0, 11) === 'book-index/') { preg_match("#^book-index/([^\\/]*)(.*)\$#", $url, $m); $url_raw = "book/{$m['1']}"; if ($m[2] !== '') { $qry = $this->sql()->table('posts')->where('post_status', 'publish')->order('id', 'ASC'); $qry->join('termusages')->on('termusage_id', '#posts.id')->and('termusage_foreign', '#"posts"'); $qry->join('terms')->on('id', '#termusages.term_id')->and('term_url', $url)->groupby('#posts.id'); } else { $parent_id = $this->sql()->table('posts')->where('post_url', $url_raw)->and('post_status', 'publish')->select()->assoc('id'); $qry = $this->sql()->table('posts')->where('post_parent', $parent_id)->and('post_status', 'publish')->order('id', 'ASC'); } return $qry->select()->allassoc(); } $qry = $this->sql()->table('posts')->where('post_status', 'publish')->order('id', 'DESC'); $qry->join('termusages')->on('termusage_id', '#posts.id')->and('termusage_foreign', '#"posts"')->field(false); $qry->join('terms')->on('id', '#termusages.term_id')->and('term_url', $url)->groupby('#posts.id')->field(false); // hasan :| $pagenation = []; if ($_limit) { $qryCount = clone $qry; $qryCount->field("#count(posts.id)"); $count = $qryCount->select()->num(); $pagenationPages = ceil($count / $_limit); $pagenationCurrent = \lib\router::get_storage("pagenation"); $pagenationNext = \lib\router::get_storage("pagenation") + 1; $pagenationPrev = \lib\router::get_storage("pagenation") - 1; if ($pagenationCurrent !== null and $pagenationCurrent < 1 || $pagenationCurrent > $pagenationPages) { \lib\error::page(T_("Does not exist!")); return; } $pagenation = ["num_page" => $pagenationPages, "pages" => intval($pagenationPages), "current" => $pagenationCurrent == 0 ? 1 : intval($pagenationCurrent), "next" => $pagenationNext <= $pagenationPages ? $pagenationNext : false, "prev" => $pagenationPrev >= 1 ? $pagenationPrev : false, "count_link" => 7, "current_url" => \lib\router::get_url()]; $start = \lib\router::get_storage("pagenation") ? (\lib\router::get_storage("pagenation") - 1) * $_limit : 0; $qry->limit($start, $_limit); } return ["pagenation" => $pagenation, "result" => $qry->select()->allassoc()]; }
/** * [__construct description] */ public function __construct() { parent::__construct(); if (MyAccount && SubDomain == null) { if (AccountService === Domain) { $domain = null; } else { $domain = AccountService . MainTld; } $param = $this->url('param'); if ($param) { $param = '?' . $param; } switch ($this->module()) { case 'signin': case 'login': $this->redirector()->set_domain($domain)->set_url(MyAccount . '/login' . $param)->redirect(); break; case 'signup': case 'register': $this->redirector()->set_domain($domain)->set_url(MyAccount . '/signup' . $param)->redirect(); break; case 'signout': case 'logout': // if(Domain !== MainService) // $this->redirector()->set_domain(MainService.'.'.Tld)->set_url('logout')->redirect(); $this->redirector()->set_domain()->set_url(MyAccount . '/logout' . $param)->redirect(); break; // case 'favicon.ico': // $this->redirector()->set_domain()->set_url('static/images/favicon.png')->redirect(); // break; } } $myrep = router::get_repository_name(); // running template base module for homepage if (\lib\router::get_storage('CMS') && $myrep === 'content' && method_exists($this, 's_template_finder') && get_class($this) === 'content\\home\\controller') { $this->s_template_finder(); } $this->pagnation_config(); $this->save_ref(); }
public function _corridor() { if (method_exists($this, 'corridor')) { $this->corridor(); } if (!$this->method) { $this->method = 'get'; } $processor_arg = false; if (isset($this->model_api_processor)) { $name = $this->model_api_processor->method; $args = $this->model_api_processor->args; $api_callback = call_user_func_array(array($this->model(), $name), array($args)); $this->api_callback = $api_callback; } if (saloos::is_json_accept()) { $this->display = false; } if (!\lib\router::get_storage('api') && $this->method == 'get' && $this->display) { $this->view(); if (isset($this->view_api_processor)) { $name = $this->view_api_processor->method; $args = $this->view_api_processor->args; if (isset($this->api_callback)) { $args->api_callback = $api_callback; } call_user_func_array(array($this->view(), $name), array($args)); } if ($this->display) { $this->view()->corridor(); } } elseif (router::get_storage('api') || !$this->display) { $mycallback = isset($this->api_callback) ? $this->api_callback : null; debug::msg('callback', $mycallback); $processor_arg = object(array('force_json' => true)); } if ($this->model) { $this->model()->_processor($processor_arg); } }
function _route() { if (!$this->login() && Tld !== 'dev') { $mydomain = AccountService ? AccountService . MainTld : null; \lib\debug::warn(T_("first of all, you must login to system!")); $this->redirector(null, false)->set_domain($mydomain)->set_url('login')->redirect(); exit; } // // Restrict unwanted module // if(!$this->cpModlueList()) // \lib\error::page(T_("Not found!")); $mymodule = $this->cpModule('table'); $cpModule = $this->cpModule('raw'); // var_dump($this->child()); $this->display_name = 'content_cp/templates/raw.html'; switch ($this->child()) { case 'dbtables': \lib\utility\dbTables::create(); exit; break; case 'twigtrans': \lib\utility\twigTrans::extract(\lib\utility::get('path')); exit; break; case 'server': if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && !class_exists("COM")) { ob_start(); echo "<!DOCTYPE html><meta charset='UTF-8'/><title>Extract text form twig files</title><body style='padding:0 1%;margin:0 1%;direction:ltr;overflow:hidden'>"; echo "<h1>" . T_("First you need to enable COM on windows") . "</h1>"; echo "<a target='_blank' href='http://www.php.net/manual/en/class.com.php'>" . T_("Read More") . "</a>"; break; } \lib\utility\Linfo::show(); exit; $this->display_name = 'content_cp/templates/raw-all.html'; break; case 'twitter': $a = \lib\utility\SocialNetwork::twitter('hello! test #api'); var_dump($a); break; case 'sitemap': $site_url = \lib\router::get_storage('url_site'); $sitemap = new \lib\utility\Sitemap($site_url, root . 'public_html/', 'sitemap'); // echo "<pre>"; // add posts foreach ($this->model()->sitemap('posts', 'post') as $row) { $sitemap->addItem($row['post_url'], '0.8', 'daily', $row['post_publishdate']); } // add pages foreach ($this->model()->sitemap('posts', 'page') as $row) { $sitemap->addItem($row['post_url'], '0.6', 'weekly', $row['post_publishdate']); } // add attachments foreach ($this->model()->sitemap('posts', 'attachment') as $row) { $sitemap->addItem($row['post_url'], '0.2', 'weekly', $row['post_publishdate']); } // add books foreach ($this->model()->sitemap('posts', 'book') as $row) { $sitemap->addItem($row['post_url'], '0.6', 'yearly', $row['post_publishdate']); } // add cats and tags foreach ($this->model()->sitemap('terms') as $row) { $sitemap->addItem($row['term_url'], '0.4', 'weekly', $row['date_modified']); } $sitemap->createSitemapIndex(); echo "<p class='alert alert-success'>Create sitemap Successfully!</p>"; // echo "Create Successful"; break; case 'git': echo shell_exec("/" . Domain . " git pull"); // exec('git pull'); break; case null: $mypath = $this->url('path', '_'); if (is_file(addons . 'content_cp/templates/static_' . $mypath . '.html')) { $this->display_name = 'content_cp/templates/static_' . $mypath . '.html'; } // $this->display_name = 'content_cp/templates/static_'.$mypath.'.html'; break; default: $this->display_name = 'content_cp/templates/static_tools.html'; return; break; } $this->get()->ALL(); return; }
/** * return * @param string $_loc location * @param string $_type type of permission needed * @return [type] [description] */ public static function access($_content = null, $_loc = null, $_type = null, $_block = null) { $myStatus = null; $su = null; // if user is superviser then set su to true // permission id 1 is supervisior of system if (isset($_SESSION['user']['permission']) && $_SESSION['user']['permission'] === "1") { $su = true; $suStatus = self::permListFill('su'); } // if programmer not set content, give it automatically from address if ($_content === 'all') { $myStatus = []; if ($su) { foreach ($suStatus as $key => $value) { if (isset($value['enable'])) { $myStatus[$key] = $value['enable']; } } } elseif (isset($_SESSION['permission'])) { foreach ($_SESSION['permission'] as $key => $value) { if (isset($value['enable'])) { $myStatus[$key] = $value['enable']; } } } return $myStatus; } elseif (!$_content) { $_content = \lib\router::get_repository_name(); if ($_content !== "content") { $_content = substr($_content, strpos($_content, '_') + 1); } } if (!isset($suStatus[$_content]) || !isset($suStatus[$_content]['modules'])) { $su = false; } // if user want specefic location if ($_loc == 'all') { if ($su) { $myStatus = $suStatus[$_content]['modules']; } elseif (isset($_SESSION['permission'][$_content]['modules'])) { $myStatus = $_SESSION['permission'][$_content]['modules']; } } elseif ($_loc) { if ($_type) { if ($su) { if (isset($suStatus[$_content]['modules'][$_loc][$_type])) { $myStatus = $suStatus[$_content]['modules'][$_loc][$_type]; } } elseif (isset($_SESSION['permission'][$_content]['modules'][$_loc][$_type])) { $myStatus = $_SESSION['permission'][$_content]['modules'][$_loc][$_type]; } } else { if ($su) { $myStatus = $suStatus[$_content]['modules'][$_loc]; } elseif (isset($_SESSION['permission'][$_content]['modules'][$_loc])) { $myStatus = $_SESSION['permission'][$_content]['modules'][$_loc]; } } } else { if ($su) { $myStatus = $suStatus[$_content]['enable']; } elseif (isset($_SESSION['permission'][$_content]['enable'])) { $myStatus = $_SESSION['permission'][$_content]['enable']; } } if (!$myStatus) { if ($_block === "notify" && $_type && $_loc) { $msg = null; switch ($_type) { case 'view': $msg = "You can't view this part of system"; break; case 'add': $msg = T_("You can't add new") . ' ' . T_($_loc); break; case 'edit': $msg = T_("You can't edit") . ' ' . T_($_loc); break; case 'delete': $msg = T_("You can't delete") . ' ' . T_($_loc); break; default: $msg = "You can't access to this part of system"; break; } $msg = $msg . "<br/> " . T_("Because of your permission"); \lib\debug::error(T_($msg)); // exit(); } elseif ($_block) { \lib\error::access(T_("You can't access to this page!")); } else { // do nothing! } } return $myStatus; }
/** * create special message depending on settings * @param [type] $_msg [description] * @param [type] $_arg [description] * @param [type] $_settings [description] * @return [type] [description] */ private static function message($_msg = null, $_arg = null, $_settings = null) { $_arg = trim($_arg); $sms_msg = null; $sms_header = null; $sms_footer = null; $sms_maxOne = 160; $sms_forceOne = null; $sms_template = ['signup', 'recovery', 'verification', 'changepass']; $template = null; // if user want one of our template create message automatically if (in_array($_msg, $sms_template)) { $template = $_msg; } elseif (!$_msg) { $template = is_null($_msg) ? \lib\router::get_url() : $_msg; } // set message header if (isset($_settings['meta']['header']) && $_settings['meta']['header']) { $sms_header = T_($_settings['meta']['header']); } // set message footer if (isset($_settings['meta']['footer']) && $_settings['meta']['footer']) { $sms_footer = T_($_settings['meta']['footer']); } // set message footer if (isset($_settings['meta']['one']) && $_settings['meta']['one']) { $sms_forceOne = $_settings['meta']['one']; } // if user want our template if ($template) { // if user want to send message for this template // then create related message if (isset($_settings['meta'][$template])) { // set related message depending on status passed switch ($template) { case 'signup': $_msg = T_('Your verification code is') . ' ' . $_arg; break; case 'recovery': $_msg = T_('Your recovery code is') . ' ' . $_arg; break; case 'verification': $_msg = T_('You account is verified successfully'); break; case 'changepass': $_msg = T_('Your password is changed successfully'); break; } } else { return false; } } else { // else if possible translate user message $_msg = T_($_msg); } $_msg = trim($_msg); // if message is not set then return false if (!$_msg) { return false; } // create complete message $sms_msg = $sms_header . "\n" . $_msg . "\n\n" . $sms_footer; if ($sms_forceOne && mb_strlen($sms_msg) > self::is_rtl($sms_msg, true)) { // create complete message $sms_msg = $sms_header . "\n" . $_msg; if ($sms_forceOne && mb_strlen($sms_msg) > self::is_rtl($sms_msg, true)) { // create complete message $sms_msg = $_msg; } } // return final message:) return $sms_msg; }
/** * check status of permission to access special module * @param [type] $route [description] * @return [type] [description] */ public function check($route) { $mysub = router::get_sub_domain(); if (router::get_sub_domain() === "cp") { $mymodule = router::get_url(0); $mychild = router::get_url(1); $mymethod = $this->api_method; $myrequest = 'view'; $myblock = 'block'; if (strrpos($mychild, '=') !== false) { $mychild = substr($mychild, 0, strrpos($mychild, '=')); } // set request name by type of it switch ($mymethod) { case 'get': $myrequest = 'view'; break; case 'post': $myrequest = 'add'; $myblock = 'notify'; break; case 'put': $myrequest = 'edit'; $myblock = 'notify'; break; case 'delete': $myrequest = 'delete'; $myblock = 'notify'; break; default: $myrequest = '#invalid'; break; } // find request by 2th slash in url named as child switch ($mychild) { case 'add': $myrequest = 'add'; break; case 'edit': $myrequest = 'edit'; break; case 'delete': $myrequest = 'delete'; break; } // set some setting for special module switch ($mymodule) { case 'posts': case 'pages': case 'users': case 'options': case 'permissions': case 'tags': case 'cats': break; case 'profile': $myblock = false; break; default: break; } // Check permission and if user can do this operation // allow to do it, else show related message in notify center $myController = \lib\main::$controller; $myController->access($mysub, $mymodule, $myrequest, $myblock); } parent::check(...func_get_args()); }
/** * check current protocol and if needed redirect to another! * @return [type] [description] */ private static function check_protocol() { // create new url for protocol checker $newUrl = ""; $currentPath = $_SERVER['REQUEST_URI']; $mainSite = \lib\utility\option::get('config', 'meta', 'redirectURL'); // if redirect to main site is enable and all thing is okay // then redirect to the target url if (\lib\utility\option::get('config', 'meta', 'multiDomain') && \lib\utility\option::get('config', 'meta', 'redirectToMain') && $mainSite && Tld !== 'dev' && parse_url($mainSite, PHP_URL_HOST) != \lib\router::get_root_domain()) { // as soon as posible we create language detector library switch (Tld) { case 'ir': $newUrl = $mainSite . "/fa"; break; default: break; } } elseif ($currentPath !== '/' && rtrim($currentPath, '/') !== $currentPath) { $newUrl = $mainSite . rtrim($currentPath, '/'); } else { // if want to force using https then redirect to https of current url if (\lib\utility\option::get('config', 'meta', 'https')) { if (Protocol === 'http') { $newUrl = 'https://'; } } elseif (Protocol === 'https') { $newUrl = 'http://'; } if ($newUrl) { $newUrl .= router::get_root_domain() . '/' . router::get_url(); } } // var_dump($newUrl);exit(); // if newUrl is exist and we must to redirect // then complete url and redirect to this address if ($newUrl && !\lib\utility::get('force')) { // redirect to best protocol because we want it! $redirector = new \lib\redirector($newUrl); $redirector->redirect(); } }
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 saloos language and if needed convert to persian date * else show default date * @param [type] $_date [description] * @return [type] [description] */ public static function date($_format, $_stamp = false, $_type = false, $_persianChar = true) { $result = null; if (strlen($_stamp) < 2) { $_stamp = false; } // get target language if ($_type === 'default') { $_type = substr(\lib\router::get_storage('defaultLanguage'), 0, 2); } elseif ($_type === 'current') { $_type = substr(\lib\router::get_storage('language'), 0, 2); } // if need persian use it else use default date function if ($_type === true || $_type === 'fa') { $result = \lib\utility\jdate::date($_format, $_stamp, $_persianChar); } else { if ($_stamp) { $result = date($_format, $_stamp); } else { $result = date($_format); } } return $result; }
/** * 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; }
/** * clearly return url property for use * @param [type] $_type type of url you need * @param [type] $_arg an argument for pass into some condition * @return [type] the url value */ public function url($_type = null, $_arg = null) { $tmp_result = null; $myprefix = Protocol . "://"; $mypostfix = '/'; $mytld = router::get_root_domain('tld'); switch ($_type) { // sub domain like 'account' case 'sub': return router::get_sub_domain($_arg); break; case 'path': $myUrl = router::get_url($_arg); if ($_arg == '_') { // filter url to delete disallow characters $myUrl = router::urlfilterer($myUrl); // dont use $ in id $myUrl = str_replace('$', 'dollar', $myUrl); } return $myUrl; break; case 'breadcrumb': $myurl = router::get_url(-1); $breadcrumb = array(); foreach ($myurl as $value) { $tmp_pos = strpos($value, '='); array_push($breadcrumb, $tmp_pos ? substr($value, 0, $tmp_pos) : $value); } return $breadcrumb; break; case 'param': return \lib\utility::get(null, $_arg); break; // domain tld like 'com' // domain tld like 'com' case 'tld': return $mytld; break; // domain name like 'ermile' // domain name like 'ermile' case 'domain': return router::get_root_domain('domain'); break; // domain name except subdomain like 'ermile.com' // domain name except subdomain like 'ermile.com' case 'raw': return router::get_root_domain('domain') . '.' . $mytld; break; // like raw plus http[s]:// domain name except subdomain like 'http://ermile.com/' // like raw plus http[s]:// domain name except subdomain like 'http://ermile.com/' case 'root': return $myprefix . router::get_root_domain() . $mypostfix; break; // use main protocol and give it from config file if not exist use root url // return http or https // use main protocol and give it from config file if not exist use root url // return http or https case 'MainProtocol': if (defined('MainProtocol') && constant('MainProtocol') && is_string(constant('MainProtocol'))) { return constant('MainProtocol'); } else { return 'http'; } break; // use main site and give it from config file if not exist use root url // like raw plus http[s]:// domain name except subdomain like 'http://ermile.com/' // use main site and give it from config file if not exist use root url // like raw plus http[s]:// domain name except subdomain like 'http://ermile.com/' case 'MainSite': if (defined('MainSite') && constant('MainSite') && is_string(constant('MainSite'))) { return constant('MainSite'); } else { return router::get_root_domain() . $mypostfix; } break; // base url for user in base tag with http[s] // base url for user in base tag with http[s] case 'base': return router::$base; break; // full url except get parameter with http[s] // full url except get parameter with http[s] case 'full': return $myprefix . router::get_domain() . '/' . router::get_url(); break; // return module info // return module info case 'module': if ($_arg === 'prefix') { $mymodule = substr(router::get_url(0), 0, -1); } elseif ($_arg == 'array') { $mymodule = router::get_url(-1); } elseif ($_arg == 'cp') { $mymodule = router::get_url(0); switch ($mymodule) { case 'tags': case 'cats': $mymodule = 'terms'; break; case 'pages': $mymodule = 'posts'; break; } } else { $mymodule = router::get_url(0); } return $mymodule; break; case 'child': $mychild = router::get_url(1); if (strrpos($mychild, '=') !== false) { $mychild = substr($mychild, 0, strrpos($mychild, '=')); } if (!$_arg) { return $mychild; } if ($mychild == 'add') { return T_('add new'); } if ($mychild == 'edit') { return T_('edit'); } if ($mychild == 'delete') { return T_('delete'); } break; // login service and main service with full address // login service and main service with full address case 'LoginService': case 'account': return $myprefix . AccountService . MainTld . '/' . MyAccount; break; case 'MainService': $_arg = is_array($_arg) ? $_arg : array('com', 'dev'); if (in_array($mytld, $_arg)) { return $myprefix . constant('MainService') . '.' . $mytld; } else { return $myprefix . constant('MainService') . MainTld; } break; default: return null; break; } }
public function loadController() { /** * find controller; */ $url_property = router::get_url_property(-1); $myrep = router::get_repository_name(); if (!router::get_controller()) { $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\' . router::get_method() . '\\controller'; $prv_class = router::get_class(); // var_dump($controller_name); if (!class_exists($controller_name)) { if ((!isset($url_property[1]) || $url_property[1] != router::get_method()) && router::get_method() != 'home') { router::add_url_property(router::get_method()); } $prv_method = router::get_method(); router::set_method('home'); $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\' . router::get_method() . '\\controller'; // var_dump(router::get_url_property(-1)); // var_dump($controller_name); if (!class_exists($controller_name)) { router::set_class($prv_class); $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\controller'; // var_dump(router::get_url_property(-1)); // var_dump($controller_name); if (!class_exists($controller_name)) { if ((!isset($url_property[0]) || $url_property[0] != router::get_class()) && router::get_class() != 'home') { router::add_url_property(router::get_class()); } router::set_class('home'); $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\' . router::get_method() . '\\controller'; // var_dump(router::get_url_property(-1)); // var_dump($controller_name); // if (!class_exists($controller_name)) { router::set_class('home'); $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\controller'; // var_dump(router::get_url_property(-1)); // $controller_name='\account\home\controller'; // var_dump($controller_name); if (!class_exists($controller_name)) { \lib\error::page("content not found"); } } } } } } else { $controller_name = router::get_controller(); } router::set_controller($controller_name); if (!class_exists($controller_name)) { error::page($controller_name); } $controller = new $controller_name(); self::$controller = $controller; // running template base module for homepage if (\lib\router::get_storage('CMS') && $myrep == 'content' && method_exists($controller, 's_template_finder')) { $controller->s_template_finder(); } if (method_exists($controller, '_route')) { $controller->_route(); } if (router::get_controller() !== $controller_name) { $this->loadController(); return; } if (method_exists($controller, 'config')) { $controller->config(); } if (method_exists($controller, 'options')) { $controller->options(); } if (count(router::get_url_property(-1)) > 0 && $controller->route_check_true === false) { error::page('Unavailable'); } $controller->_corridor(); }
public function query_search($_parameter = array()) { $search = array_key_exists('search', $_parameter) ? $_parameter['search'] : null; $image = array_key_exists('image', $_parameter) ? $_parameter['image'] : null; $video = array_key_exists('video', $_parameter) ? $_parameter['video'] : null; $audio = array_key_exists('audio', $_parameter) ? $_parameter['audio'] : null; $other = array_key_exists('other', $_parameter) ? $_parameter['other'] : null; $where = ''; if ($search) { $where .= "(post_title LIKE '%{$search}%' OR post_content LIKE '%{$search}%')"; } $_type = ['image', 'audio', 'video']; $type = array(); if ($image) { array_push($type, 'image'); } if ($video) { array_push($type, 'video'); } if ($audio) { array_push($type, 'audio'); } if ($other) { array_push($type, 'other'); } if (count($type) > 0 && count($type) < 4) { $where .= empty($where) ? '' : " AND "; if ($other) { if (count($type) == 1) { $_type = join("\"' ,'\"", $_type); $where .= "json_extract(post_meta, '\$.type') NOT IN ('\"{$_type}\"')"; } else { $_type = join("\"' ,'\"", array_diff($_type, $type)); $type = count($type) > 1 ? "\"" . join("\"' ,'\"", $type) . "\"" : $type[0]; $where .= "(json_extract(post_meta, '\$.type') IN ('{$type}')"; $where .= " OR json_extract(post_meta, '\$.type') NOT IN ('\"{$_type}\"'))"; } } else { $type = count($type) > 1 ? "\"" . join("\"' ,'\"", $type) . "\"" : $type[0]; $where .= "json_extract(post_meta, '\$.type') in ('{$type}')"; } } $where .= empty($where) ? '' : " AND "; $where .= "post_type = 'attachment'"; $length = 5; $start = 0; if ($_parameter['pagnation']) { list($start, $length) = $this->controller->pagnation_make_limit($length); } $query = "SELECT SQL_CALC_FOUND_ROWS posts.*, FOUND_ROWS() FROM posts WHERE {$where} LIMIT {$start}, {$length}"; $result = \lib\db::query($query); $query_rows = "SELECT FOUND_ROWS() as rows"; $result_rows = \lib\db::query($query_rows); $rows = $result_rows->fetch_assoc()['rows']; if ($_parameter['pagnation']) { $this->controller->pagnation_make($rows); $pagnation = $this->controller->pagnation; } else { $pagnation['total_pages'] = intval(ceil($rows / $length)); $pagnation['current'] = 1; $pagnation['next'] = $pagnation['current'] + 1 <= $pagnation['total_pages'] ? $pagnation['current'] + 1 : false; $pagnation['prev'] = $pagnation['current'] - 1 >= 1 ? $pagnation['current'] - 1 : false; $pagnation['count_link'] = 7; $pagnation['current_url'] = \lib\router::get_class() . '/attachments_data'; $pagnation['length'] = $length; } $decode_result = \lib\utility\filter::meta_decode(\lib\db::fetch_all($result)); return ['data' => $decode_result, 'pagnation' => $pagnation]; }
function _route() { // check permission to access to cp if (Tld !== 'dev') { parent::_permission('cp'); } // // Restrict unwanted module // if(!$this->cpModlueList()) // \lib\error::page(T_("Not found!")); $exist = false; $mymodule = $this->cpModule('table'); $cpModule = $this->cpModule('raw'); // var_dump($this->child()); $this->display_name = 'content_cp/templates/raw.html'; switch ($this->child()) { case 'dbtables': $exist = true; echo \lib\utility\dbTables::create(); break; case 'db': $exist = true; if (\lib\utility::get('upgrade')) { // do upgrade $result = \lib\db::install(true); } elseif (\lib\utility::get('backup')) { $result = \lib\db::backup(true); } echo '<pre>'; print_r($result); echo '</pre>'; break; case 'twigtrans': $exist = true; $mypath = \lib\utility::get('path'); $myupdate = \lib\utility::get('update'); echo \lib\utility\twigTrans::extract($mypath, $myupdate); break; case 'phpinfo': $exist = true; phpinfo(); break; case 'server': $exist = true; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && !class_exists("COM")) { ob_start(); echo "<!DOCTYPE html><meta charset='UTF-8'/><title>Extract text form twig files</title><body style='padding:0 1%;margin:0 1%;direction:ltr;overflow:hidden'>"; echo "<h1>" . T_("First you need to enable COM on windows") . "</h1>"; echo "<a target='_blank' href='http://www.php.net/manual/en/class.com.php'>" . T_("Read More") . "</a>"; break; } \lib\utility\tools::linfo(); $this->display_name = 'content_cp/templates/raw-all.html'; break; case 'twitter': $a = \lib\utility\socialNetwork::twitter('hello! test #api'); // var_dump($a); break; case 'mergefiles': $exist = true; echo \lib\utility\tools::mergefiles('merged-project.php'); if (\lib\utility::get('type') === 'all') { echo \lib\utility\tools::mergefiles('merged-saloos-lib.php', core . lib); echo \lib\utility\tools::mergefiles('merged-saloos-cp.php', addons . 'content_cp/'); echo \lib\utility\tools::mergefiles('merged-saloos-account.php', addons . 'content_account/'); echo \lib\utility\tools::mergefiles('merged-saloos-includes.php', addons . 'includes/'); } break; case 'sitemap': $exist = true; $site_url = \lib\router::get_storage('url_site'); $sitemap = new \lib\utility\sitemap($site_url, root . 'public_html/', 'sitemap'); // echo "<pre>"; // add posts foreach ($this->model()->sitemap('posts', 'post') as $row) { $sitemap->addItem($row['post_url'], '0.8', 'daily', $row['post_publishdate']); } // add pages foreach ($this->model()->sitemap('posts', 'page') as $row) { $sitemap->addItem($row['post_url'], '0.6', 'weekly', $row['post_publishdate']); } // add attachments foreach ($this->model()->sitemap('posts', 'attachment') as $row) { $sitemap->addItem($row['post_url'], '0.2', 'weekly', $row['post_publishdate']); } // add books foreach ($this->model()->sitemap('posts', 'book') as $row) { $sitemap->addItem($row['post_url'], '0.6', 'yearly', $row['post_publishdate']); } // add cats and tags foreach ($this->model()->sitemap('terms') as $row) { $sitemap->addItem($row['term_url'], '0.4', 'weekly', $row['date_modified']); } $sitemap->createSitemapIndex(); echo "<p class='alert alert-success'>Create sitemap Successfully!</p>"; // echo "Create Successful"; break; case 'git': // declare variables $exist = true; $rep = null; $result = []; $location = '../../'; $name = \lib\utility::get('name'); $output = null; // switch by name of repository switch ($name) { case 'saloos': $location .= 'saloos'; $rep .= "https://github.com/Ermile/Saloos.git"; break; case 'addons': $location .= 'saloos/saloos-addons'; $rep .= "https://github.com/Ermile/Saloos-Addons.git"; break; default: $exist = false; return; break; } // change location to address of requested chdir($location); // start show result $output = "<pre>"; $output .= 'Repository address: ' . getcwd() . '<br/>'; $output .= 'Remote address: ' . $rep . '<hr/>'; $command = 'git pull ' . $rep . ' 2>&1'; // Print the exec output inside of a pre element exec($command, $result); if (!$result) { $output .= T_('Not Work!'); } foreach ($result as $line) { $output .= $line . "\n"; } $output .= "</pre>"; echo $output; break; case null: $mypath = $this->url('path', '_'); if (is_file(addons . 'content_cp/templates/static_' . $mypath . '.html')) { $this->display_name = 'content_cp/templates/static_' . $mypath . '.html'; } // $this->display_name = 'content_cp/templates/static_'.$mypath.'.html'; break; default: $this->display_name = 'content_cp/templates/static_tools.html'; return; break; } // $this->get()->ALL(); if ($exist) { $this->model()->_processor(object(array("force_json" => false, "force_stop" => true))); } return; }