Esempio n. 1
0
 public function pagnation_config()
 {
     if (preg_match("#^([1-9][0-9]*)\$#", \lib\router::get_url_property('page'), $_page)) {
         $page = intval($_page[1]);
         \lib\router::set_storage('pagnation', $page);
         $this->pagnation['current'] = $page;
         \lib\router::remove_url_property('page');
         if ($page == 1) {
             $redirect = new \lib\redirector(null, true);
             $redirect->url = preg_replace("/\\/page=1/", "", $redirect->url);
             $redirect->redirect();
         }
     }
     if (preg_match("#^(\\d+)\$#", \lib\router::get_url_property('length'), $length)) {
         $this->pagnation_set('length', intval($length[1]));
         $this->pagnation_set('custom_length', true);
         \lib\router::remove_url_property('length');
     }
 }
Esempio n. 2
0
 /**
  * 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();
     }
 }