get() public method

Returns a configuration value, prioritizing layers as per the layers property.
public get ( $key, $layer = null, $channel = false ) : mixed
return mixed the config value, or NULL if not found
Beispiel #1
0
 /**
  * This is called for each file to set up the directories and files
  * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @param array attributes from the <file> tag
  * @param string file name
  * @return array an array consisting of:
  *
  *    1 the original, pre-baseinstalldir installation directory
  *    2 the final installation directory
  *    3 the full path to the final location of the file
  *    4 the location of the pre-installation file
  */
 function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null)
 {
     if (!$this->_setup['locationconfig']) {
         return false;
     }
     if ($this->_setup['honorsbaseinstall']) {
         $dest_dir = $save_destdir = $this->config->get($this->_setup['locationconfig'], $layer, $pkg->getChannel());
         if (!empty($atts['baseinstalldir'])) {
             $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
         }
     } elseif ($this->_setup['unusualbaseinstall']) {
         $dest_dir = $save_destdir = $this->config->get($this->_setup['locationconfig'], null, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage();
         if (!empty($atts['baseinstalldir'])) {
             $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
         }
     } else {
         $dest_dir = $save_destdir = $this->config->get($this->_setup['locationconfig'], null, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage();
     }
     if (dirname($file) != '.' && empty($atts['install-as'])) {
         $dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
     }
     if (empty($atts['install-as'])) {
         $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
     } else {
         $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
     }
     $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
     // Clean up the DIRECTORY_SEPARATOR mess
     $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
     list($dest_dir, $dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!{$ds2}+!"), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), array($dest_dir, $dest_file, $orig_file));
     return array($save_destdir, $dest_dir, $dest_file, $orig_file);
 }
 /**
  * @param  string  $suiteClassName
  * @param  string  $suiteClassFile
  * @return ReflectionClass
  * @throws Exception
  * @access public
  */
 public function load($suiteClassName, $suiteClassFile = '')
 {
     $suiteClassName = str_replace('.php', '', $suiteClassName);
     $suiteClassFile = !empty($suiteClassFile) ? $suiteClassFile : str_replace('_', '/', $suiteClassName) . '.php';
     if (!class_exists($suiteClassName)) {
         if (!file_exists($suiteClassFile)) {
             $config = new PEAR_Config();
             $includePaths = explode(PATH_SEPARATOR, get_include_path());
             $includePaths[] = $config->get('test_dir');
             foreach ($includePaths as $includePath) {
                 $file = $includePath . DIRECTORY_SEPARATOR . $suiteClassFile;
                 if (file_exists($file)) {
                     $suiteClassFile = $file;
                     break;
                 }
             }
         }
         PHPUnit2_Util_Fileloader::checkAndLoad($suiteClassFile);
     }
     if (class_exists($suiteClassName)) {
         return new ReflectionClass($suiteClassName);
     } else {
         throw new Exception(sprintf('Class %s could not be found in %s.', $suiteClassName, $suiteClassFile));
     }
 }
Beispiel #3
0
 /**
  * @param array output of package.getDownloadURL
  * @param string|array|object information for detecting packages to be downloaded, and
  *                            for errors
  * @param array name information of the package
  * @param array|null packages to be downloaded
  * @access private
  */
 function _analyzeDownloadURL($info, $param, $pname, $params = null)
 {
     if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
         return false;
     }
     if (!$info) {
         if (!is_string($param)) {
             $saveparam = ", cannot download \"{$param}\"";
         } else {
             $saveparam = '';
         }
         // no releases exist
         return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
     }
     if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
         $err = false;
         if ($pname['channel'] == 'pear.php.net') {
             if ($info['info']->getChannel() != 'pecl.php.net') {
                 $err = true;
             }
         } else {
             $err = true;
         }
         if ($err) {
             return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
         }
     }
     if (!isset($info['url'])) {
         // releases exist, but we failed to get any
         if (isset($this->_downloader->_options['force'])) {
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } else {
                 $vs = ' within preferred state ' . $this->_config->get('preferred_state') . '"';
             }
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"');
             }
             // download the latest release
             return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
         } else {
             // construct helpful error message
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } else {
                 $vs = ' within preferred state ' . $this->_downloader->config->get('preferred_state') . '"';
             }
             $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install');
             return $err;
         }
     }
     return $info;
 }
 /**
  * Initialize Task.
  * This method includes any necessary PHPUnit2 libraries and triggers
  * appropriate error if they cannot be found.  This is not done in header
  * because we may want this class to be loaded w/o triggering an error.
  */
 function init()
 {
     if (version_compare(PHP_VERSION, '5.0.3') < 0) {
         throw new BuildException("PHPUnit2Task requires PHP version >= 5.0.3.", $this->getLocation());
     }
     /**
      * Ugly hack to get PHPUnit version number
      */
     $config = new PEAR_Config();
     $registry = new PEAR_Registry($config->get('php_dir'));
     $pkg_info = $registry->_packageInfo("PHPUnit", null, "pear.phpunit.de");
     if ($pkg_info != NULL) {
         if (version_compare($pkg_info['version']['api'], "3.0.0") >= 0) {
             PHPUnitUtil::$installedVersion = 3;
         } else {
             PHPUnitUtil::$installedVersion = 2;
         }
     } else {
         /**
          * Try to find PHPUnit2
          */
         require_once 'PHPUnit2/Util/Filter.php';
         if (!class_exists('PHPUnit2_Util_Filter')) {
             throw new BuildException("PHPUnit2Task depends on PEAR PHPUnit2 package being installed.", $this->getLocation());
         }
         PHPUnitUtil::$installedVersion = 2;
     }
     // other dependencies that should only be loaded when class is actually used.
     require_once 'phing/tasks/ext/phpunit/PHPUnitTestRunner.php';
     require_once 'phing/tasks/ext/phpunit/BatchTest.php';
     require_once 'phing/tasks/ext/phpunit/FormatterElement.php';
     //require_once 'phing/tasks/ext/phpunit/SummaryPHPUnit2ResultFormatter.php';
     // add some defaults to the PHPUnit filter
     if (PHPUnitUtil::$installedVersion == 3) {
         require_once 'PHPUnit/Util/Filter.php';
         // point PHPUnit_MAIN_METHOD define to non-existing method
         define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
         PHPUnit_Util_Filter::addFileToFilter('PHPUnitTask.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('PHPUnitTestRunner.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Task.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Target.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Project.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing/Phing.php', 'PHING');
         PHPUnit_Util_Filter::addFileToFilter('phing.php', 'PHING');
     } else {
         require_once 'PHPUnit2/Util/Filter.php';
         PHPUnit2_Util_Filter::addFileToFilter('PHPUnitTask.php');
         PHPUnit2_Util_Filter::addFileToFilter('PHPUnitTestRunner.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Task.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Target.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Project.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing/Phing.php');
         PHPUnit2_Util_Filter::addFileToFilter('phing.php');
     }
 }
Beispiel #5
0
 /**
  * Initialize post-install scripts for running
  *
  * This method can be used to detect post-install scripts, as the return value
  * indicates whether any exist
  * @return bool
  */
 function initPostinstallScripts()
 {
     $filelist = $this->getFilelist();
     $contents = $this->getContents();
     $contents = $contents['dir']['file'];
     if (!is_array($contents) || !isset($contents[0])) {
         $contents = array($contents);
     }
     $taskfiles = array();
     foreach ($contents as $file) {
         $atts = $file['attribs'];
         unset($file['attribs']);
         if (count($file)) {
             $taskfiles[$atts['name']] = $file;
         }
     }
     $common = new PEAR_Common();
     $common->debug = $this->_config->get('verbose');
     $this->_scripts = array();
     foreach ($taskfiles as $name => $tasks) {
         if (!isset($filelist[$name])) {
             // file was not installed due to installconditions
             continue;
         }
         $atts = $filelist[$name];
         foreach ($tasks as $tag => $raw) {
             $taskname = $this->getTask($tag);
             $task =& new $taskname($this->_config, $common, PEAR_TASK_INSTALL);
             if (!$task->isScript()) {
                 continue;
                 // scripts are only handled after installation
             }
             $lastversion = isset($this->_packageInfo['_lastversion']) ? $this->_packageInfo['_lastversion'] : null;
             $task->init($raw, $atts, $lastversion);
             $res = $task->startSession($this, $atts['installed_as']);
             if (!$res) {
                 continue;
                 // skip this file
             }
             if (PEAR::isError($res)) {
                 return $res;
             }
             $assign =& $task;
             $this->_scripts[] =& $assign;
         }
     }
     if (count($this->_scripts)) {
         return true;
     }
     return false;
 }
Beispiel #6
0
 function createGpgCmd()
 {
     if ($this->_config->get('sig_type') != 'gpg') {
         return PEAR::raiseError("only support 'gpg' for signature type");
     }
     $sig_bin = $this->_config->get('sig_bin');
     if (empty($sig_bin) || !file_exists($sig_bin)) {
         return PEAR::raiseError("can't access gpg binary: {$sig_bin}");
     }
     $keyid = trim($this->_config->get('sig_keyid'));
     $keydir = trim($this->_config->get('sig_keydir'));
     if (strlen($keydir) && !file_exists($keydir) && !@mkdir($keydir)) {
         return PEAR::raiseError("sig_keydir '{$keydir}' doesn't exist or is not accessible");
     }
     $cmd = escapeshellcmd($sig_bin);
     if (strlen($keyid)) {
         $cmd .= " --default-key " . escapeshellarg($keyid);
     }
     if (strlen($keydir)) {
         $cmd .= " --homedir " . escapeshellarg($keydir);
     }
     return $cmd;
 }
Beispiel #7
0
 /**
  * This is called for each file to set up the directories and files
  * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @param array attributes from the <file> tag
  * @param string file name
  * @return array an array consisting of:
  *
  *    1 the original, pre-baseinstalldir installation directory
  *    2 the final installation directory
  *    3 the full path to the final location of the file
  *    4 the location of the pre-installation file
  */
 function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null)
 {
     $role = $this->getRoleFromClass();
     $info = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . $role);
     if (PEAR::isError($info)) {
         return $info;
     }
     if (!$info['locationconfig']) {
         return false;
     }
     if ($info['honorsbaseinstall']) {
         $dest_dir = $save_destdir = $this->config->get($info['locationconfig'], $layer, $pkg->getChannel());
         if (!empty($atts['baseinstalldir'])) {
             $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
         }
     } elseif ($info['unusualbaseinstall']) {
         $dest_dir = $save_destdir = $this->config->get($info['locationconfig'], $layer, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage();
         if (!empty($atts['baseinstalldir'])) {
             $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
         }
     } else {
         $save_destdir = $dest_dir = $this->config->get($info['locationconfig'], $layer, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage();
     }
     if (dirname($file) != '.' && empty($atts['install-as'])) {
         $dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
     }
     if (empty($atts['install-as'])) {
         $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
     } else {
         $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
     }
     $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
     // Clean up the DIRECTORY_SEPARATOR mess
     $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
     list($dest_dir, $dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!{$ds2}+!"), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), array($dest_dir, $dest_file, $orig_file));
     return array($save_destdir, $dest_dir, $dest_file, $orig_file);
 }
 /**
  * Set up the registry/location of dependency DB
  * @param PEAR_Config|false
  * @param string|false full path to the dependency database, or false to use default
  */
 function setConfig(&$config, $depdb = false)
 {
     if (!$config) {
         $this->_config =& PEAR_Config::singleton();
     } else {
         $this->_config =& $config;
     }
     $this->_registry =& $this->_config->getRegistry();
     if (!$depdb) {
         $this->_depdb = $this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb';
     } else {
         $this->_depdb = $depdb;
     }
     $this->_lockfile = dirname($this->_depdb) . DIRECTORY_SEPARATOR . '.depdblock';
 }
Beispiel #9
0
 function getPackageDownloadUrl($package, $version = null)
 {
     if ($version) {
         $package .= "-{$version}";
     }
     if ($this === null || $this->_config === null) {
         $package = "http://pear.php.net/get/{$package}";
     } else {
         $package = "http://" . $this->_config->get('master_server') . "/get/{$package}";
     }
     if (!extension_loaded("zlib")) {
         $package .= '?uncompress=yes';
     }
     return $package;
 }
Beispiel #10
0
 /**
  * Constructor.
  *
  * Searches all installed applications and libraries for migration
  * directories and builds lists of migrateable modules and directories.
  *
  * @param string $basedir   Base directory of a Git checkout. If provided
  *                          a framework/ sub directory is searched for
  *                          migration scripts too.
  * @param string $pearconf  Path to a PEAR configuration file.
  */
 public function __construct($basedir = null, $pearconf = null)
 {
     // Loop through all applications.
     foreach ($GLOBALS['registry']->listAllApps() as $app) {
         $dir = $GLOBALS['registry']->get('fileroot', $app) . '/migration';
         if (is_dir($dir)) {
             $this->apps[] = $app;
             $this->_lower[] = Horde_String::lower($app);
             $this->dirs[] = realpath($dir);
         }
     }
     // Silence PEAR errors.
     $old_error_reporting = error_reporting();
     error_reporting($old_error_reporting & ~E_DEPRECATED);
     $pear = new PEAR_Config($pearconf);
     // Loop through local framework checkout.
     if ($basedir) {
         $packageFile = new PEAR_PackageFile($pear);
         foreach (glob($basedir . '/framework/*/migration') as $dir) {
             $package = $packageFile->fromPackageFile(dirname($dir) . '/package.xml', PEAR_VALIDATE_NORMAL);
             if ($package instanceof PEAR_Error) {
                 Horde::log(sprintf('%s: %s', $package->getMessage(), print_r($package->getUserInfo(), true)), Horde_Log::ERR);
                 continue;
             }
             $this->apps[] = $package->getName();
             $this->_lower[] = Horde_String::lower($package->getName());
             $this->dirs[] = realpath($dir);
         }
     }
     // Loop through installed PEAR packages.
     $registry = $pear->getRegistry();
     foreach (glob($pear->get('data_dir') . '/*/migration') as $dir) {
         $package = $registry->getPackage(basename(dirname($dir)), 'pear.horde.org');
         if ($package == false) {
             Horde::log("Ignoring package in directory {$dir}", Horde_Log::WARN);
             continue;
         }
         $app = $package->getName();
         if (!in_array($app, $this->apps)) {
             $this->apps[] = $app;
             $this->_lower[] = Horde_String::lower($app);
             $this->dirs[] = realpath($dir);
         }
     }
     error_reporting($old_error_reporting);
 }
 static function getSampleDir()
 {
     $config = new PEAR_Config();
     return $config->get('data_dir') . '/XML_Feed_Parser/samples';
 }
Beispiel #12
0
 /**
  * @param array output of package.getDownloadURL
  * @param string|array|object information for detecting packages to be downloaded, and
  *                            for errors
  * @param array name information of the package
  * @param array|null packages to be downloaded
  * @param bool is this an optional dependency?
  * @param bool is this any kind of dependency?
  * @access private
  */
 function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false, $isdependency = false)
 {
     if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
         return false;
     }
     if ($info === false) {
         $saveparam = !is_string($param) ? ", cannot download \"{$param}\"" : '';
         // no releases exist
         return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
     }
     if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
         $err = false;
         if ($pname['channel'] == 'pecl.php.net') {
             if ($info['info']->getChannel() != 'pear.php.net') {
                 $err = true;
             }
         } elseif ($info['info']->getChannel() == 'pecl.php.net') {
             if ($pname['channel'] != 'pear.php.net') {
                 $err = true;
             }
         } else {
             $err = true;
         }
         if ($err) {
             return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
         }
     }
     $preferred_state = $this->_config->get('preferred_state');
     if (!isset($info['url'])) {
         $package_version = $this->_registry->packageInfo($info['info']->getPackage(), 'version', $info['info']->getChannel());
         if ($this->isInstalled($info)) {
             if ($isdependency && version_compare($info['version'], $package_version, '<=')) {
                 // ignore bogus errors of "failed to download dependency"
                 // if it is already installed and the one that would be
                 // downloaded is older or the same version (Bug #7219)
                 return false;
             }
         }
         if ($info['version'] === $package_version) {
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' . ' (' . $package_version . ') is the same as the locally installed one.');
             }
             return false;
         }
         if (version_compare($info['version'], $package_version, '<=')) {
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' . ' (' . $info['version'] . ') is a lower version than the locally installed one (' . $package_version . ').');
             }
             return false;
         }
         $instead = ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"';
         // releases exist, but we failed to get any
         if (isset($this->_downloader->_options['force'])) {
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($preferred_state, true))) {
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $preferred_state . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = PEAR_Dependency2::_getExtraString($pname);
                     $instead = '';
                 }
             } else {
                 $vs = ' within preferred state "' . $preferred_state . '"';
             }
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . $instead);
             }
             // download the latest release
             return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
         } else {
             if (isset($info['php']) && $info['php']) {
                 $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . ', latest release is version ' . $info['php']['v'] . ', but it requires PHP version "' . $info['php']['m'] . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['php']['v'])) . '" to install', PEAR_DOWNLOADER_PACKAGE_PHPVERSION);
                 return $err;
             }
             // construct helpful error message
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($preferred_state, true))) {
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
                         // optional dep failure!
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $preferred_state . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
                         // optional dep failure!
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = PEAR_Dependency2::_getExtraString($pname);
                 }
             } else {
                 $vs = ' within preferred state "' . $this->_downloader->config->get('preferred_state') . '"';
             }
             $options = $this->_downloader->getOptions();
             // this is only set by the "download-all" command
             if (isset($options['ignorepreferred_state'])) {
                 $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install', PEAR_DOWNLOADER_PACKAGE_STATE);
                 return $err;
             }
             // Checks if the user has a package installed already and checks the release against
             // the state against the installed package, this allows upgrades for packages
             // with lower stability than the preferred_state
             $stability = $this->_registry->packageInfo($pname['package'], 'stability', $pname['channel']);
             if (!$this->isInstalled($info) || !in_array($info['info']->getState(), PEAR_Common::betterStates($stability['release'], true))) {
                 $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install');
                 return $err;
             }
         }
     }
     if (isset($info['deprecated']) && $info['deprecated']) {
         $this->_downloader->log(0, 'WARNING: "' . $this->_registry->parsedPackageNameToString(array('channel' => $info['info']->getChannel(), 'package' => $info['info']->getPackage()), true) . '" is deprecated in favor of "' . $this->_registry->parsedPackageNameToString($info['deprecated'], true) . '"');
     }
     return $info;
 }
Beispiel #13
0
 /**
  * Create a PEAR_PackageFile_v* from a compresed Tar or Tgz file.
  * @access  public
  * @param string contents of package.xml file
  * @param int package state (one of PEAR_VALIDATE_* constants)
  * @return  PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @using   Archive_Tar to extract the files
  * @using   fromPackageFile() to load the package after the package.xml
  *          file is extracted.
  */
 function &fromTgzFile($file, $state)
 {
     if (!class_exists('Archive_Tar')) {
         require_once 'Archive/Tar.php';
     }
     $tar = new Archive_Tar($file);
     if ($this->_debug <= 1) {
         $tar->pushErrorHandling(PEAR_ERROR_RETURN);
     }
     $content = $tar->listContent();
     if ($this->_debug <= 1) {
         $tar->popErrorHandling();
     }
     if (!is_array($content)) {
         if (is_string($file) && strlen($file < 255) && (!file_exists($file) || !@is_file($file))) {
             $ret = PEAR::raiseError("could not open file \"{$file}\"");
             return $ret;
         }
         $file = realpath($file);
         $ret = PEAR::raiseError("Could not get contents of package \"{$file}\"" . '. Invalid tgz file.');
         return $ret;
     }
     if (!count($content) && !@is_file($file)) {
         $ret = PEAR::raiseError("could not open file \"{$file}\"");
         return $ret;
     }
     $xml = null;
     $origfile = $file;
     foreach ($content as $file) {
         $name = $file['filename'];
         if ($name == 'package2.xml') {
             // allow a .tgz to distribute both versions
             $xml = $name;
             break;
         }
         if ($name == 'package.xml') {
             $xml = $name;
             break;
         } elseif (preg_match('/package.xml$/', $name, $match)) {
             $xml = $name;
             break;
         }
     }
     $tmpdir = System::mktemp('-t "' . $this->_config->get('temp_dir') . '" -d pear');
     if ($tmpdir === false) {
         $ret = PEAR::raiseError("there was a problem with getting the configured temp directory");
         return $ret;
     }
     PEAR_PackageFile::addTempFile($tmpdir);
     $this->_extractErrors();
     PEAR::staticPushErrorHandling(PEAR_ERROR_CALLBACK, array($this, '_extractErrors'));
     if (!$xml || !$tar->extractList(array($xml), $tmpdir)) {
         $extra = implode("\n", $this->_extractErrors());
         if ($extra) {
             $extra = ' ' . $extra;
         }
         PEAR::staticPopErrorHandling();
         $ret = PEAR::raiseError('could not extract the package.xml file from "' . $origfile . '"' . $extra);
         return $ret;
     }
     PEAR::staticPopErrorHandling();
     $ret =& PEAR_PackageFile::fromPackageFile("{$tmpdir}/{$xml}", $state, $origfile);
     return $ret;
 }
 /**
  * (non-PHPdoc)
  * @see lib/Faett/Core/Interfaces/Faett_Core_Interfaces_Service#getPassword($channel)
  */
 public function getPassword($channel, $layer = 'user')
 {
     // return the password for channel
     return $this->_config->get('password', $layer, $channel);
 }
Beispiel #15
0
 /**
  * Get directory holding RNG schemas. Method is based on that 
  * found in Contact_AddressBook.
  *
  * @return string PEAR data directory.
  * @access public
  * @static
  */
 static function getSchemaDir()
 {
     require_once 'PEAR/Config.php';
     $config = new PEAR_Config();
     return $config->get('data_dir') . '/XML_Feed_Parser/schemas';
 }
Beispiel #16
0
<?php
require_once 'PEAR/Config.php';  
require_once 'PEAR/Registry.php';  
  
$config = new PEAR_Config();  
$reg = new PEAR_Registry($config->get('php_dir'));  
$packages = $reg->listPackages();  
  
foreach($packages as $value)  
{  
    echo $value."<br>";  
}  
?>
Beispiel #17
0
 /**
  * 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;
     }
 }
Beispiel #18
0
 /**
  * BEARスケルトンアプリ作成
  *
  * @param string $path  アプリケーシン絶対or相対パス
  * @param string $pearc .pearrcパス
  *
  * @return void
  */
 private function _initApp($path, $pearc = '')
 {
     $bearPath = _BEAR_BEAR_HOME;
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         throw Exception("Windows is not supported for init-app, copy data/app instaed.\n");
         exit;
     }
     $config = new PEAR_Config($pearc);
     $pearPath = $config->get('php_dir');
     $pearDataPath = $config->get('data_dir');
     //usr/share/php/data
     $source = "{$pearDataPath}/BEAR/data/app";
     if (!file_exists($source)) {
         $source = _BEAR_BEAR_HOME . '/data/app';
     }
     if (!file_exists($source)) {
         die("error: no valid app folder\n{$source}\n");
     }
     $exec = "/bin/cp -R {$source} {$path}";
     // コピー先エラーチェック
     if (file_exists($path)) {
         die("'{$path}' already exists\n");
     }
     $result = shell_exec($exec);
     if ($result) {
         die("cp error. src=[{$source}] dest=[{$path}]");
     }
     // 属性変更
     $dirs = array();
     $dirs[] = "{$path}/logs";
     $dirs[] = "{$path}/tmp";
     $dirs[] = "{$path}/tmp/cache_lite";
     $dirs[] = "{$path}/tmp/session";
     $dirs[] = "{$path}/tmp/smarty_cache";
     $dirs[] = "{$path}/tmp/smarty_templates_c";
     $dirs[] = "{$path}/tmp/upload";
     $dirs[] = "{$path}/tmp/misc";
     foreach ($dirs as $dir) {
         if (chmod($dir, 0777) == false) {
             die("chmod fault path=[{$dir}]\n");
         }
     }
     // .htaccess
     $htacessPath = "{$path}/htdocs/htaccess.txt";
     $htacessPathNew = "{$path}/htdocs/.htaccess";
     if (!file_exists($htacessPath)) {
         die("[ERROR] htaccss missing error = [{$htacessPath}]\n");
     }
     // symlink
     $from = "{$pearDataPath}/BEAR/data/htdocs/__bear";
     $to = "{$path}/htdocs/__bear";
     $result = symlink($from, $to);
     if ($result === false) {
         rmdir($to);
         echo "Please make symlink manually.\n'ln -s {$from} {$to}'\n";
     }
     $from = "{$pearDataPath}/BEAR/data/htdocs/__edit";
     $to = "{$path}/htdocs/__edit";
     $result = symlink($from, $to);
     if ($result === false) {
         rmdir($to);
         echo "Please make symlink manually.\n'ln -s {$from} {$to}'\n";
     }
     $from = "{$pearDataPath}/Panda/data/htdocs/__panda";
     $to = "{$path}/htdocs/__panda";
     $result = symlink($from, $to);
     if ($result === false) {
         rmdir($to);
         echo "Please make symlink manually.\n'ln -s {$from} {$to}'\n";
     }
     // 置換
     $files = array($htacessPath);
     $ignoreline = array("#", ":");
     $err = error_reporting();
     error_reporting(0);
     $snr = new File_SearchReplace('@APP-DIR@', $path, $files, "{$path}/htdocs/", false, $ignoreline);
     $snr->doSearch();
     $snr = new File_SearchReplace('@VENDORS-PEAR-DIR@', "{$bearPath}/BEAR/vendors/PEAR", $files, "{$path}/htdocs/", false, $ignoreline);
     $snr->doSearch();
     $snr = new File_SearchReplace('/opt/local/lib/php', $pearPath, $files, "{$path}/htdocs/", false, $ignoreline);
     $snr->doSearch();
     error_reporting($err);
     //mv htaccess.txt .htaccess
     $result = rename($htacessPath, $htacessPathNew);
     if (!$result) {
         echo "htaccess rename error [{$htacessPath}] to [{$htacessPathNew}]\n";
     }
     echo "BEAR App files are made at '{$path}'.\n";
     echo "Thank you for using BEAR.";
 }
Beispiel #19
0
 /**
  * @param array output of package.getDownloadURL
  * @param string|array|object information for detecting packages to be downloaded, and
  *                            for errors
  * @param array name information of the package
  * @param array|null packages to be downloaded
  * @param bool is this an optional dependency?
  * @access private
  */
 function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false)
 {
     if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
         return false;
     }
     if (!$info) {
         if (!is_string($param)) {
             $saveparam = ", cannot download \"{$param}\"";
         } else {
             $saveparam = '';
         }
         // no releases exist
         return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
     }
     if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
         $err = false;
         if ($pname['channel'] == 'pecl.php.net') {
             if ($info['info']->getChannel() != 'pear.php.net') {
                 $err = true;
             }
         } elseif ($info['info']->getChannel() == 'pecl.php.net') {
             if ($pname['channel'] != 'pear.php.net') {
                 $err = true;
             }
         } else {
             $err = true;
         }
         if ($err) {
             return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
         }
     }
     if (!isset($info['url'])) {
         $instead = ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"';
         // releases exist, but we failed to get any
         if (isset($this->_downloader->_options['force'])) {
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = PEAR_Dependency2::_getExtraString($pname);
                     $instead = '';
                 }
             } else {
                 $vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
             }
             if (!isset($options['soft'])) {
                 $this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . $instead);
             }
             // download the latest release
             return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
         } else {
             // construct helpful error message
             if (isset($pname['version'])) {
                 $vs = ', version "' . $pname['version'] . '"';
             } elseif (isset($pname['state'])) {
                 $vs = ', stability "' . $pname['state'] . '"';
             } elseif ($param == 'dependency') {
                 if (!class_exists('PEAR_Common')) {
                     require_once 'PEAR/Common.php';
                 }
                 if (!in_array($info['info']->getState(), PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
                         // optional dep failure!
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
                 } else {
                     if (!class_exists('PEAR_Dependency2')) {
                         require_once 'PEAR/Dependency2.php';
                     }
                     if ($optional) {
                         // don't spit out confusing error message, and don't die on
                         // optional dep failure!
                         return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
                     }
                     $vs = PEAR_Dependency2::_getExtraString($pname);
                 }
             } else {
                 $vs = ' within preferred state "' . $this->_downloader->config->get('preferred_state') . '"';
             }
             $options = $this->_downloader->getOptions();
             // this is only set by the "download-all" command
             if (isset($options['ignorepreferred_state'])) {
                 $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install', PEAR_DOWNLOADER_PACKAGE_STATE);
                 return $err;
             }
             $err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install');
             return $err;
         }
     }
     return $info;
 }
 * BEAR 開発用info画面
 *
 * PHP versions 5
 *
 * @category   BEAR
 * @package    BEAR
 * @subpackage Debug
 * @author     Akihito Koriyama <*****@*****.**>
 * @copyright  2008-2011 Akihito Koriyama  All rights reserved.
 * @license    http://opensource.org/licenses/bsd-license.php BSD
 * @link       http://www.bear-project.net/
 */
if (isset($_GET['_pear_dir'])) {
    // パーミッションチェック
    $config = new PEAR_Config();
    $pearDataPath = $config->get('data_dir');
    if (strpos(_BEAR_BEAR_HOME, $pearDataPath)) {
        $dataDir = "{$pearDataPath}/BEAR";
    } else {
        $dataDir = _BEAR_BEAR_HOME . '/data/';
    }
    if (file_exists("{$pearDataPath}/BEAR")) {
        $dataDir = '$pearDataPath/BEAR';
    } elseif (file_exists($pearDataPath . '/data')) {
        $dataDir = 'BEAR/data';
    }
} else {
    $pearDataPath = '<a href="?_beardebug_setting&_pear_dir">{pear data_dir}</a>';
}
$exit = false;
if (PHP_SAPI !== 'cli') {
Beispiel #21
0
    $result = "Database support is ok";
    $status = OK;
}
print_row("Database Support", $result, $status);
// PEAR
$have_pear = false;
if (!($pear_dir = find_path($path_list, "PEAR"))) {
    $result = "Not installed.  The PEAR extension is required by several other " . "PHP extensions that Maia needs.  See <a href=\"http://pear.php.net/\">this page</a> " . "for more information about downloading and installing PEAR.";
    $status = ERROR;
} else {
    // include_once ("PEAR/Remote.php");      // PEAR::Remote
    include_once "PEAR/Registry.php";
    // PEAR::Registry
    $have_pear = true;
    $pear = new PEAR_Config();
    $pear_reg = new PEAR_Registry($pear->get('php_dir'));
    $pear_info = $pear_reg->packageInfo("PEAR");
    $pear_list = $pear_reg->listPackages();
    $pear_version = is_array($pear_info["version"]) ? $pear_info["version"]["release"] : $pear_info["version"];
    $result = $pear_version;
    $status = OK;
}
print_row("PEAR", $result, $status);
// PEAR::Mail_Mime
if ($have_pear) {
    if (!in_array("mail_mime", $pear_list)) {
        $result = "Not installed.  This PHP extension is required to decode " . "MIME-structured e-mail.  Use <b>pear install Mail_Mime</b> to " . "install this.";
        $status = ERROR;
    } else {
        $info = $pear_reg->packageInfo("Mail_Mime");
        $result = is_array($info["version"]) ? $info["version"]["release"] : $info["version"];
Beispiel #22
0
 /**
  * Create a PEAR_PackageFile_v* from an XML string.
  * @access  public
  * @param   string $data contents of package.xml file
  * @param   int $state package state (one of PEAR_VALIDATE_* constants)
  * @param   string $file full path to the package.xml file (and the files
  *          it references)
  * @param   string $archive optional name of the archive that the XML was
  *          extracted from, if any
  * @return  PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @uses    parserFactory() to construct a parser to load the package.
  */
 function &fromXmlString($data, $state, $file, $archive = false)
 {
     if (preg_match('/<package[^>]+version="([0-9]+\\.[0-9]+)"/', $data, $packageversion)) {
         if (!in_array($packageversion[1], array('1.0', '2.0', '2.1'))) {
             return PEAR::raiseError('package.xml version "' . $packageversion[1] . '" is not supported, only 1.0, 2.0, and 2.1 are supported.');
         }
         $object =& $this->parserFactory($packageversion[1]);
         if ($this->_logger) {
             $object->setLogger($this->_logger);
         }
         $object->setConfig($this->_config);
         $pf = $object->parse($data, $file, $archive);
         if (PEAR::isError($pf)) {
             return $pf;
         }
         if ($this->_rawReturn) {
             return $pf;
         }
         if ($pf->validate($state)) {
             if ($this->_logger) {
                 if ($pf->getValidationWarnings(false)) {
                     foreach ($pf->getValidationWarnings() as $warning) {
                         $this->_logger->log(0, 'WARNING: ' . $warning['message']);
                     }
                 }
             }
             if (method_exists($pf, 'flattenFilelist')) {
                 $pf->flattenFilelist();
                 // for v2
             }
             return $pf;
         } else {
             if ($this->_config->get('verbose') > 0) {
                 if ($this->_logger) {
                     if ($pf->getValidationWarnings(false)) {
                         foreach ($pf->getValidationWarnings(false) as $warning) {
                             $this->_logger->log(0, 'ERROR: ' . $warning['message']);
                         }
                     }
                 }
             }
             $a = PEAR::raiseError('Parsing of package.xml from file "' . $file . '" failed', 2, null, null, $pf->getValidationWarnings());
             return $a;
         }
     } elseif (preg_match('/<package[^>]+version="([^"]+)"/', $data, $packageversion)) {
         $a = PEAR::raiseError('package.xml file "' . $file . '" has unsupported package.xml <package> version "' . $packageversion[1] . '"');
         return $a;
     } else {
         if (!class_exists('PEAR_ErrorStack')) {
             require_once 'PEAR/ErrorStack.php';
         }
         PEAR_ErrorStack::staticPush('PEAR_PackageFile', PEAR_PACKAGEFILE_ERROR_NO_PACKAGEVERSION, 'warning', array('xml' => $data), 'package.xml "' . $file . '" has no package.xml <package> version');
         $object =& $this->parserFactory('1.0');
         $object->setConfig($this->_config);
         $pf = $object->parse($data, $file, $archive);
         if (PEAR::isError($pf)) {
             return $pf;
         }
         if ($this->_rawReturn) {
             return $pf;
         }
         if ($pf->validate($state)) {
             if ($this->_logger) {
                 if ($pf->getValidationWarnings(false)) {
                     foreach ($pf->getValidationWarnings() as $warning) {
                         $this->_logger->log(0, 'WARNING: ' . $warning['message']);
                     }
                 }
             }
             if (method_exists($pf, 'flattenFilelist')) {
                 $pf->flattenFilelist();
                 // for v2
             }
             return $pf;
         } else {
             $a = PEAR::raiseError('Parsing of package.xml from file "' . $file . '" failed', 2, null, null, $pf->getValidationWarnings());
             return $a;
         }
     }
 }
Beispiel #23
0
 /**
  * Check if a package is installed
  */
 function packageInstalled($package_name, $version = null, $pear_user_config = null)
 {
     if (is_null($pear_user_config)) {
         $config = new PEAR_Config();
     } else {
         $config = new PEAR_Config($pear_user_config);
     }
     $reg = new PEAR_Registry($config->get('php_dir'));
     if (is_null($version)) {
         return $reg->packageExists($package_name);
     } else {
         $installed = $reg->packageInfo($package_name);
         return version_compare($version, $installed['version'], '<=');
     }
 }
 /**
  * @return array
  * @access public
  */
 public function collectTests()
 {
     $config = new PEAR_Config();
     $iterator = new AppendIterator();
     $result = array();
     if (substr(PHP_OS, 0, 3) == 'WIN') {
         $delimiter = ';';
     } else {
         $delimiter = ':';
     }
     $paths = explode($delimiter, ini_get('include_path'));
     $paths[] = $config->get('test_dir');
     foreach ($paths as $path) {
         $iterator->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
     }
     foreach ($iterator as $path => $file) {
         if ($this->isTestClass($file)) {
             if (substr(PHP_OS, 0, 3) == 'WIN') {
                 $path = str_replace('/', '\\', $path);
             }
             $result[] = $path;
         }
     }
     return $result;
 }
Beispiel #25
0
 /**
  * PEAR_Common constructor
  *
  * @access public
  */
 function __construct()
 {
     parent::__construct();
     $this->config =& PEAR_Config::singleton();
     $this->debug = $this->config->get('verbose');
 }
Beispiel #26
0
function readSqlFile($file)
{
    $result = false;
    $result = file_get_contents($file, true);
    if ($result === false) {
        $incFile = "ringside" . DIRECTORY_SEPARATOR . "sql" . DIRECTORY_SEPARATOR . $file;
        error_log("Could not find file, looking in {$incFile}");
        $result = file_get_contents($incFile, true);
        if ($result === false) {
            writeLine("Could not locate the file ringside/config/{$file} , looking in PEAR");
            error_log("Could not find file, looking in PEAR");
            $hasPear = (include_once 'PEAR/Config.php');
            if ($hasPear !== false) {
                $pear = new PEAR_Config();
                $pearDataDir = $pear->get("data_dir");
                if ($pearDataDir !== false) {
                    $pearDataDir .= DIRECTORY_SEPARATOR . "ringside" . DIRECTORY_SEPARATOR . "config";
                    $result = file_get_contents($pearDataDir . DIRECTORY_SEPARATOR . $file);
                    if ($result === false) {
                        writeLine("Check your pear setting for data_dir : " . $pear->get("data_dir"));
                        writeLine("From the command line 'pear config-set data_dir [data dir used during installation]'");
                        writeLine("To See your configuration settings 'pear config-show user");
                        error_log($package . '/' . $file . " not read into memory from include_path or " . $pearDataDir . DIRECTORY_SEPARATOR . $file);
                    }
                } else {
                    error_log($package . '/' . $file . " not read into memory and pear Data dir is empty");
                }
            } else {
                error_log($package . '/' . $file . " not read into memory and pear not available ");
            }
        }
    }
    return $result;
}
Beispiel #27
0
 function _initializeDepDB()
 {
     if (!isset($this->_dependencyDB)) {
         static $initializing = false;
         if (!$initializing) {
             $initializing = true;
             if (!$this->_config) {
                 // never used?
                 $file = OS_WINDOWS ? 'pear.ini' : '.pearrc';
                 $this->_config =& new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR . $file);
                 $this->_config->setRegistry($this);
                 $this->_config->set('php_dir', $this->install_dir);
             }
             $this->_dependencyDB =& PEAR_DependencyDB::singleton($this->_config);
             if (PEAR::isError($this->_dependencyDB)) {
                 // attempt to recover by removing the dep db
                 if (file_exists($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb')) {
                     @unlink($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb');
                 }
                 $this->_dependencyDB =& PEAR_DependencyDB::singleton($this->_config);
                 if (PEAR::isError($this->_dependencyDB)) {
                     echo $this->_dependencyDB->getMessage();
                     echo 'Unrecoverable error';
                     exit(1);
                 }
             }
             $initializing = false;
         }
     }
 }
Beispiel #28
0
 /**
  *
  *
  * @return Array
  * @access public
  * @static
  * @since  Method available since Release 3.0.0
  */
 public static function getIncludePaths()
 {
     $includePaths = explode(PATH_SEPARATOR, get_include_path());
     @(include_once 'PEAR/Config.php');
     if (class_exists('PEAR_Config', FALSE)) {
         $config = new PEAR_Config();
         $includePaths[] = $config->get('test_dir');
     }
     return $includePaths;
 }
 /**
  * PEAR_Common constructor
  *
  * @access public
  */
 function PEAR_Common()
 {
     parent::PEAR();
     $this->config =& PEAR_Config::singleton();
     $this->debug = $this->config->get('verbose');
 }
Beispiel #30
0
 /**
  * Locates a given data file used by this plugin and returns the path to
  * it. This is currently used mainly for compatibility with PEAR packaging.
  *
  * @param string $filename Name of the file
  * @return string|null File path or NULL if the file cannot be found 
  */
 public function findDataFile($filename)
 {
     $class = get_class($this);
     $r = new ReflectionClass($class);
     $path = dirname($r->getFilename()) . '/' . $this->getName() . '/' . $filename;
     if (file_exists($path)) {
         return $path;
     }
     if (class_exists('PEAR_Config')) {
         $config = new PEAR_Config();
         $dataDir = $config->get('data_dir');
         $path = rtrim($dataDir, '\\/') . '/' . $class . '/' . str_replace('_', '/', $class) . '/' . $filename;
         if (file_exists($path)) {
             return $path;
         }
     }
     return null;
 }