/** * Run task after prompt. * * @param array $info Parameter array. * @param string $name Postinstall phase. */ public function run($info, $phase) { if ($phase !== 'first') { return; } if (!$this->_config->set('horde_dir', $info['horde_dir'], 'user', 'pear.horde.org')) { print "Could not save horde_dir configuration value to PEAR config.\n"; return; } $res = $this->_config->writeConfigFile(); if ($res instanceof PEAR_Error) { print 'ERROR: ' . $res->getMessage() . "\n"; exit; } print "Configuration successfully saved to PEAR config.\n"; }
/** * (non-PHPdoc) * @see lib/Faett/Core/Interfaces/Faett_Core_Interfaces_Service#setPassword() */ public function setPassword($password, $channel, $layer = 'user') { // set password for channel $this->_config->set('password', $password, $layer, $channel); // write config $this->_config->store($layer); }
function configSet($key, $value, $layer = 'user') { $this->_config->set($key, $value, $layer); $this->_preferredState = $this->_config->get('preferred_state'); if (!$this->_preferredState) { // don't inadvertantly use a non-set preferred_state $this->_preferredState = null; } }
function doConfigCreate($command, $options, $params) { if (count($params) != 2) { return PEAR::raiseError('config-create: must have 2 parameters, root path and ' . 'filename to save as'); } $root = $params[0]; // Clean up the DIRECTORY_SEPARATOR mess $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; $root = preg_replace(array('!\\\\+!', '!/+!', "!{$ds2}+!"), array('/', '/', '/'), $root); if ($root[0] != '/') { if (!isset($options['windows'])) { return PEAR::raiseError('Root directory must be an absolute path beginning ' . 'with "/", was: "' . $root . '"'); } if (!preg_match('/^[A-Za-z]:/', $root)) { return PEAR::raiseError('Root directory must be an absolute path beginning ' . 'with "\\" or "C:\\", was: "' . $root . '"'); } } $windows = isset($options['windows']); if ($windows) { $root = str_replace('/', '\\', $root); } if (!file_exists($params[1]) && !@touch($params[1])) { return PEAR::raiseError('Could not create "' . $params[1] . '"'); } $params[1] = realpath($params[1]); $config = new PEAR_Config($params[1], '#no#system#config#', false, false); if ($root[strlen($root) - 1] == '/') { $root = substr($root, 0, strlen($root) - 1); } $config->noRegistry(); $config->set('php_dir', $windows ? "{$root}\\pear\\php" : "{$root}/pear/php", 'user'); $config->set('data_dir', $windows ? "{$root}\\pear\\data" : "{$root}/pear/data"); $config->set('www_dir', $windows ? "{$root}\\pear\\www" : "{$root}/pear/www"); $config->set('cfg_dir', $windows ? "{$root}\\pear\\cfg" : "{$root}/pear/cfg"); $config->set('ext_dir', $windows ? "{$root}\\pear\\ext" : "{$root}/pear/ext"); $config->set('doc_dir', $windows ? "{$root}\\pear\\docs" : "{$root}/pear/docs"); $config->set('test_dir', $windows ? "{$root}\\pear\\tests" : "{$root}/pear/tests"); $config->set('cache_dir', $windows ? "{$root}\\pear\\cache" : "{$root}/pear/cache"); $config->set('download_dir', $windows ? "{$root}\\pear\\download" : "{$root}/pear/download"); $config->set('temp_dir', $windows ? "{$root}\\pear\\temp" : "{$root}/pear/temp"); $config->set('bin_dir', $windows ? "{$root}\\pear" : "{$root}/pear"); $config->writeConfigFile(); $this->_showConfig($config); $this->ui->outputData('Successfully created default configuration file "' . $params[1] . '"', $command); }
/** * Execute the 'login' command. * * @param string $command command name * * @param array $options option_name => value * * @param array $params list of additional parameters * * @return bool TRUE on success or * a PEAR error on failure * * @access public */ function doLogin($command, $options, $params) { $reg =& $this->config->getRegistry(); // If a parameter is supplied, use that as the channel to log in to if (isset($params[0])) { $channel = $params[0]; } else { $channel = $this->config->get('default_channel'); } $chan = $reg->getChannel($channel); if (PEAR::isError($chan)) { return $this->raiseError($chan); } $server = $this->config->get('preferred_mirror', null, $channel); $remote =& $this->config->getRemote(); $username = $this->config->get('username', null, $channel); if (empty($username)) { $username = isset($_ENV['USER']) ? $_ENV['USER'] : null; } $this->ui->outputData("Logging in to {$server}.", $command); list($username, $password) = $this->ui->userDialog($command, array('Username', 'Password'), array('text', 'password'), array($username, '')); $username = trim($username); $password = trim($password); $ourfile = $this->config->getConfFile('user'); if (!$ourfile) { $ourfile = $this->config->getConfFile('system'); } $this->config->set('username', $username, 'user', $channel); $this->config->set('password', $password, 'user', $channel); if ($chan->supportsREST()) { $ok = true; } else { $remote->expectError(401); $ok = $remote->call('logintest'); $remote->popExpect(); } if ($ok === true) { $this->ui->outputData("Logged in.", $command); // avoid changing any temporary settings changed with -d $ourconfig = new PEAR_Config($ourfile, $ourfile); $ourconfig->set('username', $username, 'user', $channel); $ourconfig->set('password', $password, 'user', $channel); $ourconfig->store(); } else { return $this->raiseError("Login failed!"); } return true; }
/** * @param string Package name * @param string Channel name * @return PEAR_PackageFile_v1|PEAR_PackageFile_v2|null * @access private */ function &_getPackage($package, $channel = 'pear.php.net') { $info = $this->_packageInfo($package, null, $channel); if ($info === null) { return $info; } $a = $this->_config; if (!$a) { $this->_config =& new PEAR_Config(); $this->_config->set('php_dir', $this->statedir); } if (!class_exists('PEAR_PackageFile')) { require_once 'PEAR/PackageFile.php'; } $pkg =& new PEAR_PackageFile($this->_config); $pf =& $pkg->fromArray($info); return $pf; }
function _pear_init() { // Remove E_STRICT from error_reporting error_reporting(error_reporting() & ~E_STRICT); require_once 'PEAR.php'; require_once 'PEAR/Frontend.php'; require_once 'PEAR/Config.php'; require_once 'PEAR/Registry.php'; require_once 'PEAR/Command.php'; require_once 'PEAR/Remote.php'; // current symfony release $sf_version = preg_replace('/\\-\\w+$/', '', file_get_contents(sfConfig::get('sf_symfony_lib_dir') . '/VERSION')); // PEAR PEAR_Command::setFrontendType('CLI'); $ui =& PEAR_Command::getFrontendObject(); // read user/system configuration (don't use the singleton) $config = new PEAR_Config(); $config_file = sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . '.pearrc'; // change the configuration for symfony use $config->set('php_dir', sfConfig::get('sf_plugins_dir')); $config->set('data_dir', sfConfig::get('sf_plugins_dir')); $config->set('test_dir', sfConfig::get('sf_plugins_dir')); $config->set('doc_dir', sfConfig::get('sf_plugins_dir')); $config->set('bin_dir', sfConfig::get('sf_plugins_dir')); // change the PEAR temp dir $config->set('cache_dir', sfConfig::get('sf_cache_dir')); $config->set('download_dir', sfConfig::get('sf_cache_dir')); $config->set('tmp_dir', sfConfig::get('sf_cache_dir')); // save out configuration file $config->writeConfigFile($config_file, 'user'); // use our configuration file $config =& PEAR_Config::singleton($config_file); $config->set('verbose', 1); $ui->setConfig($config); date_default_timezone_set('UTC'); // register our channel $symfony_channel = array('attribs' => array('version' => '1.0', 'xmlns' => 'http://pear.php.net/channel-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'http://pear.php.net/dtd/channel-1.0 http://pear.php.net/dtd/channel-1.0.xsd'), 'name' => 'pear.symfony-project.com', 'summary' => 'symfony project PEAR channel', 'suggestedalias' => 'symfony', 'servers' => array('primary' => array('rest' => array('baseurl' => array(array('attribs' => array('type' => 'REST1.0'), '_content' => 'http://pear.symfony-project.com/Chiara_PEAR_Server_REST/'), array('attribs' => array('type' => 'REST1.1'), '_content' => 'http://pear.symfony-project.com/Chiara_PEAR_Server_REST/'))))), '_lastmodified' => array('ETag' => "113845-297-dc93f000", 'Last-Modified' => date('r'))); pake_mkdirs(sfConfig::get('sf_plugins_dir') . '/.channels/.alias'); file_put_contents(sfConfig::get('sf_plugins_dir') . '/.channels/pear.symfony-project.com.reg', serialize($symfony_channel)); file_put_contents(sfConfig::get('sf_plugins_dir') . '/.channels/.alias/symfony.txt', 'pear.symfony-project.com'); // register symfony for dependencies $symfony = array('name' => 'symfony', 'channel' => 'pear.symfony-project.com', 'date' => date('Y-m-d'), 'time' => date('H:i:s'), 'version' => array('release' => $sf_version, 'api' => '1.0.0'), 'stability' => array('release' => 'stable', 'api' => 'stable'), 'xsdversion' => '2.0', '_lastmodified' => time(), 'old' => array('version' => $sf_version, 'release_state' => 'stable')); $dir = sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . '.registry' . DIRECTORY_SEPARATOR . '.channel.pear.symfony-project.com'; pake_mkdirs($dir); file_put_contents($dir . DIRECTORY_SEPARATOR . 'symfony.reg', serialize($symfony)); return $config; }
private function createConfig($root, $pearConfDir) { $old = error_reporting(0); $windows = $this->isWindows(); $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; $root = preg_replace(array('!\\\\+!', '!/+!', "!{$ds2}+!"), array('/', '/', '/'), $root); if ($root[0] != '/') { if ($windows) { throw new Exception('Root directory must be an absolute path beginning ' . 'with "/", was: "' . $root . '"'); } if (!preg_match('/^[A-Za-z]:/', $root)) { throw new Exception('Root directory must be an absolute path beginning ' . 'with "\\" or "C:\\", was: "' . $root . '"'); } } if ($windows) { $root = str_replace('/', '\\', $root); } if (!file_exists($pearConfDir) && !@touch($pearConfDir)) { throw new Exception('Could not create "' . $pearConfDir . '"'); } $config = new PEAR_Config($pearConfDir, '#no#system#config#', false, false); if ($root[strlen($root) - 1] == '/') { $root = substr($root, 0, strlen($root) - 1); } $config->noRegistry(); $config->set('php_dir', $windows ? "{$root}" : "{$root}", 'user'); $config->set('data_dir', $windows ? "{$root}\\pear\\data" : "{$root}/data"); $config->set('www_dir', $windows ? "{$root}\\pear\\www" : "{$root}/pear/www"); $config->set('cfg_dir', $windows ? "{$root}\\pear\\cfg" : "{$root}/pear/cfg"); $config->set('ext_dir', $windows ? "{$root}\\pear\\ext" : "{$root}/pear/ext"); $config->set('doc_dir', $windows ? "{$root}\\pear\\docs" : "{$root}/pear/docs"); $config->set('test_dir', $windows ? "{$root}\\pear\\tests" : "{$root}/pear/tests"); $config->set('cache_dir', $windows ? "{$root}\\pear\\cache" : "{$root}/pear/cache"); $config->set('download_dir', $windows ? "{$root}\\pear\\download" : "{$root}/pear/download"); $config->set('temp_dir', $windows ? "{$root}\\pear\\temp" : "{$root}/pear/temp"); $config->set('bin_dir', $windows ? "{$root}\\" : "{$root}/"); $config->writeConfigFile(); error_reporting($old); return $config; }
/** * Updates the source for the package. * * We have to update required dependencies automatically to make sure that * everything still works properly. * * It is the developers responsibility to make sure the user is given the * option to update any optional dependencies if needed. This can be done * by creating a new instance of PEAR_PackageUpdate for the optional * dependency. * * @access public * @return boolean true if the update was successful. * @since 0.4.0a1 * @throws PEAR_PACKAGEUPDATE_ERROR_NOTINSTALLED */ function update() { // Create a config object. $config = new PEAR_Config(); // Change the verbosity but keep track of the value to reset it just in // case this does something permanent. $verbose = $config->get('verbose'); $config->set('verbose', 0); // Create a command object to do the upgrade. // If the current version is 0.0.0 don't upgrade. That would be a // sneaky way for devs to install packages without the use knowing. if ($this->instVersion == '0.0.0') { $this->pushError(PEAR_PACKAGEUPDATE_ERROR_NOTINSTALLED, NULL, array('packagename' => $this->packageName)); return false; } require_once 'PEAR/Command.php'; $upgrade = PEAR_Command::factory('upgrade', $config); // Try to upgrade the application. $channelPackage = $this->channel . '/' . $this->packageName; $result = $upgrade->doInstall('upgrade', array('onlyreqdeps' => true), array($channelPackage)); // Reset the verbose level just to be safe. $config->set('verbose', $verbose); // Check for errors. if (PEAR::isError($result)) { $this->pushError($result); return false; } else { return true; } }
public function create() { $old = error_reporting(0); $root = $this->root; $configFile = $root . '/.pearrc'; $config = new \PEAR_Config($configFile, '#no#system#config#', false, false); $config->noRegistry(); $config->set('php_dir', $root, 'user'); $config->set('data_dir', "{$root}/pear/data"); $config->set('www_dir', "{$root}/pear/www"); $config->set('cfg_dir', "{$root}/pear/cfg"); $config->set('ext_dir', "{$root}/pear/ext"); $config->set('doc_dir', "{$root}/pear/docs"); $config->set('test_dir', "{$root}/pear/tests"); $config->set('cache_dir', "{$root}/pear/cache"); $config->set('download_dir', "{$root}/pear/download"); $config->set('temp_dir', "{$root}/pear/temp"); $config->set('bin_dir', "{$root}/"); $config->writeConfigFile(); error_reporting($old); $this->prepare(); }