Exemplo n.º 1
0
 public static function register($driver, $hook)
 {
     $driverName = Telephony::getDriverName();
     if (!$driverName or $driverName == 'none') {
         return true;
     } elseif (!class_exists($driverName)) {
         Kohana::log('error', 'Telephony -> Unable to register the dialplan driver \'' . $driverName . '\'');
         return false;
     }
     $hookClass = $driverName . '_' . $driver . '_Driver';
     if (!class_exists($hookClass)) {
         Kohana::log('error', 'Telephony -> Unable to register the dialplan hook \'' . $driver . '\'(' . $hookClass . ')');
         return false;
     }
     if (empty(self::$dialplanSections)) {
         kohana::log('debug', 'Telephony -> EVAL ' . $driverName . '::getDialplanSections();');
         $sections = eval('return ' . $driverName . '::getDialplanSections();');
         if (is_array($sections)) {
             self::$dialplanSections = $sections;
         }
     }
     if (!in_array($hook, self::$dialplanSections)) {
         //Logger::ExceptionByCaller();
         throw new Exception('The hook ' . $hook . ' is not a recognized telephony global hook. (While trying to register callback ' . $driver . ')');
     }
     // Register event as _telephony.action with the callback array as the callback
     Event::add('_telephony.' . $hook, array($hookClass, $hook));
     Kohana::log('debug', 'Telephony -> Added hook for _telephony.' . $hook . ' to call ' . $hookClass . '::' . $hook);
     return TRUE;
 }
Exemplo n.º 2
0
 /**
  * Adds the register method to load after system.ready
  */
 public function __construct()
 {
     // Hook into routing
     if (file_exists(DOCROOT . "application/config/database.php")) {
         Event::add('system.ready', array($this, 'register'));
     }
 }
Exemplo n.º 3
0
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     // Add a Sub-Nav Link
     Event::add('ushahidi_action.nav_admin_reports', array($this, '_report_link'));
     // Only add the events if we are on that controller
     if (Router::$current_uri == "admin/reports") {
         plugin::add_stylesheet('analysis/views/css/buttons');
         // Add Buttons to the report List
         Event::add('ushahidi_action.report_extra_admin', array($this, '_reports_list_buttons'));
     } elseif (Router::$controller == 'analysis') {
         plugin::add_javascript('analysis/views/js/ui.dialog');
         plugin::add_javascript('analysis/views/js/ui.draggable');
         plugin::add_javascript('analysis/views/js/ui.resizable');
         plugin::add_stylesheet('analysis/views/css/main');
     } elseif (strripos(Router::$current_uri, "admin/reports/edit") !== false) {
         plugin::add_stylesheet('analysis/views/css/report');
         plugin::add_javascript('analysis/views/js/jquery.copy.min');
         Event::add('ushahidi_action.report_pre_form_admin', array($this, '_reports_list_analysis'));
         Event::add('ushahidi_action.header_scripts_admin', array($this, '_save_analysis_js'));
         Event::add('ushahidi_action.report_edit', array($this, '_save_analysis'));
     } elseif (strripos(Router::$current_uri, "reports/submit") !== false) {
         //Add dropdown fields to the submit form
         Event::add('ushahidi_action.report_form', array($this, '_submit_form'));
         //Save the contents of the dropdown
         Event::add('ushahidi_action.report_submit', array($this, '_handle_post_data'));
         Event::add('ushahidi_action.report_add', array($this, '_save_submit_form'));
     }
 }
Exemplo n.º 4
0
 /**
  * On first session instance creation, sets up the driver and creates session.
  *
  * @param string Force a specific session_id
  */
 protected function __construct($session_id = NULL)
 {
     $this->input = Input::instance();
     // This part only needs to be run once
     if (Session::$instance === NULL) {
         // Load config
         Session::$config = Kohana::config('session');
         // Makes a mirrored array, eg: foo=foo
         Session::$protect = array_combine(Session::$protect, Session::$protect);
         // Configure garbage collection
         ini_set('session.gc_probability', (int) Session::$config['gc_probability']);
         ini_set('session.gc_divisor', 100);
         ini_set('session.gc_maxlifetime', Session::$config['expiration'] == 0 ? 86400 : Session::$config['expiration']);
         // Create a new session
         $this->create(NULL, $session_id);
         if (Session::$config['regenerate'] > 0 and $_SESSION['total_hits'] % Session::$config['regenerate'] === 0) {
             // Regenerate session id and update session cookie
             $this->regenerate();
         } else {
             // Always update session cookie to keep the session alive
             cookie::set(Session::$config['name'], $_SESSION['session_id'], Session::$config['expiration']);
         }
         // Close the session on system shutdown (run before sending the headers), so that
         // the session cookie(s) can be written.
         Event::add('system.shutdown', array($this, 'write_close'));
         // Singleton instance
         Session::$instance = $this;
     }
     Kohana_Log::add('debug', 'Session Library initialized');
 }
Exemplo n.º 5
0
 /**
  * Constructs a new challenge.
  *
  * @return  void
  */
 public function __construct()
 {
     // Generate a new challenge
     $this->response = $this->generate_challenge();
     // Store the correct Captcha response in a session
     Event::add('system.post_controller', array($this, 'update_response_session'));
 }
 /**
  * Registers the main event add method
  */
 public function __construct()
 {
     // Hook into routing
     Event::add('system.pre_controller', array($this, 'add'));
     $this->post_data = null;
     //initialize this for later use
 }
Exemplo n.º 7
0
 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     // checke request is ajax
     $this->ajax_request = request::is_ajax();
     // Load the template
     $this->template = new View($this->template);
     if ($this->auto_render == TRUE) {
         Event::add('system.post_controller', array($this, '_render'));
     }
     /**
      * 判断用户登录情况
      */
     if (isset($_REQUEST['session_id'])) {
         $session = Session::instance($_REQUEST['session_id']);
         $manager = role::get_manager($_REQUEST['session_id']);
     } else {
         $session = Session::instance();
         $manager = role::get_manager();
     }
     /* 当前请求的URL */
     $current_url = urlencode(url::current(TRUE));
     //当前用户管理的站点的ID
     $this->site_id = site::id();
 }
Exemplo n.º 8
0
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     if (strripos(Router::$current_uri, "admin") !== false) {
         Event::add('ushahidi_action.header_nav', array($this, '_add_offline_tab_header'));
         //adds the mobile tab
     }
 }
Exemplo n.º 9
0
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     // Only add the events if we are on that controller
     if (Router::$controller == 'reports' and Router::$method == 'view') {
         Event::add('ushahidi_filter.report_description', array($this, '_embed_youtube'));
     }
 }
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     // Only add the events if we are on that controller
     if (Router::$controller == 'reports') {
         switch (Router::$method) {
             // Hook into the Report Add/Edit Form in Admin
             case 'edit':
                 // Hook into the form itself
                 Event::add('ushahidi_action.report_form_admin', array($this, '_report_form'));
                 // Hook into the report_submit_admin (post_POST) event right before saving
                 // Event::add('ushahidi_action.report_submit_admin', array($this, '_report_validate'));
                 // Hook into the report_edit (post_SAVE) event
                 Event::add('ushahidi_action.report_edit', array($this, '_report_form_submit'));
                 break;
                 // Hook into the Report view (front end)
             // Hook into the Report view (front end)
             case 'view':
                 plugin::add_stylesheet('actionable/views/css/actionable');
                 Event::add('ushahidi_action.report_meta', array($this, '_report_view'));
                 break;
         }
     } elseif (Router::$controller == 'feed') {
         // Add Actionable Tag to RSS Feed
         Event::add('ushahidi_action.feed_rss_item', array($this, '_feed_rss'));
     }
 }
Exemplo n.º 11
0
 /**
  * overload steam add function with different add listener
  *
  * @return void
  * @author Andy Bennett
  */
 public function add()
 {
     Event::clear('steamform_' . $this->setup['name'] . '_add.complete');
     Event::add('steamform_' . $this->setup['name'] . '_add.complete', array('Galleries_Controller', 'event_add_complete'));
     // We can't use parent here, as that wipes out the event we've set!
     Steam_Core::add();
 }
Exemplo n.º 12
0
 /**
  * Template loading and setup routine.
  */
 public function __construct($initSession = TRUE)
 {
     self::$msgNotice[0] = _('Access Denied');
     self::$msgNotice[1] = _('Login First Please');
     parent::__construct();
     $this->autoMinifiy = Lemon::config('core.output_minify');
     // checke request is ajax
     $this->ajaxRequest = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
     $this->logon = Logon::getInstance();
     $this->cookieLogon();
     // do init session
     if ($initSession == TRUE) {
         $PHPSESSIONID = $this->input->get('PHPSESSIONID');
         if (!empty($PHPSESSIONID)) {
             $this->sessionInstance = Session::instance($PHPSESSIONID);
         } else {
             $this->sessionInstance = Session::instance();
         }
         $getLogonInfo = $this->logon->getLogonInfo();
         if ($getLogonInfo['userId'] == 0 || $this->check_mgr && $getLogonInfo['mgrRole'] == Logon::$MGR_ROLE_LABEL_GUEST) {
             // 未登录用户才尝试去session里尝试获取一下用户信息。
             $this->setLogonInfoBySession();
         }
     }
     $this->userRoleLabel = $this->logon->getLogonInfoValueByKey('userRoleLabel', Logon::$USER_ROLE_LABEL_GUEST);
     $this->mgrRole = $this->logon->getLogonInfoValueByKey('mgrRole', Logon::$MGR_ROLE_LABEL_GUEST);
     // Load the app
     $this->template = new View($this->template);
     if ($this->autoRender == TRUE) {
         // Render the app immediately after the controller method
         Event::add('system.post_controller', array($this, '_render'));
     }
 }
Exemplo n.º 13
0
 /**
  * Send the contents of a file or a data string with the proper MIME type and exit.
  *
  * @uses exit()
  * @uses Kohana::close_buffers()
  *
  * @param   string  a file path or file name
  * @param   string  optional data to send
  * @return  void
  */
 public static function send($filename, $data = NULL)
 {
     if ($data === NULL) {
         $filepath = realpath($filename);
         $filename = basename($filepath);
         $filesize = filesize($filepath);
     } else {
         $filename = basename($filename);
         $filesize = strlen($data);
     }
     // Retrieve MIME type by extension
     $mime = Kohana::config('mimes.' . strtolower(substr(strrchr($filename, '.'), 1)));
     $mime = empty($mime) ? 'application/octet-stream' : $mime[0];
     // Close output buffers
     Kohana::close_buffers(FALSE);
     // Clear any output
     Event::add('system.display', create_function('', 'Kohana::$output = "";'));
     // Send headers
     header("Content-Type: {$mime}");
     header('Content-Length: ' . sprintf('%d', $filesize));
     header('Content-Transfer-Encoding: binary');
     // Send data
     if ($data === NULL) {
         $handle = fopen($filepath, 'rb');
         fpassthru($handle);
         fclose($handle);
     } else {
         echo $data;
     }
     exit;
 }
Exemplo n.º 14
0
 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     $this->obj_session = Session::instance();
     $this->obj_user_lib = User::instance();
     // checke request is ajax
     $this->ajax_request = request::is_ajax();
     if ($this->auto_render == TRUE) {
         Event::add('system.post_controller', array($this, '_render'));
     }
     //$session = Session::instance();
     $user = array();
     $user = $this->obj_session->get('USER');
     //var_dump($_SESSION);
     if (!empty($user)) {
         $this->_user = $this->obj_user_lib->get_user_by_uid($user['id']);
     }
     unset($user);
     $data = array();
     $data['site_config'] = Kohana::config('site_config.site');
     $host = $_SERVER['HTTP_HOST'];
     $dis_site_config = Kohana::config('distribution_site_config');
     if (array_key_exists($host, $dis_site_config) == true && isset($dis_site_config[$host])) {
         $data['site_config']['site_title'] = $dis_site_config[$host]['site_name'];
         $data['site_config']['keywords'] = $dis_site_config[$host]['keywords'];
         $data['site_config']['description'] = $dis_site_config[$host]['description'];
     }
     $this->_site_config = $data;
 }
Exemplo n.º 15
0
 /**
  * @see EventInterface::add()
  */
 public function add($fd, $flag, $func, $args = array())
 {
     switch ($flag) {
         case self::EV_SIGNAL:
             $fd_key = (int) $fd;
             $event = \Event::signal($this->_eventBase, $fd, $func);
             if (!$event || !$event->add()) {
                 return false;
             }
             $this->_eventSignal[$fd_key] = $event;
             return true;
         case self::EV_TIMER:
         case self::EV_TIMER_ONCE:
             $param = array($func, (array) $args, $flag, $fd, self::$_timerId);
             $event = new \Event($this->_eventBase, -1, \Event::TIMEOUT | \Event::PERSIST, array($this, "timerCallback"), $param);
             if (!$event || !$event->addTimer($fd)) {
                 return false;
             }
             $this->_eventTimer[self::$_timerId] = $event;
             return self::$_timerId++;
         default:
             $fd_key = (int) $fd;
             $real_flag = $flag === self::EV_READ ? \Event::READ | \Event::PERSIST : \Event::WRITE | \Event::PERSIST;
             $event = new \Event($this->_eventBase, $fd, $real_flag, $func, $fd);
             if (!$event || !$event->add()) {
                 return false;
             }
             $this->_allEvents[$fd_key][$flag] = $event;
             return true;
     }
 }
Exemplo n.º 16
0
	/**
	 * Adds all the events to the main Ushahidi application
	 */
	public function add()
	{
		// Only add the events if we are on that controller
		if (Router::$controller == 'reports')
		{
			switch (Router::$method)
			{
				// Hook into the Report Add/Edit Form in Admin
				case 'edit':
					// Hook into the form itself
					Event::add('ushahidi_action.report_form_admin', array($this, '_report_form'));
					// Hook into the report_edit (post_SAVE) event
					Event::add('ushahidi_action.report_edit', array($this, '_report_form_submit'));
					break;
				
				// Hook into the Report view (front end)
				case 'view':
					Event::add('ushahidi_action.report_extra', array($this, '_report_view'));
					break;
			}
		}
		elseif (Router::$controller == 'feed')
		{
			// Add Actionable Tag to RSS Feed
			//Event::add('ushahidi_action.feed_rss_item', array($this, '_feed_rss'));
		}
	}
Exemplo n.º 17
0
 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     $this->auth = new Auth();
     // Load the template
     $this->template = new View($this->template);
     if ($this->auto_render == TRUE) {
         // Render the template immediately after the controller method
         Event::add('system.post_controller', array($this, '_render'));
     }
     $this->session = Session::instance();
     //Template Variables
     $this->template->navigation = new View('/shadadmin/navigation');
     $this->template->search = '';
     //new View('/shadadmin/templates/search')
     $this->template->blog = '';
     //new View('/shadadmin/templates/blog')
     //Template - error messages
     $this->template->message = '';
     $this->template->message_type = '';
     $this->template->playlist_table = '';
     $this->template->component_type = '';
     $this->template->list_video_playlist = '';
     $this->template->list_image_playlist = '';
     $this->template->list_text_playlist = '';
     if ($this->auth->logged_in('login')) {
         $username = Auth::instance()->get_user()->username;
     } else {
         $username = '';
     }
     //Display Username
     $this->template->username = $username;
 }
Exemplo n.º 18
0
 /**
  * Adds the register method to load after system.ready
  */
 public function __construct()
 {
     // Hook into routing
     if (Kohana::config('config.installer_check') == FALSE or file_exists(DOCROOT . "application/config/database.php")) {
         Event::add('system.ready', array('Themes', 'register_theme'));
     }
 }
Exemplo n.º 19
0
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     Event::add('ushahidi_action.report_add', array($this, '_report_add'));
     Event::add('ushahidi_action.checkin_recorded', array($this, '_checkin_recorded'));
     Event::add('ushahidi_action.message_twitter_add', array($this, '_message_twitter_add'));
     Event::add('ushahidi_action.feed_item_add', array($this, '_feed_item_add'));
 }
Exemplo n.º 20
0
 public function __construct()
 {
     parent::__construct();
     if (!$this->role || (!in_array('login', $this->role->name) || count($this->role->name) <= 1 && url::current() != 'auth')) {
         return url::redirect('auth');
     }
     if ($this->input->get('no_html')) {
         $this->template = 'template/no_html';
     }
     $this->template = new View($this->template);
     if ($this->user) {
         $this->template->menu = new View('template/menu');
         $this->template->menu->acces = array();
         if (isset($this->user->username)) {
             $this->template->username = $this->user->username;
         }
         if (isset($this->role->name)) {
             $this->template->menu->acces = $this->role->name;
         }
     }
     $this->template->titre = false;
     $this->template->button = false;
     $this->template->add_element_button = false;
     $this->template->add_sauv = false;
     $this->template->navigation = false;
     $this->template->navigationURL = false;
     $this->template->msg = $this->input->get('msg');
     if ($this->auto_render == true) {
         Event::add('system.post_controller', array($this, '_render'));
     }
 }
Exemplo n.º 21
0
 /**
  * Adds all the events to the main Ushahidi application
  */
 public function add()
 {
     Event::add('ushahidi_filter.map_base_layers', array($this, '_add_layer'));
     if (Router::$controller != 'settings') {
         Event::add('ushahidi_filter.map_layers_js', array($this, '_add_map_layers_js'));
     }
 }
Exemplo n.º 22
0
 public function __construct()
 {
     // Hook into routing, but not if running unit tests
     if (!in_array(MODPATH . 'phpUnit', kohana::config('config.modules'))) {
         Event::add('system.routing', array($this, 'check'));
     }
 }
Exemplo n.º 23
0
 /**
  * Add a new message to the log.
  *
  * @param   string  type of message
  * @param   string  message text
  * @return  void
  */
 public static function add($type, $message)
 {
     // Make sure the drivers and config are loaded
     if (!is_array(Kohana_Log::$config)) {
         Kohana_Log::$config = Kohana::config('log');
     }
     if (!is_array(Kohana_Log::$drivers)) {
         foreach ((array) Kohana::config('log.drivers') as $driver_name) {
             // Set driver name
             $driver = 'Log_' . ucfirst($driver_name) . '_Driver';
             // Load the driver
             if (!Kohana::auto_load($driver)) {
                 throw new Kohana_Exception('Log Driver Not Found: %driver%', array('%driver%' => $driver));
             }
             // Initialize the driver
             $driver = new $driver(array_merge(Kohana::config('log'), Kohana::config('log_' . $driver_name)));
             // Validate the driver
             if (!$driver instanceof Log_Driver) {
                 throw new Kohana_Exception('%driver% does not implement the Log_Driver interface', array('%driver%' => $driver));
             }
             Kohana_Log::$drivers[] = $driver;
         }
         // Always save logs on shutdown
         Event::add('system.shutdown', array('Kohana_Log', 'save'));
     }
     Kohana_Log::$messages[] = array('date' => time(), 'type' => $type, 'message' => $message);
 }
Exemplo n.º 24
0
 /**
  * constructor; set up listeners
  *
  * @author Andy Bennett
  */
 public function __construct()
 {
     $this->init();
     Kohana::config_load('steamauth');
     $this->conf = Kohana::config('steamauth.steamauth');
     Event::add('steamauth.login_success', array('steamauth_listeners', 'login_success'));
     Event::add('steamauth.logged_in', array('steamauth_listeners', 'logged_in'));
     Event::add('steamauth.show_login_form', array('steamauth_listeners', 'login_form'));
     Event::add('steamauth.logged_out', array('steamauth_listeners', 'logged_out'));
     Event::add('steamform_auth_register.complete', array('steamauth_listeners', 'register_complete'));
     Event::add('steamform_auth_register.complete', array('auth_email_events', 'register_complete_email'));
     Event::add('steamform_auth_register.show_form', array('steamauth_listeners', 'register_show_form'));
     Event::add('steamform_auth_profile.complete', array('steamauth_listeners', 'profile_complete'));
     Event::add('steamform_auth_profile.show_form', array('steamauth_listeners', 'profile_show_form'));
     Event::add('steamauth.change_credential_form', array('steamauth_listeners', 'change_credential_form'));
     Event::add('steamauth.change_credential_email', array('auth_email_events', 'change_credential_email'));
     Event::add('steamauth.change_credential_success', array('steamauth_listeners', 'change_credential_success'));
     Event::add('steamauth.forgotten_credential_form', array('steamauth_listeners', 'forgotten_credential_form'));
     Event::add('steamauth.forgotten_credential_email', array('auth_email_events', 'forgotten_credential_email'));
     Event::add('steamauth.forgotten_credential_sent', array('steamauth_listeners', 'forgotten_credential_sent'));
     Event::add('steamauth.forgotten_identity_form', array('steamauth_listeners', 'forgotten_identity_form'));
     Event::add('steamauth.forgotten_identity_email', array('auth_email_events', 'forgotten_identity_email'));
     Event::add('steamauth.forgotten_identity_sent', array('steamauth_listeners', 'forgotten_identity_sent'));
     Event::add('steamauth.activated', array('auth_email_events', 'activation_email'));
     Event::add('steamauth.activated', array('steamauth_listeners', 'activation_complete'));
     Event::add('steamauth.activation_error', array('steamauth_listeners', 'activation_error'));
     Event::add('steamauth.forgotten_credential_reset_email', array('auth_email_events', 'forgotten_credential_reset_email'));
     Event::add('steamauth.forgotten_credential_reset', array('steamauth_listeners', 'forgotten_credential_reset'));
     Event::add('steamauth.forgotten_credential_reset_error', array('steamauth_listeners', 'forgotten_credential_reset_error'));
     // Singleton instance
     self::$instance = $this;
 }
Exemplo n.º 25
0
 /**
  * On first session instance creation, sets up the driver and creates session.
  */
 public function __construct()
 {
     $this->input = Input::instance();
     // This part only needs to be run once
     if (self::$instance === NULL) {
         // Load config
         self::$config = Kohana::config('session');
         // Makes a mirrored array, eg: foo=foo
         self::$protect = array_combine(self::$protect, self::$protect);
         // Configure garbage collection
         ini_set('session.gc_probability', (int) self::$config['gc_probability']);
         ini_set('session.gc_divisor', 100);
         ini_set('session.gc_maxlifetime', self::$config['expiration'] == 0 ? 86400 : self::$config['expiration']);
         // Create a new session
         $this->create();
         if (self::$config['regenerate'] > 0 and $_SESSION['total_hits'] % self::$config['regenerate'] === 0) {
             // Regenerate session id and update session cookie
             $this->regenerate();
         } else {
             // Always update session cookie to keep the session alive
             cookie::set(self::$config['name'], $_SESSION['session_id'], self::$config['expiration']);
         }
         // Close the session just before sending the headers, so that
         // the session cookie(s) can be written.
         Event::add('system.send_headers', array($this, 'write_close'));
         // Make sure that sessions are closed before exiting
         register_shutdown_function(array($this, 'write_close'));
         // Singleton instance
         self::$instance = $this;
     }
     Kohana::log('debug', 'Session Library initialized');
 }
 public function __construct()
 {
     $block = array("classname" => "polaroid_reports_block", "name" => "Polaroid Reports", "description" => "List the 35 latest reports in the system. Part of the Polaroid Theme.");
     blocks::register($block);
     // Hook into routing
     Event::add('system.pre_controller', array($this, 'add'));
 }
 public function _serve_from_cache()
 {
     // Check the expiry time in the request headers and just return
     // Not Modified if appropriate
     if ($this->expiry_time) {
         expires::check($this->expiry_time);
     }
     // If caching is turned on and we're using Kohana's cache library ...
     if ($this->cache and !$this->cache_config_writes_to_docroot()) {
         // Get cache id (calling this cache_id() method if it's not already set)
         $cache_id = isset($this->cache_id) ? $this->cache_id : ($this->cache_id = $this->cache_id());
         // Try to retrive it from the cache
         $content = $this->cache_instance()->get($cache_id);
         if (!empty($content)) {
             // Serve the cached content ...
             echo $content;
             // ... run the shutdown events
             Kohana::shutdown();
             // ... and bail out
             exit;
         }
     }
     // Add handler to cache the output (we check whether caching is
     // turned on at the final moment)
     Event::add('system.display', array($this, '_cache_output'));
 }
Exemplo n.º 28
0
 /**
  * Adds invite only check to the routing event
  */
 public function __construct()
 {
     // Hook only if enabled in config
     if (Kohana::config('site.inviteonly')) {
         Event::add('system.routing', array($this, 'login'));
     }
 }
Exemplo n.º 29
0
 /**
  * Checks to see if a page should be updated or send Not Modified status
  *
  * @param   integer  Seconds added to the modified time received to calculate what should be sent
  * @return  bool     FALSE when the request needs to be updated
  */
 public static function check($seconds = 60)
 {
     if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) and expires::check_headers()) {
         if (($strpos = strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], ';')) !== FALSE) {
             // IE6 and perhaps other IE versions send length too, compensate here
             $mod_time = substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, $strpos);
         } else {
             $mod_time = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
         }
         $mod_time = strtotime($mod_time);
         $mod_time_diff = $mod_time + $seconds - time();
         if ($mod_time_diff > 0) {
             // Re-send headers
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s T', $mod_time));
             header('Expires: ' . gmdate('D, d M Y H:i:s T', time() + $mod_time_diff));
             header('Cache-Control: max-age=' . $mod_time_diff);
             header('Status: 304 Not Modified', TRUE, 304);
             // Prevent any output
             Event::add('system.display', array('expires', 'prevent_output'));
             // Exit to prevent other output
             exit;
         }
     }
     return FALSE;
 }
Exemplo n.º 30
0
 /**
  * Template loading and setup routine.
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     // Load the template
     $this->template = new View($this->template);
     // Feed $feed
     $this->feed = Kohana::config('rss.feeds');
     // Links
     $this->links = Kohana::config('links.links');
     $this->links = base::links_filter($this->links);
     sort($this->links);
     // Blocks
     $this->blocks_left = Kohana::config('blocks.left');
     $this->blocks_top = Kohana::config('blocks.top');
     $this->blocks_right = Kohana::config('blocks.right');
     if (count($this->blocks_left) > 0) {
         sort($this->blocks_left);
     }
     if (count($this->blocks_top) > 0) {
         sort($this->blocks_top);
     }
     if (count($this->blocks_right) > 0) {
         sort($this->blocks_right);
     }
     if ($this->auto_render == TRUE) {
         // Render the template immediately after the controller method
         Event::add('system.post_controller', array($this, '_render'));
     }
     // Remove old files from upload directory
     base::remove_old_uploads();
 }