⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dependency2.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php/** * PEAR_Dependency2, advanced dependency validation * * 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     Greg Beaver <cellog@php.net> * @copyright  1997-2005 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 * @version    CVS: $Id: Dependency2.php,v 1.1.2.4 2006/05/22 10:19:33 cellog Exp $ * @link       http://pear.php.net/package/PEAR * @since      File available since Release 1.4.0a1 *//** * Required for the PEAR_VALIDATE_* constants */require_once 'PEAR/Validate.php';/** * Dependency check for PEAR packages * * This class handles both version 1.0 and 2.0 dependencies * WARNING: *any* changes to this class must be duplicated in the * test_PEAR_Dependency2 class found in tests/PEAR_Dependency2/setup.php.inc, * or unit tests will not actually validate the changes * @category   pear * @package    PEAR * @author     Greg Beaver <cellog@php.net> * @copyright  1997-2005 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 * @version    Release: @PEAR-VER@ * @link       http://pear.php.net/package/PEAR * @since      Class available since Release 1.4.0a1 */class PEAR_Dependency2{    /**     * One of the PEAR_VALIDATE_* states     * @see PEAR_VALIDATE_NORMAL     * @var integer     */    var $_state;    /**     * Command-line options to install/upgrade/uninstall commands     * @param array     */    var $_options;    /**     * @var OS_Guess     */    var $_os;    /**     * @var PEAR_Registry     */    var $_registry;    /**     * @var PEAR_Config     */    var $_config;    /**     * @var PEAR_DependencyDB     */    var $_dependencydb;    /**     * Output of PEAR_Registry::parsedPackageName()     * @var array     */    var $_currentPackage;    /**     * @param PEAR_Config     * @param array installation options     * @param array format of PEAR_Registry::parsedPackageName()     * @param int installation state (one of PEAR_VALIDATE_*)     */    function PEAR_Dependency2(&$config, $installoptions, $package,                              $state = PEAR_VALIDATE_INSTALLING)    {        $this->_config = &$config;        if (!class_exists('PEAR_DependencyDB')) {            require_once 'PEAR/DependencyDB.php';        }        if (isset($installoptions['packagingroot'])) {            // make sure depdb is in the right location            $config->setInstallRoot($installoptions['packagingroot']);        }        $this->_registry = &$config->getRegistry();        $this->_dependencydb = &PEAR_DependencyDB::singleton($config);        if (isset($installoptions['packagingroot'])) {            $config->setInstallRoot(false);        }        $this->_options = $installoptions;        $this->_state = $state;        if (!class_exists('OS_Guess')) {            require_once 'OS/Guess.php';        }        $this->_os = new OS_Guess;        $this->_currentPackage = $package;    }    function _getExtraString($dep)    {        $extra = ' (';        if (isset($dep['uri'])) {            return '';        }        if (isset($dep['recommended'])) {            $extra .= 'recommended version ' . $dep['recommended'];        } else {            if (isset($dep['min'])) {                $extra .= 'version >= ' . $dep['min'];            }            if (isset($dep['max'])) {                if ($extra != ' (') {                    $extra .= ', ';                }                $extra .= 'version <= ' . $dep['max'];            }            if (isset($dep['exclude'])) {                if (!is_array($dep['exclude'])) {                    $dep['exclude'] = array($dep['exclude']);                }                if ($extra != ' (') {                    $extra .= ', ';                }                $extra .= 'excluded versions: ';                foreach ($dep['exclude'] as $i => $exclude) {                    if ($i) {                        $extra .= ', ';                    }                    $extra .= $exclude;                }            }        }        $extra .= ')';        if ($extra == ' ()') {            $extra = '';        }        return $extra;    }    /**     * This makes unit-testing a heck of a lot easier     */    function getPHP_OS()    {        return PHP_OS;    }    /**     * This makes unit-testing a heck of a lot easier     */    function getsysname()    {        return $this->_os->getSysname();    }    /**     * Specify a dependency on an OS.  Use arch for detailed os/processor information     *     * There are two generic OS dependencies that will be the most common, unix and windows.     * Other options are linux, freebsd, darwin (OS X), sunos, irix, hpux, aix     */    function validateOsDependency($dep)    {        if ($this->_state != PEAR_VALIDATE_INSTALLING &&              $this->_state != PEAR_VALIDATE_DOWNLOADING) {            return true;        }        if (isset($dep['conflicts'])) {            $not = true;        } else {            $not = false;        }        if ($dep['name'] == '*') {            return true;        }        switch (strtolower($dep['name'])) {            case 'windows' :                if ($not) {                    if (strtolower(substr($this->getPHP_OS(), 0, 3)) == 'win') {                        if (!isset($this->_options['nodeps']) &&                              !isset($this->_options['force'])) {                            return $this->raiseError("Cannot install %s on Windows");                        } else {                            return $this->warning("warning: Cannot install %s on Windows");                        }                    }                } else {                    if (strtolower(substr($this->getPHP_OS(), 0, 3)) != 'win') {                        if (!isset($this->_options['nodeps']) &&                              !isset($this->_options['force'])) {                            return $this->raiseError("Can only install %s on Windows");                        } else {                            return $this->warning("warning: Can only install %s on Windows");                        }                    }                }            break;            case 'unix' :                $unices = array('linux', 'freebsd', 'darwin', 'sunos', 'irix', 'hpux', 'aix');                if ($not) {                    if (in_array($this->getSysname(), $unices)) {                        if (!isset($this->_options['nodeps']) &&                              !isset($this->_options['force'])) {                            return $this->raiseError("Cannot install %s on any Unix system");                        } else {                            return $this->warning(                                "warning: Cannot install %s on any Unix system");                        }                    }                } else {                    if (!in_array($this->getSysname(), $unices)) {                        if (!isset($this->_options['nodeps']) &&                              !isset($this->_options['force'])) {                            return $this->raiseError("Can only install %s on a Unix system");                        } else {                            return $this->warning(                                "warning: Can only install %s on a Unix system");                        }                    }                }            break;            default :                if ($not) {                    if (strtolower($dep['name']) == strtolower($this->getSysname())) {                        if (!isset($this->_options['nodeps']) &&                              !isset($this->_options['force'])) {                            return $this->raiseError('Cannot install %s on ' . $dep['name'] .                                ' operating system');                        } else {                            return $this->warning('warning: Cannot install %s on ' .                                $dep['name'] . ' operating system');                        }                    }                } else {                    if (strtolower($dep['name']) != strtolower($this->getSysname())) {                        if (!isset($this->_options['nodeps']) &&                              !isset($this->_options['force'])) {                            return $this->raiseError('Cannot install %s on ' .                                $this->getSysname() .                                ' operating system, can only install on ' . $dep['name']);                        } else {                            return $this->warning('warning: Cannot install %s on ' .                                $this->getSysname() .                                ' operating system, can only install on ' . $dep['name']);                        }                    }                }        }        return true;    }    /**     * This makes unit-testing a heck of a lot easier     */    function matchSignature($pattern)    {        return $this->_os->matchSignature($pattern);    }    /**     * Specify a complex dependency on an OS/processor/kernel version,     * Use OS for simple operating system dependency.     *     * This is the only dependency that accepts an eregable pattern.  The pattern     * will be matched against the php_uname() output parsed by OS_Guess     */    function validateArchDependency($dep)    {        if ($this->_state != PEAR_VALIDATE_INSTALLING) {            return true;        }        if (isset($dep['conflicts'])) {            $not = true;        } else {            $not = false;        }        if (!$this->matchSignature($dep['pattern'])) {            if (!$not) {                if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                    return $this->raiseError('%s Architecture dependency failed, does not ' .                        'match "' . $dep['pattern'] . '"');                } else {                    return $this->warning('warning: %s Architecture dependency failed, does ' .                        'not match "' . $dep['pattern'] . '"');                }            }            return true;        } else {            if ($not) {                if (!isset($this->_options['nodeps']) && !isset($this->_options['force'])) {                    return $this->raiseError('%s Architecture dependency failed, required "' .

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -