public static function init() { parse_str(file_get_contents("php://input"), static::$data); static::$data = array_merge($_GET, $_POST); $met = $_SERVER['REQUEST_METHOD']; static::$header['method'] = $met; $path = str_replace('?' . $_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI']); static::$header['path'] = $path; $queries = []; $sQuery = $_SERVER['QUERY_STRING']; $a = explode('&', $sQuery); if (count($a) > 0) { foreach ($a as $b) { $c = explode('=', $b); if (is_array($c) && count($c) === 2) { $d = ''; $v = $c[1]; if (is_numeric($v)) { $d = 1 * $v; } else { if (is_string($v)) { $d = urldecode($v); } } $queries[$c[0]] = $d; } } } static::$header['query'] = (object) $queries; }
/** * @return DataGenerator */ public static function getData() { if (!isset(static::$data)) { static::$data = new DataGenerator(); } return static::$data; }
/** * Given a State FIPS code and an ending year, returns the (unadjusted) county-level unemployment levels for the previous 10 year period. * Seasonally adjusted data does not appear to be available at the county level. * * @param string stateId * @param string endYear * @return string[] $data */ public static function grabUnadjUnemploymentData($stateId, $endYear) { ini_set('max_execution_time', 0); static::$data = array(); $codes = FipsCodeGenerator::getFipsList($stateId); $index = 0; $tableList = array(); foreach ($codes as $code) { if (count($tableList) >= 25) { $results = static::queryAPI($tableList, $endYear); static::addToData($results); $tableList = array(); } $entry = ''; if (substr($code, -3) == '000') { //the code is a state code $entry .= static::$tablePrefixes['stateUnadjUnemployRate']; $entry .= $code; $entry .= static::$tableSuffixes['stateUnadjUnemployRate']; } else { $entry .= static::$tablePrefixes['countyUnadjUnemployRate']; $entry .= $code; $entry .= static::$tableSuffixes['countyUnadjUnemployRate']; } array_push($tableList, $entry); //appends the entry to the indexed list } $results = static::queryAPI($tableList, $endYear); static::addToData($results); ksort(static::$data); return static::$data; }
/** * Add data to pass. * * @param array $data */ public static function add(array $data) { // Filter and merge data $data = array_filter($data, function ($value) { return !is_null($value); }); $data = array_merge_recursive(static::$data, $data); static::$data = $data; }
/** * @param EmailTemplate static::$emailTemplate * @param array $postData * @param string$wizardFormClassName */ public static function resolveEmailTemplateByWizardPostData(EmailTemplate $emailTemplate, array $postData, $wizardFormClassName) { assert('is_array($postData)'); assert('is_string($wizardFormClassName)'); static::$data = ArrayUtil::getArrayValue($postData, $wizardFormClassName); static::$emailTemplate = $emailTemplate; static::resolveMetadataMembers(); static::resolveOwner(); static::resolveFileAttachments(); }
/** * Clear a key within the cache data, or call without an argument to clear all the cached data. * * @param string $key The key of the cached data * * @return void */ public static function clear($key = null) { if ($key) { if (isset(static::$data[$key])) { unset(static::$data[$key]); } } else { static::$data = []; } }
/** * loadGlobalProvider * * @return Data */ public static function loadGlobalProvider() { if (static::$data) { return static::$data; } $event = new Event('loadGlobalProvider'); $event['data'] = new Data(); Ioc::getDispatcher()->triggerEvent($event); return static::$data = $event['data']; }
public static function remove($key = null) { // reset the entire array if (is_null($key)) { return static::$data = array(); } // unset a single key unset(static::$data[$key]); // return the array without the removed key return static::$data; }
public static function _toData() { if (is_null(static::$data)) { static::_get(); $data = array(); foreach (static::$array['classes'] as $class) { $data[$class['id']] = $class['name']; } static::$data = $data; } }
public static function load($config_file = null, $config_data = null) { if (!empty($config_file) && Helper::checkFile($config_file) && !($yaml = file_get_contents($config_file))) { throw new \Exception("Failed to read config file {$config_file}"); } if (empty($config_data) && !($data = Yaml::parse($yaml))) { throw new \Exception("Failed to parse config file {$config_file}"); } static::$data = static::$base = array_merge(static::$data, $data); self::$cache = array(); }
/** * Gets a layout. * * @param string $name * @param array $data * @return string */ public static function get(string $name, array $data = []) : string { // Merge the data. static::$data = array_merge_recursive(static::data(), $data); // Merge validation errors into the view data. if (!isset(static::$data['errors']) && ($errors = Session::flash('validation_errors'))) { static::$data['errors'] = $errors; } // Get the path to the layout. $path = path('layouts') . $name . '.layout.php'; // Load. return Component::load($path, static::data()); }
/** * @param array $options * @return string * @throws \yii\base\Exception */ public static function Export(array $options = []) { static::$data = isset($options['data']) ? $options['data'] : []; static::$fileName = isset($options['fileName']) ? $options['fileName'] : 'file.csv'; if (!isset($options['dirName'])) { throw new Exception('You must set dirName'); } static::$dirName = $options['dirName']; if (static::$dirName[strlen(static::$dirName - 1)] !== '/') { static::$dirName .= '/'; } return self::array2csv(static::$data, static::$dirName, static::$fileName); }
protected static function loadData() { if (static::$loaded) { return; } static::$data = static::$original = Cache::remember('fluxbb.config', 24 * 60, function () { $data = DB::table('config')->get(); $cache = array(); foreach ($data as $row) { $cache[$row->conf_name] = $row->conf_value; } return $cache; }); static::$loaded = true; }
/** * @param string $key * @param mixed $default * @return mixed */ public static function get($key, $default = null) { $platform = self::getPlatform(); if (!preg_match('/[a-z-]/', $key)) { throw new \InvalidArgumentException('Invalid config key:' . $key); } $data = static::$data; if ($platform->hasPersonalConfig()) { $data = $platform->getConfigByKey('laravelpagseguro'); } if (is_null($data)) { $data = (include __DIR__ . '/application-config.php'); static::$data = $data; } return array_key_exists($key, $data) ? $data[$key] : $default; }
public static function init() { $config = array('db' => array()); require_once APP . 'config.php'; static::$data = new stdClass(); static::$data->title = $config['default']['title']; static::$template = $config['default']['template']; // Database config options define('DB_HOST', $config['db']['host']); define('DB_NAME', $config['db']['name']); define('DB_USER', $config['db']['user']); define('DB_PASS', base64_decode($config['db']['pass'])); // Path to remove from uri static::$path = $config['path']; static::$profiler = $config['profiler']['log']; static::$profiler_query = $config['profiler']['query']; static::$status = $config['status']; }
/** * @return Zhpe_DbInterface * @throws Exception */ public static function data() { if (is_null(static::$data)) { if (!isset(Config::$modules[static::$module]['dsn'])) { $err = Zhpe_I18in::en('Config not exists', ": Config::\$modules['%s']['dsn']"); throw new Exception(sprintf($err, static::$module)); } $dsnKey = Config::$modules[static::$module]['dsn']; if (!isset(Config::$dsn[$dsnKey]['type'])) { $err = Zhpe_I18in::en('Config not exists', ": Config::\$dsn['%s']['type']"); throw new Exception(sprintf($err, $dsnKey)); } // Data Access Objects $cls = 'Zhpe_Db' . Config::$dsn[$dsnKey]['type']; static::$data = new $cls(static::$module, static::$table, static::$primary, static::$joins); } //Return static::$data anywhere. return static::$data; }
/** * Initializes the session system */ static function init() { //Create the session authentication controller and internal data storage if (!static::$auth) { static::$auth = new Authenticator(); static::$data = new Internal(); } //Initialize supplied modules foreach (func_get_args() as $arg) { if ($arg instanceof ISessionStorage) { static::$data = $arg; } elseif ($arg instanceof ISessionExtra) { static::$extra[get_class($arg)] = $arg; } elseif ($arg instanceof IAuthenticator) { static::$auth->setAuthenticator($arg); } elseif ($arg instanceof ISessionSource) { static::$auth->setSource($arg); } } }
/** * Returns the config array form the multiple config files * * @param string $env * @return array * @throws Exception */ public static function getConfig($env) { if (!in_array($env, static::$validEnvironments)) { throw new Exception('Application Config', 'Environment ' . $env . ' is invalid'); } $config = array(); foreach (self::$configFiles as $configFile => $type) { $configFile = dirname(APPLICATION_PATH) . str_replace('{ENV}', $env, $configFile); if (file_exists($configFile)) { if ('global' == $type) { $local = new \Zend_Config_Ini($configFile, $env); } else { $local = new \Zend_Config_Ini($configFile); } $config = self::merge($config, $local->toArray()); } } static::$data = $config; return $config; }
public static function start() { // run gc static::gc(); // get session id $name = Config::get('session.name', 'anchorcms'); static::$id = Cookie::get($name); if (static::$id === false) { Log::info('Session cookie not found: ' . $name); static::$id = Str::random(32); } // load session data $sql = "select data from sessions where id = ? and ip = ? and ua = ? limit 1"; $args = array(static::$id, Input::ip_address(), Input::user_agent()); if ($session = Db::row($sql, $args)) { static::$data = unserialize($session->data); } else { // Session not found regenerate ID static::$id = Str::random(32); Db::insert('sessions', array('id' => static::$id, 'date' => date(DATE_ISO8601), 'ip' => Input::ip_address(), 'ua' => Input::user_agent(), 'data' => serialize(static::$data))); } }
/** * Sets or overwrites a variable in the data array * * <code> * * r::set('username', 'bastian'); * * dump($request); * * // sample output: array( * // 'username' => 'bastian' * // ... other stuff from the request * // ); * * </code> * * @param mixed $key The key to set/replace. Use an array to set multiple values at once * @param mixed $value The value * @return array */ public static function set($key, $value = null) { // set multiple values at once if (is_array($key)) { foreach ($key as $k => $v) { static::set($k, $v); } // return this for chaining return; } // make sure the data array is actually an array if (is_null(static::$data)) { static::$data = array(); } // sanitize the static::$data[$key] = static::sanitize($value); // return the new data array return static::$data; }
/** * @inheritdoc */ public function getAll(array $only = [], array $exclude = [], Sanitize $sanitize = null) { if (empty($_COOKIE)) { return []; } static::$data = Serialize::unserializeRecursive($_COOKIE); static::$data = $this->sanitize(static::$data, $sanitize); return static::$data = ArrayHelper::only(static::$data, $only, $exclude); }
/** * Initialize all classes required for runtime. Master initialize method. * * @access public * @return void * @static */ public static function initialize() { // Try and autoload from include_paths first spl_autoload_register(); spl_autoload_register('\\titon\\core\\App::autoload'); // Initialize core components Environment::initialize(); Debugger::initialize(); Router::initialize(); // Get super globals $get = $_GET; $post = $_POST; $files = array(); if (!empty($_FILES)) { foreach ($_FILES as $model => $data) { foreach ($data as $meta => $values) { $keys = array_keys($values); $files[$model][$keys[0]][$meta] = $values[$keys[0]]; } } } // Clear magic quotes, just in case if (get_magic_quotes_gpc() > 0) { $stripSlashes = function ($data) { return is_array($data) ? array_map($stripSlashes, $data) : stripslashes($data); }; $get = $stripSlashes($get); $post = $stripSlashes($post); $files = $stripSlashes($files); } static::$data = array_merge_recursive($post, $files); static::$globals = array('_GET' => $get, '_POST' => $post, '_FILES' => $files, '_SERVER' => $_SERVER, '_ENV' => $_ENV); }
/** * Add test environment * * {@inheritdoc} * @see ApiTestCase::setUpBeforeClass() */ public static function setUpBeforeClass() { parent::setUpBeforeClass(); static::$data = [static::$testEnvId => []]; if (empty(static::$userSpec)) { static::$userSpec = new SpecManager(self::$apiVersion, 'user'); } if (empty(static::$accountSpec)) { static::$accountSpec = new SpecManager(self::$apiVersion, 'account'); } }
/** * Adds list as array. * @param array $data */ public function addMulti(array $data) { static::$data = $data; }
/** * fillTable, remplir un table pour permet le developpement. * * @param string|array $table [optional] * @param int $n * @param array $desciption [ * "column" => [ * "field" => "name", * "type": "int|longint|bigint|mediumint|smallint|tinyint", * "auto" => false|true * ] * @return mixed */ public static function fillTable($table = null, $n = 1, $desciption = []) { if (is_int($table)) { $n = $table; $table = null; } if (!is_string($table)) { $table = static::$table; } $database = Database::table($table); if (static::$data === null) { static::$data = $desciption; } $r = 0; for ($i = 0; $i < $n; $i++) { $data = []; foreach (static::$data as $column) { if (in_array($column['type'], ['int', 'longint', 'bigint', 'mediumint', 'smallint', 'tinyint'])) { if ($column['auto']) { $value = null; } else { $value = Filler::number(); } } else { if (in_array($column['type'], ['date', 'datetime'])) { $value = Filler::date(); } else { if (in_array($column['type'], ['double', 'float'])) { $value = Filler::float(); } else { if ($column['type'] == 'timestamp') { $value = time(); } else { if ($column['type'] == 'enum') { $value = $column['default']; } else { if (preg_match('/text$/', $column['type'])) { $value = Str::slice(Filler::string(), 0, 1000); } else { $value = Str::slice(Filler::string(), 0, rand(1, $column['size'])); } } } } } } $data[$column['field']] = $value; } $r += $database->insert($data); } return $r; }
/** * Önbelleğe alınan tüm verileri siler * * @return mixed */ public function flush() { static::$data = []; return $this; }
/** * Instantiate the singleton * * @return void */ protected function __construct() { static::$data = s::get('flash', []); s::remove('flash'); }
/** * 重置模板输出信息 * @return [type] [description] */ private static function reset() { static::$viewPath = []; static::$data = []; static::$return = false; }
public static function clear() { static::$data = []; }
/** * Add test environment, test Acl, setups test user, environment and API key */ public static function setUpBeforeClass() { if (!Scalr::getContainer()->config->defined('scalr.phpunit.apiv2')) { static::markTestIncomplete('phpunit apiv2 configurations is invalid'); } if (Scalr::getContainer()->config->defined('scalr.phpunit.apiv2.params.max_results')) { static::$maxResults = Scalr::config('scalr.phpunit.apiv2.params.max_results'); } static::$testUserId = Scalr::config('scalr.phpunit.apiv2.userid'); static::$user = User::findPk(static::$testUserId); static::$testUserType = static::$user->type; static::$testEnvId = Scalr::config('scalr.phpunit.apiv2.envid'); static::$env = Environment::findPk(static::$testEnvId); if (empty(static::$user) || empty(static::$env)) { static::markTestIncomplete('Either test environment or user is invalid.'); } $apiKeyName = static::getTestName(); $apiKeyEntity = ApiKeyEntity::findOne([['name' => $apiKeyName], ['userId' => static::$testUserId]]); if (empty($apiKeyEntity)) { $apiKeyEntity = new ApiKeyEntity(static::$testUserId); $apiKeyEntity->name = $apiKeyName; $apiKeyEntity->save(); } static::$apiKeyEntity = $apiKeyEntity; static::$defaultAcl = Scalr::getContainer()->acl; static::$data = [static::$testEnvId => []]; if (empty(static::$fullAccessAcl)) { static::$fullAccessAcl = new ApiTestAcl(); static::$fullAccessAcl->setDb(Scalr::getContainer()->adodb); static::$fullAccessAcl->createTestAccountRole(static::$user->getAccountId(), static::getTestName(ApiFixture::ACL_FULL_ACCESS), ApiTestAcl::ROLE_ID_FULL_ACCESS); static::$fullAccessAcl->aclType = ApiFixture::ACL_FULL_ACCESS; } if (empty(static::$readOnlyAccessAcl)) { static::$readOnlyAccessAcl = new ApiTestAcl(); static::$readOnlyAccessAcl->setDb(Scalr::getContainer()->adodb); static::$readOnlyAccessAcl->createTestAccountRole(static::$user->getAccountId(), static::getTestName(ApiFixture::ACL_READ_ONLY_ACCESS), ApiTestAcl::ROLE_ID_READ_ONLY_ACCESS); static::$readOnlyAccessAcl->aclType = ApiFixture::ACL_READ_ONLY_ACCESS; } }