本文整理汇总了PHP中Q_Config::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Q_Config::set方法的具体用法?PHP Q_Config::set怎么用?PHP Q_Config::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Q_Config
的用法示例。
在下文中一共展示了Q_Config::set方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Broadcast_control_response_content
function Broadcast_control_response_content($params)
{
$user = Users::loggedInUser(true);
$organizations = Broadcast_Agreement::select('a.userId, a.publisherId, u.organization_title, u.organization_domain', 'a')->join(Broadcast_User::table() . ' u', array('a.publisherId' => 'u.userId'))->where(array('a.userId' => $user->id))->fetchAll(PDO::FETCH_ASSOC);
foreach ($organizations as $k => $org) {
$messages = Streams_Message::select('content')->where(array('publisherId' => $org['publisherId'], 'streamName' => 'Broadcast/main'))->orderBy('sentTime')->fetchAll(PDO::FETCH_ASSOC);
$organizations[$k]['messages'] = array();
foreach ($messages as $msg) {
$content = json_decode($msg['content'], true);
if (isset($content['link'])) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $content['link']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; cs-CZ; rv:1.7.12) Gecko/20050929");
$page_contents = curl_exec($ch);
curl_close($ch);
preg_match('/<title>([^<]+)<\\/title>/', $page_contents, $matches);
if (isset($matches[1])) {
$content['link_title'] = $matches[1];
}
}
$organizations[$k]['messages'][] = $content;
}
}
Q_Config::set('Q', 'response', 'Broadcast', 'layout_html', 'Broadcast/layout/canvas.php');
Q_Response::addStylesheet('css/canvas.css');
Q_Response::addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
Q_Response::addScript('js/canvas.js');
return Q::view('Broadcast/content/control.php', compact('organizations'));
}
示例2: Q_init
function Q_init()
{
// apc_clear_cache('user');
// the following statement causes the session to be opened for every request
if (!empty($_SERVER['HTTP_HOST'])) {
Q_Session::setNonce();
}
if (Q_Config::get('Trump', 'testing', false)) {
apc_clear_cache('user');
}
$logging = Q_Config::get('Db', 'logging', true);
if ($logging) {
Q::log("\n-----");
Q_Config::set('Q', 'handlersAfterEvent', 'Db/query/execute', 'log_shard_query');
}
}
示例3: Q_init
function Q_init()
{
if (Q_Config::get('Db', 'logging', true)) {
// logging database queries
Q::log("\n-----");
Q_Config::set('Q', 'handlersAfterEvent', 'Db/query/execute', 'log_shard_query');
Q_Config::set('Q', 'handlersAfterEvent', 'Db/query/exception', 'log_shard_query');
}
if (!empty($_SERVER['HTTP_HOST'])) {
// the following statement causes the session to be opened for every request
Q_Session::setNonce();
}
if (Q_Config::get('Shipping', 'testing', false)) {
// sometimes the APC can cause files to appear missing
// if they were created after it tried to load them once
apc_clear_cache('user');
}
}
示例4: Broadcast_widget_response
function Broadcast_widget_response()
{
$app = Q_Config::expect('Q', 'app');
Q_Config::set('Q', 'response', 'layout', 'html', "{$app}/layout/widget.php");
Q_Config::set('Q', 'response', $app, 'slotNames', array('widget', 'title', 'notices'));
}
示例5: hashPassphrase
/**
* Hashes a passphrase
* @method hashPassphrase
* @static
* @param {string} $passphrase the passphrase to hash
* @param {string} [$existing_hash=null] must provide when comparing with a passphrase
* hash that has been already stored. It contains the salt for the passphrase.
* @return {string} the hashed passphrase, or "" if the passphrase was ""
*/
static function hashPassphrase($passphrase, $existing_hash = null)
{
if ($passphrase === '') {
return '';
}
$hash_function = Q_Config::get('Users', 'passphrase', 'hashFunction', 'sha1');
$passphraseHash_iterations = Q_Config::get('Users', 'passphrase', 'hashIterations', 1103);
$salt_length = Q_Config::set('Users', 'passphrase', 'saltLength', 0);
if ($salt_length > 0) {
if (empty($existing_hash)) {
$salt = substr(sha1(uniqid(mt_rand(), true)), 0, $salt_length);
} else {
$salt = substr($existing_hash, -$salt_length);
}
}
$salt2 = isset($salt) ? '_' . $salt : '';
$result = $passphrase;
// custom hash function
if (!is_callable($hash_function)) {
throw new Q_Exception_MissingFunction(array('function_name' => $hash_function));
}
$confounder = $passphrase . $salt2;
$confounder_len = strlen($confounder);
for ($i = 0; $i < $passphraseHash_iterations; ++$i) {
$result = call_user_func($hash_function, $result . $confounder[$i % $confounder_len]);
}
$result .= $salt2;
return $result;
}
示例6: addAlias
/**
* Adds the first alias to the configuration
* @method addAlias
* @static
*/
static function addAlias()
{
if (defined('APP_WEB_DIR')) {
Q_Config::set('Q', 'aliases', '', APP_WEB_DIR);
}
}
示例7: setShard
/**
* Add a named shard under a database connection
* Can contain the keys "dsn", "username", "password", "driver_options"
* They are used in constructing the PDO object.
* @method setShard
* @static
* @deprecated Shards configuration is maintained via config
* @param {string} $conn_name
* The name of the connection to which the shard pertains
* @param {string} $shard_name
* The name under which to store the shard modifications
* @param {array} $modifications
* The shard modifications. Can include the keys:
* 'dsn', 'host', 'port', 'dbname', 'unix_socket', 'charset',
* 'username', 'password', 'driver_options',
*/
static function setShard($conn_name, $shard_name, $modifications)
{
if (class_exists('Q_Config')) {
Q_Config::set('Db', 'connections', $conn_name, 'shards', $shard_name, $modifications);
} else {
// Standalone, no Q
self::$shards[$conn_name][$shard_name] = $modifications;
}
}
示例8: split
//.........这里部分代码省略.........
echo "Table name is not defined\n";
return false;
}
if (!($shard = $config->get('shard', false)) && Q_Config::get('Db', 'connections', $connection, 'shards', false)) {
echo "Shard to partition is not defined\n";
return false;
}
if (!($parts = $config->get('parts', false))) {
echo "New parts are not defined\n";
return false;
}
if ($node = $config->get('node', null)) {
$nodeInternal = Q_Config::expect('Q', 'nodeInternal');
$node = array("http://{$nodeInternal['host']}:{$nodeInternal['port']}/Q_Utils/query", $node);
}
// now we shall distinguish if table is already sharded or not
if ($shard === false) {
if (!($fields = $config->get('fields', false))) {
echo "To start sharding you shall define 'fields' parameter\n";
return false;
}
}
// weather provided split config is mapped or not
$split_mapped = array_keys($parts) !== range(0, count($parts) - 1);
// set up config for shards if it does not exist yet
if ($shard === false) {
$partition = array();
foreach ($fields as $name => $hash) {
if (empty($hash)) {
$hash = 'md5';
}
$part = explode('%', $hash);
$hash = $part[0];
$len = isset($part[1]) ? $part[1] : Db_Query::HASH_LEN;
// "0" has the lowest ascii code for both md5 and normalize
// $partition[] = $hash === 'md5' ? str_pad('', $len, "0", STR_PAD_LEFT) : str_pad('', $len, " ", STR_PAD_LEFT);
$partition[] = str_pad('', $len, "0", STR_PAD_LEFT);
}
$shard = join('.', $partition);
if (Q_Config::get('Db', 'connections', $connection, 'indexes', $table, false)) {
echo "Shards are not defined but indexes for table '{$table}' are defined in local config\n";
return false;
}
// Let's merge in dummy shards section - shard with name '' is handled as single table
Q_Config::merge(array('Db' => array('connections' => array($connection => array("shards" => array(), "indexes" => array($table => array("fields" => $fields, "partition" => $split_mapped ? array($shard => '') : array($shard))))))));
$shard_name = '';
}
// get partition information
if (!($partition = Q_Config::get('Db', 'connections', $connection, 'indexes', $table, 'partition', false))) {
echo "Upps, cannot get shards partitioning\n";
return false;
}
// weather main config is mapped or not
// also $points contains the partitioning array without mapping
$points = ($mapped = array_keys($partition) !== range(0, count($partition) - 1)) ? array_keys($partition) : $partition;
$i = array_search($shard, $points);
$next = isset($points[++$i]) ? $points[$i] : null;
$fields = Q_Config::expect('Db', 'connections', $connection, 'indexes', $table, 'fields');
// now $shard and $next contain boundaries for data to split
// $points contain partitioning array without mapping - array
// $parts contains split parts (shards) definition - array or object ($split_mapped)
// $partition contains current partitioning - array or object ($mapped)
// $fields contains field names and hashes
// time to calculate new split point(s)
if (!isset($shard_name)) {
$shard_name = $mapped ? $partition[$shard] : $shard;
示例9: installPlugin
/**
* @method installPlugin
* @static
* @param {string} $plugin_name
* @param {array} $options
* @throws {Exception}
*/
static function installPlugin($plugin_name, $options)
{
set_time_limit(Q_Config::expect('Q', 'install', 'timeLimit'));
// Connect Qbix platform if it's not already connected
self::prepare();
$app_dir = APP_DIR;
$plugin_dir = Q_PLUGINS_DIR . DS . $plugin_name;
$app_web_plugins_dir = APP_WEB_DIR . DS . 'plugins';
echo "Installing plugin '{$plugin_name}' into '{$app_dir}'" . PHP_EOL;
// Do we even have such a plugin?
if (!is_dir($plugin_dir)) {
throw new Exception("Plugin '{$plugin_name}' not found in " . Q_PLUGINS_DIR);
}
// Ensure that the plugin has config.json
if (!file_exists($plugin_conf_file = $plugin_dir . DS . 'config' . DS . 'plugin.json')) {
throw new Exception("Could not load plugin's config. Check {$plugin_conf_file}");
}
$files_dir = $plugin_dir . DS . 'files';
$app_plugins_file = APP_LOCAL_DIR . DS . 'plugins.json';
// Check access to $app_web_plugins_dir
if (!file_exists($app_web_plugins_dir)) {
if (!@mkdir($app_web_plugins_dir, 0755, true)) {
throw new Exception("Could not create {$app_web_plugins_dir}");
}
}
if (!is_dir($app_web_plugins_dir)) {
throw new Exception("{$app_web_plugins_dir} exists, but is not a directory");
} elseif (!is_writable($app_web_plugins_dir)) {
throw new Exception("Can not write to {$app_web_plugins_dir}");
}
// Check access to $app_plugins_file
if (file_exists($app_plugins_file) && !is_writable($app_plugins_file)) {
throw new Exception("Can not write to {$app_plugins_file}");
} elseif (!file_exists($app_plugins_file) && !is_writable(dirname($app_plugins_file))) {
throw new Exception("Can not write to " . dirname($app_plugins_file));
}
// Check access to $files_dir
if (!file_exists($files_dir)) {
if (!@mkdir($files_dir, $options['dirmode'], true)) {
throw new Exception("Could not create {$files_dir}");
}
}
// Do we now have plugin's config?
if (Q_Config::get('Q', 'pluginInfo', $plugin_name, 'version', null) == null) {
throw new Exception("Could not identify plugin version. Check {$plugin_conf_file}");
}
$plugin_conf = Q_Config::get('Q', 'pluginInfo', $plugin_name, null);
$plugin_version = $plugin_conf['version'];
if (file_exists($app_plugins_file)) {
Q_Config::load($app_plugins_file, true);
}
// Do we already have this plugin installed for this app?
// Check requirements for plugin (will throw exceptions if they aren't met)
if (!isset($options['noreq']) || !$options['noreq']) {
echo "Checking requirements" . PHP_EOL;
Q_Bootstrap::checkRequirements(array($plugin_name));
}
// Checking LOCAL plugin version in plugins.json file
if (($version_installed = Q_Config::get('Q', 'pluginLocal', $plugin_name, 'version', null)) != null) {
//We have this plugin installed
echo "Plugin '{$plugin_name}' (version: {$version_installed}) is already installed" . PHP_EOL;
if (Q::compare_version($version_installed, $plugin_version) < 0) {
echo "Upgrading '{$plugin_name}' to version: {$plugin_version}" . PHP_EOL;
}
}
// Check and fix permissions
self::checkPermissions($files_dir, $options);
if (isset($plugin_conf['permissions'])) {
foreach ($plugin_conf['permissions'] as $perm) {
self::checkPermissions($files_dir . DS . $perm, $options);
}
}
// Symbolic links
echo 'Creating symbolic links' . PHP_EOL;
self::symlink($plugin_dir . DS . 'web', $app_web_plugins_dir . DS . $plugin_name);
// Checking if schema update is requested and updating database version
$connections = Q_Config::get('Q', 'pluginInfo', $plugin_name, 'connections', array());
foreach ($connections as $connection) {
self::installSchema(Q_PLUGINS_DIR . DS . $plugin_name, $plugin_name, 'plugin', $connection, $options);
}
// Push plugin name into Q/plugins array
if (!in_array($plugin_name, $current_plugins = Q_Config::get('Q', 'plugins', array()))) {
$current_plugins[] = $plugin_name;
Q_Config::set('Q', 'plugins', $current_plugins);
//TODO: When do we save Q/plugins to disk?
}
// Save info about plugin
echo 'Registering plugin' . PHP_EOL;
Q_Config::set('Q', 'pluginLocal', $plugin_name, $plugin_conf);
Q_Config::save($app_plugins_file, array('Q', 'pluginLocal'));
echo Q_Utils::colored("Plugin '{$plugin_name}' successfully installed" . PHP_EOL, 'green');
}