本文整理汇总了PHP中configure函数的典型用法代码示例。如果您正苦于以下问题:PHP configure函数的具体用法?PHP configure怎么用?PHP configure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了configure函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init(array $argv = array(), $verbosity = 0)
{
$this->_verbosity = $verbosity;
/* First element is the php script name. Store it for debugging. */
$this->_php_exec = array_shift($argv);
/* Second element is just the executable we called to run ZF commands. Store it for printing errors/usage. */
$this->_native_exec = array_shift($argv);
$opts = $this->getOptions()->addArguments($argv);
$opts->parse();
// Shortcut to verbosity option so that we can display more earlier
if (isset($opts->verbosity)) {
$this->_verbosity = $opts->verbosity;
}
// Shortcut to help option so that no arguments have to be specified
if (isset($opts->help)) {
$this->printHelp();
return null;
}
try {
$actionName = array_shift($argv);
$context = Zend_Build_Manifest::getInstance()->getContext(self::MF_ACTION_TYPE, $actionName);
$config = $this->_parseParams($context, $argv);
$action = new $context->class();
$action . setConfig($config);
$action . configure();
} catch (Zend_Console_Exception $e) {
throw $e->prependUsage($this->getUsage());
}
return $this;
}
示例2: configureWebService
/**
* Prompts the user for web service configuration details based on the given
* named web service.
*
* @param $serviceName {String}
* The name of the web service to configure.
*
* @return {String}
* The configuration string for the web service. Formatted as follows:
*
* {serviceName}|{serviceMeta}|{serviceHandler}
*
* Where
* serviceName is the named web service
* serviceMeta is the URL to fetch metadata for the named service
* serviceHandler is the JS class to use when handling responses
*/
function configureWebService($serviceName)
{
print "\nConfiguration details for {$serviceName}...\n";
$serviceMeta = configure('SERVICE_META', '/', ' Meta URL');
$serviceHandler = configure('SERVICE_HANDLER', 'HazardResponse', ' Response Handler');
return "{$serviceName}|{$serviceMeta}|{$serviceHandler}";
}
示例3: main
/**
* Create package.xml
*
* @param boolean $debug
* @return void
*/
function main($debug = true)
{
if (file_exists(PACAGE_XML)) {
fputs(STDOUT, 'ignore existing package.xml? [y/N]: ');
$noChangeLog = 0 === strncasecmp(trim(fgets(STDIN)), 'y', 1);
} else {
$noChangeLog = false;
}
if ($noChangeLog) {
rename(PACAGE_XML, PACAGE_XML . '.orig');
}
$package = init(configure(PACAGE_YML));
$package->generateContents();
if ($debug) {
$package->debugPackageFile();
if ($noChangeLog) {
rename(PACAGE_XML . '.orig', PACAGE_XML);
}
} else {
$package->writePackageFile();
}
}
示例4: promptYesNo
<?php
// ----------------------------------------------------------------------
// Admin data download/uncompress
// ----------------------------------------------------------------------
$answer = promptYesNo("\nUpdating administrative dataset. Existing data will be deleted, continue?", true);
if (!$answer) {
echo "Skipping administrative.\n";
return;
}
$adminSql = configure('ADMIN_SQL', $defaultScriptDir . DIRECTORY_SEPARATOR . 'admin.sql', "Admin regions schema script");
$dbInstaller->runScript($adminSql);
echo "Success!!\n";
// download admin region data
echo "\nDownloading and loading admin region data:\n";
$url = configure('GLOBAL_ADMIN_URL', 'ftp://hazards.cr.usgs.gov/web/hazdev-geoserve-ws/admin/', "Admin download url");
$filenames = array('globaladmin.zip');
$download_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR;
// create temp directory
mkdir($download_path);
foreach ($filenames as $filename) {
$downloaded_file = $download_path . $filename;
downloadURL($url . $filename, $downloaded_file);
// uncompress admin data
if (pathinfo($downloaded_file)['extension'] === 'zip') {
print 'Extracting ' . $downloaded_file . "\n";
extractZip($downloaded_file, $download_path);
}
}
// ----------------------------------------------------------------------
// Admin data load
示例5: date_default_timezone_set
<?php
date_default_timezone_set('UTC');
// work from lib directory
chdir(dirname($argv[0]));
$CONFIG_FILE = '../conf/config.ini';
// Initial configuration stuff
if (!file_exists($CONFIG_FILE)) {
print "{$CONFIG_FILE} not found. Please configure the application " . 'before trying to set up the database. Configuration can be ' . "done as part of the installation process.\n";
exit(-1);
}
include_once 'install-funcs.inc.php';
include_once '../conf/config.inc.php';
$dataDirectory = configure('DATA_DIR', $CONFIG['DATA_DIR'], 'Enter directory where observatory files can be located');
if (!file_exists($dataDirectory)) {
print "\tThe indicated directory does not exist. Please try again.\n";
exit(-1);
}
include_once 'classes/ObservationFileParser.class.php';
$parser = new ObservationFileParser($OBSERVATORY_FACTORY, $USER_FACTORY);
$files = recursiveGlob($dataDirectory, '*.bns');
$errorCount = 0;
foreach ($files as $file) {
$warnings = array();
try {
$observation = $parser->parse($file, $warnings);
$OBSERVATION_FACTORY->createObservation($observation);
} catch (Exception $e) {
$warnings[] = $e->getMessage();
}
if (count($warnings) !== 0) {
示例6: config
public function config($args = null)
{
$result = configure($args);
return $result;
}
示例7: hello
<?php
require 'frank.php';
class Helpers
{
function hello($name)
{
return "Hello, {$name}";
}
}
configure(function () {
$test = 'test';
set(array('views' => dirname(__FILE__) . '/templates'));
});
after(function () {
echo " AFTER!";
});
get("/", function () {
render('form', array('locals' => array('test' => 'test')));
});
template("form", function ($locals) {
echo '<form method="post">
<input type="submit" value="submit" />
</form>';
});
post("/", function () {
echo "post";
});
get("/hello/:name", function ($params) {
pass('/hello/' . $params['name'] . '/test');
});
示例8: create_admin_user
function create_admin_user()
{
global $output, $mybb, $errors, $db, $lang;
$mybb->input['action'] = "adminuser";
// If no errors then check for errors from last step
if (!is_array($errors)) {
if (empty($mybb->input['bburl'])) {
$errors[] = $lang->config_step_error_url;
}
if (empty($mybb->input['bbname'])) {
$errors[] = $lang->config_step_error_name;
}
if (is_array($errors)) {
configure();
}
}
$output->print_header($lang->create_admin, 'admin');
if (is_array($errors)) {
$error_list = error_list($errors);
echo $lang->sprintf($lang->admin_step_error_config, $error_list);
$adminuser = $mybb->input['adminuser'];
$adminemail = $mybb->input['adminemail'];
} else {
require MYBB_ROOT . 'inc/config.php';
$db = db_connection($config);
echo $lang->admin_step_setupsettings;
$settings = file_get_contents(INSTALL_ROOT . 'resources/settings.xml');
$parser = new XMLParser($settings);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
// Insert all the settings
foreach ($tree['settings'][0]['settinggroup'] as $settinggroup) {
$groupdata = array('name' => $db->escape_string($settinggroup['attributes']['name']), 'title' => $db->escape_string($settinggroup['attributes']['title']), 'description' => $db->escape_string($settinggroup['attributes']['description']), 'disporder' => intval($settinggroup['attributes']['disporder']), 'isdefault' => $settinggroup['attributes']['isdefault']);
$gid = $db->insert_query('settinggroups', $groupdata);
++$groupcount;
foreach ($settinggroup['setting'] as $setting) {
$settingdata = array('name' => $db->escape_string($setting['attributes']['name']), 'title' => $db->escape_string($setting['title'][0]['value']), 'description' => $db->escape_string($setting['description'][0]['value']), 'optionscode' => $db->escape_string($setting['optionscode'][0]['value']), 'value' => $db->escape_string($setting['settingvalue'][0]['value']), 'disporder' => intval($setting['disporder'][0]['value']), 'gid' => $gid, 'isdefault' => 1);
$db->insert_query('settings', $settingdata);
$settingcount++;
}
}
if (my_substr($mybb->input['bburl'], -1, 1) == '/') {
$mybb->input['bburl'] = my_substr($mybb->input['bburl'], 0, -1);
}
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['bbname'])), "name='bbname'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['bburl'])), "name='bburl'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['websitename'])), "name='homename'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['websiteurl'])), "name='homeurl'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['cookiedomain'])), "name='cookiedomain'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['cookiepath'])), "name='cookiepath'");
$db->update_query("settings", array('value' => $db->escape_string($mybb->input['contactemail'])), "name='adminemail'");
$db->update_query("settings", array('value' => 'mailto:' . $db->escape_string($mybb->input['contactemail'])), "name='contactlink'");
write_settings();
echo $lang->sprintf($lang->admin_step_insertesettings, $settingcount, $groupcount);
include_once MYBB_ROOT . "inc/functions_task.php";
$tasks = file_get_contents(INSTALL_ROOT . 'resources/tasks.xml');
$parser = new XMLParser($tasks);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
// Insert scheduled tasks
foreach ($tree['tasks'][0]['task'] as $task) {
$new_task = array('title' => $db->escape_string($task['title'][0]['value']), 'description' => $db->escape_string($task['description'][0]['value']), 'file' => $db->escape_string($task['file'][0]['value']), 'minute' => $db->escape_string($task['minute'][0]['value']), 'hour' => $db->escape_string($task['hour'][0]['value']), 'day' => $db->escape_string($task['day'][0]['value']), 'weekday' => $db->escape_string($task['weekday'][0]['value']), 'month' => $db->escape_string($task['month'][0]['value']), 'enabled' => $db->escape_string($task['enabled'][0]['value']), 'logging' => $db->escape_string($task['logging'][0]['value']));
$new_task['nextrun'] = fetch_next_run($new_task);
$db->insert_query("tasks", $new_task);
$taskcount++;
}
echo $lang->sprintf($lang->admin_step_insertedtasks, $taskcount);
$views = file_get_contents(INSTALL_ROOT . 'resources/adminviews.xml');
$parser = new XMLParser($views);
$parser->collapse_dups = 0;
$tree = $parser->get_tree();
// Insert admin views
foreach ($tree['adminviews'][0]['view'] as $view) {
$fields = array();
foreach ($view['fields'][0]['field'] as $field) {
$fields[] = $field['attributes']['name'];
}
$conditions = array();
if (is_array($view['conditions'][0]['condition'])) {
foreach ($view['conditions'][0]['condition'] as $condition) {
if (!$condition['value']) {
continue;
}
if ($condition['attributes']['is_serialized'] == 1) {
$condition['value'] = unserialize($condition['value']);
}
$conditions[$condition['attributes']['name']] = $condition['value'];
}
}
$custom_profile_fields = array();
if (is_array($view['custom_profile_fields'][0]['field'])) {
foreach ($view['custom_profile_fields'][0]['field'] as $field) {
$custom_profile_fields[] = $field['attributes']['name'];
}
}
$new_view = array("uid" => 0, "type" => $db->escape_string($view['attributes']['type']), "visibility" => intval($view['attributes']['visibility']), "title" => $db->escape_string($view['title'][0]['value']), "fields" => $db->escape_string(serialize($fields)), "conditions" => $db->escape_string(serialize($conditions)), "custom_profile_fields" => $db->escape_string(serialize($custom_profile_fields)), "sortby" => $db->escape_string($view['sortby'][0]['value']), "sortorder" => $db->escape_string($view['sortorder'][0]['value']), "perpage" => intval($view['perpage'][0]['value']), "view_type" => $db->escape_string($view['view_type'][0]['value']));
$db->insert_query("adminviews", $new_view);
$view_count++;
}
echo $lang->sprintf($lang->admin_step_insertedviews, $view_count);
//.........这里部分代码省略.........
示例9: parse_ini_file
<?php
include_once 'install/DatabaseInstaller.class.php';
include_once 'install-funcs.inc.php';
// Read in DSN
$CONFIG_FILE = '../conf/config.ini';
$CONFIG = parse_ini_file($CONFIG_FILE);
$defaultScriptDir = getcwd() . '/sql/pgsql/';
// Remove the database
$answer = configure('DO_SCHEMA_LOAD', 'Y', "\nWould you like to remove the data for this application");
if (!responseIsAffirmative($answer)) {
print "Normal exit.\n";
exit(0);
}
$answer = configure('CONFIRM_DO_SCHEMA_LOAD', 'N', "\nRemoving the data removes any existing database, schema, users, and/or data.\n" . 'Are you sure you wish to continue');
if (!responseIsAffirmative($answer)) {
print "\nNormal exit.\n";
exit(0);
}
// Setup root DSN
$username = configure('DB_ROOT_USER', 'root', "\nDatabase adminitrator user");
$password = configure('DB_ROOT_PASS', '', "Database administrator password", true);
$installer = DatabaseInstaller::getInstaller($CONFIG['DB_DSN'], $username, $password);
// Drop tables
$installer->runScript($defaultScriptDir . 'drop_tables.sql');
// Disable postgis
$installer->disablePostgis();
// Drop user
$installer->dropUser(array('SELECT'), $CONFIG['DB_USER']);
// Drop database
$installer->dropDatabase();
示例10: db_open
function db_open()
{
global $_josh;
//skip if already connected
if (isset($_josh["db"]["pointer"])) {
return;
}
error_debug("<b>db_open</b> running");
//todo: be able to specify new variables. it should close the open connection and connect to the new thing.
//connect to db
if (!isset($_josh["db"]["language"]) || !isset($_josh["db"]["database"]) || !isset($_josh["db"]["username"]) || !isset($_josh["db"]["password"]) || !isset($_josh["db"]["location"])) {
configure();
//error_handle("database variables error", "joshserver could not find the right database connection variables. please fix this before proceeding.");
} elseif ($_josh["db"]["language"] == "mysql") {
error_debug("<b>db_open</b> trying to connect mysql on " . $_josh["db"]["location"]);
if ($_josh["db"]["pointer"] = @mysql_connect($_josh["db"]["location"], $_josh["db"]["username"], $_josh["db"]["password"])) {
} else {
error_handle("database connection error", "this application is not able to connect its database. we're sorry for the inconvenience, the administrator is attempting to fix the issue.");
}
} elseif ($_josh["db"]["language"] == "mssql") {
error_debug("<b>db_open</b> trying to connect mssql on " . $_josh["db"]["location"] . " with username " . $_josh["db"]["username"]);
if ($_josh["db"]["pointer"] = @mssql_connect($_josh["db"]["location"], $_josh["db"]["username"], $_josh["db"]["password"])) {
} else {
error_handle("database connection error", "this application is not able to connect its database. we're sorry for the inconvenience, the administrator is attempting to fix the issue.");
}
}
//select db
db_switch();
}
示例11: Exception
<?php
include_once '../install-funcs.inc.php';
$CONFIG_FILE = '../../conf/config.ini';
if (!file_exists($CONFIG_FILE)) {
throw new Exception('Configuration file does not exist.');
}
$CONFIG = parse_ini_file($CONFIG_FILE);
$adminDsn = configure('adminDsn', $CONFIG['DB_DSN'], 'Database DSN for administration');
$adminUser = configure('adminUser', 'root', 'Database administrator username');
$adminPass = configure('adminPass', '', 'Database administrator password', true);
$db = new PDO($adminDsn, $adminUser, $adminPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (strpos($adminDsn, 'pgsql') === 0) {
$db->exec('SET SEARCH_PATH = ' . $CONFIG['DB_SCHEMA']);
}
示例12: promptYesNo
// ----------------------------------------------------------------------
// Geonames data download/uncompress
// ----------------------------------------------------------------------
// TODO:: prompt user to download geoname data (cities1000.zip, US.zip)
$answer = promptYesNo("\nUpdating geonames dataset. Existing data will be deleted, continue?", true);
if (!$answer) {
echo "Skipping geonames.\n";
return;
}
$geonamesSql = configure('GEONAMES_SQL', $defaultScriptDir . DIRECTORY_SEPARATOR . 'geonames.sql', "Geonames schema script");
$dbInstaller->runScript($geonamesSql);
echo "Success!!\n";
// download geoname data
echo "\nDownloading and loading geonames data:\n";
$url = configure('GEONAMES_URL', 'ftp://hazards.cr.usgs.gov/web/hazdev-geoserve-ws/geonames/', "Geonames download url");
$filenames = array('cities1000.zip', 'US.zip', 'admin1CodesASCII.txt', 'countryInfo.txt');
$download_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'geonames' . DIRECTORY_SEPARATOR;
// create temp directory
mkdir($download_path);
foreach ($filenames as $filename) {
$downloaded_file = $download_path . $filename;
downloadURL($url . $filename, $downloaded_file);
// uncompress geonames data
if (pathinfo($downloaded_file)['extension'] === 'zip') {
print 'Extracting ' . $downloaded_file . "\n";
extractZip($downloaded_file, $download_path);
}
}
// ----------------------------------------------------------------------
// Geonames data load
示例13: promptYesNo
<?php
// ----------------------------------------------------------------------
// Timezones data download
// ----------------------------------------------------------------------
$answer = promptYesNo("\nUpdating timezone dataset. Existing data will be deleted, continue?", true);
if (!$answer) {
echo "Skipping timezone.\n";
return;
}
$timezoneSql = configure('TIMEZONE_SQL', $defaultScriptDir . DIRECTORY_SEPARATOR . 'timezone.sql', "Timezone regions schema script");
$dbInstaller->runScript($timezoneSql);
echo "Success!!\n";
// download timezone region data
echo "\nDownloading and loading timezone region data:\n";
$url = configure('GLOBAL_ADMIN_URL', 'ftp://hazards.cr.usgs.gov/web/hazdev-geoserve-ws/timezones/', "Timezone download url");
$filenames = array('timezones.dat');
$download_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'timezone' . DIRECTORY_SEPARATOR;
// create temp directory
mkdir($download_path);
foreach ($filenames as $filename) {
$downloaded_file = $download_path . $filename;
downloadURL($url . $filename, $downloaded_file);
}
// ----------------------------------------------------------------------
// timezone data load
// ----------------------------------------------------------------------
// TIMEZONE
echo "\nLoading timezone data ... ";
$dbInstaller->copyFrom($download_path . 'timezones.dat', 'timezone', array('NULL AS \'\'', 'CSV', 'HEADER'));
echo "SUCCESS!!\n";
示例14: configure
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
configure("MINIFY_JSCSS", !DEBUG);
configure("MINIFY_YUI", false);
class MinifierPlugin extends Plugins
{
private static function globRecursive($pattern, $flags = 0)
{
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
$files = array_merge($files, self::globRecursive($dir . '/' . basename($pattern), $flags));
}
return $files;
}
public static function minify_images()
{
$path = Cli::addOption("path", WWW_PATH, "Path where to find images");
$norun = Cli::addSwitch("n", "Do not run the scripts, only print files to process");
Cli::enableHelp();
示例15: promptYesNo
<?php
// ----------------------------------------------------------------------
// Offshore polygon data download/uncompress
// ----------------------------------------------------------------------
$answer = promptYesNo("\nUpdating offshore region dataset. Existing data will be deleted, continue?", true);
if (!$answer) {
echo "Skipping offshore regions.\n";
return;
}
$offshoreSql = configure('ADMIN_SQL', $defaultScriptDir . DIRECTORY_SEPARATOR . 'offshore.sql', "offshore regions schema script");
$dbInstaller->runScript($offshoreSql);
echo "Success!!\n";
// download admin region data
echo "\nDownloading and loading offshore region data:\n";
$url = configure('OFFSHORE_URL', 'ftp://hazards.cr.usgs.gov/web/hazdev-geoserve-ws/offshore/', "Offshore download url");
$filenames = array('feoffshore.dat');
$download_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'fe' . DIRECTORY_SEPARATOR;
// create temp directory
mkdir($download_path);
foreach ($filenames as $filename) {
$downloaded_file = $download_path . $filename;
downloadURL($url . $filename, $downloaded_file);
// uncompress offshore data
if (pathinfo($downloaded_file)['extension'] === 'zip') {
print 'Extracting ' . $downloaded_file . "\n";
extractZip($downloaded_file, $download_path);
}
}
// ----------------------------------------------------------------------
// Offshore data load