config.php
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 421 行 · 第 1/2 页
PHP
421 行
<?php/** * PEAR_Command_Config (config-show, config-get, config-set, config-help, config-create commands) * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category pear * @package PEAR * @author Stig Bakken <ssb@php.net> * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Config.php,v 1.53 2007/06/11 05:11:53 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 0.1 *//** * base class */require_once 'PEAR/Command/Common.php';/** * PEAR commands for managing configuration data. * * @category pear * @package PEAR * @author Stig Bakken <ssb@php.net> * @author Greg Beaver <cellog@php.net> * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 1.6.1 * @link http://pear.php.net/package/PEAR * @since Class available since Release 0.1 */class PEAR_Command_Config extends PEAR_Command_Common{ // {{{ properties var $commands = array( 'config-show' => array( 'summary' => 'Show All Settings', 'function' => 'doConfigShow', 'shortcut' => 'csh', 'options' => array( 'channel' => array( 'shortopt' => 'c', 'doc' => 'show configuration variables for another channel', 'arg' => 'CHAN', ),), 'doc' => '[layer]Displays all configuration values. An optional argumentmay be used to tell which configuration layer to display. Validconfiguration layers are "user", "system" and "default". To displayconfigurations for different channels, set the default_channelconfiguration variable and run config-show again.', ), 'config-get' => array( 'summary' => 'Show One Setting', 'function' => 'doConfigGet', 'shortcut' => 'cg', 'options' => array( 'channel' => array( 'shortopt' => 'c', 'doc' => 'show configuration variables for another channel', 'arg' => 'CHAN', ),), 'doc' => '<parameter> [layer]Displays the value of one configuration parameter. Thefirst argument is the name of the parameter, an optional second argumentmay be used to tell which configuration layer to look in. Valid configurationlayers are "user", "system" and "default". If no layer is specified, a valuewill be picked from the first layer that defines the parameter, in the orderjust specified. The configuration value will be retrieved for the channelspecified by the default_channel configuration variable.', ), 'config-set' => array( 'summary' => 'Change Setting', 'function' => 'doConfigSet', 'shortcut' => 'cs', 'options' => array( 'channel' => array( 'shortopt' => 'c', 'doc' => 'show configuration variables for another channel', 'arg' => 'CHAN', ),), 'doc' => '<parameter> <value> [layer]Sets the value of one configuration parameter. The first argument isthe name of the parameter, the second argument is the new value. Someparameters are subject to validation, and the command will fail withan error message if the new value does not make sense. An optionalthird argument may be used to specify in which layer to set theconfiguration parameter. The default layer is "user". Theconfiguration value will be set for the current channel, whichis controlled by the default_channel configuration variable.', ), 'config-help' => array( 'summary' => 'Show Information About Setting', 'function' => 'doConfigHelp', 'shortcut' => 'ch', 'options' => array(), 'doc' => '[parameter]Displays help for a configuration parameter. Without arguments itdisplays help for all configuration parameters.', ), 'config-create' => array( 'summary' => 'Create a Default configuration file', 'function' => 'doConfigCreate', 'shortcut' => 'coc', 'options' => array( 'windows' => array( 'shortopt' => 'w', 'doc' => 'create a config file for a windows install', ), ), 'doc' => '<root path> <filename>Create a default configuration file with all directory configurationvariables set to subdirectories of <root path>, and save it as <filename>.This is useful especially for creating a configuration file for a remotePEAR installation (using the --remoteconfig option of install, upgrade,and uninstall).', ), ); // }}} // {{{ constructor /** * PEAR_Command_Config constructor. * * @access public */ function PEAR_Command_Config(&$ui, &$config) { parent::PEAR_Command_Common($ui, $config); } // }}} // {{{ doConfigShow() function doConfigShow($command, $options, $params) { if (is_array($params)) { $layer = isset($params[0]) ? $params[0] : NULL; } else { $layer = NULL; } // $params[0] -> the layer if ($error = $this->_checkLayer($layer)) { return $this->raiseError("config-show:$error"); } $keys = $this->config->getKeys(); sort($keys); $channel = isset($options['channel']) ? $options['channel'] : $this->config->get('default_channel'); $reg = &$this->config->getRegistry(); if (!$reg->channelExists($channel)) { return $this->raiseError('Channel "' . $channel . '" does not exist'); } $data = array('caption' => 'Configuration (channel ' . $channel . '):'); foreach ($keys as $key) { $type = $this->config->getType($key); $value = $this->config->get($key, $layer, $channel); if ($type == 'password' && $value) { $value = '********'; } if ($value === false) { $value = 'false'; } elseif ($value === true) { $value = 'true'; } $data['data'][$this->config->getGroup($key)][] = array($this->config->getPrompt($key) , $key, $value); } foreach ($this->config->getLayers() as $layer) { $data['data']['Config Files'][] = array(ucfirst($layer) . ' Configuration File', 'Filename' , $this->config->getConfFile($layer)); } $this->ui->outputData($data, $command); return true; } // }}} // {{{ doConfigGet() function doConfigGet($command, $options, $params) { if (!is_array($params)) { $args_cnt = 0; } else { $args_cnt = count($params); } switch ($args_cnt) { case 1: $config_key = $params[0];
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?