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

📄 dependency.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php//// +----------------------------------------------------------------------+// | PHP Version 5                                                        |// +----------------------------------------------------------------------+// | Copyright (c) 1997-2006 The PHP Group                                |// +----------------------------------------------------------------------+// | This source file is subject to version 3.01 of the PHP license,      |// | that is bundled with this package in the file LICENSE, and is        |// | available through the world-wide-web at the following url:           |// | 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 world-wide-web, please send a note to          |// | license@php.net so we can mail you a copy immediately.               |// +----------------------------------------------------------------------+// | Authors: Tomas V.V.Cox <cox@idecnet.com>                             |// |          Stig Bakken <ssb@php.net>                                   |// +----------------------------------------------------------------------+//// THIS FILE IS DEPRECATED IN FAVOR OF DEPENDENCY2.PHP, AND IS NOT USED IN THE INSTALLER// $Id: Dependency.php,v 1.14.4.21.2.3 2006/01/01 13:51:22 sniper Exp $require_once "PEAR.php";require_once "OS/Guess.php";define('PEAR_DEPENDENCY_MISSING',        -1);define('PEAR_DEPENDENCY_CONFLICT',       -2);define('PEAR_DEPENDENCY_UPGRADE_MINOR',  -3);define('PEAR_DEPENDENCY_UPGRADE_MAJOR',  -4);define('PEAR_DEPENDENCY_BAD_DEPENDENCY', -5);define('PEAR_DEPENDENCY_MISSING_OPTIONAL', -6);define('PEAR_DEPENDENCY_CONFLICT_OPTIONAL',       -7);define('PEAR_DEPENDENCY_UPGRADE_MINOR_OPTIONAL',  -8);define('PEAR_DEPENDENCY_UPGRADE_MAJOR_OPTIONAL',  -9);/** * Dependency check for PEAR packages * * The class is based on the dependency RFC that can be found at * http://cvs.php.net/cvs.php/pearweb/rfc. It requires PHP >= 4.1 * * @author Tomas V.V.Vox <cox@idecnet.com> * @author Stig Bakken <ssb@php.net> */class PEAR_Dependency{    // {{{ constructor    /**     * Constructor     *     * @access public     * @param  object Registry object     * @return void     */    function PEAR_Dependency(&$registry)    {        $this->registry = &$registry;    }    // }}}    // {{{ callCheckMethod()    /**    * This method maps the XML dependency definition to the    * corresponding one from PEAR_Dependency    *    * <pre>    * $opts => Array    *    (    *        [type] => pkg    *        [rel] => ge    *        [version] => 3.4    *        [name] => HTML_Common    *        [optional] => false    *    )    * </pre>    *    * @param  string Error message    * @param  array  Options    * @return boolean    */    function callCheckMethod(&$errmsg, $opts)    {        $rel = isset($opts['rel']) ? $opts['rel'] : 'has';        $req = isset($opts['version']) ? $opts['version'] : null;        $name = isset($opts['name']) ? $opts['name'] : null;        $channel = isset($opts['channel']) ? $opts['channel'] : 'pear.php.net';        $opt = (isset($opts['optional']) && $opts['optional'] == 'yes') ?            $opts['optional'] : null;        $errmsg = '';        switch ($opts['type']) {            case 'pkg':                return $this->checkPackage($errmsg, $name, $req, $rel, $opt, $channel);                break;            case 'ext':                return $this->checkExtension($errmsg, $name, $req, $rel, $opt);                break;            case 'php':                return $this->checkPHP($errmsg, $req, $rel);                break;            case 'prog':                return $this->checkProgram($errmsg, $name);                break;            case 'os':                return $this->checkOS($errmsg, $name);                break;            case 'sapi':                return $this->checkSAPI($errmsg, $name);                break;            case 'zend':                return $this->checkZend($errmsg, $name);                break;            default:                return "'{$opts['type']}' dependency type not supported";        }    }    // }}}    // {{{ checkPackage()    /**     * Package dependencies check method     *     * @param string $errmsg    Empty string, it will be populated with an error message, if any     * @param string $name      Name of the package to test     * @param string $req       The package version required     * @param string $relation  How to compare versions with each other     * @param bool   $opt       Whether the relationship is optional     * @param string $channel   Channel name     *     * @return mixed bool false if no error or the error string     */    function checkPackage(&$errmsg, $name, $req = null, $relation = 'has',                          $opt = false, $channel = 'pear.php.net')    {        if (is_string($req) && substr($req, 0, 2) == 'v.') {            $req = substr($req, 2);        }        switch ($relation) {            case 'has':                if (!$this->registry->packageExists($name, $channel)) {                    if ($opt) {                        $errmsg = "package `$channel/$name' is recommended to utilize some features.";                        return PEAR_DEPENDENCY_MISSING_OPTIONAL;                    }                    $errmsg = "requires package `$channel/$name'";                    return PEAR_DEPENDENCY_MISSING;                }                return false;            case 'not':                if ($this->registry->packageExists($name, $channel)) {                    $errmsg = "conflicts with package `$channel/$name'";                    return PEAR_DEPENDENCY_CONFLICT;                }                return false;            case 'lt':            case 'le':            case 'eq':            case 'ne':            case 'ge':            case 'gt':                $version = $this->registry->packageInfo($name, 'version', $channel);                if (!$this->registry->packageExists($name, $channel)                    || !version_compare("$version", "$req", $relation))                {                    $code = $this->codeFromRelation($relation, $version, $req, $opt);                    if ($opt) {                        $errmsg = "package `$channel/$name' version " . $this->signOperator($relation) .                            " $req is recommended to utilize some features.";                        if ($version) {                            $errmsg .= "  Installed version is $version";                        }                        return $code;                    }                    $errmsg = "requires package `$channel/$name' " .                        $this->signOperator($relation) . " $req";                    return $code;                }                return false;        }        $errmsg = "relation '$relation' with requirement '$req' is not supported (name=$channel/$name)";        return PEAR_DEPENDENCY_BAD_DEPENDENCY;    }    // }}}    // {{{ checkPackageUninstall()    /**     * Check package dependencies on uninstall     *     * @param string $error     The resultant error string     * @param string $warning   The resultant warning string     * @param string $name      Name of the package to test     * @param string $channel   Channel name of the package     *     * @return bool true if there were errors     */    function checkPackageUninstall(&$error, &$warning, $package, $channel = 'pear.php.net')    {        $channel = strtolower($channel);        $error = null;        $channels = $this->registry->listAllPackages();        foreach ($channels as $channelname => $packages) {            foreach ($packages as $pkg) {                if ($pkg == $package && $channel == $channelname) {                    continue;                }                $deps = $this->registry->packageInfo($pkg, 'release_deps', $channel);                if (empty($deps)) {                    continue;                }                foreach ($deps as $dep) {                    $depchannel = isset($dep['channel']) ? $dep['channel'] : 'pear.php.net';                    if ($dep['type'] == 'pkg' && (strcasecmp($dep['name'], $package) == 0) &&                          ($depchannel == $channel)) {                        if ($dep['rel'] == 'ne') {                            continue;                        }                        if (isset($dep['optional']) && $dep['optional'] == 'yes') {                            $warning .= "\nWarning: Package '$depchannel/$pkg' optionally depends on '$channel:/package'";                        } else {                            $error .= "Package '$depchannel/$pkg' depends on '$channel/$package'\n";                        }                    }                }            }        }        return ($error) ? true : false;    }    // }}}    // {{{ checkExtension()    /**     * Extension dependencies check method     *     * @param string $name        Name of the extension to test     * @param string $req_ext_ver Required extension version to compare with     * @param string $relation    How to compare versions with eachother     * @param bool   $opt         Whether the relationship is optional     *     * @return mixed bool false if no error or the error string     */    function checkExtension(&$errmsg, $name, $req = null, $relation = 'has',        $opt = false)    {        if ($relation == 'not') {            if (extension_loaded($name)) {

⌨️ 快捷键说明

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