v2.php

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 1,918 行 · 第 1/5 页

PHP
1,918
字号
        foreach ($sub as $dep) {            if (strtolower($dep['name']) == strtolower($p->getPackage())) {                if (isset($dep['channel'])) {                    if (strtolower($dep['channel']) == strtolower($p->getChannel())) {                        return true;                    }                } else {                    if ($dep['uri'] == $p->getURI()) {                        return true;                    }                }            }        }        return false;    }    function dependsOn($package, $channel)    {        if (!($deps = $this->getDependencies())) {            return false;        }        foreach (array('package', 'subpackage') as $type) {            foreach (array('required', 'optional') as $needed) {                if (isset($deps[$needed][$type])) {                    if (!isset($deps[$needed][$type][0])) {                        $deps[$needed][$type] = array($deps[$needed][$type]);                    }                    foreach ($deps[$needed][$type] as $dep) {                        $depchannel = isset($dep['channel']) ? $dep['channel'] : '__uri';                        if (strtolower($dep['name']) == strtolower($package) &&                              $depchannel == $channel) {                            return true;                        }                      }                }            }            if (isset($deps['group'])) {                if (!isset($deps['group'][0])) {                    $dep['group'] = array($deps['group']);                }                foreach ($deps['group'] as $group) {                    if (isset($group[$type])) {                        if (!is_array($group[$type])) {                            $group[$type] = array($group[$type]);                        }                        foreach ($group[$type] as $dep) {                            $depchannel = isset($dep['channel']) ? $dep['channel'] : '__uri';                            if (strtolower($dep['name']) == strtolower($package) &&                                  $depchannel == $channel) {                                return true;                            }                          }                    }                }            }        }        return false;    }    /**     * Get the contents of a dependency group     * @param string     * @return array|false     */    function getDependencyGroup($name)    {        $name = strtolower($name);        if (!isset($this->_packageInfo['dependencies']['group'])) {            return false;        }        $groups = $this->_packageInfo['dependencies']['group'];        if (!isset($groups[0])) {            $groups = array($groups);        }        foreach ($groups as $group) {            if (strtolower($group['attribs']['name']) == $name) {                return $group;            }        }        return false;    }    /**     * Retrieve a partial package.xml 1.0 representation of dependencies     *     * a very limited representation of dependencies is returned by this method.     * The <exclude> tag for excluding certain versions of a dependency is     * completely ignored.  In addition, dependency groups are ignored, with the     * assumption that all dependencies in dependency groups are also listed in     * the optional group that work with all dependency groups     * @param boolean return package.xml 2.0 <dependencies> tag     * @return array|false     */    function getDeps($raw = false, $nopearinstaller = false)    {        if (isset($this->_packageInfo['dependencies'])) {            if ($raw) {                return $this->_packageInfo['dependencies'];            }            $ret = array();            $map = array(                'php' => 'php',                'package' => 'pkg',                'subpackage' => 'pkg',                'extension' => 'ext',                'os' => 'os',                'pearinstaller' => 'pkg',                );            foreach (array('required', 'optional') as $type) {                $optional = ($type == 'optional') ? 'yes' : 'no';                if (!isset($this->_packageInfo['dependencies'][$type])) {                    continue;                }                foreach ($this->_packageInfo['dependencies'][$type] as $dtype => $deps) {                    if ($dtype == 'pearinstaller' && $nopearinstaller) {                        continue;                    }                    if (!isset($deps[0])) {                        $deps = array($deps);                    }                    foreach ($deps as $dep) {                        if (!isset($map[$dtype])) {                            // no support for arch type                            continue;                        }                        if ($dtype == 'pearinstaller') {                            $dep['name'] = 'PEAR';                            $dep['channel'] = 'pear.php.net';                        }                        $s = array('type' => $map[$dtype]);                        if (isset($dep['channel'])) {                            $s['channel'] = $dep['channel'];                        }                        if (isset($dep['uri'])) {                            $s['uri'] = $dep['uri'];                        }                        if (isset($dep['name'])) {                            $s['name'] = $dep['name'];                        }                        if (isset($dep['conflicts'])) {                            $s['rel'] = 'not';                        } else {                            if (!isset($dep['min']) &&                                  !isset($dep['max'])) {                                $s['rel'] = 'has';                                $s['optional'] = $optional;                            } elseif (isset($dep['min']) &&                                  isset($dep['max'])) {                                $s['rel'] = 'ge';                                $s1 = $s;                                $s1['rel'] = 'le';                                $s['version'] = $dep['min'];                                $s1['version'] = $dep['max'];                                if (isset($dep['channel'])) {                                    $s1['channel'] = $dep['channel'];                                }                                if ($dtype != 'php') {                                    $s['name'] = $dep['name'];                                    $s1['name'] = $dep['name'];                                }                                $s['optional'] = $optional;                                $s1['optional'] = $optional;                                $ret[] = $s1;                            } elseif (isset($dep['min'])) {                                if (isset($dep['exclude']) &&                                      $dep['exclude'] == $dep['min']) {                                    $s['rel'] = 'gt';                                } else {                                    $s['rel'] = 'ge';                                }                                $s['version'] = $dep['min'];                                $s['optional'] = $optional;                                if ($dtype != 'php') {                                    $s['name'] = $dep['name'];                                }                            } elseif (isset($dep['max'])) {                                if (isset($dep['exclude']) &&                                      $dep['exclude'] == $dep['max']) {                                    $s['rel'] = 'lt';                                } else {                                    $s['rel'] = 'le';                                }                                $s['version'] = $dep['max'];                                $s['optional'] = $optional;                                if ($dtype != 'php') {                                    $s['name'] = $dep['name'];                                }                            }                        }                        $ret[] = $s;                    }                }            }            if (count($ret)) {                return $ret;            }        }        return false;    }    /**     * @return php|extsrc|extbin|zendextsrc|zendextbin|bundle|false     */    function getPackageType()    {        if (isset($this->_packageInfo['phprelease'])) {            return 'php';        }        if (isset($this->_packageInfo['extsrcrelease'])) {            return 'extsrc';        }        if (isset($this->_packageInfo['extbinrelease'])) {            return 'extbin';        }        if (isset($this->_packageInfo['zendextsrcrelease'])) {            return 'zendextsrc';        }        if (isset($this->_packageInfo['zendextbinrelease'])) {            return 'zendextbin';        }        if (isset($this->_packageInfo['bundle'])) {            return 'bundle';        }        return false;    }    /**     * @return array|false     */    function getReleases()    {        $type = $this->getPackageType();        if ($type != 'bundle') {            $type .= 'release';        }        if ($this->getPackageType() && isset($this->_packageInfo[$type])) {            return $this->_packageInfo[$type];        }        return false;    }    /**     * @return array     */    function getChangelog()    {        if (isset($this->_packageInfo['changelog'])) {            return $this->_packageInfo['changelog'];        }        return false;    }    function hasDeps()    {        return isset($this->_packageInfo['dependencies']);    }    function getPackagexmlVersion()    {        if (isset($this->_packageInfo['zendextsrcrelease'])) {            return '2.1';        }        if (isset($this->_packageInfo['zendextbinrelease'])) {            return '2.1';        }        return '2.0';    }    /**     * @return array|false     */    function getSourcePackage()    {        if (isset($this->_packageInfo['extbinrelease']) ||              isset($this->_packageInfo['zendextbinrelease'])) {            return array('channel' => $this->_packageInfo['srcchannel'],                         'package' => $this->_packageInfo['srcpackage']);        }        return false;    }    function getBundledPackages()    {        if (isset($this->_packageInfo['bundle'])) {            return $this->_packageInfo['contents']['bundledpackage'];        }        return false;    }    function getLastModified()    {        if (isset($this->_packageInfo['_lastmodified'])) {            return $this->_packageInfo['_lastmodified'];        }        return false;    }    /**     * Get the contents of a file listed within the package.xml     * @param string     * @return string     */    function getFileContents($file)    {        if ($this->_archiveFile == $this->_packageFile) { // unpacked            $dir = dirname($this->_packageFile);            $file = $dir . DIRECTORY_SEPARATOR . $file;            $file = str_replace(array('/', '\\'),                array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $file);            if (file_exists($file) && is_readable($file)) {                return implode('', file($file));            }        } else { // tgz            $tar = &new Archive_Tar($this->_archiveFile);            $tar->pushErrorHandling(PEAR_ERROR_RETURN);            if ($file != 'package.xml' && $file != 'package2.xml') {                $file = $this->getPackage() . '-' . $this->getVersion() . '/' . $file;            }            $file = $tar->extractInString($file);            $tar->popErrorHandling();            if (PEAR::isError($file)) {                return PEAR::raiseError("Cannot locate file '$file' in archive");            }            return $file;        }    }    function &getRW()    {        if (!class_exists('PEAR_PackageFile_v2_rw')) {            require_once 'PEAR/PackageFile/v2/rw.php';        }        $a = new PEAR_PackageFile_v2_rw;        foreach (get_object_vars($this) as $name => $unused) {            if (!isset($this->$name)) {                continue;            }            if ($name == '_config' || $name == '_logger'|| $name == '_registry' ||                  $name == '_stack') {                $a->$name = &$this->$name;            } else {                $a->$name = $this->$name;            }        }        return $a;    }    function &getDefaultGenerator()    {        if (!class_exists('PEAR_PackageFile_Generator_v2')) {            require_once 'PEAR/PackageFile/Generator/v2.php';        }        $a = &new PEAR_PackageFile_Generator_v2($this);        return $a;    }    function analyzeSourceCode($file, $string = false)    {        if (!isset($this->_v2Validator) ||              !is_a($this->_v2Validator, 'PEAR_PackageFile_v2_Validator')) {            if (!class_exists('PEAR_PackageFile_v2_Validator')) {                require_once 'PEAR/PackageFile/v2/Validator.php';            }            $this->_v2Validator = new PEAR_PackageFile_v2_Validator;        }        return $this->_v2Validator->analyzeSourceCode($file, $string);    }    function validate($state = PEAR_VALIDATE_NORMAL)    {        if (!isset($this->_packageInfo) || !is_array($this->_packageInfo)) {            return false;        }        if (!isset($this->_v2Validator) ||              !is_a($this->_v2Validator, 'PEAR_PackageFile_v2_Validator')) {            if (!class_exists('PEAR_PackageFile_v2_Validator')) {                require_once 'PEAR/PackageFile/v2/Validator.php';            }            $this->_v2Validator = new PEAR_PackageFile_v2_Validator;        }        if (isset($this->_packageInfo['xsdversion'])) {        

⌨️ 快捷键说明

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