/** * Application initialization * - Loads the plugins * - Sets the cookie configuration */ public static function init() { // Set defaule cache configuration Cache::$default = Kohana::$config->load('site')->get('default_cache'); try { $cache = Cache::instance()->get('dummy' . rand(0, 99)); } catch (Exception $e) { // Use the dummy driver Cache::$default = 'dummy'; } // Load the plugins Swiftriver_Plugins::load(); // Add the current default theme to the list of modules $theme = Swiftriver::get_setting('site_theme'); if (isset($theme) and $theme != "default") { Kohana::modules(array_merge(array('themes/' . $theme->value => THEMEPATH . $theme->value), Kohana::modules())); } // Clean up unset($active_plugins, $theme); // Load the cookie configuration $cookie_config = Kohana::$config->load('cookie'); Cookie::$httponly = TRUE; Cookie::$salt = $cookie_config->get('salt', Swiftriver::DEFAULT_COOKIE_SALT); Cookie::$domain = $cookie_config->get('domain') or ''; Cookie::$secure = $cookie_config->get('secure') or FALSE; Cookie::$expiration = $cookie_config->get('expiration') or 0; // Set the default site locale I18n::$lang = Swiftriver::get_setting('site_locale'); }
/** * * Initializes configs for the APP to run */ public static function initialize() { /** * Load all the configs from DB */ //Change the default cache system, based on your config /config/cache.php Cache::$default = Core::config('cache.default'); //is not loaded yet in Kohana::$config Kohana::$config->attach(new ConfigDB(), FALSE); //overwrite default Kohana init configs. Kohana::$base_url = Core::config('general.base_url'); //enables friendly url @todo from config Kohana::$index_file = FALSE; //cookie salt for the app Cookie::$salt = Core::config('auth.cookie_salt'); /* if (empty(Cookie::$salt)) { // @TODO missing cookie salt : add warning message } */ // -- i18n Configuration and initialization ----------------------------------------- I18n::initialize(Core::config('i18n.locale'), Core::config('i18n.charset')); //Loading the OC Routes // if (($init_routes = Kohana::find_file('config','routes'))) // require_once $init_routes[0];//returns array of files but we need only 1 file //faster loading require_once APPPATH . 'config/routes.php'; //getting the selected theme, and loading options Theme::initialize(); }
/** * * Initializes configs for the APP to run */ public static function initialize() { //enables friendly url Kohana::$index_file = FALSE; //temporary cookie salt in case of exception Cookie::$salt = 'cookie_oc_temp'; //Change the default cache system, based on your config /config/cache.php Cache::$default = Core::config('cache.default'); //loading configs from table config //is not loaded yet in Kohana::$config Kohana::$config->attach(new ConfigDB(), FALSE); //overwrite default Kohana init configs. Kohana::$base_url = Core::config('general.base_url'); //cookie salt for the app Cookie::$salt = Core::config('auth.cookie_salt'); // i18n Configuration and initialization I18n::initialize(Core::config('i18n.locale'), Core::config('i18n.charset')); //Loading the OC Routes require_once APPPATH . 'config/routes.php'; //getting the selected theme, and loading options Theme::initialize(); //run crontab if (core::config('general.cron') == TRUE) { Cron::run(); } }
/** * Construct controller */ public function before() { parent::before(); Cache::$default = 'default'; // Check if this was an interna request or direct $this->internal = $this->request !== Request::instance(); // Ajax request? $this->ajax = Request::$is_ajax; // Load current user, null if none if (self::$user === false) { self::$user = Visitor::instance()->get_user(); } }
public static function init() { if (isset(Kohana::$environment)) { self::$env = Kohana::$environment; } Cache::$default = 'default'; Sourcemap_JS::add_packages(isset(Kohana::config('js')->packages) ? Kohana::config('js')->packages : array()); //Sourcemap_JS::$bundle = self::$env == self::DEV ? false : true; Sourcemap_JS::$bundle = false; Sourcemap_JS::$minified = self::$env == self::DEV ? false : true; Sourcemap_JS::$bundle_path = 'assets/scripts/bundles/' . self::site() . '/'; Sourcemap_CSS::$convert_less = self::$env == self::DEV ? false : true; // Use db for session storage Session::$default = 'database'; }
public function before() { Cache::$default = 'memcache'; $controller = $this->request->controller(); $action = $this->request->action(); if (!Auth::instance()->logged_in()) { if (!in_array($action, ['login', 'logout']) && $_SERVER['REQUEST_URI'] != '/') { $this->redirect('/'); } $this->template = 'not_auth'; } else { if ($controller == 'Index' && $action == 'index') { $this->redirect('/clients'); } //подключаем меню $menu = Kohana::$config->load('menu'); $content = View::factory('includes/menu')->bind('menu', $menu); View::set_global('menu', $content); } parent::before(); $allow = Access::allow(strtolower($controller . '_' . $action)); //если не аяксовый запрос if (!$this->request->is_ajax()) { if ($allow == false) { throw new HTTP_Exception_403(); } //рендерим шаблон страницы if (!in_array($controller, ['Index'])) { $this->tpl = View::factory('pages/' . strtolower($controller) . '/' . $action); } $this->_checkCustomDesign(); $this->_appendFilesBefore(); } //если все таки аякс if ($allow == false) { echo '<script>alert("У вас недостаточно прав доступа");</script>'; die; } }
* Attach the file write to logging. Multiple writers are supported. */ Kohana::$log->attach(new Log_File(APPPATH . 'logs')); /** * Attach a file reader to config. Multiple readers are supported. */ Kohana::$config->attach(new Config_File()); /** * Enable modules. Modules are referenced by a relative or absolute path. */ Kohana::modules(array('cache' => MODPATH . 'cache', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'orm' => MODPATH . 'orm', 'paypal' => MODPATH . 'paypal', 'kandler' => MODPATH . 'kandler', 'email' => MODPATH . 'email', 'pagination' => MODPATH . 'pagination', 'sitemap' => MODPATH . 'sitemap', 'amazon' => MODPATH . 'amazon')); /** * Cache */ Kohana::$caching = TRUE; Cache::$default = 'apc'; /** * Set the routes. Each route must have a minimum of a name, a URI and a set of * defaults for the URI. */ // Default route Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'ads', 'action' => 'home')); // Error route Route::set('error', 'error/<action>(/<message>)', array('action' => '[0-9]++', 'message' => '.+'))->defaults(array('controller' => 'error_handler')); /** * Cookie configuration settings */ Cookie::$salt = 'ASJ12094X:F?!*!*AD'; Cookie::$expiration = Date::MONTH; Cookie::$httponly = TRUE; Cookie::$secure = isset($_SERVER["HTTPS"]);
<?php defined('SYSPATH') or die('No direct script access.'); /** * Set the default cache driver */ Cache::$default = defined('CACHE_TYPE') ? CACHE_TYPE : 'file'; Observer::observe('modules::after_load', function () { if (IS_INSTALLED and ACL::check('system.cache.settings')) { Observer::observe('view_setting_plugins', function () { echo View::factory('cache/settings'); }); Observer::observe('validation_settings', function ($validation, $filter) { $filter->rule('cache.front_page', 'intval')->rule('cache.page_parts', 'intval')->rule('cache.tags', 'intval'); }); } });
} else { require SYSPATH . "classes" . DIRECTORY_SEPARATOR . "JsonApiApplication" . EXT; } date_default_timezone_set("australia/brisbane"); setlocale(LC_ALL, "en_AU.utf-8"); spl_autoload_register(array("JsonApiApplication", "auto_load")); ini_set("unserialize_callback_func", "spl_autoload_call"); mb_substitute_character("none"); if (isset($_SERVER["JSONAPIAPPLICATION_ENV"])) { JsonApiApplication::$environment = constant("JsonApiApplication::" . strtoupper($_SERVER["JSONAPIAPPLICATION_ENV"])); } I18n::lang("en-au"); JsonApiApplication::init(array("base_url" => "/JsonApiApplication/", "errors" => true, "index_file" => FALSE)); JsonApiApplication::$log->attach(new Log_File(APPPATH . "logs")); JsonApiApplication::$config->attach(new JsonApiApplication_Config_File()); JsonApiApplication::modules(array("auth" => MODPATH . "auth", "orm" => MODPATH . "orm", "cache" => MODPATH . "cache", "database" => MODPATH . "database", "mailer" => MODPATH . "mailer")); Cache::$default = "file"; Route::set("home", "home(/<catcher>)", array("catcher" => ".*"))->defaults(array("controller" => "welcome", "action" => "read")); Route::set("welcome", "")->defaults(array("controller" => "welcome", "action" => "read")); Route::set("navigation", "navigation/read/<id>")->defaults(array("controller" => "navigation", "action" => "read")); Route::set("page", "page/read/<id>")->defaults(array("controller" => "page", "action" => "read")); Route::set("testimonial", "testimonial/read/<limit>/<offset>")->defaults(array("controller" => "testimonial", "action" => "read")); Route::set("posts", "posts/read/<limit>/<offset>")->defaults(array("controller" => "posts", "action" => "read")); Route::set("post", "post/read/<id>")->defaults(array("controller" => "post", "action" => "read")); Route::set("comments", "comments/read/<id>/<limit>/<offset>")->defaults(array("controller" => "comments", "action" => "read")); Route::set("categories", "categories/read/<limit>/<offset>")->defaults(array("controller" => "categories", "action" => "read")); Route::set("contactinfo", "contactinfo/read/<id>")->defaults(array("controller" => "contactinfo", "action" => "read")); Route::set("contact", "contact/post")->defaults(array("controller" => "contact", "action" => "post")); Route::set("captcha", "contact/read")->defaults(array("controller" => "contact", "action" => "read")); Cookie::$salt = "LOASWnL7A1WKQMk1JALCP1H5BMelyIPQNVdXiGsbEEVhVtyApGsFC6LyINUsDHl1"; /*if (!Route::cache()) Route::cache(TRUE);*/
*/ Kohana::$log->attach(new Kohana_Log_File(APPPATH . 'logs')); /** * Attach a file reader to config. Multiple readers are supported. */ Kohana::$config->attach(new Kohana_Config_File()); /** * Enable modules. Modules are referenced by a relative or absolute path. */ Kohana::modules(array('core' => MODPATH . 'anqh', 'events' => MODPATH . 'events', 'forum' => MODPATH . 'forum', 'galleries' => MODPATH . 'galleries', 'music' => MODPATH . 'music', 'venues' => MODPATH . 'venues', 'blog' => MODPATH . 'blog', 'auto-modeler' => MODPATH . 'auto-modeler', 'cache' => MODPATH . 'cache', 'database' => MODPATH . 'database', 'email' => MODPATH . 'email', 'image' => MODPATH . 'image', 'oauth2' => MODPATH . 'oauth2', 'pagination' => MODPATH . 'pagination', 'postgresql' => MODPATH . 'postgresql')); /** * Set cookie salt. */ Cookie::$salt = 'anqh'; /** * Set cache config. */ Cache::$default = 'default'; /** * Set session handler. */ Session::$default = 'database'; /** * Initialize session. */ Session::instance(); /** * Set the routes. Each route must have a minimum of a name, a URI and a set of * defaults for the URI. */ Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'index', 'action' => 'index'));