public function __construct()
 {
     // check that site was enabled.
     if (!\Model_Sites::isSiteEnabled()) {
         $request = \Request::forge('error/403')->execute();
         $response = new \Response($request, 403);
         $response->set_status(403);
         $response->send(true);
         unset($request, $response);
         exit;
     }
     // fix changed current language but autoload not reload
     \Lang::load('fslang');
     // call web cron to run tasks (including purge old login history)
     \Library\WebCron::forge()->init();
     // set default theme name
     // @todo [fuelstart][theme] for theme management. you should get default theme setting from db here.
     \Config::load('theme', true);
     $theme_active = \Config::get('theme.active');
     $this->theme_system_name = $theme_active;
     unset($theme_active);
 }
Example #2
0
 /**
  * redirect to url that contain language
  * example:
  * http://localhost/ -> http://localhost/en
  * http://localhost/page -> http://localhost/en/page
  *
  * @author Vee Winch.
  * @license MIT
  * @link http://rundiz.com The author's website.
  * @package Fuel Start
  */
 public function redirectLanguageUri()
 {
     $locales = \Config::get('locales');
     $default_lang = \Config::get('language');
     if (is_array($locales) && !empty($locales)) {
         if (!count($this->segments)) {
             // current uri is in root web. the url is http://domain.tld/fuelphp_root_web/
             $need_redirect = true;
             // redirect to http://domain.tld/fuelphp_root_web/{lang}
             $redirect_url = $default_lang;
         } else {
             // current url is in dir or /lang
             $uri_exp = explode('/', \Input::uri());
             // the \Input::uri will return uri segments with / at the start. when explode it, the first array might be null.
             // check that first array of exploded uri is not null.
             if (isset($uri_exp[0]) && $uri_exp[0] != null) {
                 $first_uri = $uri_exp[0];
             } elseif (isset($uri_exp[1])) {
                 $first_uri = $uri_exp[1];
             } else {
                 // in case that \Input::uri with exploded / is not array or something wrong.
                 $first_uri = $default_lang;
             }
             // if first uri is NOT in locales.
             if (!array_key_exists($first_uri, $locales)) {
                 // first uri segment is not lang. the url is http://domain.tld/fuelphp_root_web/page
                 $need_redirect = true;
                 // redirect to http://domain.tld/fuelphp_root_web/{lang}/page
                 $redirect_url = $default_lang . '/' . implode('/', $this->segments);
             }
         }
         // if need to redirect.
         if (isset($need_redirect) && $need_redirect === true) {
             // set no cache header.
             $response = new Response();
             $response->set_header('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
             $response->set_header('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT');
             $response->set_header('Pragma', 'no-cache');
             $response->send_headers();
             // clean vars.
             unset($default_lang, $first_uri, $locales, $need_redirect);
             // go! redirect. (do not use fuelphp redirect because it generate error 404 in home page)
             $redirect_url = self::createNL($redirect_url);
             // use redirect manually.
             $response->set_status(301);
             $response->set_header('Location', $redirect_url);
             $response->send(true);
             exit;
         }
         // clean vars.
         unset($default_lang, $locales);
     }
     // clean vars.
     unset($default_lang, $locales);
 }
Example #3
0
File: http.php Project: jaz303/zing
 public static function redirect($absolute_url, $permanent = false)
 {
     $response = new Response();
     $response->set_status($permanent ? Constants::MOVED_PERMANENTLY : Constants::MOVED_TEMPORARILY);
     $response->set_header('Location', $absolute_url);
     return $response;
 }