public static function input($arguments) { if (!defined("STDIN")) { define("STDIN", fopen('php://stdin', 'r')); } $_argv = array(); $_argv['command'] = null; $_argv['args'] = array(); $_argv['options'] = array(); $i = 0; foreach ($arguments as $k => $v) { $v = strtolower($v); if (substr($v, 0, 2) == '--') { $_argv['options'][] = $v; } else { if ($i == 1) { $_argv['command'] = $v; } if ($i > 1) { $_argv['args'][] = $v; } } $i++; } $command = $_argv['command']; $method = 'help'; if (strpos($command, ':') !== false) { list($command, $method) = explode(':', $command); } static::$command = $command; static::$method = $method; static::$arguments = $_argv['args']; static::$options = $_argv['options']; return $_argv; }
public static function init($options) { static::$options = $options; if (empty($options['transports'])) { $options['transports'] = array('default' => array('driver' => 'smtp', 'host' => 'localhost', 'port' => 25)); } $first = ''; foreach ($options['transports'] as $key => $value) { $value['name'] = $key; if (!isset($value['driver'])) { throw new \Exception('[Norm] Cannot instantiate transport "' . $key . '", Driver "' . @$value['driver'] . '" not found!'); } elseif (isset(static::$aliases[$value['driver']])) { $value['driver'] = static::$aliases[$value['driver']]; } $Driver = $value['driver']; static::$transports[$key] = new $Driver($value); if (!static::$transports[$key] instanceof Transport) { throw new \Exception('BonoMail transport [' . $key . '] should be instance of Transport'); } if (!$first) { $first = $key; } } if (!static::$defaultTransport) { static::$defaultTransport = $first; } }
public function __construct($options = [], Application $app = null, RepositoryContract $config = null, Dispatcher $dispatcher = null) { static::$options = $config !== null ? array_merge($options, $config->get('tracy')) : $options; TracyDebugger::$time = array_get($_SERVER, 'REQUEST_TIME_FLOAT', microtime(true)); TracyDebugger::$maxDepth = array_get(static::$options, 'maxDepth'); TracyDebugger::$maxLen = array_get(static::$options, 'maxLen'); TracyDebugger::$showLocation = array_get(static::$options, 'showLocation'); TracyDebugger::$strictMode = array_get(static::$options, 'strictMode'); TracyDebugger::$editor = array_get(static::$options, 'editor'); $bar = TracyDebugger::getBar(); foreach (array_get(static::$options, 'panels') as $key => $enabled) { if ($enabled === true) { $class = '\\' . __NAMESPACE__ . '\\Panels\\' . ucfirst($key) . 'Panel'; if (class_exists($class) === false) { $class = $key; } $this->panels[$key] = new $class($app, static::$options); $bar->addPanel($this->panels[$key], $class); } } if ($dispatcher !== null) { $dispatcher->listen('kernel.handled', function ($request, $response) { return static::appendDebugbar($request, $response); }); } else { TracyDebugger::enable(); } }
/** * Fetch all options * * @return mixed */ public function fetchAll() { if (static::$options === null) { static::$options = $this->createModel()->orderBy('key', 'asc')->get(); } return static::$options; }
/** * Get an option from the config file * * @param string $option The key of the option * * @return mixed Its value */ public static function option($option) { // Get config file if (!static::$options) { static::$options = (include __DIR__ . '/../config/config.php'); } return ArraysMethods::get(static::$options, $option); }
/** * Configure the Logger. * * @param null|array $options */ public static function configure($options = null) { if (empty($options) || !is_array($options)) { $options = array(); } $options = array_replace(static::$defaults, static::$options, $options); static::$options = $options; }
protected static function opts($key = null) { if (is_null(static::$options)) { static::$options = App::getInstance()['bind9'] ?: []; } if (0 === func_num_args()) { return static::$options; } else { return isset(static::$options[$key]) ? static::$options[$key] : null; } }
/** * * @param array $options */ public static function config(array $options = array()) { if (!static::$options) { $defaults = array('session.name' => basename(RADIUM_APP_PATH), 'session.cookie_lifetime' => 1209600, 'session.gc_maxlifetime' => 1209600); $options += $defaults; static::$options = $options; } else { static::$options = $options + static::$options; } return static::$options; }
public static function using($driver, $options = null) { $class = 'Email\\' . ucfirst(strtolower($driver)); if (!class_exists($class)) { throw new Exception("[core.email] : {$driver} driver not found."); } static::$driver_name = $driver; static::$options = $options; static::$driver = new $class(); static::$driver->onInit($options); }
/** * Initializes the cache. * * With the $options array it's possible to define: * - expiration of the key, (time in seconds) * - a namespace for the key * * this last one is useful in the case two applications use * a shared key/store (for instance a shared Memcached db) * * Ex: * $cfg_ar = ActiveRecord\Config::instance(); * $cfg_ar->set_cache('memcache://localhost:11211',array('namespace' => 'my_cool_app', * 'expire' => 120 * )); * * In the example above all the keys expire after 120 seconds, and the * all get a postfix 'my_cool_app'. * * (Note: expiring needs to be implemented in your cache store.) * * @param string $url URL to your cache server * @param array $options Specify additional options */ public static function initialize($url, $options = array()) { if ($url) { $url = parse_url($url); $file = ucwords(Inflector::instance()->camelize($url['scheme'])); $class = "ActiveRecord\\{$file}"; require_once __DIR__ . "/cache/{$file}.php"; static::$adapter = new $class($url); } else { static::$adapter = null; } static::$options = array_merge(array('expire' => 30, 'namespace' => ''), $options); }
/** * Return array of options as value-label pairs * * @param bool $addEmptyEntry * * @return array Format: array(array('value' => '<value>', 'label' => '<label>'), ...) */ public function toOptionArray($addEmptyEntry = true) { if (null === static::$options) { static::$options = []; if ($addEmptyEntry) { static::$options[] = ['label' => __('No Cms Block ...'), 'value' => '']; } /** @var \Magento\Cms\Model\Block $block */ foreach ($this->getCmsBlockCollection() as $block) { static::$options[] = ['label' => $block->getTitle(), 'value' => $block->getIdentifier()]; } } return static::$options; }
public static function register(Di $di) { static::$di = $di; $di->set('Phalcon\\Http\\Cookie', 'Phwoolcon\\Http\\Cookie'); static::$cookies = static::$di->getShared('cookies'); static::$cookies->reset(); static::$options = $options = Config::get('cookies'); static::$cookies->useEncryption($encrypt = $options['encrypt']); $encrypt and static::$di->getShared('crypt')->setKey($options['encrypt_key'])->setPadding(Crypt::PADDING_ZERO); /* @var \Phalcon\Http\Response $response */ if ($response = $di->getShared('response')) { $response->setCookies(static::$cookies); } Events::attach('view:generatePhwoolconJsOptions', function (Event $event) { $options = $event->getData() ?: []; $options['cookies'] = ['domain' => static::$options['domain'], 'path' => static::$options['path']]; $event->setData($options); return $options; }); }
public static function init($options) { static::$options = $options; $first = null; if (!empty($options['spools'])) { foreach ($options['spools'] as $key => $spool) { $spool['name'] = $key; if (isset(static::$aliases[$spool['driver']])) { $spool['driver'] = static::$aliases[$spool['driver']]; } $Driver = $spool['driver']; static::$spools[$key] = new $Driver($spool); if (is_null($first)) { $first = $key; } } if (!static::$defaultSpool) { static::$defaultSpool = $first; } } }
public static function driver($options) { static::$options = $options; static::$cache = Cache::getInstance(static::$options); }
/** * Set the options value * * @param array $options The options value * * @static */ public static function setOptions(array $options) { static::$options = $options; }
/** * Replace the current array of options with another * * @param array $options The new options */ public static function replace($options) { static::$options = $options; }
public function modulesLoaded($e) { $config = $e->getConfigListener()->getMergedConfig(); static::$options = $config['cobalt']; }
/** * Safely fetch a command line argument by name or position * * @param string $key * @param mixed $default * @return mixed */ public static function arg($key, $default = NULL) { if (static::$options === NULL) { static::$options = static::parse(); } return isset(static::$options[$key]) ? static::$options[$key] : $default; }
public function setOptions(ModuleEvent $e) { $config = $e->getConfigListener()->getMergedConfig(false); static::$options = $config['libra_locale']; }
public static function setup(array $options = array()) { static::$options = $options + static::$options; }
/** * Constructor for a Route * * @param string $options Array of parameters and additional options for the Route * @return void */ public static function connectFancyRoutes($options = array()) { static::$options = array_merge(static::$options, (array) $options); Configure::write('DynamicRoute.cacheKey', static::$options['cacheKey']); self::_loadDynamicRoutes(); }
public function modulesLoaded($e) { $config = $e->getConfigListener()->getJoinedConfig(); static::$options = $config['zfcuser']; }
public static function getOptionsStatic(&$settings, $model) { $allow_empty = isset($settings['mapping']['nullable']) && $settings['mapping']['nullable'] && !(isset($settings['required']) && $settings['required']); if (static::$options !== null && is_array(static::$options)) { return $allow_empty ? array('' => '') + static::$options : static::$options; } $options = array(); $target_class = 'CMF\\Model\\URL'; $filters = array(); $tree_types = array(); $types = $target_class::select('item.type')->distinct()->where('item.item_id IS NOT NULL')->orderBy('item.type', 'ASC')->getQuery()->getScalarResult(); foreach ($types as $type) { $type = $type['type']; if (!class_exists($type)) { continue; } $metadata = $type::metadata(); $root_class = $metadata->rootEntityName; if (isset($root_class)) { $type = $root_class; } $name = $type::plural(); if (isset($options[$name])) { continue; } $group = \Arr::get($options, $name, array()); $repository = \D::manager()->getRepository($type); $prop = property_exists('menu_title', $type) ? 'menu_title' : 'title'; if ($repository instanceof \Gedmo\Tree\Entity\Repository\NestedTreeRepository && !in_array($name, $tree_types)) { $tree_types[] = $name; // Put in the tree data... $query = $type::select('item, url')->leftJoin('item.url', 'url')->where('item.lvl > 0'); if (count($filters) > 0) { foreach ($filters as $filter) { $query = $query->andWhere('item.' . $filter); } } $tree = $query->orderBy('item.root, item.lft', 'ASC')->getQuery(); // Set the query hint if multi lingual! if (\CMF\Doctrine\Extensions\Translatable::enabled()) { $tree->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'); } $tree = $tree->getArrayResult(); $tree = $repository->buildTree($tree, array()); $options[$name] = static::buildTreeOptionsStatic($tree, $prop, array()); continue; } $items = $type::select("item.id, item.{$prop}, url.url, url.id url_id")->leftJoin('item.url', 'url')->orderBy("item.{$prop}", "ASC")->getQuery(); // Set the query hint if multi lingual! if (\CMF\Doctrine\Extensions\Translatable::enabled()) { $items->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'); } $items = $items->getArrayResult(); if (is_array($items) && count($items) > 0) { foreach ($items as $item) { $group[strval($item[$prop])] = $item['url']; } $options[$name] = $group; } } foreach ($options as $group_name => &$group_value) { if (is_array($group_value) && !in_array($group_name, $tree_types)) { uasort($group_value, function ($a, $b) { return strcmp(strtolower($a), strtolower($b)); }); } } uksort($options, function ($a, $b) { return strcmp(strtolower($a), strtolower($b)); }); static::$options = $options; return $allow_empty ? array('' => '') + $options : $options; }
/** * Configure the Spark application. * * @param array $options * @return void */ public static function configure(array $options) { static::$options = $options; }
/** * 設定をセットする */ public static function set_option() { if (!static::$options) { static::$options = get_option('bce_basics'); } }
/** * Register additional config file * * @param string $fileName Config file name * * @return void */ public static function registerConfigFile($fileName) { if (false === array_search($fileName, static::$configFiles)) { static::$configFiles[] = $fileName; static::$options = null; } }
/** * @param array $options */ public function __construct(array $options = null) { static::$options = array_merge(static::$options, $options); $this->startTime = microtime(true); date_default_timezone_set('UTC'); $this->debug(1, "Starting new request from " . $this->getIP() . " to " . $_SERVER['REQUEST_URI']); if (isset($options['docRoot'])) { $this->docRoot = $options['docRoot']; } else { $this->calcDocRoot(); } //On windows systems I'm assuming fileinode returns an empty string or a number that doesn't change. Check this. $this->salt = @filemtime(__FILE__) . '-' . @fileinode(__FILE__); $this->debug(3, "Salt is: " . $this->salt); if (static::$options['file_cache_directory']) { if (!is_dir(static::$options['file_cache_directory'])) { @mkdir(static::$options['file_cache_directory']); if (!is_dir(static::$options['file_cache_directory'])) { $this->error("Could not create the file cache directory."); return false; } } if (!touch(static::$options['file_cache_directory'] . '/index.html')) { $this->error("Could not create the index.html file - to fix this create an empty file named index.html file in the cache directory."); } } else { static::$options['file_cache_directory'] = sys_get_temp_dir(); } //Clean the cache before we do anything because we don't want the first visitor after FILE_CACHE_TIME_BETWEEN_CLEANS expires to get a stale image. $this->cleanCache(); $this->myHost = preg_replace('/^www\\./i', '', $_SERVER['HTTP_HOST']); $this->src = static::$options['src']; $this->url = parse_url($this->src); $this->src = preg_replace('/https?:\\/\\/(?:www\\.)?' . $this->myHost . '/i', '', $this->src); if (strlen($this->src) <= 3) { $this->error("No image specified"); return false; } if (static::$options['block_external_leechers'] && array_key_exists('HTTP_REFERER', $_SERVER) && !preg_match('/^https?:\\/\\/(?:www\\.)?' . $this->myHost . '(?:$|\\/)/i', $_SERVER['HTTP_REFERER'])) { // base64 encoded red image that says 'no hotlinkers' // nothing to worry about! :) $imgData = base64_decode("R0lGODlhUAAMAIAAAP8AAP///yH5BAAHAP8ALAAAAABQAAwAAAJpjI+py+0Po5y0OgAMjjv01YUZ\nOGplhWXfNa6JCLnWkXplrcBmW+spbwvaVr/cDyg7IoFC2KbYVC2NQ5MQ4ZNao9Ynzjl9ScNYpneb\nDULB3RP6JuPuaGfuuV4fumf8PuvqFyhYtjdoeFgAADs="); header('Content-Type: image/gif'); header('Content-Length: ' . strlen($imgData)); header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header("Pragma: no-cache"); header('Expires: ' . gmdate('D, d M Y H:i:s', time())); echo $imgData; return false; exit(0); } if (preg_match('/^https?:\\/\\/[^\\/]+/i', $this->src)) { $this->debug(2, "Is a request for an external URL: " . $this->src); $this->isURL = true; } else { $this->debug(2, "Is a request for an internal file: " . $this->src); } if ($this->isURL && !static::$options['allow_external']) { $this->error("You are not allowed to fetch images from an external website."); return false; } if ($this->isURL) { if (static::$options['allow_all_external_sites']) { $this->debug(2, "Fetching from all external sites is enabled."); } else { $this->debug(2, "Fetching only from selected external sites is enabled."); $allowed = false; foreach (static::$options['allowed_sites'] as $site) { if (strtolower(substr($this->url['host'], -strlen($site) - 1)) === strtolower(".{$site}") || strtolower($this->url['host']) === strtolower($site)) { $this->debug(3, "URL hostname {$this->url['host']} matches {$site} so allowing."); $allowed = true; } } if (!$allowed) { return $this->error("You may not fetch images from that site. To enable this site in timthumb, you can either add it to \$ALLOWED_SITES and set ALLOW_EXTERNAL=true. Or you can set ALLOW_ALL_EXTERNAL_SITES=true, depending on your security needs."); } } } $cachePrefix = $this->isURL ? '_ext_' : '_int_'; if ($this->isURL) { $arr = explode('&', $_SERVER['QUERY_STRING']); asort($arr); $this->cachefile = static::$options['file_cache_directory'] . '/' . FILE_CACHE_PREFIX . $cachePrefix . md5($this->salt . implode('', $arr) . $this->fileCacheVersion) . FILE_CACHE_SUFFIX; } else { $this->localImage = $this->getLocalImagePath($this->src); if (!$this->localImage) { $this->debug(1, "Could not find the local image: {$this->localImage}"); $this->error("Could not find the internal image you specified."); $this->set404(); return false; } $this->debug(1, "Local image path is {$this->localImage}"); $this->localImageMTime = @filemtime($this->localImage); //We include the mtime of the local file in case in changes on disk. $this->cachefile = static::$options['file_cache_directory'] . '/' . FILE_CACHE_PREFIX . $cachePrefix . md5($this->salt . $this->localImageMTime . $_SERVER['QUERY_STRING'] . $this->fileCacheVersion) . FILE_CACHE_SUFFIX; } $this->debug(2, "Cache file is: " . $this->cachefile); return true; }