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

📄 validator.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 5 页
字号:
        $this->_validatePackageDep($dep, $group, '<subpackage>');        if (isset($dep['providesextension'])) {            $this->_subpackageCannotProvideExtension(@$dep['name']);        }        if (isset($dep['conflicts'])) {            $this->_subpackagesCannotConflict(@$dep['name']);        }    }    function _validateExtensionDep($dep, $group = false, $installcondition = false)    {        if (isset($dep['conflicts'])) {            $structure = array(                'name',                '*min',                '*max',                '*exclude',                'conflicts',            );        } else {            $structure = array(                'name',                '*min',                '*max',                '*recommended',                '*exclude',            );        }        if ($installcondition) {            $type = '<installcondition><extension>';        } else {            $type = '<dependencies>' . $group . '<extension>';        }        if (isset($dep['name'])) {            $type .= '<name>' . $dep['name'] . '</name>';        }        $this->_stupidSchemaValidate($structure, $dep, $type);        if (isset($dep['min'])) {            if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',                  $dep['min'])) {                $this->_invalidVersion(substr($type, 1) . '<min', $dep['min']);            }        }        if (isset($dep['max'])) {            if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',                  $dep['max'])) {                $this->_invalidVersion(substr($type, 1) . '<max', $dep['max']);            }        }        if (isset($dep['recommended'])) {            if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',                  $dep['recommended'])) {                $this->_invalidVersion(substr($type, 1) . '<recommended', $dep['recommended']);            }        }        if (isset($dep['exclude'])) {            if (!is_array($dep['exclude'])) {                $dep['exclude'] = array($dep['exclude']);            }            foreach ($dep['exclude'] as $exclude) {                if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',                      $exclude)) {                    $this->_invalidVersion(substr($type, 1) . '<exclude', $exclude);                }            }        }    }    function _validateOsDep($dep, $installcondition = false)    {        $structure = array(            'name',            '*conflicts',        );        $type = $installcondition ? '<installcondition><os>' : '<dependencies><required><os>';        if ($this->_stupidSchemaValidate($structure, $dep, $type)) {            if ($dep['name'] == '*') {                if (array_key_exists('conflicts', $dep)) {                    $this->_cannotConflictWithAllOs($type);                }            }        }    }    function _validateArchDep($dep, $installcondition = false)    {        $structure = array(            'pattern',            '*conflicts',        );        $type = $installcondition ? '<installcondition><arch>' : '<dependencies><required><arch>';        $this->_stupidSchemaValidate($structure, $dep, $type);    }    function _validateInstallConditions($cond, $release)    {        $structure = array(            '*php',            '*extension',            '*os',            '*arch',        );        if (!$this->_stupidSchemaValidate($structure,              $cond, $release)) {            return false;        }        foreach (array('php', 'extension', 'os', 'arch') as $type) {            if (isset($cond[$type])) {                $iter = $cond[$type];                if (!is_array($iter) || !isset($iter[0])) {                    $iter = array($iter);                }                foreach ($iter as $package) {                    if ($type == 'extension') {                        $this->{"_validate{$type}Dep"}($package, false, true);                    } else {                        $this->{"_validate{$type}Dep"}($package, true);                    }                }            }        }    }    function _validateDependencies()    {        $structure = array(            'required',            '*optional',            '*group->name->hint'        );        if (!$this->_stupidSchemaValidate($structure,              $this->_packageInfo['dependencies'], '<dependencies>')) {            return false;        }        foreach (array('required', 'optional') as $simpledep) {            if (isset($this->_packageInfo['dependencies'][$simpledep])) {                if ($simpledep == 'optional') {                    $structure = array(                        '*package',                        '*subpackage',                        '*extension',                    );                } else {                    $structure = array(                        'php',                        'pearinstaller',                        '*package',                        '*subpackage',                        '*extension',                        '*os',                        '*arch',                    );                }                if ($this->_stupidSchemaValidate($structure,                      $this->_packageInfo['dependencies'][$simpledep],                      "<dependencies><$simpledep>")) {                    foreach (array('package', 'subpackage', 'extension') as $type) {                        if (isset($this->_packageInfo['dependencies'][$simpledep][$type])) {                            $iter = $this->_packageInfo['dependencies'][$simpledep][$type];                            if (!isset($iter[0])) {                                $iter = array($iter);                            }                            foreach ($iter as $package) {                                if ($type != 'extension') {                                    if (isset($package['uri'])) {                                        if (isset($package['channel'])) {                                            $this->_UrlOrChannel($type,                                                $package['name']);                                        }                                    } else {                                        if (!isset($package['channel'])) {                                            $this->_NoChannel($type, $package['name']);                                        }                                    }                                }                                $this->{"_validate{$type}Dep"}($package, "<$simpledep>");                            }                        }                    }                    if ($simpledep == 'optional') {                        continue;                    }                    foreach (array('php', 'pearinstaller', 'os', 'arch') as $type) {                        if (isset($this->_packageInfo['dependencies'][$simpledep][$type])) {                            $iter = $this->_packageInfo['dependencies'][$simpledep][$type];                            if (!isset($iter[0])) {                                $iter = array($iter);                            }                            foreach ($iter as $package) {                                $this->{"_validate{$type}Dep"}($package);                            }                        }                    }                }            }        }        if (isset($this->_packageInfo['dependencies']['group'])) {            $groups = $this->_packageInfo['dependencies']['group'];            if (!isset($groups[0])) {                $groups = array($groups);            }            $structure = array(                '*package',                '*subpackage',                '*extension',            );            foreach ($groups as $group) {                if ($this->_stupidSchemaValidate($structure, $group, '<group>')) {                    if (!PEAR_Validate::validGroupName($group['attribs']['name'])) {                        $this->_invalidDepGroupName($group['attribs']['name']);                    }                    foreach (array('package', 'subpackage', 'extension') as $type) {                        if (isset($group[$type])) {                            $iter = $group[$type];                            if (!isset($iter[0])) {                                $iter = array($iter);                            }                            foreach ($iter as $package) {                                if ($type != 'extension') {                                    if (isset($package['uri'])) {                                        if (isset($package['channel'])) {                                            $this->_UrlOrChannelGroup($type,                                                $package['name'],                                                $group['name']);                                        }                                    } else {                                        if (!isset($package['channel'])) {                                            $this->_NoChannelGroup($type,                                                $package['name'],                                                $group['name']);                                        }                                    }                                }                                $this->{"_validate{$type}Dep"}($package, '<group name="' .                                    $group['attribs']['name'] . '">');                            }                        }                    }                }            }        }    }    function _validateCompatible()    {        $compat = $this->_packageInfo['compatible'];        if (!isset($compat[0])) {            $compat = array($compat);        }        $required = array('name', 'channel', 'min', 'max', '*exclude');        foreach ($compat as $package) {            $type = '<compatible>';            if (is_array($package) && array_key_exists('name', $package)) {                $type .= '<name>' . $package['name'] . '</name>';            }            $this->_stupidSchemaValidate($required, $package, $type);            if (is_array($package) && array_key_exists('min', $package)) {                if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',                      $package['min'])) {                    $this->_invalidVersion(substr($type, 1) . '<min', $package['min']);                }            }            if (is_array($package) && array_key_exists('max', $package)) {                if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',                      $package['max'])) {                    $this->_invalidVersion(substr($type, 1) . '<max', $package['max']);                }            }            if (is_array($package) && array_key_exists('exclude', $package)) {                if (!is_array($package['exclude'])) {                    $package['exclude'] = array($package['exclude']);                }                foreach ($package['exclude'] as $exclude) {                    if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',                          $exclude)) {                        $this->_invalidVersion(substr($type, 1) . '<exclude', $exclude);                    }                }            }        }    }    function _validateBundle($list)    {        if (!is_array($list) || !isset($list['bundledpackage'])) {            return $this->_NoBundledPackages();        }        if (!is_array($list['bundledpackage']) || !isset($list['bundledpackage'][0])) {            return $this->_AtLeast2BundledPackages();        }        foreach ($list['bundledpackage'] as $package) {            if (!is_string($package)) {                $this->_bundledPackagesMustBeFilename();            }        }    }    function _validateFilelist($list = false, $allowignore = false, $dirs = '')    {        $iscontents = false;        if (!$list) {            $iscontents = true;            $list = $this->_packageInfo['contents'];            if (isset($this->_packageInfo['bundle'])) {                return $this->_validateBundle($list);            }        }        if ($allowignore) {            $struc = array(                '*install->name->as',                '*ignore->name'            );        } else {            $struc = array(                '*dir->name->?baseinstalldir',                '*file->name->role->?baseinstalldir->?md5sum'            );            if (isset($list['dir']) && isset($list['file'])) {                // stave off validation errors without requiring a set order.                $_old = $list;                if (isset($list['attribs'])) {                    $list = array('attribs' => $_old['attribs']);                }                $list['dir'] = $_old['dir'];                $list['file'] = $_old['file'];            }        }

⌨️ 快捷键说明

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