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

📄 common.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 5 页
字号:
        }        if (!empty($info['configure_options'])) {            $i = 1;            foreach ($info['configure_options'] as $c) {                if (empty($c['name'])) {                    $errors[] = "configure option $i: missing name";                }                if (empty($c['prompt'])) {                    $errors[] = "configure option $i: missing prompt";                }                $i++;            }        }        if (empty($info['filelist'])) {            $errors[] = 'no files';        } else {            foreach ($info['filelist'] as $file => $fa) {                if (empty($fa['role'])) {                    $errors[] = "file $file: missing role";                    continue;                } elseif (!in_array($fa['role'], PEAR_Common::getFileRoles())) {                    $errors[] = "file $file: invalid role, should be one of: "                        . implode(' ', PEAR_Common::getFileRoles());                }                if ($fa['role'] == 'php' && $dir_prefix) {                    $this->log(1, "Analyzing $file");                    $srcinfo = $this->analyzeSourceCode($dir_prefix . DIRECTORY_SEPARATOR . $file);                    if ($srcinfo) {                        $this->buildProvidesArray($srcinfo);                    }                }                // (ssb) Any checks we can do for baseinstalldir?                // (cox) Perhaps checks that either the target dir and                //       baseInstall doesn't cointain "../../"            }        }        $this->_packageName = $pn = $info['package'];        $pnl = strlen($pn);        foreach ((array)$this->pkginfo['provides'] as $key => $what) {            if (isset($what['explicit'])) {                // skip conformance checks if the provides entry is                // specified in the package.xml file                continue;            }            extract($what);            if ($type == 'class') {                if (!strncasecmp($name, $pn, $pnl)) {                    continue;                }                $warnings[] = "in $file: class \"$name\" not prefixed with package name \"$pn\"";            } elseif ($type == 'function') {                if (strstr($name, '::') || !strncasecmp($name, $pn, $pnl)) {                    continue;                }                $warnings[] = "in $file: function \"$name\" not prefixed with package name \"$pn\"";            }        }        return true;    }    // }}}    // {{{ buildProvidesArray()    /**     * Build a "provides" array from data returned by     * analyzeSourceCode().  The format of the built array is like     * this:     *     *  array(     *    'class;MyClass' => 'array('type' => 'class', 'name' => 'MyClass'),     *    ...     *  )     *     *     * @param array $srcinfo array with information about a source file     * as returned by the analyzeSourceCode() method.     *     * @return void     *     * @access public     *     */    function buildProvidesArray($srcinfo)    {        $file = basename($srcinfo['source_file']);        $pn  = $this->_packageName;        $pnl = strlen($pn);        foreach ($srcinfo['declared_classes'] as $class) {            $key = "class;$class";            if (isset($this->pkginfo['provides'][$key])) {                continue;            }            $this->pkginfo['provides'][$key] =                array('file'=> $file, 'type' => 'class', 'name' => $class);            if (isset($srcinfo['inheritance'][$class])) {                $this->pkginfo['provides'][$key]['extends'] =                    $srcinfo['inheritance'][$class];            }        }        foreach ($srcinfo['declared_methods'] as $class => $methods) {            foreach ($methods as $method) {                $function = "$class::$method";                $key = "function;$function";                if ($method{0} == '_' || !strcasecmp($method, $class) ||                    isset($this->pkginfo['provides'][$key])) {                    continue;                }                $this->pkginfo['provides'][$key] =                    array('file'=> $file, 'type' => 'function', 'name' => $function);            }        }        foreach ($srcinfo['declared_functions'] as $function) {            $key = "function;$function";            if ($function{0} == '_' || isset($this->pkginfo['provides'][$key])) {                continue;            }            if (!strstr($function, '::') && strncasecmp($function, $pn, $pnl)) {                $warnings[] = "in1 " . $file . ": function \"$function\" not prefixed with package name \"$pn\"";            }            $this->pkginfo['provides'][$key] =                array('file'=> $file, 'type' => 'function', 'name' => $function);        }    }    // }}}    // {{{ analyzeSourceCode()    /**     * Analyze the source code of the given PHP file     *     * @param  string Filename of the PHP file     * @return mixed     * @access public     */    function analyzeSourceCode($file)    {        if (!function_exists("token_get_all")) {            return false;        }        if (!$fp = @fopen($file, "r")) {            return false;        }        $contents = fread($fp, filesize($file));        $tokens = token_get_all($contents);/*        for ($i = 0; $i < sizeof($tokens); $i++) {            @list($token, $data) = $tokens[$i];            if (is_string($token)) {                var_dump($token);            } else {                print token_name($token) . ' ';                var_dump(rtrim($data));            }        }*/        $look_for = 0;        $paren_level = 0;        $bracket_level = 0;        $brace_level = 0;        $lastphpdoc = '';        $current_class = '';        $current_class_level = -1;        $current_function = '';        $current_function_level = -1;        $declared_classes = array();        $declared_functions = array();        $declared_methods = array();        $used_classes = array();        $used_functions = array();        $extends = array();        $nodeps = array();        $inquote = false;        for ($i = 0; $i < sizeof($tokens); $i++) {            if (is_array($tokens[$i])) {                list($token, $data) = $tokens[$i];            } else {                $token = $tokens[$i];                $data = '';            }            if ($inquote) {                if ($token != '"') {                    continue;                } else {                    $inquote = false;                }            }            switch ($token) {                case '"':                    $inquote = true;                    break;                case T_CURLY_OPEN:                case T_DOLLAR_OPEN_CURLY_BRACES:                case '{': $brace_level++; continue 2;                case '}':                    $brace_level--;                    if ($current_class_level == $brace_level) {                        $current_class = '';                        $current_class_level = -1;                    }                    if ($current_function_level == $brace_level) {                        $current_function = '';                        $current_function_level = -1;                    }                    continue 2;                case '[': $bracket_level++; continue 2;                case ']': $bracket_level--; continue 2;                case '(': $paren_level++;   continue 2;                case ')': $paren_level--;   continue 2;                case T_CLASS:                    if (($current_class_level != -1) || ($current_function_level != -1)) {                        PEAR::raiseError("Parser error: Invalid PHP file $file",                            PEAR_COMMON_ERROR_INVALIDPHP);                        return false;                    }                case T_FUNCTION:                case T_NEW:                case T_EXTENDS:                    $look_for = $token;                    continue 2;                case T_STRING:                    if ($look_for == T_CLASS) {                        $current_class = $data;                        $current_class_level = $brace_level;                        $declared_classes[] = $current_class;                    } elseif ($look_for == T_EXTENDS) {                        $extends[$current_class] = $data;                    } elseif ($look_for == T_FUNCTION) {                        if ($current_class) {                            $current_function = "$current_class::$data";                            $declared_methods[$current_class][] = $data;                        } else {                            $current_function = $data;                            $declared_functions[] = $current_function;                        }                        $current_function_level = $brace_level;                        $m = array();                    } elseif ($look_for == T_NEW) {                        $used_classes[$data] = true;                    }                    $look_for = 0;                    continue 2;                case T_VARIABLE:                    $look_for = 0;                    continue 2;                case T_COMMENT:                    if (preg_match('!^/\*\*\s!', $data)) {                        $lastphpdoc = $data;                        if (preg_match_all('/@nodep\s+(\S+)/', $lastphpdoc, $m)) {                            $nodeps = array_merge($nodeps, $m[1]);                        }                    }                    continue 2;                case T_DOUBLE_COLON:                    if ($tokens[$i - 1][0] != T_STRING) {                        PEAR::raiseError("Parser error: Invalid PHP file $file",                            PEAR_COMMON_ERROR_INVALIDPHP);                        return false;                    }                    $class = $tokens[$i - 1][1];                    if (strtolower($class) != 'parent') {                        $used_classes[$class] = true;                    }                    continue 2;            }        }        return array(            "source_file" => $file,            "declared_classes" => $declared_classes,            "declared_methods" => $declared_methods,            "declared_functions" => $declared_functions,            "used_classes" => array_diff(array_keys($used_classes), $nodeps),            "inheritance" => $extends,            );    }    // }}}    // {{{  betterStates()    /**     * Return an array containing all of the states that are more stable than     * or equal to the passed in state     *     * @param string Release state     * @param boolean Determines whether to include $state in the list     * @return false|array False if $state is not a valid release state     */    function betterStates($state, $include = false)    {        static $states = array('snapshot', 'devel', 'alpha', 'beta', 'stable');        $i = array_search($state, $states);        if ($i === false) {            return false;        }        if ($include) {            $i--;        }        return array_slice($states, $i + 1);    }    // }}}    // {{{ detectDependencies()    function detectDependencies($any, $status_callback = null)    {        if (!function_exists("token_get_all")) {            return false;        }        if (PEAR::isError($info = $this->infoFromAny($any))) {            return $this->raiseError($info);        }        if (!is_array($info)) {            return false;        }        $deps = array();        $used_c = $decl_c = $decl_f = $decl_m = array();        foreach ($info['filelist'] as $file => $fa) {            $tmp = $this->analyzeSourceCode($file);            $used_c = @array_merge($used_c, $tmp['used_classes']);            $decl_c = @array_merge($decl_c, $tmp['declared_classes']);            $decl_f = @array_merge($decl_f, $tmp['declared_functions']);            $decl_m = @array_merge($decl_m, $tmp['declared_methods']);            $inheri = @array_merge($inheri, $tmp['inheritance']);        }        $used_c = array_unique($used_c);        $decl_c = array_unique($decl_c);        $undecl_c = array_diff($used_c, $decl_c);        return array('used_classes' => $used_c,                     'declared_classes' => $decl_c,                     'declared_methods' => $decl_m,                     'declared_functions' => $decl_f,                     'undeclared_classes' => $undecl_c,                     'inheritance' => $inheri,                     );    }    // }}}    // {{{ getUserRoles()    /**     * Get the valid roles for a PEAR package maintainer     *     * @return array     * @static     */    function getUserRoles()    {        return $GLOBALS['_PEAR_Common_maintainer_roles'];    }    // }}}    // {{{ getReleaseStates()    /**     * Get the valid package release states of packages     *     * @return array     * @static     */    function getReleaseStates()    {        return $GLOBALS['_PEAR_Common_release_states'];    }    // }}}    // {{{ getDependencyTypes()    /**     * Get the implemented dependency types (php, ext, pkg etc.)     *     * @return array     * @static     */    function getDependencyTypes()    {        return $GLOBALS['_PEAR_Common_dependency_types'];    }    // }}}    // {{{ getDependencyRelations()

⌨️ 快捷键说明

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