Ejemplo n.º 1
0
 /**
  * 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');
 }
Ejemplo n.º 2
0
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 * - boolean  expose      set the X-Powered-By header                        FALSE
 */
Kohana::init(array('base_url' => '/kohana/'));
/**
 * 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());
Cookie::$salt = 'vFkdZeP74127asfNT';
// Please don't change this option at the work site
Cookie::$expiration = 1209600;
// 1209600 - 2 weeks
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('parsers' => MODPATH . 'parsers'));
/**
 * Cookie Salt
 * @see  http://kohanaframework.org/3.3/guide/kohana/cookies
 * 
 * If you have not defined a cookie salt in your Cookie class then
 * uncomment the line below and define a preferrably long salt.
 */
// Cookie::$salt = NULL;
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
Ejemplo n.º 3
0
 function action_add_comment($postid)
 {
     $this->allowcomment = $this->post->get_access($this->postid);
     $this->action_post_main();
     $this->action_main_categories();
     $this->username = Auth::instance()->get_user()->username;
     if (Captcha::valid($_POST['captcha']) and $this->allowcomment == 1 or !empty($this->username)) {
         $this->validate = $this->comment->validate_comment();
         if ($this->post->check_post($postid) == TRUE and $this->validate === TRUE) {
             $this->comment->add_comment($postid);
             Cookie::$expiration = Date::WEEK;
             Cookie::set('comment_username', $_POST['username']);
             Cookie::set('comment_url', $_POST['url']);
             $this->request->redirect($_SERVER['HTTP_REFERER']);
         } else {
             $this->template->content->errors = $this->validate;
         }
     }
     $this->action_comments_params();
 }
Ejemplo n.º 4
0
 */
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"]);
Cookie::$domain = '.gowork.at';
Ejemplo n.º 5
0
 * Initialize Kohana, setting the default options.
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
 * - string   index_file  name of your index file, usually "index.php"       index.php
 * - string   charset     internal character set used for input and output   utf-8
 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - integer  cache_life  lifetime, in seconds, of items cached              60
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 * - boolean  expose      set the X-Powered-By header                        FALSE
 */
Kohana::init(array('errors' => true, 'base_url' => '/', 'index_file' => false));
Cookie::$salt = 'asdahsdfzfcsEERfAf';
Cookie::$httponly = TRUE;
Cookie::$expiration = Date::WEEK;
/**
 * 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('oauth' => MODPATH . 'oauth', 'cache' => MODPATH . 'cache', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'minion' => MODPATH . 'minion', 'orm' => MODPATH . 'orm', 'unittest' => MODPATH . 'unittest'));
require APPPATH . 'routes' . EXT;
Ejemplo n.º 6
0
# copy config/init.php.default to config/init.php
Kohana::init(include APPPATH . 'config/init.php');
/**
 * 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());
/**
 * Cookie config.
 */
$cookie = Kohana::$config->load('cookie');
Cookie::$salt = $cookie->salt;
Cookie::$expiration = $cookie->expiration;
Cookie::$domain = $cookie->domain;
Cookie::$path = $cookie->path;
Cookie::$secure = $cookie->secure;
Cookie::$httponly = $cookie->httponly;
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array());
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('api', '<directory>(/<controller>(/<action>(/<params>)))', array('params' => '.*', 'directory' => '(v1|v2)'))->defaults(array('controller' => 'defaults', 'action' => 'index', 'directory' => 'v1'));
Route::set('join', 'join')->defaults(array('controller' => 'auth', 'action' => 'join'));
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'welcome', 'action' => 'index'));
Ejemplo n.º 7
0
Kohana::init(array('base_url' => '/', 'caching' => TRUE, 'profile' => FALSE, 'index_file' => FALSE));
/**
 * 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('auth' => MODPATH . 'auth', 'cache' => MODPATH . 'cache', 'codebench' => MODPATH . 'codebench', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'minion' => MODPATH . 'minion', 'unittest' => MODPATH . 'unittest', 'userguide' => MODPATH . 'userguide', 'cms' => MODPATH . 'cms', 'tbl' => MODPATH . 'tbl', 'tpl' => MODPATH . 'tpl', 'pgn' => MODPATH . 'pgn', 'notice' => MODPATH . 'notice', 'email' => MODPATH . 'email', 'mysqli' => MODPATH . 'mysqli'));
/**
 * Get settings
 */
// Kohx
$settings = (object) Tbl::factory('settings')->read()->as_array('key', 'value');
// Set timezoon
date_default_timezone_set($settings->timezoon);
Cookie::$salt = $settings->cooki_salt;
Cookie::$expiration = Cms_Helper::sec($settings->cooki_expiration);
Session::$default = 'database';
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
// Kohx
Cms_Route::write();
// Default
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'home', 'action' => 'index'));
Ejemplo n.º 8
0
 */
spl_autoload_register(array('Kohana', 'auto_load'));
/**
 * Enable the Kohana auto-loader for unserialization.
 *
 * @link http://www.php.net/manual/function.spl-autoload-call
 * @link http://www.php.net/manual/var.configuration#unserialize-callback-func
 */
ini_set('unserialize_callback_func', 'spl_autoload_call');
// -- Configuration and initialization -----------------------------------------
/**
 * Set the default language
 */
I18n::lang('en-us');
Cookie::$salt = 'generatedsalt';
Cookie::$expiration = 6400;
/**
 * Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
 *
 * Note: If you supply an invalid environment name, a PHP warning will be thrown
 * saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
 */
if (isset($_SERVER['KOHANA_ENV'])) {
    Kohana::$environment = constant('Kohana::' . strtoupper($_SERVER['KOHANA_ENV']));
}
/**
 * Initialize Kohana, setting the default options.
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
Ejemplo n.º 9
0
 */
spl_autoload_register(array('Kohana', 'auto_load'));
/**
 * Enable the Kohana auto-loader for unserialization.
 *
 * @see  http://php.net/spl_autoload_call
 * @see  http://php.net/manual/var.configuration.php#unserialize-callback-func
 */
ini_set('unserialize_callback_func', 'spl_autoload_call');
// -- Configuration and initialization -----------------------------------------
/**
 * Set the default language
 */
I18n::lang('lv');
Cookie::$salt = 'user cookie';
Cookie::$expiration = 604800;
/**
 * Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
 *
 * Note: If you supply an invalid environment name, a PHP warning will be thrown
 * saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
 */
if (isset($_SERVER['KOHANA_ENV'])) {
    Kohana::$environment = constant('Kohana::' . strtoupper($_SERVER['KOHANA_ENV']));
}
/**
 * Initialize Kohana, setting the default options.
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
Ejemplo n.º 10
0
 /**
  * Set default cookie [salt](gleez/cookie/config#salt)
  * and [lifetime](gleez/cookie/config#expiration)
  *
  * Also you can define a salt for the `Cookie` class in bootstrap.php:
  * ~~~
  * Cookie::$salt = [really-long-cookie-salt-here]
  * ~~~
  */
 protected static function _set_cookie()
 {
     /** @var Cookie::$salt string */
     Cookie::$salt = Config::get('cookie.salt');
     /** @var Cookie::$expiration string */
     Cookie::$expiration = Config::get('cookie.lifetime');
 }
Ejemplo n.º 11
0
Kohana::init(array('base_url' => '/ko32example/site', 'index_file' => FALSE, 'profile' => Kohana::$environment !== Kohana::PRODUCTION, 'caching' => Kohana::$environment === Kohana::PRODUCTION, 'errors' => FALSE));
/**
 * 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());
/**
* Cookie
*/
// Set the magic salt to add to a cookie
Cookie::$salt = Kohana::$config->load('ko32example.cookie_salt');
// Set the number of seconds before a cookie expires
Cookie::$expiration = Kohana::$config->load('ko32example.cookie_lifetime');
// Restrict the path that the cookie is available to
//Cookie::$path = '/';
// Restrict the domain that the cookie is available to
//Cookie::$domain = 'www.kerkness.ca';
// Only transmit cookies over secure connections
//Cookie::$secure = TRUE;
// Only transmit cookies over HTTP, disabling Javascript access
//Cookie::$httponly = TRUE;
/**
 * Session
 */
Session::$default = 'database';
/**
 * Set the default language
 */
Ejemplo n.º 12
0
 private function get_new_id()
 {
     $sql = "insert into guest_id values (null, :md5sum , UNIX_TIMESTAMP(),UNIX_TIMESTAMP())";
     $md5sum = md5(date('dmY') . '-mega-' . rand(0, 1000));
     $query = DB::query(Database::INSERT, $sql);
     $query->param(':md5sum', $md5sum);
     $query->execute();
     $sql = "select LAST_INSERT_ID() as guest_id from dual";
     $query = DB::query(Database::SELECT, $sql);
     $res = $query->execute();
     $res = $res->as_array();
     $guest_id = $res[0]['guest_id'];
     $session = Session::instance();
     $session->set('guest_id', $guest_id);
     $session->set('guest_md5sum', $md5sum);
     if ($this->config["expiration"]) {
         Cookie::$expiration = $this->config["expiration"];
     } else {
         Cookie::$expiration = 2419200;
     }
     Cookie::set('guest_id', $guest_id);
     Cookie::set('guest_md5sum', $md5sum);
     return $guest_id;
 }
Ejemplo n.º 13
0
 * Initialize Kohana, setting the default options.
 *
 * The following options are available:
 *
 * - string   base_url    path, and optionally domain, of your application   NULL
 * - string   index_file  name of your index file, usually "index.php"       index.php
 * - string   charset     internal character set used for input and output   utf-8
 * - string   cache_dir   set the internal cache directory                   APPPATH/cache
 * - integer  cache_life  lifetime, in seconds, of items cached              60
 * - boolean  errors      enable or disable error handling                   TRUE
 * - boolean  profile     enable or disable internal profiling               TRUE
 * - boolean  caching     enable or disable internal caching                 FALSE
 * - boolean  expose      set the X-Powered-By header                        FALSE
 */
Kohana::init(array('base_url' => HTTPPRO . $_SERVER['HTTP_HOST']));
Cookie::$expiration = 86400 * 7;
//Cookie::$secure = TRUE;
Cookie::$httponly = TRUE;
Cookie::$salt = 'Hppi-ECi0Cv23GUi99vB58gh5TLcEfds4i098';
/**
 * 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', 'kohana-mssql' => MODPATH . 'kohana-mssql', 'database' => MODPATH . 'database', 'captcha' => MODPATH . 'captcha', 'koredis' => MODPATH . 'koredis'));