示例#1
1
 /**
  * start conversation
  * @return [type] [description]
  */
 public static function start()
 {
     $result = [['text' => "به *_fullName_* خوش آمدید." . " /help", 'reply_markup' => menu::main(true)]];
     // on debug mode send made by ermile at the end of start msg
     if (\lib\utility\option::get('telegram', 'meta', 'debug')) {
         $result[] = ['text' => "Made by @Ermile"];
     }
     return $result;
 }
示例#2
0
 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);
 }
示例#3
0
 /**
  * [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;
 }
示例#4
0
 /**
  * return list of exist permission in system
  * @return [array] contain list of permissions
  */
 public function permList($_status = false)
 {
     $permList = [];
     if ($_status === false) {
         $permList = \lib\utility\option::get('permissions', 'meta');
         return $permList;
     }
     // get list of permissions
     $qryPerm = $this->sql()->table('options')->where('user_id', 'IS', 'NULL')->and('post_id', 'IS', "NULL")->and('option_cat', 'permissions')->and('option_status', "enable");
     if ($_status) {
         $qryPerm->groupOpen('g_status')->and('option_status', '=', "'enable'")->or('option_status', 'IS', "NULL")->or('option_status', "")->groupClose('g_status');
     }
     $qryPerm = $qryPerm->select()->allassoc();
     foreach ($qryPerm as $row) {
         $permList[$row['option_key']] = $row['option_value'];
     }
     return $permList;
 }
示例#5
0
 function _permission($_content = null, $_login = true)
 {
     // if user is not login then redirect
     if ($_login && !$this->login()) {
         \lib\debug::warn(T_("first of all, you must login to system!"));
         $mydomain = \lib\utility\option::get('config', 'meta', 'redirectURL');
         if ($mydomain && $mydomain !== 'on') {
             $this->redirector($mydomain . '/login', false)->redirect();
         } else {
             $this->redirector(null, false)->set_domain()->set_url('login')->redirect();
         }
     }
     // if content is not set then
     if ($_content === null) {
         $_content = \lib\router::get_sub_domain();
     }
     // Check permission and if user can do this operation
     // allow to do it, else show related message in notify center
     $this->access($_content, null, null, 'block');
 }
示例#6
0
 /**
  * default action to handle message texts
  * @param  [type] [description]
  * @return [type]       [description]
  */
 public static function answer($forceSample = null)
 {
     $answer = null;
     // read from saloos command template
     $cmdFolder = __NAMESPACE__ . '\\commands\\';
     // use user defined command
     if (!$forceSample && self::$cmdFolder) {
         $cmdFolder = self::$cmdFolder;
     }
     foreach (self::$priority as $class) {
         $funcName = $cmdFolder . $class . '::exec';
         // generate func name
         if (is_callable($funcName)) {
             // get response
             $answer = call_user_func($funcName, self::$cmd);
             // if has response break loop
             if ($answer || is_array($answer)) {
                 break;
             }
         }
     }
     // if we dont have answer text then use default text
     if (!$answer) {
         if (self::response('chat', 'type') === 'group') {
             // if saloos bot joied to group show thanks message
             if (self::response('new_chat_member', 'username') === self::$name) {
                 $msg = "Thanks for using me!\r\n\nI'm Bot.";
                 $msg = "با تشکر از شما عزیزان به خاطر دعوت از من!\r\n\nمن یک ربات هستم.";
                 $answer = ['text' => $msg];
             }
         } elseif (\lib\utility\option::get('telegram', 'meta', 'debug') && !is_array($answer)) {
             // then if not exist set default text
             $answer = ['text' => self::$defaultText];
             if (self::$defaultMenu && is_object(self::$defaultMenu)) {
                 $answer['reply_markup'] = call_user_func(self::$defaultMenu);
             }
         }
     }
     return $answer;
 }
示例#7
0
 public function view_child()
 {
     $mytable = $this->cpModule('table');
     $mychild = $this->child();
     // $this->global->js       = array($this->url->myStatic.'js/cp/medium-editor.min.js');
     $this->data->enum = \lib\sql\getTable::enumValues('posts');
     switch ($mytable) {
         case 'posts':
             // show list of tags
             $this->data->tagList = $this->model()->sp_term_list();
             // for each type of post
             switch ($this->cpModule('raw')) {
                 case 'pages':
                     $this->data->parentList = $this->model()->sp_parent_list();
                     break;
                 case 'polls':
                     $this->data->parentList = $this->model()->sp_parent_list(true, 'poll');
                     $this->data->catList = $this->model()->sp_cats('cat_poll');
                     break;
                 case 'attachments':
                     $this->data->maxSize = \lib\utility\upload::max_file_upload_in_bytes();
                     // $this->include->uploader      = true;
                     // array_push($this->global->js, $this->url->myStatic.'js/cp/uploader.js');
                     $this->data->catList = $this->model()->sp_cats('filecat');
                     $this->data->catListSelected = $this->model()->sp_cats('filecat', true);
                     break;
                 case 'books':
                     $this->data->catList = $this->model()->sp_cats('bookcat');
                     $this->data->catListSelected = $this->model()->sp_cats('bookcat', true);
                     $this->data->parentList = $this->model()->sp_parent_list(true, 'book');
                     break;
                 case 'socialnetwork':
                     $this->data->catList = null;
                     break;
                 default:
                     $this->data->catList = $this->model()->sp_cats();
                     break;
             }
             break;
         default:
             switch ($this->cpModule('raw')) {
                 case 'categories':
                 case 'pollcategories':
                 case 'filecategories':
                 case 'bookcategories':
                     $this->data->parentList = $this->model()->sp_category_list($this->cpModule('type'));
                     break;
             }
             $this->data->field_list = \lib\sql\getTable::get($mytable);
             $myform = $this->createform('@' . db_name . '.' . $mytable, $this->data->child);
             break;
     }
     // if module for users then fill permission list
     if ($this->cpModule('raw') === 'users') {
         $this->draw_users();
     }
     if ($mychild === 'edit') {
         $this->data->datarow = $this->model()->datarow($mytable, null, true);
         // set shortURL
         $this->data->shortURL = 'sp_' . \lib\utility\shortURL::encode($this->data->datarow['id']);
         if (isset($this->data->datarow['post_meta'])) {
             $this->data->datarow['post_meta'] = json_decode($this->data->datarow['post_meta'], true);
         }
         if ($this->cpModule('raw') === 'attachments') {
             if (isset($this->data->datarow['meta']['slug'])) {
                 $this->data->datarow['post_slug'] = $this->data->datarow['meta']['slug'];
             }
         }
         if ($mytable === 'posts') {
             // $this->data->datarow['post_content'] .= '<img src="/static/images/logo.png" />';
             // var_dump($this->data->datarow['post_content']);
             $url = $this->data->datarow['post_url'];
             $this->data->datarow['cat_url'] = substr($url, 0, strrpos($url, '/'));
             // if defaultlang and lang of the post is not the same then add lang to url
             $defaultLang = substr(\lib\utility\option::get('config', 'meta', 'defaultLang'), 0, 2);
             if ($defaultLang !== $this->data->datarow['post_language']) {
                 $this->data->datarow['post_url'] = $this->data->datarow['post_language'] . "/" . $this->data->datarow['post_url'];
             }
         }
     }
 }
示例#8
0
 /**
  * setWebhook for telegram
  * @param string $_url  [description]
  * @param [type] $_file [description]
  */
 public static function setWebhook($_url = '', $_file = null)
 {
     if (empty($_url)) {
         $_url = \lib\utility\option::get('telegram', 'meta', 'hook');
     }
     $answer = ['url' => $_url];
     // if (!is_null($_file))
     // {
     // 	$data['certificate'] = \CURLFile($_file);
     // }
     return exec::send('setWebhook', $answer, 'description') . ': ' . $_url;
 }
示例#9
0
 /**
  * Execute cURL call
  * @return mixed Result of the cURL call
  */
 public static function send($_method = null, array $_data = null, $_output = null)
 {
     if (!isset($_data['is_json'])) {
         $is_json = true;
     } else {
         $is_json = $_data['is_json'];
         unset($_data['is_json']);
     }
     // if telegram is off then do not run
     if (!\lib\utility\option::get('telegram', 'status')) {
         return 'telegram is off!';
     }
     // if method or data is not set return
     if (!$_method || !$_data) {
         return 'method or data is not set!';
     }
     if (array_key_exists('method', $_data)) {
         if ($_data['method'] == 'answerInlineQuery') {
             $is_json = true;
         }
         unset($_data['method']);
     }
     $response_callback = null;
     if (array_key_exists('response_callback', $_data)) {
         $response_callback = $_data['response_callback'];
         unset($_data['response_callback']);
     }
     // if api key is not set get it from options
     if (!self::$api_key) {
         self::$api_key = \lib\utility\option::get('telegram', 'meta', 'key');
     }
     // if key is not correct return
     if (strlen(self::$api_key) < 20) {
         return 'api key is not correct!';
     }
     // initialize curl
     $ch = curl_init();
     if ($ch === false) {
         return 'Curl failed to initialize';
     }
     $curlConfig = [CURLOPT_URL => "https://api.telegram.org/bot" . self::$api_key . "/{$_method}", CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SAFE_UPLOAD => true, CURLOPT_SSL_VERIFYPEER => false];
     curl_setopt_array($ch, $curlConfig);
     if (!empty($_data)) {
         if ($is_json) {
             $data_string = json_encode($_data);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
         } else {
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
             // curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
             // curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($_data));
             curl_setopt($ch, CURLOPT_POSTFIELDS, $_data);
         }
     }
     if (Tld === 'dev') {
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     }
     $result = curl_exec($ch);
     if ($response_callback) {
         if (is_object($response_callback)) {
             call_user_func_array($response_callback, [json_decode($result), $_data]);
         } elseif (is_array($response_callback)) {
             $args = array_splice($response_callback, 1);
             array_unshift($args, json_decode($result), $_data);
             call_user_func_array($response_callback[0], $args);
         }
     }
     if ($result === false) {
         return curl_error($ch) . ':' . curl_errno($ch);
     }
     if (empty($result) | is_null($result)) {
         return 'Empty server response';
     }
     curl_close($ch);
     //Logging curl requests
     if (substr($result, 0, 1) === "{") {
         $result = json_decode($result, true);
         if ($_output && isset($result[$_output])) {
             $result = $result[$_output];
         }
     }
     log::save($result);
     // return result
     return $result;
 }
示例#10
0
文件: router.php 项目: Ermile/Saloos
 /**
  * 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();
     }
 }
示例#11
0
文件: define.php 项目: Ermile/Saloos
 public function __construct()
 {
     // check php version to upper than 5.6
     if (version_compare(phpversion(), '5.6', '<')) {
         die("<p>For using Saloos you must update php version to 5.6 or higher!</p>");
     }
     /**
      * If DEBUG is TRUE you can see the full error description, If set to FALSE show userfriendly messages
      * change it from project config.php
      */
     if (!defined('DEBUG')) {
         if (\lib\utility\option::get('config', 'meta', 'debug')) {
             define('DEBUG', true);
         } elseif (Tld === 'dev') {
             define('DEBUG', true);
         } else {
             define('DEBUG', false);
         }
     }
     if (DEBUG) {
         ini_set('display_errors', 'On');
         ini_set('display_startup_errors', 'On');
         ini_set('error_reporting', 'E_ALL | E_STRICT');
         ini_set('track_errors', 'On');
         ini_set('display_errors', 1);
         error_reporting(E_ALL);
         //Setting for the PHP Error Handler
         // set_error_handler('\lib\error::myErrorHandler');
         //Setting for the PHP Exceptions Error Handler
         // set_exception_handler('\lib\error::myErrorHandler');
         //Setting for the PHP Fatal Error
         // register_shutdown_function('\lib\error::myErrorHandler');
     } else {
         error_reporting(0);
         ini_set('display_errors', 0);
     }
     /**
      * A session is a way to store information (in variables) to be used across multiple pages.
      * Unlike a cookie, the information is not stored on the users computer.
      * access to session with this code: $_SESSION["test"]
      */
     if (is_string(Domain)) {
         session_name(Domain);
     }
     // set session cookie params
     session_set_cookie_params(0, '/', '.' . Service, false, true);
     // if user enable saving sessions in db
     // temporary disable because not work properly
     if (false) {
         $handler = new \lib\utility\sessionHandler();
         session_set_save_handler($handler, true);
     }
     // start sessions
     session_start();
     /**
      * in coming soon period show public_html/pages/coming/ folder
      * developer must set get parameter like site.com/dev=anyvalue
      * for disable this attribute turn off it from config.php in project root
      */
     if (\lib\utility\option::get('config', 'meta', 'coming') || defined('CommingSoon')) {
         // if user set dev in get, show the site
         if (isset($_GET['dev'])) {
             setcookie('preview', 'yes', time() + 30 * 24 * 60 * 60, '/', '.' . Service);
         } elseif (router::get_url(0) === 'saloos_tg') {
             // allow telegram to commiunate on coming soon
         } elseif (!isset($_COOKIE["preview"])) {
             header('Location: http://' . AccountService . MainTld . '/static/page/coming/', true, 302);
             exit;
         }
     }
     // use saloos php gettext function
     require_once lib . 'utility/gettext/gettext.inc';
     // change header and remove php from it
     header("X-Powered-By: Saloos!");
 }
示例#12
0
 /**
  * call model func and return needed option in all condition
  * @return [type] return string or array contain option value
  */
 public function option()
 {
     return \lib\utility\option::get(...func_get_args());
 }
示例#13
0
 public static function detect_language()
 {
     /**
      * set default language to storage for next use
      */
     // var_dump(\lib\utility\option::get('config', 'meta', 'defaultLanguage'));
     $default_lang = \lib\utility\option::get('config', 'meta', 'defaultLang');
     if ($default_lang) {
         router::set_storage('defaultLanguage', $default_lang);
     } else {
         router::set_storage('defaultLanguage', 'en_US');
     }
     // if current tld is ir or referrer from site with ir tld,
     // change language to fa_IR
     if (\lib\router::get_storage('language')) {
         $myLang = router::get_storage('language');
         switch (Tld) {
             case 'ir':
                 $myLang = "fa_IR";
                 break;
             default:
                 break;
         }
         if (defined('MainService') && Tld !== 'dev') {
             // for example redirect ermile.ir to ermile.com/fa
             $myLang = substr($myLang, 0, 2);
             $myredirect = new \lib\redirector();
             $myredirect->set_domain()->set_url($myLang)->redirect();
         } else {
             // else show in that domain with fa langusage
             router::set_storage('language', $myLang);
         }
     }
     /**
      * Localized Language, defaults to English.
      *
      * Change this to localize Saloos. A corresponding MO file for the chosen
      * language must be installed to content/languages. For example, install
      * fa_IR.mo to content/languages and set LANGUAGE to 'fa_IR' to enable Persian
      * language support.
      */
     router::set_storage('language', router::get_storage('defaultLanguage'));
     if (router::get_repository_name() === 'content') {
         // $mysub = router::get_sub_domain();
         $mysub = router::get_url(0);
         $myList = \lib\utility\option::languages();
         // check langlist with subdomain and if is equal set current language
         foreach ($myList as $key => $value) {
             $myLang = substr($key, 0, 2);
             if ($mysub === $myLang) {
                 if (router::get_storage('defaultLanguage') === $key) {
                     // redirect to homepage
                     $myredirect = new \lib\redirector();
                     $myredirect->set_domain()->set_url()->redirect();
                 } else {
                     router::set_storage('language', $key);
                     // update base url
                     router::$base .= '/' . router::get_url(0);
                     router::remove_url($myLang);
                 }
             }
         }
     } else {
         // change with get all times except on content or root,
         // because in root user must change language with subdomain
         if (isset($_GET["lang"])) {
             router::set_storage('language', $_GET["lang"]);
         } elseif (isset($_COOKIE["lang"])) {
             router::set_storage('language', $_COOKIE["lang"]);
         }
         // save language preference for future page requests
         setcookie('lang', router::get_storage('language'), time() + 30 * 24 * 60 * 60, '/', '.' . Service);
     }
     // check direction of language and set for rtl languages
     switch (router::get_storage('language')) {
         case 'fa_IR':
         case 'ar_SU':
             router::set_storage('direction', 'rtl');
             break;
         default:
             router::set_storage('direction', 'ltr');
             break;
     }
     return router::get_storage('language');
 }
示例#14
0
 /**
  * check signup and if can add new user
  * @return [type] [description]
  */
 public static function signup($_mobile, $_pass, $_perm = null, $_name = null, $_ref = null)
 {
     // first if perm is true get default permission from db
     if ($_perm === true) {
         // if use true fill it with default value
         $_perm = \lib\utility\option::get('account');
         // default value not set in database
         if ($_perm == '') {
             $_perm = null;
         }
     } else {
         $_perm = null;
     }
     $query = "\n\t\t\tSELECT\n\t\t\t\tid\n\t\t\tFROM\n\t\t\t\tusers\n\t\t\tWHERE\n\t\t\t\tuser_mobile = '{$_mobile}'\n\t\t\tLIMIT 1\n\t\t";
     $result = \lib\db::get($query, 'id', true);
     if ($result) {
         // signup called and the mobile exist
         return false;
     } else {
         $ref = null;
         // get the ref and set in users_parent
         if (isset($_SESSION['user']['ref'])) {
             $ref = $_SESSION['user']['ref'];
         } elseif ($_ref) {
             $ref = $_ref;
         }
         // signup up users
         $args = ['user_mobile' => $_mobile, 'user_pass' => \lib\utility::hasher($_pass), 'user_displayname' => $_name, 'user_permission' => $_perm, 'user_parent' => $ref, 'user_createdate' => date('Y-m-d H:i:s')];
         $insert_new = self::insert($args);
         $insert_id = \lib\db::insert_id();
         self::$user_id = $insert_id;
         // save ref in dashboard
         if ($ref && $insert_id) {
             self::dashboard_ref($ref, "user_referred");
         }
         return $insert_id;
     }
 }
示例#15
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();
     }
 }
示例#16
0
 public function __construct($object = false)
 {
     parent::__construct($object);
     $this->permissions = \lib\utility\option::get('permissions', 'meta');
 }