本文整理汇总了PHP中config::find方法的典型用法代码示例。如果您正苦于以下问题:PHP config::find方法的具体用法?PHP config::find怎么用?PHP config::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config
的用法示例。
在下文中一共展示了config::find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = config::find();
if (!isset($params['sort'])) {
$query->orderBy(['id_config' => SORT_DESC]);
}
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id_config' => $this->id_config, 'config_name' => $this->config_name, 'config_value' => $this->config_value]);
$query->andFilterWhere(['like', 'config_name', $this->config_name])->andFilterWhere(['like', 'config_value', $this->config_value]);
return $dataProvider;
}
示例2: upgrade
public function upgrade()
{
//get the db variables
$config = new config();
$config_exists = $config->exists();
$config_path = $config->find();
$config->get();
$db_type = $config->db_type;
$db_name = $config->db_name;
$db_username = $config->db_username;
$db_password = $config->db_password;
$db_host = $config->db_host;
$db_path = $config->db_path;
$db_port = $config->db_port;
//get the PROJECT PATH
include "root.php";
//get the list of installed apps from the core and app directories (note: GLOB_BRACE doesn't work on some systems)
$config_list_1 = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$config_list_2 = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_menu.php");
$config_list = array_merge((array) $config_list_1, (array) $config_list_2);
unset($config_list_1, $config_list_2);
$db = $this->db;
$x = 0;
foreach ($config_list as &$config_path) {
include $config_path;
$x++;
}
//get the domains
$sql = "select * from v_domains ";
$prep_statement = $this->db->prepare($sql);
$prep_statement->execute();
$domains = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement);
//get the domain_settings
$sql = "select * from v_domain_settings ";
$sql .= "where domain_setting_enabled = 'true' ";
$prep_statement = $this->db->prepare($sql);
$prep_statement->execute();
$domain_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement);
//get the default settings
$sql = "select * from v_default_settings ";
$sql .= "where default_setting_enabled = 'true' ";
$prep_statement = $this->db->prepare($sql);
$prep_statement->execute();
$database_default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($prep_statement);
//get the domain_uuid
foreach ($domains as $row) {
if (count($domains) == 1) {
$_SESSION["domain_uuid"] = $row["domain_uuid"];
$_SESSION["domain_name"] = $row['domain_name'];
} else {
if (lower_case($row['domain_name']) == lower_case($domain_array[0]) || lower_case($row['domain_name']) == lower_case('www.' . $domain_array[0])) {
$_SESSION["domain_uuid"] = $row["domain_uuid"];
$_SESSION["domain_name"] = $row['domain_name'];
}
$_SESSION['domains'][$row['domain_uuid']]['domain_uuid'] = $row['domain_uuid'];
$_SESSION['domains'][$row['domain_uuid']]['domain_name'] = $row['domain_name'];
}
}
//loop through all domains
$domain_count = count($domains);
$domains_processed = 1;
foreach ($domains as &$row) {
//get the values from database and set them as php variables
$domain_uuid = $row["domain_uuid"];
$domain_name = $row["domain_name"];
//get the context
$context = $domain_name;
//show the domain when display_type is set to text
if ($display_type == "text") {
echo "\n";
echo $domain_name;
echo "\n";
}
//get the default settings - this needs to be done to reset the session values back to the defaults for each domain in the loop
foreach ($database_default_settings as $row) {
$name = $row['default_setting_name'];
$category = $row['default_setting_category'];
$subcategory = $row['default_setting_subcategory'];
if (strlen($subcategory) == 0) {
if ($name == "array") {
$_SESSION[$category][] = $row['default_setting_value'];
} else {
$_SESSION[$category][$name] = $row['default_setting_value'];
}
} else {
if ($name == "array") {
$_SESSION[$category][$subcategory][] = $row['default_setting_value'];
} else {
$_SESSION[$category][$subcategory]['uuid'] = $row['default_setting_uuid'];
$_SESSION[$category][$subcategory][$name] = $row['default_setting_value'];
}
}
}
//get the domains settings for the current domain
foreach ($domain_settings as $row) {
if ($row['domain_uuid'] == $domain_uuid) {
$name = $row['domain_setting_name'];
//.........这里部分代码省略.........
示例3: testProtectedConfigSettings
/**
* @depends testInitSessionCredentials
*/
public function testProtectedConfigSettings($session_token)
{
$sensitiveSettings = array('proxy_passwd', 'smtp_passwd');
// set a non empty value to the sessionts to check
foreach ($sensitiveSettings as $name) {
Config::setConfigurationValues('core', array($name => 'not_empty_password'));
$value = Config::getConfigurationValues('core', array($name));
$this->assertArrayHasKey($name, $value);
$this->assertNotEmpty($value[$name]);
}
$where = "'" . implode("', '", $sensitiveSettings) . "'";
$config = new config();
$rows = $config->find("`context`='core' AND `name` IN ({$where})");
$this->assertEquals(count($sensitiveSettings), count($rows));
// Check the value is not retrieved for sensitive settings
foreach ($rows as $row) {
$res = $this->doHttpRequest('GET', "Config/" . $row['id'], ['headers' => ['Session-Token' => $session_token]]);
$this->assertEquals(200, $res->getStatusCode());
$body = $res->getBody();
$data = json_decode($body, true);
$this->assertEquals('', $data['value']);
}
// Check an other setting is disclosed (when not empty)
$config = new Config();
$config->getFromDBByQuery("WHERE `context`='core' AND `name`='admin_email'");
$res = $this->doHttpRequest('GET', "Config/" . $config->getID(), ['headers' => ['Session-Token' => $session_token]]);
$this->assertEquals(200, $res->getStatusCode());
$body = $res->getBody();
$data = json_decode($body, true);
$this->assertNotEquals('', $data['value']);
// Check a search does not disclose sensitive values
$criteria = array();
$queryString = "";
foreach ($rows as $row) {
$queryString = "&criteria[][link]=or&criteria[][field]=1&criteria[][searchtype]=equals&criteria[][value]=" . $row['name'];
}
$res = $this->doHttpRequest('GET', "search/Config" . "?{$queryString}", ['headers' => ['Session-Token' => $session_token], 'query' => array()]);
$this->assertEquals(200, $res->getStatusCode());
$body = $res->getBody();
$data = json_decode($body, true);
foreach ($data['data'] as $row) {
foreach ($row as $col) {
$this->assertNotEquals($col, 'not_empty_password');
}
}
}
示例4: config
<?php
require_once 'config.inc';
$ob = new config();
$ob->set_file("./config.conf");
print $ob->find("test4") . "\n";
$ret = $ob->find_array("test");
foreach ($ret as $wk) {
print "{$wk}, ";
}
print "\n";
示例5: schema
public function schema($format = '')
{
//set the global variable
global $db, $upgrade_data_types, $text, $output_format;
if ($format == '') {
$format = $output_format;
}
//get the db variables
$config = new config();
$config_exists = $config->exists();
$config_path = $config->find();
$config->get();
$db_type = $config->db_type;
$db_name = $config->db_name;
$db_username = $config->db_username;
$db_password = $config->db_password;
$db_host = $config->db_host;
$db_path = $config->db_path;
$db_port = $config->db_port;
//get the PROJECT PATH
include "root.php";
//add multi-lingual support
if (!isset($text)) {
$language = new text();
$text = $language->get(null, 'core/upgrade');
}
//PHP PDO check if table or column exists
//check if table exists
// SELECT * FROM sqlite_master WHERE type='table' AND name='v_cdr'
//check if column exists
// SELECT * FROM sqlite_master WHERE type='table' AND name='v_cdr' AND sql LIKE '%caller_id_name TEXT,%'
//aditional information
// http://www.sqlite.org/faq.html#q9
//postgresql
//list all tables in the database
// SELECT table_name FROM pg_tables WHERE schemaname='public';
//check if table exists
// SELECT * FROM pg_tables WHERE schemaname='public' AND table_name = 'v_groups'
//check if column exists
// SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'v_cdr') AND attname = 'caller_id_name';
//mysql
//list all tables in the database
// SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'fusionpbx'
//check if table exists
// SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'fusionpbx' AND TABLE_NAME = 'v_groups'
//check if column exists
// SELECT * FROM information_schema.COLUMNS where TABLE_SCHEMA = 'fusionpbx' AND TABLE_NAME = 'v_cdr' AND COLUMN_NAME = 'context'
//oracle
//check if table exists
// SELECT TABLE_NAME FROM ALL_TABLES
//get the $apps array from the installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x = 0;
foreach ($config_list as &$config_path) {
include $config_path;
$x++;
}
//update the app db array add exists true or false
$sql = '';
foreach ($apps as $x => &$app) {
if (isset($app['db'])) {
foreach ($app['db'] as $y => &$row) {
if (is_array($row['table'])) {
$table_name = $row['table']['text'];
} else {
$table_name = $row['table'];
}
if (strlen($table_name) > 0) {
//check if the table exists
if ($this->db_table_exists($db_type, $db_name, $table_name)) {
$apps[$x]['db'][$y]['exists'] = 'true';
} else {
$apps[$x]['db'][$y]['exists'] = 'false';
}
//check if the column exists
foreach ($row['fields'] as $z => $field) {
if ($field['deprecated'] == "true") {
//skip this field
} else {
if (is_array($field['name'])) {
$field_name = $field['name']['text'];
} else {
$field_name = $field['name'];
}
if (strlen(field_name) > 0) {
if ($this->db_column_exists($db_type, $db_name, $table_name, $field_name)) {
//found
$apps[$x]['db'][$y]['fields'][$z]['exists'] = 'true';
} else {
//not found
$apps[$x]['db'][$y]['fields'][$z]['exists'] = 'false';
}
}
unset($field_name);
}
}
unset($table_name);
}
}
}
//.........这里部分代码省略.........