示例#1
0
 public static function setup()
 {
     language::$available_languages = Kohana::config('locale.languages');
     if (Router::$language === NULL) {
         $redirect = NULL;
         if (empty(Router::$current_uri)) {
             if (($lang = language::browser_language()) !== '') {
                 $redirect = $lang;
             } else {
                 reset(language::$available_languages);
                 $redirect = key(language::$available_languages);
             }
         } else {
             if (($lang = language::browser_language()) !== '') {
                 $redirect = $lang . '/' . Router::$current_uri;
             } else {
                 reset(language::$available_languages);
                 $redirect = key(language::$available_languages) . '/' . Router::$current_uri;
             }
         }
         url::redirect($redirect);
     }
     Kohana::config_set('locale.language', language::$available_languages[Router::$language]['language']);
     I18n::$lang = language::$available_languages[Router::$language]['language'][0];
 }
 public static function add($controller_name, $method_name, $parameters = array(), $priority = 5, $application_path = '')
 {
     if ($priority < 1 or $priority > 10) {
         Kohana::log('error', 'The priority of the task was out of range!');
         return FALSE;
     }
     $application_path = empty($application_path) ? APPPATH : $application_path;
     $old_module_list = Kohana::config('core.modules');
     Kohana::config_set('core.modules', array_merge($old_module_list, array($application_path)));
     // Make sure the controller name and method are valid
     if (Kohana::auto_load($controller_name)) {
         // Only add it to the queue if the controller method exists
         if (Kohana::config('queue.validate_methods') and !method_exists($controller_name, $method_name)) {
             Kohana::log('error', 'The method ' . $controller_name . '::' . $method_name . ' does not exist.');
             return FALSE;
         }
         // Add the action to the run queue with the priority
         $task = new Task_Model();
         $task->set_fields(array('application' => $application_path, 'class' => $controller_name, 'method' => $method_name, 'params' => serialize($parameters), 'priority' => $priority));
         $task->save();
         // Restore the module list
         Kohana::config_set('core.modules', $old_module_list);
         return TRUE;
     }
     Kohana::log('error', 'The class ' . $controller_name . ' does not exist.');
     return FALSE;
 }
示例#3
0
 /**
  * Loads all ushahidi plugins
  */
 public function register()
 {
     $db = Database::instance();
     $plugins = array();
     // Get the list of plugins from the db
     foreach ($db->getwhere('plugin', array('plugin_active' => 1, 'plugin_installed' => 1)) as $plugin) {
         $plugins[$plugin->plugin_name] = PLUGINPATH . $plugin->plugin_name;
     }
     // Now set the plugins
     Kohana::config_set('core.modules', array_merge(Kohana::config('core.modules'), $plugins));
     // We need to manually include the hook file for each plugin,
     // because the additional plugins aren't loaded until after the application hooks are loaded.
     foreach ($plugins as $key => $plugin) {
         if (file_exists($plugin . '/hooks')) {
             $d = dir($plugin . '/hooks');
             // Load all the hooks
             while (($entry = $d->read()) !== FALSE) {
                 if ($entry[0] != '.') {
                     // $plugin_base Variable gives plugin hook access to the base location of the plugin
                     $plugin_base = url::base() . "plugins/" . $key . "/";
                     include $plugin . '/hooks/' . $entry;
                 }
             }
         }
     }
 }
示例#4
0
 /**
  * Verifies if the WebServer is HTTPS enabled and that the certificate is valid
  * If not, $config['site_protocol'] is set back to 'http' and a redirect is
  * performed
  */
 public function verify_https_mode()
 {
     // Is HTTPS enabled, check if Web Server is HTTPS capable
     $this->https_enabled = Kohana::config('core.site_protocol') == 'https' ? TRUE : FALSE;
     if ($this->https_enabled) {
         // URL to be used for fetching the headers
         /** 
          * Comments By: E.Kala  - 21/02/2011
          * Not an optimal solution but works for now; index.php with cause get_headers to follow the "Location:"
          * headers and this has an impedance on the page load time
          */
         $url = url::base() . 'media/css/error.css';
         // Initialize session and set cURL
         $ch = curl_init();
         // Set URL to test HTTPS connectivity
         curl_setopt($ch, CURLOPT_URL, url::base());
         // Disable following every "Location:" that is sent as part of the HTTP(S) header
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         // Suppress verification of the SSL certificate
         /** 
          * E.Kala - 17th Feb 2011
          * This currently causes an inifinte re-direct loop therefore
          */
         // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
         // Disable checking of the Common Name (CN) in the SSL certificate; Certificate may not be X.509
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
         // Suppress the header in the output
         curl_setopt($ch, CURLOPT_HEADER, FALSE);
         // Perform cURL session
         curl_exec($ch);
         // Get the cURL error no. returned; 71 => Connection failed, 0 => Success, 601=>SSL Cert validation failed
         $curl_error_no = curl_errno($ch);
         // Get the HTTP return code
         $http_return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         // Close the cURL resource
         curl_close($ch);
         unset($ch);
         // Check if connection succeeded or there was an error (except authentication of cert with known CA certificates)
         if ($curl_error_no > 0 and $curl_error_no != 60 or $http_return_code == 404) {
             // Set the protocol in the config
             Kohana::config_set('core.site_protocol', 'http');
             // Re-write the config file and set $config['site_protocol'] back to 'http'
             $config_file = @file('application/config/config.php');
             $handle = @fopen('application/config/config.php', 'w');
             if (is_array($config_file) and $handle) {
                 // Read each line in the file
                 foreach ($config_file as $line_number => $line) {
                     if (strpos(" " . $line, "\$config['site_protocol'] = 'https';") != 0) {
                         fwrite($handle, str_replace("https", "http", $line));
                     } else {
                         fwrite($handle, $line);
                     }
                 }
                 // Close the file
                 @fclose($handle);
             }
         }
     }
 }
 /**
  * Loads ushahidi themes
  */
 public function register()
 {
     // Array to hold all the CSS files
     $theme_css = array();
     // 1. Load the default theme
     Kohana::config_set('core.modules', array_merge(array(THEMEPATH . "default"), Kohana::config("core.modules")));
     $css_url = Kohana::config("cache.cdn_css") ? Kohana::config("cache.cdn_css") : url::base();
     // HACK: don't include the default style.css if using the ccnz theme
     if (Kohana::config("settings.site_style") != "ccnz") {
         $theme_css[] = $css_url . "themes/default/css/style.css";
     }
     // 2. Extend the default theme
     if (Kohana::config("settings.site_style") != "default") {
         $theme = THEMEPATH . Kohana::config("settings.site_style");
         Kohana::config_set('core.modules', array_merge(array($theme), Kohana::config("core.modules")));
         if (is_dir($theme . '/css')) {
             $css = dir($theme . '/css');
             // Load all the themes css files
             while (($css_file = $css->read()) !== FALSE) {
                 if (preg_match('/\\.css/i', $css_file)) {
                     $theme_css[] = url::base() . "themes/" . Kohana::config("settings.site_style") . "/css/" . $css_file;
                 }
             }
         }
     }
     Kohana::config_set('settings.site_style_css', $theme_css);
 }
示例#6
0
文件: Import.php 项目: swk/bluebox
 public static function package($path)
 {
     Package_Message::log('debug', 'Attempting to import package ' . $path);
     $filename = basename($path);
     if (self::is_url($path)) {
         $path = Package_Import_Remote::fetch($path);
     }
     $importPath = MODPATH . pathinfo($path, PATHINFO_FILENAME);
     if (!class_exists('ZipArchive')) {
         $return = FALSE;
         Package_Message::log('debug', 'Attempting to unzip with: /usr/bin/unzip ' . $path . ' -d ' . MODPATH);
         @system('/usr/bin/unzip ' . $path . ' -d ' . $importPath, $return);
         if ($return !== 0) {
             throw new Package_Import_Exception('System does not have zip archive support or could not extract ' . $path);
         }
     } else {
         Package_Message::log('debug', 'Attempting to unzip with: ZipArchive->open(' . $path . ', ZIPARCHIVE::CHECKCONS)');
         $zip = new ZipArchive();
         if (!($error = $zip->open($path, ZIPARCHIVE::CHECKCONS))) {
             switch ($error) {
                 case ZIPARCHIVE::ER_EXISTS:
                     throw new Package_Import_Exception('Package archive already exists: ' . $error);
                 case ZIPARCHIVE::ER_INCONS:
                     throw new Package_Import_Exception('Consistency check on the package archive failed: ' . $error);
                 case ZIPARCHIVE::ER_INVAL:
                     throw new Package_Import_Exception('Invalid argument while opening package archive: ' . $error);
                 case ZIPARCHIVE::ER_MEMORY:
                     throw new Package_Import_Exception('Memory allocation failure while opening package archive: ' . $error);
                 case ZIPARCHIVE::ER_NOENT:
                     throw new Package_Import_Exception('Could not locate package archive: ' . $error);
                 case ZIPARCHIVE::ER_NOZIP:
                     throw new Package_Import_Exception('Package archive is not a zip: ' . $error);
                 case ZIPARCHIVE::ER_OPEN:
                     throw new Package_Import_Exception('Cant open package archive: ' . $error);
                 case ZIPARCHIVE::ER_READ:
                     throw new Package_Import_Exception('Package archive read error: ' . $error);
                 case ZIPARCHIVE::ER_SEEK:
                     throw new Package_Import_Exception('Package archive seek error: ' . $error);
                 default:
                     throw new Package_Import_Exception('Unknown error while opening package archive: ' . $error);
             }
         }
         if (is_dir($importPath)) {
             throw new Package_Import_Exception('Import path `' . $importPath . '` already exists');
         }
         if (!@$zip->extractTo($importPath)) {
             throw new Package_Import_Exception('Failed to extract package archive ' . $filename . ' or no permissions to unzip to ' . MODPATH);
         }
         $zip->close();
     }
     kohana::log('debug', 'Dynamically adding `' . $importPath . '` to kohana');
     $loadedModules = Kohana::config('core.modules');
     $modules = array_unique(array_merge($loadedModules, array($importPath)));
     Kohana::config_set('core.modules', $modules);
     Package_Catalog::disableRemote();
     Package_Catalog::buildCatalog();
     Package_Catalog::enableRemote();
     return $importPath;
 }
示例#7
0
 public function setUp()
 {
     if (($config = Kohana::config('cache.testing.file')) === NULL) {
         $this->markTestSkipped('No cache.testing.file config found.');
     }
     Kohana::config_set('cache.testing.file.requests', 1);
     $this->cache = Cache::instance('testing.file');
     parent::setUp();
 }
示例#8
0
 public function __construct()
 {
     parent::__construct();
     if (IN_PRODUCTION) {
         throw new Kohana_Exception('controller.not_found');
     }
     Kohana::config_set('database.default', Kohana::config('database.test'));
     $this->profiler = new Profiler();
 }
示例#9
0
 /**
  * Add routes for products
  * @Developer brandon
  * @Date Oct 19, 2010
  */
 public static function route_products_and_categories()
 {
     foreach (ORM::factory('product')->find_all() as $object) {
         Kohana::config_set('routes.' . $object->show_path(false), inflector::plural($object->object_name) . '/show/' . $object);
     }
     foreach (ORM::factory('category')->find_all() as $object) {
         Kohana::config_set('routes.' . $object->show_path(false), inflector::plural($object->object_name) . '/show/' . $object);
     }
 }
示例#10
0
 /**
  * get the nearest locations by city
  *
  * @param string $city 
  * @param string $model
  * @param integer $limit
  * @param integer $offset
  * @return array
  * @author Andy Bennett
  */
 public function nearest_city_locations($city, $model, $limit = null, $offset = null)
 {
     $ll = latlon::latlon_from_city($city);
     if ($ll == false or empty($ll->latitude) or empty($ll->longitude)) {
         return false;
     }
     Kohana::config_set('distance.lat', $ll->latitude);
     Kohana::config_set('distance.lon', $ll->longitude);
     return ORM::factory($model)->find_all($limit, $offset);
 }
示例#11
0
 static function load_themes()
 {
     $modules = Kohana::config("core.modules");
     array_unshift($modules, THEMEPATH);
     Kohana::config_set("core.modules", $modules);
     theme::$name = config::get('s7n.theme');
     if (strpos(Router::$current_uri, 'admin') === 0) {
         theme::$name = 'admin';
     }
 }
示例#12
0
 /**
  * Load the active theme.  This is called at bootstrap time.  We will only ever have one theme
  * active for any given request.
  */
 static function load_themes()
 {
     $modules = Kohana::config("core.modules");
     if (Router::$controller == "admin") {
         array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_admin_theme"));
     } else {
         array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_site_theme"));
     }
     Kohana::config_set("core.modules", $modules);
 }
示例#13
0
 /**
  * Load the active theme.  This is called at bootstrap time.  We will only ever have one theme
  * active for any given request.
  */
 static function load_themes()
 {
     $modules = Kohana::config("core.modules");
     if (Router::$controller == "admin") {
         array_unshift($modules, THEMEPATH . "admin_default");
     } else {
         array_unshift($modules, THEMEPATH . "default");
     }
     Kohana::config_set("core.modules", $modules);
 }
示例#14
0
文件: phpunit.php 项目: swk/bluebox
 public function group($group = FALSE, $config = 'default')
 {
     if ($group) {
         $ut = new PHPUnit(array($group));
     } else {
         Kohana::config_set('phpunit.default.listGroups', TRUE);
         $ut = new PHPUnit();
     }
     $ut->execute($config);
 }
示例#15
0
 public static function load()
 {
     $query = Database::instance()->select('context, key, value')->get('config');
     $result = $query->result();
     foreach ($result as $item) {
         if (Kohana::find_file('config', $item->context)) {
             Kohana::config_set($item->context . '.' . $item->key, $item->value);
         }
     }
 }
示例#16
0
 /**
  * Set the store
  * @developer Brandon Hansen
  * @date Oct 19, 2010
  */
 public static function set()
 {
     list($subdomain, $rest) = explode('.', $_SERVER['SERVER_NAME'], 2);
     $store = ORM::factory('store')->where('domain', $subdomain)->find();
     if ($store->loaded) {
         Kohana::config_set('store.id', (string) $store);
     } else {
         Missing_Page::missing_shop();
     }
 }
示例#17
0
 public function index()
 {
     //$profiler = new Profiler;
     if (isset($_GET['emailtest'])) {
         $this->emailtest();
         die;
     }
     if (isset($_GET['database'])) {
         $this->alterDatabase();
     }
     if (isset($_GET['cronjob'])) {
         $this->cronjob();
         die;
     }
     @session_start();
     //     $lan = (@$_GET['l']<>'en') ? "es" : 'en';
     if (@$_GET['l'] != '') {
         $_SESSION['lan'] = @$_GET['l'] != 'en' ? array("es_ES", 'España') : array("en_US", 'USA');
     }
     if (@$_SESSION['lan'] != "") {
         Kohana::config_set("locale.language", $_SESSION['lan']);
     }
     $lang = new Translate();
     $lang->currency();
     $defaultobj = "category";
     $defaultact = "index";
     $module = $this->uri->segment("index") != '' ? $this->uri->segment("index") : $defaultobj;
     $action = $this->uri->segment($module) != '' ? $this->uri->segment($module) : $defaultact;
     $module = ucfirst($lang->word->{$module});
     $lib = new $module();
     $action = @$lang->word->{$action};
     $this->template->widget = $lib->GetWidgets();
     if (method_exists($lib, $action) === FALSE) {
         $lib = new $module();
         $lib->{$defaultact}();
     } else {
         $lib->{$action}();
     }
     $table_page = new fpp_page_Model();
     $header = $table_page->db2cls(46);
     $footer = $table_page->db2cls(47);
     $meta_description = $table_page->db2cls(48);
     $tr_content_page = Basic::TransVar("content_page");
     $this->template->header = strip_tags($header->{$tr_content_page});
     $this->template->footer = $footer->{$tr_content_page};
     $this->template->meta_description = strip_tags($meta_description->{$tr_content_page});
     //Executes Action's
     $this->template->title = $this->uri->segment() == '' ? 'floreria Rosabel | florerias peru | floreria | enviar flores peru' : Kohana::config("core.title_page") . $lib->GetTitle();
     $this->template->content = $lib->GetContent();
     $this->template->keywords = $lib->GetKeywords() != '' ? $lib->GetKeywords() : 'enviar flores peru, florerías en lima, florerias en lima, envio de flores a peru,florerías,florerias lima, florerias en Lima,floreria lima, Florerias de Lima, Flores domicilio Lima, Florerias en San Isidro, envio de flores a lima, envio de flores en peru,floreria amor y amistad,flores dia de las madres,arreglos florales, floreria san borja peru, florerias en trujillo, florerias en arequipa, floreria los olivos, florerias unidas,envio de flores lima, delivery flores lima, envio flores, floreria san isidro, arreglos flores, rosas, orquideas, giraloes, tulipanes, delivery flowers, send flowers lima, roses, flower shop lima';
     if (request::is_ajax()) {
         $this->auto_render = FALSE;
         echo $lib->GetContent();
     }
 }
示例#18
0
 public function __construct()
 {
     parent::__construct();
     // Load cache
     $this->cache = new Cache();
     // Load session
     $this->session = new Session();
     // Load Header & Footer
     $this->template->header = new View('header');
     $this->template->footer = new View('footer');
     // Retrieve Default Settings
     $site_name = Kohana::config('settings.site_name');
     // Prevent Site Name From Breaking up if its too long
     // by reducing the size of the font
     if (strlen($site_name) > 20) {
         $site_name_style = " style=\"font-size:21px;\"";
     } else {
         $site_name_style = "";
     }
     $this->template->header->site_name = $site_name;
     $this->template->header->site_name_style = $site_name_style;
     $this->template->header->site_tagline = Kohana::config('settings.site_tagline');
     $this->template->header->api_url = Kohana::config('settings.api_url');
     // Display News Feed?
     $this->template->header->allow_feed = Kohana::config('settings.allow_feed');
     // Javascript Header
     $this->template->header->map_enabled = FALSE;
     $this->template->header->validator_enabled = FALSE;
     $this->template->header->datepicker_enabled = FALSE;
     $this->template->header->photoslider_enabled = FALSE;
     $this->template->header->videoslider_enabled = FALSE;
     $this->template->header->main_page = FALSE;
     $this->template->header->js = '';
     $this->template->header->this_page = "";
     // Google Analytics
     $google_analytics = Kohana::config('settings.google_analytics');
     $this->template->footer->google_analytics = $this->_google_analytics($google_analytics);
     // Create Language Session
     if (isset($_GET['lang']) && !empty($_GET['lang'])) {
         $_SESSION['lang'] = $_GET['lang'];
     }
     if (isset($_SESSION['lang']) && !empty($_SESSION['lang'])) {
         Kohana::config_set('locale.language', $_SESSION['lang']);
     }
     $this->template->header->site_language = Kohana::config('locale.language');
     //Set up tracking gif
     if ($_SERVER['SERVER_NAME'] != 'localhost' && $_SERVER['SERVER_NAME'] != '127.0.0.1') {
         $track_url = $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
     } else {
         $track_url = 'null';
     }
     $this->template->footer->tracker_url = 'http://tracker.ushahidi.com/track.php?url=' . urlencode($track_url) . '&lang=' . $this->template->header->site_language . '';
     // Load profiler
     // $profiler = new Profiler;
 }
示例#19
0
 /**
  * Require administrator login
  * @Developer brandon
  * @Date Oct 11, 2010
  */
 public function __construct()
 {
     parent::__construct();
     $this->template = View::factory('layouts/admin');
     meta::set_title(store::name() . ' | Admin | ' . ucwords(Router::$controller));
     // Set the route for updating and creating files
     Kohana::config_set('routes.base_crud_route', 'admin/');
     // Require an admin login if we are in production.
     if (IN_PRODUCTION) {
         customer::require_admin_login();
     }
     ORM::factory('audit_trail')->create(array('user_id' => customer::current(), 'store_id' => store::get(), 'controller' => Router::$controller, 'method' => Router::$method, 'object_id' => $this->input->post('id')));
 }
示例#20
0
 /**
  * Load the active theme.  This is called at bootstrap time.  We will only ever have one theme
  * active for any given request.
  */
 static function load_themes()
 {
     $path = Input::instance()->server("PATH_INFO");
     $input = Input::instance();
     if (empty($path)) {
         $path = "/" . $input->get("kohana_uri");
     }
     if (!(identity::active_user()->admin && ($theme_name = $input->get("theme")))) {
         $theme_name = module::get_var("gallery", !strncmp($path, "/admin", 6) ? "active_admin_theme" : "active_site_theme");
     }
     $modules = Kohana::config("core.modules");
     array_unshift($modules, THEMEPATH . $theme_name);
     Kohana::config_set("core.modules", $modules);
 }
function fancyupload_modify_session_config()
{
    if (stripos(Kohana::user_agent(), 'Shockwave Flash') !== FALSE) {
        // Check that the session isn't attempting to validate the user agent
        $validate = Kohana::config('session.validate');
        $key = array_search('user_agent', $validate);
        if ($key !== FALSE) {
            unset($validate[$key]);
            Kohana::config('session.validate', $validate);
        }
        // Ensure that the session key won't be regenerated
        Kohana::config_set('session.regenerate', 0);
    }
}
示例#22
0
 public function setUp()
 {
     if (!extension_loaded('sqlite')) {
         $this->markTestSkipped('The Sqlite extension is not loaded');
     }
     if (($config = Kohana::config('cache.testing.sqlite')) === NULL) {
         $this->markTestSkipped('No cache.testing.sqlite config found.');
     }
     if (Kohana::config('cache_sqlite') === NULL) {
         $this->markTestSkipped('No cache_sqlite config found.');
     }
     Kohana::config_set('cache.testing.sqlite.requests', 1);
     $this->cache = Cache::instance('testing.sqlite');
     parent::setUp();
 }
示例#23
0
 /**
  * Register A Block
  *
  * @param array $block an array with classname, name and description
  */
 public static function register($block = array())
 {
     // global variable that contains all the blocks
     $blocks = Kohana::config("settings.blocks");
     if (!is_array($blocks)) {
         $blocks = array();
     }
     if (is_array($block) and array_key_exists("classname", $block) and array_key_exists("name", $block) and array_key_exists("description", $block)) {
         if (!array_key_exists($block["classname"], $blocks)) {
             $blocks[$block["classname"]] = array("name" => $block["name"], "description" => $block["description"]);
         }
     }
     asort($blocks);
     Kohana::config_set("settings.blocks", $blocks);
 }
示例#24
0
 /**
  * Verifies if the WebServer is HTTPS enabled and that the certificate is valid
  * If not, $config['site_protocol'] is set back to 'http' and a redirect is
  * performed
  */
 public function verify_https_mode()
 {
     // Is HTTPS enabled, check if Web Server is HTTPS capable
     $this->https_enabled = Kohana::config('core.site_protocol') == 'https' ? TRUE : FALSE;
     if ($this->https_enabled) {
         // URL to be used for fetching the headers
         /** 
          * Comments By: E.Kala  - 21/02/2011
          * Not an optimal solution but works for now; index.php with cause get_headers to follow the "Location:"
          * headers and this has an impedance on the page load time
          */
         // cURL options
         $curl_options = array(CURLOPT_URL => url::base() . 'media/css/error.css', CURLOPT_FOLLOWLOCATION => FALSE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HEADER, FALSE);
         // Initialize session and set cURL
         $ch = curl_init();
         // Set the cURL options in the $curl_options array
         curl_setopt_array($ch, $curl_options);
         // Perform cURL session
         curl_exec($ch);
         // Get the cURL error no. returned; 71 => Connection failed, 0 => Success, 601=>SSL Cert validation failed
         $curl_error_no = curl_errno($ch);
         // Get the HTTP return code
         $http_return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         // Close the cURL resource
         curl_close($ch);
         unset($ch);
         // Check if connection succeeded or there was an error (except authentication of cert with known CA certificates)
         if ($curl_error_no > 0 and $curl_error_no != 60 or $http_return_code == 404) {
             // Set the protocol in the config
             Kohana::config_set('core.site_protocol', 'http');
             // Re-write the config file and set $config['site_protocol'] back to 'http'
             $config_file = @file('application/config/config.php');
             $handle = @fopen('application/config/config.php', 'w');
             if (is_array($config_file) and $handle) {
                 // Read each line in the file
                 foreach ($config_file as $line_number => $line) {
                     if (strpos(" " . $line, "\$config['site_protocol'] = 'https';") != 0) {
                         fwrite($handle, str_replace("https", "http", $line));
                     } else {
                         fwrite($handle, $line);
                     }
                 }
                 // Close the file
                 @fclose($handle);
             }
         }
     }
 }
 /**
  * Registers the main event add method
  */
 public function __construct()
 {
     // Dirty hack to load this plugin before the current theme, but after default
     $modules = Kohana::config('core.modules');
     $sharing_path = PLUGINPATH . 'sharing_two';
     unset($modules[array_search($sharing_path, $modules)]);
     $d_index = array_search(THEMEPATH . "default", $modules);
     $modules = array_merge(array_slice($modules, 0, $d_index), array($sharing_path), array_slice($modules, $d_index));
     Kohana::config_set('core.modules', $modules);
     // Try to alter routing now
     Sharing::routing();
     // hook into routing - in case we're running too early
     Event::add_after('system.routing', array('Router', 'find_uri'), array('Sharing', 'routing'));
     //  Add other events just before controller runs
     Event::add('system.pre_controller', array($this, 'add'));
 }
示例#26
0
	/**
	 * Adds all the events to the main Ushahidi application
	 */
	public function add()
	{
		// Add JS for Map Settings Page
		$api_url_all = Kohana::config('settings.api_url_all');
		$api_url_all .= html::script(url::base().'plugins/cloudmade/views/js/cloudmade.js');
		Kohana::config_set('settings.api_url_all', $api_url_all);
		
		// Add a Sub-Nav Link
		Event::add('ushahidi_filter.map_base_layers', array($this, '_add_layer'));
		
		// Reconfigure the default map api
		if (Kohana::config('settings.default_map') == "cloudmade")
		{
			Kohana::config_set('settings.api_url', "<script type=\"text/javascript\" src=\"".url::base()."plugins/cloudmade/views/js/cloudmade.js\"></script>" );
		}
	}
 /**
  * Loads ushahidi themes
  */
 public function register()
 {
     // Array to hold all the CSS files
     $theme_css = array();
     // Array to hold all the Javascript files
     $theme_js = array();
     // 1. Load the default theme
     Kohana::config_set('core.modules', array_merge(array(THEMEPATH . "default"), Kohana::config("core.modules")));
     $css_url = Kohana::config("cdn.cdn_css") ? Kohana::config("cdn.cdn_css") : url::base();
     $theme_css[] = $css_url . "themes/default/css/style.css";
     // 2. Extend the default theme
     $theme = THEMEPATH . Kohana::config("settings.site_style");
     if (Kohana::config("settings.site_style") != "default") {
         Kohana::config_set('core.modules', array_merge(array($theme), Kohana::config("core.modules")));
         if (is_dir($theme . '/css')) {
             $css = dir($theme . '/css');
             // Load all the themes css files
             while (($css_file = $css->read()) !== FALSE) {
                 if (preg_match('/\\.css/i', $css_file)) {
                     $theme_css[] = url::base() . "themes/" . Kohana::config("settings.site_style") . "/css/" . $css_file;
                 }
             }
         }
         if (is_dir($theme . '/js')) {
             $js = dir($theme . '/js');
             // Load all the themes js files
             while (($js_file = $js->read()) !== FALSE) {
                 if (preg_match('/\\.js/i', $js_file)) {
                     $theme_js[] = url::base() . "themes/" . Kohana::config("settings.site_style") . "/js/" . $js_file;
                 }
             }
         }
     }
     // 3. Find and add hooks
     // We need to manually include the hook file for each theme
     if (file_exists($theme . '/hooks')) {
         $d = dir($theme . '/hooks');
         // Load all the hooks
         while (($entry = $d->read()) !== FALSE) {
             if ($entry[0] != '.') {
                 include $theme . '/hooks/' . $entry;
             }
         }
     }
     Kohana::config_set('settings.site_style_css', $theme_css);
     Kohana::config_set('settings.site_style_js', $theme_js);
 }
示例#28
0
 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');
         }
     }
 }
示例#29
0
 /**
  * Runs the loaded task
  * 
  */
 public function execute()
 {
     // Load the application
     $old_module_list = Kohana::config('core.modules');
     Kohana::config_set('core.modules', array_merge($old_module_list, array($this->data['application'])));
     if (Kohana::auto_load($this->data['class'])) {
         // Delete it from the queue
         $this->delete();
         $class = new $this->data['class']();
         // Run the task
         call_user_func_array(array($class, $this->data['method']), unserialize($this->data['params']));
         Kohana::log('info', 'Ran ' . $this->data['class'] . '->' . $this->data['method']);
         // Restore the module list
         Kohana::config_set('core.modules', $old_module_list);
         unset($class);
     } else {
         Kohana::log('info', $this->data['class'] . ' not found. Aborting.');
     }
 }
示例#30
0
 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);
 }