/** * This function will determine there is a valid user on a page the requires * a user. If the user does not exist then it will redirect to the login * page. * * @return bool */ public static function redirectInvalidUser() { // If the system is installing then there is no login required if (Bluebox_Installer::is_installing()) { Kohana::config_set('core.require_login', FALSE); return TRUE; } $session = Session::instance(); // If there is no current user if (!self::isUserAuthentic()) { $controller = strtolower(Router::$controller); $method = strtolower(Router::$method); $noAuth = FALSE; $controllerBypass = Event::$data->getAuthBypass(); if (!empty($controllerBypass) and is_array($controllerBypass)) { self::$authBypass = arr::merge(self::$authBypass, array($controller => $controllerBypass)); } if (!empty(self::$authBypass[$controller])) { if (in_array($method, self::$authBypass[$controller])) { kohana::log('debug', 'The url `' . url::current() . '` is configured for auth bypass, allowing'); $noAuth = TRUE; } } if (!$noAuth) { // this will redirect from the login page back to this page kohana::log('debug', 'This user is not authorized for `' . url::current() . '`, presenting login form'); $session->set("requested_url", "/" . url::current()); if (request::is_ajax()) { header('HTTP/1.0 401 Forbidden'); flush(); die; } else { url::redirect('user/login'); } return FALSE; } } Event::run('bluebox.users.redirectInvalidUser'); $user_debug = self::getAttr('debug_level'); if ($user_debug > Kohana::config('core.log_threshold')) { self::changeDebugLevel($user_debug); } $log = sprintf('Effective user_id %s - account_id %s', self::getAttr('user_id'), self::getAttr('account_id')); kohana::log('debug', $log); $log = sprintf('Authentic user_id %s - account_id %s', self::getAuthenticAttr('user_id'), self::getAuthenticAttr('account_id')); kohana::log('debug', $log); return TRUE; }
public function checkDBConnectivity() { // Are heading somewhere other then the installer? If so, check that we're OK to proceed. if (!Bluebox_Installer::is_installing()) { // Check DB connectivity $manager = Doctrine_Manager::getInstance(); try { $manager->getCurrentConnection()->connect(); Doctrine::getTable('Package')->findAll(); } catch (Doctrine_Connection_Exception $e) { // We can't connect to the database - run the installer! // Get the guess the URL to work on Kohana::config_set('core.site_domain', Bluebox_Installer::guess_site_domain()); url::redirect('/installer'); } } }
public static function bootstrapPackages($ignoreInstaller = FALSE) { if (Bluebox_Installer::is_installing() and $ignoreInstaller !== TRUE) { return TRUE; } $installedPackages = Doctrine::getTable('Package')->findByStatus(Package_Manager::STATUS_INSTALLED); if (empty($installedPackages)) { return FALSE; } $loadList = $navigation = array(); foreach ($installedPackages as $package) { $packageDir = DOCROOT . $package['basedir']; $loadList[$package['name']] = $packageDir; if (is_dir($packageDir . '/models')) { // Note that with MODEL_LOADING_CONSERVATIVE set, the model isn't really loaded until first requested Doctrine::loadModels($packageDir . '/models', Doctrine::MODEL_LOADING_CONSERVATIVE); } if (empty($package['navigation'])) { continue; } $navigation[$package['name']] = $package['navigation']; } $loadedModules = Kohana::config('core.modules'); $systemModules = array_unique(array_merge($loadedModules, $loadList)); Kohana::config_set('core.modules', $systemModules); foreach ($loadList as $packageDir) { // Load hooks only for modules in the DB, if hooks are enabled if (Kohana::config('core.enable_hooks') === TRUE) { if (is_dir($packageDir . '/hooks')) { // Since we're running late, we need to go grab // the hook files again (sad but true) $hooks = Kohana::list_files('hooks', TRUE, $packageDir . '/hooks'); foreach ($hooks as $file) { // Load the hook include_once $file; } } } } navigation::bootstrap($navigation); }
public function commit() { // Activate any changed settings on the switch, live if (!Bluebox_Installer::is_installing()) { if (self::$dirty) { Event::run('freeswitch.reload.xml'); } if (self::$aclDirty) { Event::run('freeswitch.reload.acl'); } if (self::$xmlcdrDirty) { Event::run('freeswitch.reload.xmlcdr'); } if (self::$sofiaDirty) { Event::run('freeswitch.reload.sofia'); } } self::$dirty = FALSE; self::$aclDirty = FALSE; self::$sofiaDirty = FALSE; self::$xmlcdrDirty = FALSE; self::$trunksDirty = FALSE; }
<?php defined('SYSPATH') or die('No direct access allowed.'); if (!Bluebox_Installer::is_installing()) { Event::add('bluebox.message_html', array('ErrorReporter', 'provideHelpLink')); }