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

📄 common.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php//// +----------------------------------------------------------------------+// | PHP Version 4                                                        |// +----------------------------------------------------------------------+// | Copyright (c) 1997-2003 The PHP Group                                |// +----------------------------------------------------------------------+// | This source file is subject to version 3.0 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: Stig Bakken <ssb@php.net>                                   |// |          Tomas V.V.Cox <cox@idecnet.com>                             |// +----------------------------------------------------------------------+//// $Id: Common.php,v 1.121 2004/03/12 18:22:48 pajoye Exp $require_once 'PEAR.php';require_once 'Archive/Tar.php';require_once 'System.php';require_once 'PEAR/Config.php';// {{{ constants and globals/** * PEAR_Common error when an invalid PHP file is passed to PEAR_Common::analyzeSourceCode() */define('PEAR_COMMON_ERROR_INVALIDPHP', 1);define('_PEAR_COMMON_PACKAGE_NAME_PREG', '[A-Za-z][a-zA-Z0-9_]+');define('PEAR_COMMON_PACKAGE_NAME_PREG', '/^' . _PEAR_COMMON_PACKAGE_NAME_PREG . '$/');// this should allow: 1, 1.0, 1.0RC1, 1.0dev, 1.0dev123234234234, 1.0a1, 1.0b1, 1.0pl1define('_PEAR_COMMON_PACKAGE_VERSION_PREG', '\d+(?:\.\d+)*(?:[a-z]+\d*)?');define('PEAR_COMMON_PACKAGE_VERSION_PREG', '/^' . _PEAR_COMMON_PACKAGE_VERSION_PREG . '$/i');// XXX far from perfect :-)define('PEAR_COMMON_PACKAGE_DOWNLOAD_PREG', '/^(' . _PEAR_COMMON_PACKAGE_NAME_PREG . ')(-([.0-9a-zA-Z]+))?$/');/** * List of temporary files and directories registered by * PEAR_Common::addTempFile(). * @var array */$GLOBALS['_PEAR_Common_tempfiles'] = array();/** * Valid maintainer roles * @var array */$GLOBALS['_PEAR_Common_maintainer_roles'] = array('lead','developer','contributor','helper');/** * Valid release states * @var array */$GLOBALS['_PEAR_Common_release_states'] = array('alpha','beta','stable','snapshot','devel');/** * Valid dependency types * @var array */$GLOBALS['_PEAR_Common_dependency_types'] = array('pkg','ext','php','prog','ldlib','rtlib','os','websrv','sapi');/** * Valid dependency relations * @var array */$GLOBALS['_PEAR_Common_dependency_relations'] = array('has','eq','lt','le','gt','ge','not');/** * Valid file roles * @var array */$GLOBALS['_PEAR_Common_file_roles'] = array('php','ext','test','doc','data','src','script');/** * Valid replacement types * @var array */$GLOBALS['_PEAR_Common_replacement_types'] = array('php-const', 'pear-config', 'package-info');/** * Valid "provide" types * @var array */$GLOBALS['_PEAR_Common_provide_types'] = array('ext', 'prog', 'class', 'function', 'feature', 'api');/** * Valid "provide" types * @var array */$GLOBALS['_PEAR_Common_script_phases'] = array('pre-install', 'post-install', 'pre-uninstall', 'post-uninstall', 'pre-build', 'post-build', 'pre-configure', 'post-configure', 'pre-setup', 'post-setup');// }}}/** * Class providing common functionality for PEAR adminsitration classes. */class PEAR_Common extends PEAR{    // {{{ properties    /** stack of elements, gives some sort of XML context */    var $element_stack = array();    /** name of currently parsed XML element */    var $current_element;    /** array of attributes of the currently parsed XML element */    var $current_attributes = array();    /** assoc with information about a package */    var $pkginfo = array();    /**     * User Interface object (PEAR_Frontend_* class).  If null,     * the log() method uses print.     * @var object     */    var $ui = null;    /**     * Configuration object (PEAR_Config).     * @var object     */    var $config = null;    var $current_path = null;    /**     * PEAR_SourceAnalyzer instance     * @var object     */    var $source_analyzer = null;    /**     * Flag variable used to mark a valid package file     * @var boolean     * @access private     */    var $_validPackageFile;    /**     * Temporary variable used in sorting packages by dependency in {@link sortPkgDeps()}     * @var array     * @access private     */    var $_packageSortTree;    // }}}    // {{{ constructor    /**     * PEAR_Common constructor     *     * @access public     */    function PEAR_Common()    {        parent::PEAR();        $this->config = &PEAR_Config::singleton();        $this->debug = $this->config->get('verbose');    }    // }}}    // {{{ destructor    /**     * PEAR_Common destructor     *     * @access private     */    function _PEAR_Common()    {        // doesn't work due to bug #14744        //$tempfiles = $this->_tempfiles;        $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];        while ($file = array_shift($tempfiles)) {            if (@is_dir($file)) {                System::rm(array('-rf', $file));            } elseif (file_exists($file)) {                unlink($file);            }        }    }    // }}}    // {{{ addTempFile()    /**     * Register a temporary file or directory.  When the destructor is     * executed, all registered temporary files and directories are     * removed.     *     * @param string  $file  name of file or directory     *     * @return void     *     * @access public     */    function addTempFile($file)    {        $GLOBALS['_PEAR_Common_tempfiles'][] = $file;    }    // }}}    // {{{ mkDirHier()    /**     * Wrapper to System::mkDir(), creates a directory as well as     * any necessary parent directories.     *     * @param string  $dir  directory name     *     * @return bool TRUE on success, or a PEAR error     *     * @access public     */    function mkDirHier($dir)    {        $this->log(2, "+ create dir $dir");        return System::mkDir(array('-p', $dir));    }    // }}}    // {{{ log()    /**     * Logging method.     *     * @param int    $level  log level (0 is quiet, higher is noisier)     * @param string $msg    message to write to the log     *     * @return void     *     * @access public     */    function log($level, $msg, $append_crlf = true)    {        if ($this->debug >= $level) {            if (is_object($this->ui)) {                $this->ui->log($msg, $append_crlf);            } else {                print "$msg\n";            }        }    }    // }}}    // {{{ mkTempDir()    /**     * Create and register a temporary directory.     *     * @param string $tmpdir (optional) Directory to use as tmpdir.     *                       Will use system defaults (for example     *                       /tmp or c:\windows\temp) if not specified     *     * @return string name of created directory     *     * @access public     */    function mkTempDir($tmpdir = '')    {        if ($tmpdir) {            $topt = array('-t', $tmpdir);        } else {            $topt = array();        }        $topt = array_merge($topt, array('-d', 'pear'));        if (!$tmpdir = System::mktemp($topt)) {            return false;        }        $this->addTempFile($tmpdir);        return $tmpdir;    }    // }}}    // {{{ setFrontendObject()    /**     * Set object that represents the frontend to be used.     *     * @param  object Reference of the frontend object     * @return void     * @access public     */    function setFrontendObject(&$ui)    {        $this->ui = &$ui;    }    // }}}    // {{{ _unIndent()    /**     * Unindent given string (?)     *     * @param string $str The string that has to be unindented.     * @return string     * @access private     */    function _unIndent($str)    {        // remove leading newlines        $str = preg_replace('/^[\r\n]+/', '', $str);        // find whitespace at the beginning of the first line        $indent_len = strspn($str, " \t");        $indent = substr($str, 0, $indent_len);        $data = '';        // remove the same amount of whitespace from following lines        foreach (explode("\n", $str) as $line) {            if (substr($line, 0, $indent_len) == $indent) {                $data .= substr($line, $indent_len) . "\n";            }        }        return $data;    }    // }}}    // {{{ _element_start()    /**     * XML parser callback for starting elements.  Used while package     * format version is not yet known.     *     * @param resource  $xp       XML parser resource     * @param string    $name     name of starting element     * @param array     $attribs  element attributes, name => value     *     * @return void     *     * @access private     */    function _element_start($xp, $name, $attribs)    {        array_push($this->element_stack, $name);        $this->current_element = $name;        $spos = sizeof($this->element_stack) - 2;        $this->prev_element = ($spos >= 0) ? $this->element_stack[$spos] : '';        $this->current_attributes = $attribs;        switch ($name) {            case 'package': {                $this->_validPackageFile = true;                if (isset($attribs['version'])) {                    $vs = preg_replace('/[^0-9a-z]/', '_', $attribs['version']);                } else {                    $vs = '1_0';                }                $elem_start = '_element_start_'. $vs;                $elem_end = '_element_end_'. $vs;                $cdata = '_pkginfo_cdata_'. $vs;                if (!method_exists($this, $elem_start) ||                      !method_exists($this, $elem_end) ||                      !method_exists($this, $cdata)) {                    $this->raiseError("No handlers for package.xml version $attribs[version]");                    return;                }                xml_set_element_handler($xp, $elem_start, $elem_end);                xml_set_character_data_handler($xp, $cdata);                break;            }        }    }    // }}}    // {{{ _element_end()    /**     * XML parser callback for ending elements.  Used while package     * format version is not yet known.     *     * @param resource  $xp    XML parser resource     * @param string    $name  name of ending element     *     * @return void     *     * @access private     */

⌨️ 快捷键说明

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