Esempio n. 1
0
 public function __construct()
 {
     parent::__construct();
     // Load profiler
     if (Kohana::config('config.enable_profiler')) {
         $this->profiler = new Profiler();
     }
     $this->auth = Auth::instance();
     $this->db = Database::instance();
     // Are we logged in? if not, do we have an auto-login cookie?
     if (!$this->auth->logged_in()) {
         // Try to login with 'remember me' token
         if (!$this->auth->auto_login()) {
             // Login user in via HTTP AUTH
             $this->auth->http_auth_login();
         }
     }
     // Get session information
     $this->user = Auth::instance()->get_user();
     // Check private deployment access
     $controller_whitelist = array('login', 'riverid', 'api', 'frontlinesms', 'smssync', 'nexmo');
     if (Kohana::config('settings.private_deployment')) {
         if (!$this->auth->logged_in('login') and !in_array(Router::$controller, $controller_whitelist)) {
             // Redirect to login form
             url::redirect('login');
         }
     }
     // Set default content-type header
     header('Content-type: text/html; charset=UTF-8');
 }
 function __construct()
 {
     parent::__construct();
     if (Kohana::config('smarty.integration') == TRUE) {
         $this->MY_Smarty = new MY_Smarty();
     }
 }
Esempio n. 3
0
 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     if ($this->auto_render == YES) {
         // Render the template along with the system display stuff
         Event::add_before('system.display', array($this, 'render'), array($this, '_render'));
     }
 }
Esempio n. 4
0
 public function __construct()
 {
     parent::__construct();
     $this->profiler = new Profiler();
     $request_parts = pathinfo(url::current());
     $this->url_extension = isset($request_parts['extension']) ? $request_parts['extension'] : null;
     $this->json_callback = $this->input->get('callback');
 }
Esempio n. 5
0
 public function __construct()
 {
     parent::__construct();
     Kohana::config_load('workermgmt');
     $this->profiler = IN_DEV_MODE ? new Profiler() : null;
     $requested_area = strtolower(Router::$controller . "::" . Router::$method);
     if (!in_array($requested_area, $this->non_authed_areas)) {
         // run authentication
         if (!Bugzilla::instance(Kohana::config('workermgmt'))->authenticated()) {
             url::redirect('login');
         }
     }
 }
Esempio n. 6
0
 public function __construct()
 {
     parent::__construct();
     $this->auth = new Auth();
     // Are we logged in? if not, do we have an auto-login cookie?
     if (!$this->auth->logged_in()) {
         $this->auth->auto_login();
     }
     // Chceck private deployment access
     $controller_whitelist = array('login', 'riverid');
     if (Kohana::config('settings.private_deployment')) {
         if (!$this->auth->logged_in('login') and !in_array(Router::$controller, $controller_whitelist)) {
             url::redirect('login');
         }
     }
 }
Esempio n. 7
0
 public function __construct()
 {
     parent::__construct();
     date_default_timezone_set('America/Los_Angeles');
     $this->db = Database::instance();
     // init property db use Database
     $this->session = Session::instance();
     // init property session use Session
     $this->Site_Model = new Site_Model();
     $this->Login_Model = new Login_Model();
     if ((int) date('d') >= '15' && (int) date('d') <= '25' && (int) date('m') == '12') {
         define('snow', 'off');
     } else {
         define('snow', 'off');
     }
     define('s3_using', 'on');
     $s3_config_main = $this->db->get('s3_config')->result_array(false);
     $s3_bucket_main = !empty($s3_config_main[0]['main_bucket']) ? $s3_config_main[0]['main_bucket'] : '';
     define('linkS3', 'https://s3-us-west-2.amazonaws.com/' . $s3_bucket_main . '/');
     // get site information, config, language
     $this->site = $this->Site_Model->get();
     $this->site['base_url'] = url::base();
     $this->site['config']['TEMPLATE'] = 'sic';
     // Get search (keyword, curpage) from session if have
     if ($this->session->get('sess_search')) {
         $this->search = $this->session->get('sess_search');
         $this->session->set_flash('sess_search', $this->search);
     } else {
         $this->search = array('keyword' => '', 'cur_page' => '');
     }
     $cur_page = $this->uri->segment('page');
     if ($cur_page) {
         $this->search['cur_page'] = '/page/' . $cur_page;
     }
     // init admin or client
     if (strpos($this->uri->segment(1), "admin") === false) {
         $this->site['theme_url'] = url::base() . 'themes/client/' . $this->site['site_client_theme'] . '/';
         $this->site['version'] = "";
         $this->init_client();
     } else {
         $this->site['theme_url'] = url::base() . 'themes/admin/';
         $this->site['site_footer'] = "";
         $this->site['version'] = "";
         $this->init_admin();
     }
     //echo Kohana::debug($_SESSION);
 }
Esempio n. 8
0
 /**
  * 构造函数
  */
 public function __construct()
 {
     parent::__construct();
     $session = Session::instance();
     $session->set('request_time', microtime(TRUE));
     $this->method = $_SERVER['REQUEST_METHOD'];
     $current_url = url::current();
     $this->current_url = $current_url;
     $url_arr = explode('/', $current_url);
     $dot_pos = strrpos($current_url, '.');
     $back_slash_pos = strpos($current_url, '/');
     if ($back_slash_pos === FALSE) {
         //防止没有设置返回类型的输入
         $this->root = substr($current_url, 0, $dot_pos ? $dot_pos : strlen($current_url));
     } else {
         $this->root = substr($current_url, 0, $back_slash_pos);
         if (isset($url_arr[1]) && !preg_match("/\\d+/is", $url_arr[1])) {
             $this->second = preg_replace('/.(xml|json)$/', '', $url_arr[1]);
         }
     }
     // 不需要授权的模块
     if (in_array($this->root, $this->un_authorized)) {
         return TRUE;
     }
     // 不需要授权的接口
     $url = preg_replace('/.(xml|json)$/', '', $this->current_url);
     if (in_array($url, $this->no_auth)) {
         return TRUE;
     }
     $headers = self::get_all_headers();
     $access_token = $this->get_access_token($headers);
     if (empty($access_token)) {
         $this->send_response(401, NULL, Kohana::lang('authorization.missing_auth'));
     }
     $token = User_Model::instance()->get_access_token($access_token);
     if (empty($token)) {
         $this->send_response(401, NULL, Kohana::lang('authorization.missing_auth'));
     }
     if (isset($token['expires']) && time() > $token['expires']) {
         $this->send_response(401, NULL, Kohana::lang('authorization.auth_expired'));
     }
     $this->user_id = $this->uid = $token['id'];
     return TRUE;
 }
Esempio n. 9
0
 public function __construct()
 {
     parent::__construct();
     // Load profiler
     // $profiler = new Profiler;
     $this->auth = Auth::instance();
     // Get session information
     $this->user = Auth::instance()->get_user();
     // Are we logged in? if not, do we have an auto-login cookie?
     if (!$this->auth->logged_in()) {
         $this->auth->auto_login();
     }
     // Chceck private deployment access
     $controller_whitelist = array('login', 'riverid');
     if (Kohana::config('settings.private_deployment')) {
         if (!$this->auth->logged_in('login') and !in_array(Router::$controller, $controller_whitelist)) {
             url::redirect('login');
         }
     }
 }
Esempio n. 10
0
 public function __construct()
 {
     parent::__construct();
     date_default_timezone_set('America/Los_Angeles');
     $this->db = Database::instance();
     // init property db use Database
     $this->session = Session::instance();
     // init property session use Session
     // get site information, config, language
     $this->site = Site_Model::get();
     $this->site['base_url'] = url::base();
     $this->site['config']['TEMPLATE'] = 'sic';
     // Get search (keyword, curpage) from session if have
     if ($this->session->get('sess_search')) {
         $this->search = $this->session->get('sess_search');
         $this->session->set_flash('sess_search', $this->search);
     } else {
         $this->search = array('keyword' => '', 'cur_page' => '');
     }
     $cur_page = $this->uri->segment('page');
     if ($cur_page) {
         $this->search['cur_page'] = '/page/' . $cur_page;
     }
     // init admin or client
     if (strpos($this->uri->segment(1), "admin") === false) {
         $this->site['theme_url'] = url::base() . 'themes/client/' . $this->site['site_client_theme'] . '/';
         $this->site['version'] = "";
         $this->init_client();
     } else {
         $this->site['theme_url'] = url::base() . 'themes/admin/';
         $this->site['site_footer'] = "";
         $this->site['version'] = "";
         $this->init_admin();
     }
     //echo Kohana::debug($_SESSION);
 }
Esempio n. 11
0
 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     // Get loaded modules
     $this->modules = Kohana_Config::instance()->get('core.modules');
     // Initialize libraries
     $this->cache = Cache::instance();
     $this->input = Input::instance();
     $this->uri = URI::instance();
     $this->visitor = Visitor::instance();
     // Validate CSRF token
     if (isset($_REQUEST['csrf'])) {
         $this->valid_csrf = csrf::valid($_REQUEST['csrf']);
     }
     // Load current user for easy controller access, null if not logged
     $this->user =& $this->visitor->get_user();
     // Build the page
     $this->template = View::factory($this->template);
     // Display the template immediately after the controller method?
     if ($this->auto_render === true) {
         Event::add('system.post_controller', array($this, '_display'));
     }
 }