本文整理汇总了PHP中readConfig函数的典型用法代码示例。如果您正苦于以下问题:PHP readConfig函数的具体用法?PHP readConfig怎么用?PHP readConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gConfig
function gConfig($key)
{
static $config = null;
if ($config == null) {
$config = readConfig();
}
$ret = isset($config[$key]) ? $config[$key] : "";
return $ret;
}
示例2: getConnection
/**
* sets up the database connection and provides it to PHPUnit
*
* @see <https://phpunit.de/manual/current/en/database.html#database.configuration-of-a-phpunit-database-testcase>
* @return \PHPUnit_Extensions_Database_DB_IDatabaseConnection PHPUnit database connection interface
**/
public final function getConnection()
{
// if the connection hasn't been established, create it
if ($this->connection === null) {
// connect to mySQL and provide the interface to PHPUnit
$config = readConfig("/etc/apache2/data-design/dmcdonald21.ini");
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/dmcdonald21.ini");
$this->connection = $this->createDefaultDBConnection($pdo, $config["database"]);
}
return $this->connection;
}
示例3: getConnection
/**
* sets up the database connection and provides it to PHPUnit
*
* @see <https://phpunit.de/manual/current/en/database.html#database.configuration-of-a-phpunit-database-testcase>
* @return \PHPUnit_Extensions_Database_DB_IDatabaseConnection PHPUnit database connection interface
*/
public final function getConnection()
{
//If the connection has not been established yet, create it
if ($this->connection === null) {
//connect to mySQL and provide the interface to PHPUnit
$config = readConfig("/etc/apache2/capstone-mysql/jpegery.ini");
$pdo = connectToEncryptedMySQL("/etc/apache2/capstone-mysql/jpegery.ini");
$this->connection = $this->createDefaultDBConnection($pdo, $config["database"]);
}
return $this->connection;
}
示例4: getConnection
/**
* sets up the database connection and provides it to PHPUnit
*
* @see <https://phpunit.de/manual/current/en/database.html#database.configuration-of-a-phpunit-database-testcase>
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection PHPUnit database connection interface
**/
public final function getConnection()
{
// if the connection hasn't been established, create it
if ($this->connection === null) {
// grab the encrypted mySQL properties file and create the DSN
$config = readConfig("/etc/apache2/data-design/dmcdonald21.ini");
$dsn = "mysql:host=" . $config["hostname"] . ";dbname=" . $config["database"];
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8");
// provide the interface to PHPUnit
$pdo = new PDO($dsn, $config["username"], $config["password"], $options);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->connection = $this->createDefaultDBConnection($pdo, $config["database"]);
}
return $this->connection;
}
示例5: phptemplate_preprocess_page
function phptemplate_preprocess_page(&$vars) {
include_once("readConfig.php");
$config = readConfig();
$vars['scripts'] = $config['scripts'] . $vars['scripts'];
$vars['styles'] = $config['styles'] . $vars['styles'];
$suggestions = array();
if (module_exists('path')) {
$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
if(stristr($alias, "layer/")) {
$suggestions = array();
$suggestions[] = "page-layer";
$vars['template_files'] = $suggestions;
}
if($alias == "map") {
$suggestions = array();
$suggestions[] = "page-map";
$vars['template_files'] = $suggestions;
}
}
}
示例6: catch
echo "<p>* * * SIX OF THIRTEEN SKIPPED THIS GAME * * *</p>" . PHP_EOL;
}
}
}
}
} catch (Exception $exception) {
echo "Something went wrong: " . $exception->getMessage() . PHP_EOL;
} catch (TypeError $typeError) {
echo "Something went wrong: " . $typeError->getMessage() . PHP_EOL;
}
//downloader for players NFL
try {
$seasoning = ["2015", "2016"];
foreach ($seasoning as $season) {
$pdo = connectToEncryptedMySQL("/etc/apache2/capstone-mysql/sprots.ini");
$config = readConfig("/etc/apache2/capstone-mysql/sprots.ini");
$apiKeys = json_decode($config["fantasyData"]);
$opts = array('http' => array('method' => "GET", 'header' => "Content-Type: application/json\r\nOcp-Apim-Subscription-key: " . $apiKeys->NFL, 'content' => "{body}"));
$context = stream_context_create($opts);
//response from Api
$response = file_get_contents("https://api.fantasydata.net/nfl/v2/JSON/Players/{$season}", false, $context);
$data = json_decode($response);
$stats = ["PlayerID ", "Team", "Number ", "FirstName ", "LastName", "Status ", "Height ", "Weight", "BirthDate ", "College ", "Experience ", "Active ", "PositionCategory ", "Name", "Age ", "ExperienceString ", "BirthDateString", "PhotoUrl ", "ByeWeek ", "UpcomingGameOpponent ", "UpcomingGameWeek", "ShortName ", "AverageDraftPosition ", "DepthPositionCategory ", "DepthPosition ", "DepthOrder ", "DepthDisplayOrder ", "CurrentTeam ", "HeightFeet ", "UpcomingOpponentRank ", "UpcomingOpponentPositionRank ", "CurrentStatus"];
$sport = Sport::getSportBySportLeague($pdo, "NFL");
foreach ($data as $player) {
$team = Team::getTeamByTeamApiId($pdo, $player->TeamID);
if ($team !== null) {
$playerToInsert = new Player(null, $player->PlayerID, $team->getTeamId(), $sport->getSportId(), $player->FirstName . " " . $player->LastName);
$playerToInsert->insert($pdo);
$game = Game::getGameByGameFirstTeamId($pdo, $team->getTeamId());
if ($game === null) {
示例7: test
test('Cached value should exist');
asrt(apc_exists("configList"), "configList does not exist");
test('Should set cached value');
$list = apc_fetch("configList");
$passed = in_array('register', $list) && in_array('login', $list);
asrt($passed, http_build_query($list));
$writeconfig = file('register.example');
$readconfig = file('login.example');
require_once 'functions_main.inc';
testSuite('Read config test');
test('Should throw error on empty parameters');
readConfig(false);
throws("no action provided");
test('Should throw error on nonexistent action');
readConfig('some_weird_action');
throws("unrecognized action");
test('Action exists, but no file for it');
readConfig('login');
throws("unable to find config for this action");
test('Action exists, but no file for it');
$passed = readConfig('login', '.example');
asrt(startsWith($passed[0], 'IMPORT'), $passed[0]);
testSuite('Test import');
test('Should throw error on empty parameters');
$toParse[0] = 'IMPORT login.example';
$toParse[1] = 'DBCONFIG best : mana';
$parsed = doIMPORT($toParse);
$dbConfig = getDbConfigs($parsed);
$passed = $dbConfig['best'] == 'mana' && $dbConfig['user'] == 'loginreader';
asrt($passed, http_build_query($dbConfig));
finish();
示例8: readConfig
<?php
require_once 'functions_utility.inc';
require_once 'functions_main.inc';
$configLinesWithoutIncludes = readConfig($_GET["action"]);
checkIfError();
$configLinesWithIncludes = doIMPORT($configLinesWithoutIncludes);
checkIfError();
$linesToParse = stripComments($configLinesWithIncludes);
checkIfError();
checkMETHOD($linesToParse);
checkIfError();
$passedVariables = MapVariables($linesToParse);
checkIfError();
doCHECK($linesToParse, $passedVariables);
checkIfError();
$sqlConnection = initDB($linesToParse);
checkIfError();
doDBCHECK($linesToParse, $sqlConnection);
checkIfError();
doACTION($linesToParse, $sqlConnection);
checkIfError();
示例9: xml_parser_create
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $tags);
xml_parser_free($parser);
// loop through the structures
foreach ($tags as $key => $val) {
if ($key == "node") {
$noderanges = $val;
// each contiguous pair of array entries are the
// lower and upper range for each node definition
for ($i = 0; $i < count($noderanges); $i += 2) {
$offset = $noderanges[$i] + 1;
$len = $noderanges[$i + 1] - $offset;
$tdb[] = parseXML(array_slice($values, $offset, $len));
}
} else {
continue;
}
}
return $tdb;
}
function parseXML($mvalues)
{
for ($i = 0; $i < count($mvalues); $i++) {
$node[$mvalues[$i]["tag"]] = $mvalues[$i]["value"];
}
return new DataNode($node);
}
$db = readConfig("config.xml");
print_r($db);
示例10: dirname
require_once dirname(dirname(dirname(__DIR__))) . "/vendor/autoload.php";
require_once dirname(dirname(__DIR__)) . "/classes/misquote.php";
require_once dirname(dirname(__DIR__)) . "/lib/xsrf.php";
require_once "/etc/apache2/data-design/encrypted-config.php";
// start the session and create a XSRF token
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
// prepare an empty reply
$reply = new stdClass();
$reply->status = 200;
$reply->data = null;
try {
// create the Pusher connection
$config = readConfig("/etc/apache2/data-design/misquote.ini");
$pusherConfig = json_decode($config["pusher"]);
$pusher = new Pusher($pusherConfig->key, $pusherConfig->secret, $pusherConfig->id, ["encrypted" => true]);
// determine which HTTP method was used
$method = array_key_exists("HTTP_X_HTTP_METHOD", $_SERVER) ? $_SERVER["HTTP_X_HTTP_METHOD"] : $_SERVER["REQUEST_METHOD"];
// sanitize the id
$id = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT);
if (($method === "DELETE" || $method === "PUT") && (empty($id) === true || $id < 0)) {
throw new InvalidArgumentException("id cannot be empty or negative", 405);
}
// grab the mySQL connection
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/misquote.ini");
// handle all RESTful calls to Misquote
// get some or all Misquotes
if ($method === "GET") {
// set an XSRF cookie on GET requests
示例11: ini_set
*
* @category VuFind
* @package Utilities
* @author Tuan Nguyen <tuan@yorku.ca>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki Wiki
*/
ini_set('memory_limit', '50M');
ini_set('max_execution_time', '3600');
/**
* Set up util environment
*/
require_once 'util.inc.php';
require_once 'sys/ConnectionManager.php';
// Read Config file
$configArray = readConfig();
// Setup Solr Connection
$solr = ConnectionManager::connectToIndex('SolrReserves');
// Connect to ILS
$catalog = ConnectionManager::connectToCatalog();
// Records to index
$index = array();
// Get instructors
$instructors = $catalog->getInstructors();
// Get Courses
$courses = $catalog->getCourses();
// Get Departments
$departments = $catalog->getDepartments();
// Get all reserve records
$reserves = $catalog->findReserves('', '', '');
if (!empty($instructors) && !empty($courses) && !empty($departments) && !empty($reserves)) {
示例12: die
* @link http://vufind.org/wiki/migration_notes Wiki
*/
// Die if we don't have enough parameters:
if (!isset($argv[3]) || !isset($argv[2]) || !isset($argv[1])) {
die("\n\nMissing command line parameter... aborting database upgrade.\n\n");
}
$mysql_admin_user = $argv[1];
$mysql_admin_pw = $argv[2];
$old_config = $argv[3];
// Try to read the ini file:
$basePath = $old_config . '/web/conf';
if (!file_exists($basePath . '/config.ini')) {
die("\n\nCan't open {$basePath}/config.ini; aborting database upgrade.\n\n");
}
require_once dirname(__FILE__) . '/../web/sys/ConfigArray.php';
$configArray = readConfig($basePath);
?>
#### Database upgrade ####
This script will upgrade your VuFind database from the previous version to the new
release. It is recommended that you make a backup before proceeding with this
script, just to be on the safe side!
<?php
// get connection credentials from config.ini
$match = preg_match("/mysql:\\/\\/([^:]+):([^@]+)@([^\\/]+)\\/(.+)/", $configArray['Database']['database'], $mysql_conn);
if (!$match) {
echo "Can't determine data needed to access your MySQL database. You have " . $configArray['Database']['database'] . "\nas connection string in your config.ini.\n";
exit(0);
}
示例13: session_start
/**
* controller/api for the listing class
*
* @author Kimberly Keller keller.kimberly@gmail.com>
*/
//verify the xsrf challenge
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
//prepare an empty reply
$reply = new stdClass();
$reply->status = 200;
$reply->data = null;
try {
// create the Pusher connection
$config = readConfig("/etc/apache2/capstone-mysql/breadbasket.ini");
$pusherConfig = json_decode($config["pusher"]);
$pusher = new Pusher($pusherConfig->key, $pusherConfig->secret, $pusherConfig->id, ["debug" => true, "encrypted" => true]);
//grab the mySQL connection
$pdo = connectToEncryptedMySql("/etc/apache2/capstone-mysql/breadbasket.ini");
//if the volunteer session is empty, the user is not logged in, throw an exception
if (empty($_SESSION["volunteer"]) === true) {
setXsrfCookie("/");
throw new RuntimeException("Please log-in or sign up", 401);
}
//determine which HTTP method was used
$method = array_key_exists("HTTP_X_HTTP_METHOD", $_SERVER) ? $_SERVER["HTTP_X_HTTP_METHOD"] : $_SERVER["REQUEST_METHOD"];
//if a put and a volunteer, temporarily give admin access to the user
if ($method === "PUT") {
$_SESSION["volunteer"]->setVolIsAdmin(true);
}
示例14: send
/**
* Send due date reminders
*
* @return void
*/
public function send()
{
global $configArray;
global $interface;
global $translator;
$iso8601 = 'Y-m-d\\TH:i:s\\Z';
ini_set('display_errors', true);
$configArray = $mainConfig = readConfig();
$datasourceConfig = getExtraConfigArray('datasources');
$siteLocal = $configArray['Site']['local'];
// Set up time zone. N.B. Don't use msg() or other functions requiring date before this.
date_default_timezone_set($configArray['Site']['timezone']);
$this->msg('Sending due date reminders');
// Setup Local Database Connection
ConnectionManager::connectToDatabase();
// And index
$db = ConnectionManager::connectToIndex();
// Initialize Mailer
$mailer = new VuFindMailer();
// Find all scheduled alerts
$sql = 'SELECT * FROM "user" WHERE "due_date_reminder" > 0 ORDER BY id';
$user = new User();
$user->query($sql);
$this->msg('Processing ' . $user->N . ' users');
$interface = false;
$institution = false;
$todayTime = new DateTime();
$catalog = ConnectionManager::connectToCatalog();
while ($user->fetch()) {
if (!$user->email || trim($user->email) == '') {
$this->msg('User ' . $user->username . ' does not have an email address, bypassing due date reminders');
continue;
}
// Initialize settings and interface
$userInstitution = reset(explode(':', $user->username, 2));
if (!$institution || $institution != $userInstitution) {
$institution = $userInstitution;
if (!isset($datasourceConfig[$institution])) {
foreach ($datasourceConfig as $code => $values) {
if (isset($values['institution']) && strcasecmp($values['institution'], $institution) == 0) {
$institution = $code;
break;
}
}
}
if (!($configArray = $this->readInstitutionConfig($institution))) {
continue;
}
// Start Interface
$interface = new UInterface($siteLocal);
$validLanguages = array_keys($configArray['Languages']);
$dateFormat = new VuFindDate();
}
$language = $user->language;
if (!in_array($user->language, $validLanguages)) {
$language = $configArray['Site']['language'];
}
$translator = new I18N_Translator(array($configArray['Site']['local'] . '/lang', $configArray['Site']['local'] . '/lang_local'), $language, $configArray['System']['debug']);
$interface->setLanguage($language);
// Go through accounts and check loans
$account = new User_account();
$account->user_id = $user->id;
if (!$account->find(false)) {
continue;
}
$remindLoans = array();
while ($account->fetch()) {
$patron = $catalog->patronLogin($account->cat_username, $account->cat_password);
if ($patron === null || PEAR::isError($patron)) {
$this->msg('Catalog login failed for user ' . $user->id . ', account ' . $account->id . ' (' . $account->cat_username . '): ' . ($patron ? $patron->getMessage() : 'patron not found'));
continue;
}
$loans = $catalog->getMyTransactions($patron);
if (PEAR::isError($loans)) {
$this->msg('Could not fetch loans for user ' . $user->id . ', account ' . $account->id . ' (' . $account->cat_username . ')');
continue;
}
foreach ($loans as $loan) {
$dueDate = new DateTime($loan['duedate']);
if ($todayTime >= $dueDate || $dueDate->diff($todayTime)->days <= $user->due_date_reminder) {
// Check that a reminder hasn't been sent already
$reminder = new Due_date_reminder();
$reminder->user_id = $user->id;
$reminder->loan_id = $loan['item_id'];
$reminder->due_date = $dueDate->format($iso8601);
if ($reminder->find(false)) {
// Reminder already sent
continue;
}
// Store also title for display in email
$title = isset($loan['title']) ? $loan['title'] : translate('Title not available');
if (isset($loan['id'])) {
$record = $db->getRecord($loan['id']);
if ($record && isset($record['title'])) {
$title = $record['title'];
//.........这里部分代码省略.........
示例15: setTcObjectComment
function setTcObjectComment($dev, $obj, $head, $body)
{
if (!ctype_alnum($dev)) {
dieErr("malformed dev");
}
$config = readConfig();
if (!is_array($config[$dev])) {
$config[$dev] = array();
}
if (strlen($head) == 0 && strlen($body) == 0) {
if (is_array($config[$dev]["comments"])) {
unset($config[$dev]["comments"][$obj]);
}
} else {
if (!is_array($config[$dev]["comments"])) {
$config[$dev]["comments"] = array();
}
$config[$dev]["comments"][$obj] = array($head, $body);
}
saveConfig($config);
}