Ejemplo n.º 1
0
 /**
  * @param array $opts Array of options. Supported keys:<ul>
  *              <li>'path' - The path on the server in which the cookie will be available on.
  *                         If set to '/', the cookie will be available within the entire domain.
  *                         If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain.
  *                         Default value is: /<br>
  *              <li>'domain' - The domain that the cookie is available to.
  *                           Setting the domain to 'www.example.com' will make the cookie available in the www subdomain and higher subdomains.
  *                           Cookies available to a lower domain, such as 'example.com' will be available to higher subdomains, such as 'www.example.com'.
  *                           Older browsers still implementing the deprecated » RFC 2109 may require a leading . to match all subdomains.
  *                           Default value is '.' + $_SERVER['SERVER_NAME'] [www is omitted]<br>
  *              <li>'prefix' - Prefix for cookies. See: self::$prefix
  */
 public static function init(array $opts = array())
 {
     if (self::$inited) {
         return;
     }
     if (isset($opts['path']) and (string) $opts['path']) {
         self::$path = (string) $opts['path'];
     }
     if (isset($opts['prefix'])) {
         self::$prefix = (string) $opts['prefix'];
     }
     if (isset($opts['domain']) and (string) $opts['domain']) {
         self::$domain = (string) $opts['domain'];
     } else {
         self::$domain = $_SERVER['SERVER_NAME'];
         self::$domain = '.' . preg_replace('#^www\\.#', '', strtolower(self::$domain));
     }
     self::$secure = (isset($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) == 'on');
 }
Ejemplo n.º 2
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.º 3
0
    HTTP::$protocol = $_SERVER['SERVER_PROTOCOL'];
}
/**
 * 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']));
}
Cookie::$salt = 'stourwebcms';
// 设置cookie 多久过期
Cookie::$expiration = 86400;
// 限制有效的cookie路径
Cookie::$path = '/';
// 限制可以访问cookie的域名
//Cookie::$domain = 'www.phpddt.com';
/**
 * 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