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'); }
public function before() { $this->template = 'panel/layout'; parent::before(); $header = View::factory('header'); $this->template->header = $header; }
public function before() { $this->template = "pokemon/layout"; $this->config = Kohana::$config->load('app'); parent::before(); $this->template->api_link = $this->config['pokemon_api_link']; }
public function before() { parent::before(); $browser = $_SERVER['HTTP_USER_AGENT']; if (strpos($browser, 'Wget') !== 0) { throw new HTTP_Exception_404(); } }
/** * 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')); } }
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'); }
public function before() { parent::before(); $moderator = false; if ($this->user and $this->user->has_access('ma')) { $moderator = true; } $this->set('moderator', $moderator); }
public function before() { $this->template = "tamagotchi/layout"; parent::before(); if ($this->session->get('game')) { $this->game = $this->session->get('game'); } else { $this->game = array("idle" => 0, "menu_state" => 0, "action_state" => 0, "clock_state" => 1, "need_state" => 0, "reverse_state" => 0, "umbrella_state" => 0); $this->session->set('game', $this->game); } }
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'); } } }
public function before() { parent::before(); if (Auth::instance()->logged_in()) { $user_id = $this->user->id; $user = $this->user; $this->set('user', $user); $profile_socials = ORM::factory('User_Social')->where('user_id', '=', $user_id)->limit(5)->find_all(); $this->set('profile_socials', $profile_socials); $avatar_uploader = View::factory('storage/avatar')->set('user_id', $this->user->id)->render(); $this->set('avatar_uploader', $avatar_uploader); } /*else{ $this->redirect('/',301); }*/ }
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'); } } }
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); }
/** * 构造函数 */ 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; }
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'); } } }
public function _kohana_load_view($template, $vars) { if ($template == '') { return; } if (substr(strrchr($template, '.'), 1) === Kohana::config('smarty.templates_ext')) { // Assign variables to the template if (is_array($vars) and count($vars) > 0) { foreach ($vars as $key => $val) { $this->MY_Smarty->assign($key, $val); } } // Send Kohana::instance to all templates $this->MY_Smarty->assign('this', $this); // Fetch the output $output = $this->MY_Smarty->fetch($template); } else { $output = parent::_kohana_load_view($template, $vars); } return $output; }
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); }
public function before() { parent::before(); }
public function before() { parent::before(); $config = array('appId' => $this->config->app_id, 'secret' => $this->config->secret, 'fileUpload' => true); $this->facebook = new Facebook($config); $authed = false; $session = null; if ($temp = $this->session->get('signed_request')) { $signed_request = $temp; } elseif (isset($_POST['signed_request'])) { $signed_request = $_POST['signed_request']; } else { $signed_request = false; } if ($signed_request) { $authed = $this->facebook->parseSignedRequest($signed_request); $this->session->set('signed_request', $signed_request); } $session = $authed; if (!$authed || empty($authed['user_id'])) { $this->session->delete('signed_request'); } if (isset($session['user_id'])) { if (isset($session['oauth_token'])) { $access_token = $session['oauth_token']; } elseif (isset($_POST['at'])) { $access_token = $_POST['at']; $this->session->set('access_token', $access_token); } elseif ($temp = $this->session->get('access_token')) { $access_token = $temp; } else { // die("nie ma tokenu"); } $this->facebook->setAccessToken($access_token); $this->user_id = $session['user_id']; $this->access_token = $access_token; } $response = array('status' => 'error'); $user = ORM::factory('User', $this->user_id); if ($user->loaded()) { $response['status'] = 'user_exist'; Auth::instance()->force_login($user); } else { try { $user_data_fb = $this->facebook->api('/me?fields=id,first_name,last_name,name,email,gender'); } catch (Exception $ex) { $response['message'] = $ex->getMessage(); echo json_encode($response); exit; } if (!isset($user_data_fb['email'])) { $user_data_fb['email'] = ''; } $user = ORM::factory('User')->where('email', '=', $user_data_fb['email'])->where('email', '!=', '')->find(); if ($user->loaded()) { $user->id = $user_data_fb['id']; $user->first_name = $user_data_fb['first_name']; $user->last_name = $user_data_fb['last_name']; if ($user->name == '') { $user->name = $user_data_fb['name']; } $user->gender = $user_data_fb['gender']; $user->save(); $response['status'] = 'user_update'; } else { $user_data_fb['created'] = date("Y-m-d H:i:s"); $id = ORM::factory('User')->register($user_data_fb); $user = ORM::factory('User', $id); $response['status'] = 'user_create'; } Auth::instance()->force_login($user); } }
/** * 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')); } }
public function before() { parent::before(); $header = View::factory('header'); $this->template->header = $header; }
public function before() { $this->template = "oceny/layout"; parent::before(); }
public function before() { $this->template = "ingress/layout"; parent::before(); }
public function before() { $this->template = "wydatki/layout"; parent::before(); }
public function before() { $this->template = "pamieta/layout"; parent::before(); }
public function before() { $this->template = "coc/layout"; $this->config = Kohana::$config->load('coc'); parent::before(); }
public function before() { parent::before(); $this->add_cumb('Magazines', 'eljournal'); }
public function before() { parent::before(); $title = ORM::factory('Specprojecttitle', 2)->title; $this->set('title', $title); }
public function before() { $this->template = 'desktop/layout'; parent::before(); }
public function before() { $this->template = "gitara/layout"; parent::before(); }
public function before() { $this->template = 'admin/layout'; parent::before(); $this->check_login(); }