本文整理汇总了PHP中Common::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::read方法的具体用法?PHP Common::read怎么用?PHP Common::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common
的用法示例。
在下文中一共展示了Common::read方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render one (or more) hidden links.
*
* @param integer $num Number of random and unique links to create.
* @return string Hidden links HTML.
*/
public function render($num = 1)
{
if (!($lnk = Common::read('Security.HttpBL.honeyPot', $this->settings['honeyPot']))) {
return;
}
$all = $this->settings['links'];
$len = rand(4, 16);
$min = array(48, 65, 97);
$max = array(57, 90, 122);
$txt = '';
$res = array();
while (strlen($txt) < $len) {
$rnd = rand(0, 2);
$txt .= chr(rand($min[$rnd], $max[$rnd]));
}
if ($num > count($all)) {
$num = count($all);
}
if (0 == $num) {
return;
}
$rnd = array_rand($all, $num);
foreach ((array) $rnd as $key) {
$res[] = String::insert($all[$key], compact('lnk', 'str'));
}
return implode(' ', $res);
}
示例2: beforeValidate
/**
* {@inheritdoc}
*/
public function beforeValidate($options = array())
{
if (empty($this->data[$this->alias]['token'])) {
$this->data[$this->alias]['token'] = $this->generate();
}
if (empty($this->data[$this->alias]['expires'])) {
if (!empty($this->expires)) {
$this->data[$this->alias]['expires'] = $this->expires;
} else {
$this->data[$this->alias]['expires'] = Common::read('Security.expireToken', '+3 days');
}
}
if (!Validation::datetime($this->data[$this->alias]['expires'])) {
$this->data[$this->alias]['expires'] = date('Y-m-d H:i:s', strtotime($this->data[$this->alias]['expires']));
}
return true;
}
示例3: sitemap
/**
* Build sitemap.xml.
*
* @return void
*/
public function sitemap()
{
Configure::write('debug', 0);
// Skip the view file by defining some XmlView magic
$this->set('_rootNode', 'urlset');
$this->set('_serialize', 'url');
$cacheKey = Common::read('Webmaster.cache.keys.sitemap', 'sitemap');
$cacheConfig = Common::read('Webmaster.cache.config', 'default');
$cacheDisabled = Common::read('Webmaster.cache.forceDisable', false);
// Load from cache when possible.
if (!$cacheDisabled) {
$url = Cache::read($cacheKey, $cacheConfig);
if (!empty($url)) {
$this->set(compact('url'));
return;
}
}
$url = array();
foreach ((array) $this->triggerEvent('Webmaster.sitemap', $this) as $link) {
extract($link);
if (!isset($loc)) {
continue;
}
foreach (array('lastmod', 'changefreq', 'priority') as $key) {
if (!isset(${$key})) {
${$key} = Configure::read('Webmaster.sitemap.' . $key);
}
}
$lastmod = date('Y-m-d\\Th:mP', strtotime($lastmod));
$url[] = compact('loc', 'lastmod', 'changefreq', 'priority');
}
if (!$cacheDisabled) {
Cache::write($cacheKey, $url, $cacheConfig);
}
$this->set(compact('url'));
}
示例4: controllerConstructClasses
public function controllerConstructClasses(CakeEvent $Event)
{
// Load `Navigation` helper.
$Event->result = Hash::merge((array) $Event->result, array('helpers' => array('Common.Navigation')));
// Load `TwitterBootstrap` helpers and components.
if ((!isset($Event->subject->twitterBootstrap) || $Event->subject->twitterBootstrap) && CakePlugin::loaded('TwitterBootstrap')) {
$Event->result = Hash::merge((array) $Event->result, array('helpers' => array('Html' => array('className' => 'TwitterBootstrap.BootstrapHtml'), 'Form' => array('className' => 'TwitterBootstrap.BootstrapForm'), 'Paginator' => array('className' => 'TwitterBootstrap.BootstrapPaginator')), 'layout' => 'Common.twitter_bootstrap'));
}
// Load `BoostCake` helpers and components.
if ((!isset($Event->subject->boostCake) || $Event->subject->boostCake) && CakePlugin::loaded('BoostCake')) {
$Event->result = Hash::merge((array) $Event->result, array('helpers' => array('Html' => array('className' => 'BoostCake.BoostCakeHtml'), 'Form' => array('className' => 'BoostCake.BoostCakeForm'), 'Paginator' => array('className' => 'BoostCake.BoostCakePaginator')), 'layout' => 'Common.twitter_bootstrap'));
}
// Load `DebugKit` component.
if (Reveal::is('DebugKit.loaded') && !Reveal::is('Page.test')) {
$Event->result = Hash::merge((array) $Event->result, array('components' => array('DebugKit.Toolbar' => array('autoRun' => Common::read('DebugKit.autoRun', true), 'forceEnable' => Common::read('DebugKit.forceEnable', false), 'panels' => array('Common.Common')))));
}
// Route custom prefixes to associated plugin's routing prefixes.
if (Reveal::is('Page.prefixed') && strpos($Event->subject->request->action, $Event->subject->request->prefix) === 0 && ($prefix = Configure::read($Event->subject->plugin . '.routingPrefixes.' . $Event->subject->request->prefix))) {
$Event->result['view'] = $prefix . substr($Event->subject->request->action, strlen($Event->subject->request->prefix));
$Event->subject->request->params['action'] = $Event->result['view'];
}
// Append new flash messages.
$Event->result = Hash::merge((array) $Event->result, array('alertMessages' => array('auth.fail' => array('message' => __d('common', "Authentication is required. Please log in to continue."), 'level' => 'error', 'redirect' => array('plugin' => 'users', 'controller' => 'users', 'action' => 'login')), 'create.success' => array('message' => __d('common', ":modelName successfully created."), 'redirect' => array('action' => 'index')), 'create.fail' => array('message' => __d('common', "There was a problem creating your :modelName, please try again."), 'level' => 'warning', 'redirect' => true), 'delete.success' => array('message' => __d('common', ":modelName successfully deleted.")), 'delete.fail' => array('message' => __d('common', "There was a problem deleting your :modelName, please try again."), 'level' => 'warning', 'redirect' => true), 'save.success' => array('message' => __d('common', ":modelName successfully updated.")), 'save.fail' => array('message' => __d('common', "There was a problem updating your :modelName, please try again."), 'level' => 'warning'), 'status.success' => array('message' => __d('common', ":modelName status successfully changed."), 'redirect' => true, 'dismiss' => true), 'status.fail' => array('message' => __d('common', "There was a problem changing the :modelName status, please try again."), 'level' => 'warning', 'redirect' => true), 'validation' => array('message' => __d('common', "Some data could not be validated. Please, check the error(s) below."), 'level' => 'error'), 'view.fail' => array('message' => __d('common', "Invalid :modelName, please try again."), 'level' => 'error', 'redirect' => true))));
}
示例5: execute
/**
* Execution method always used for tasks
*
* @return void
*/
public function execute()
{
if (!Configure::check('PHP')) {
try {
Configure::load('requirements', Common::read('Common.reader.id', 'default'));
} catch (ConfigureException $e) {
$this->out();
$this->out(__d('webmaster', "No requirements defined. See %s for more info.", Common::wiki('requirements')), 2);
return;
}
}
$width = 20;
$reqs = Configure::read('PHP');
$this->hr(true);
$this->out(__d('webmaster', "Checking system defined requirements:"));
$this->hr(true);
$this->out(__d('webmaster', "PHP Extensions:"));
$this->out(__d('webmaster', "Whether or not required PHP extensions are loaded."));
$this->hr(true);
if (empty($reqs['extensions'])) {
$reqs['extensions'] = array();
$this->out(__d('webmaster', "None required."));
}
foreach ($reqs['extensions'] as $ext) {
$out = $ext;
$out .= str_repeat(' ', $width - strlen($ext));
$out .= ': ';
if (!extension_loaded($ext)) {
$out .= __d('webmaster', "Missing");
} else {
$out .= __d('webmaster', "Loaded");
}
$this->out($out);
}
unset($reqs['extensions']);
$this->hr(true);
$this->out(__d('webmaster', "PHP Runtime Settings:"));
$this->out(__d('webmaster', "Whether or not required 'php.ini' directives are modifiable."));
$this->hr(true);
if (empty($reqs['runtime'])) {
$reqs['runtime'] = array();
$this->out(__d('webmaster', "None required."));
} else {
$all = ini_get_all();
}
foreach ($reqs['runtime'] as $varname) {
$out = $varname;
$out .= str_repeat(' ', $width - strlen($varname));
$out .= ': ';
if (!isset($all[$varname])) {
continue;
}
if ($all[$varname]['access'] < 6) {
$out .= __d('webmaster', "No");
} else {
$out .= __d('webmaster', "Yes");
}
$this->out($out);
}
unset($reqs['runtime']);
$this->hr(true);
$this->out(__d('webmaster', "PHP Settings:"));
$this->out(__d('webmaster', "Whether or not required 'php.ini' directives are correctly set."));
$this->hr(true);
if (empty($reqs)) {
$this->out(__d('webmaster', "None required."));
}
foreach ($reqs as $var => $val) {
$out = $var;
$out .= str_repeat(' ', $width - strlen($var));
$out .= ': ';
$ini = ini_get($var);
if (is_bool($val)) {
if ((bool) $ini !== $val) {
$out .= __d('webmaster', "Invalid (value: %s, expects: %s)", $ini, (int) $val);
} else {
$out .= __d('webmaster', "Valid (value: %s)", $ini);
}
continue;
}
if ($this->__inBytes($ini) < $this->__inBytes($val)) {
$out .= __d('webmaster', "Invalid (value: %s, expects: %s)", $ini, $val);
} else {
$out .= __d('webmaster', "Valid (value: %s)", $ini);
}
$this->out($out);
}
$this->hr(true);
}
示例6: _constructCrumbs
/**
* Breadcrumb constructor.
*
* @return void
*/
protected function _constructCrumbs()
{
if ($this instanceof CakeErrorController || $this instanceof PagesController || false === Common::read('Layout.showCrumbs', true) || false === $this->breadCrumbs || !empty($this->breadCrumbs)) {
return;
}
// Home.
$this->breadCrumbs = array(__d('common', "Home") => '/');
// Dashboard.
if (CakePlugin::loaded('Users') && Reveal::is('User.loggedin')) {
$this->breadCrumbs = array(__d('common', "Dashboard") => $this->Auth->loginRedirect);
if ($this->request->controller == $this->Auth->loginRedirect['controller'] && preg_match('/' . $this->Auth->loginRedirect['action'] . '$/', $this->action) && (empty($this->Auth->loginRedirect['plugin']) || $this->plugin == Inflector::camelize($this->Auth->loginRedirect['plugin']))) {
$this->breadCrumbs[__d('common', "Dashboard")] = array();
return;
}
}
// Plugin.
if (!empty($this->plugin)) {
$title = empty($this->crumbTitles[$this->plugin]) ? $this->plugin : $this->crumbTitles[$this->plugin];
$this->breadCrumbs[$title] = array('plugin' => Inflector::underscore($this->plugin), 'controller' => Inflector::underscore($this->plugin), 'action' => 'index');
if (Router::normalize(Router::url($this->breadCrumbs[$title])) == $this->request->here) {
$this->breadCrumbs[$title] = array();
}
if (($this->plugin == $this->name || !empty($this->crumbTitles[$this->name]) && $this->plugin == $this->crumbTitles[$this->name]) && in_array('index', explode('_', $this->action))) {
return;
}
}
// Controller.
if (!empty($this->crumbTitles[$this->name])) {
$this->breadCrumbs[$this->crumbTitles[$this->name]] = array('action' => 'index');
} else {
if (!array_key_exists($this->name, $this->crumbTitles)) {
$this->breadCrumbs[!empty($this->modelName) ? Inflector::pluralize($this->modelName) : Inflector::humanize(Inflector::underscore($this->name))] = array('action' => 'index');
}
}
if (array_pop(explode('_', $this->action)) == 'index') {
$this->breadCrumbs[end(array_keys($this->breadCrumbs))] = array();
return;
}
// Action
if (!empty($this->crumbTitles[$this->action])) {
$this->breadCrumbs[$this->crumbTitles[$this->action]] = array();
} else {
if (!array_key_exists($this->action, $this->crumbTitles)) {
$action = str_replace($this->request->prefix, '', $this->action);
if ($action == $this->action) {
$action = str_replace(Configure::read($this->plugin . '.routingPrefixes.' . $this->request->prefix), '', $this->action);
}
$this->breadCrumbs[Inflector::humanize(Inflector::underscore($action))] = array();
}
}
}
示例7: read
/**
* Get configuration environment variable ($_SERVER[...]) and overwrites it
* with equivalent key from runtime configuration. If none found, uses
* `$default` value.
*
* Example:
*
* `$_SERVER['REDIS_HOST']` would be defined in runtinme as `Redis.host`
*
* @param string $name Variable to obtain. Use '.' to access array elements.
* @param mixed $default Optional. Default value to return if variable not configured.
* @param string $plugin Optional. Name of plugin that may have over-written the configuration key.
* @return mixed Variable's value.
*/
public static function read($name, $default = null, $plugin = null)
{
if (!is_null($plugin)) {
$result = Common::read("{$plugin}.{$name}");
if (!is_null($result)) {
return $result;
}
}
$key = str_replace('.', '_', strtoupper($name));
if (isset($_SERVER[$key])) {
return $_SERVER[$key];
}
if (Configure::check($name)) {
return Configure::read($name);
}
return $default;
}
示例8: blackHole
/**
* Blackholes clients that meet one of the `HttpBLComponent::$conditions`.
*
* @param Controller $Controller Instance of the current Controller.
* @param array $condition Optional. Matching condition.
* @return void
*/
public function blackHole(Controller $Controller, $condition = null)
{
if (method_exists($Controller, 'blackHoleHttpBL')) {
return $Controller->blackHoleHttpBL($condition);
}
if ($honeyPot = Common::read('Security.HttpBL.honeyPot') || ($honeyPot = $this->honeyPot)) {
return $Controller->redirect($honeyPot, 301);
}
$this->_stop();
}
示例9: tearDownAfterClass
/**
* {@inheritdoc}
*/
public static function tearDownAfterClass()
{
self::_restoreSettings();
Configure::write('Config.language', Common::read('App.locale', 'eng'));
if (is_a(self::$_this, 'CommonTestCase')) {
// Drop all fixturized tables to avoid conflict with other test cases.
self::$_this->fixtureManager->shutDown();
}
}
示例10: define
*/
if (CakePlugin::loaded('I18n')) {
App::uses('I18nRoute', 'I18n.Routing/Route');
Router::defaultRouteClass('I18nRoute');
Configure::write('Config.language', Configure::read('L10n.language'));
Configure::write('Config.languages', Configure::read('L10n.languages'));
if (!defined('DEFAULT_LANGUAGE')) {
define('DEFAULT_LANGUAGE', Configure::read('L10n.language'));
}
}
/**
* Configure `CakeNumber` currencies.
*/
if (class_exists('CakeNumber')) {
CakeNumber::defaultCurrency(Common::read('L10n.currency', 'USD'));
foreach (Common::read('L10n.currencies', array()) as $currencyName => $currencyFormat) {
CakeNumber::addFormat($currencyName, $currencyFormat);
}
}
if (!function_exists('__t')) {
/**
* Translates different type of strings depending on the number of arguments it is passed and their types. Supports:
*
* - all of `__()`, `__n()`, `__d()`, `__dn()`
* - placeholders for `String::insert()`
*
* Examples:
*
* - __t('Hello world!')
* - __t('Hello :name!', array('name' => 'world'))
* - __t('Hello mate!', 'Hello mates!', 2)
示例11:
<?php
Configure::write('Security.expireToken', Common::read('Security.expireToken', '+3 days'));