install.php
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 1,172 行 · 第 1/4 页
PHP
1,172 行
'shortcut' => 'rs', 'options' => array( ), 'doc' => '<package>Run post-installation scripts in package <package>, if any exist.'), ); // }}} // {{{ constructor /** * PEAR_Command_Install constructor. * * @access public */ function PEAR_Command_Install(&$ui, &$config) { parent::PEAR_Command_Common($ui, $config); } // }}} /** * For unit testing purposes */ function &getDownloader(&$ui, $options, &$config) { if (!class_exists('PEAR_Downloader')) { require_once 'PEAR/Downloader.php'; } $a = &new PEAR_Downloader($ui, $options, $config); return $a; } /** * For unit testing purposes */ function &getInstaller(&$ui) { if (!class_exists('PEAR_Installer')) { require_once 'PEAR/Installer.php'; } $a = &new PEAR_Installer($ui); return $a; } function enableExtension($binaries, $type) { if (!($phpini = $this->config->get('php_ini', null, 'pear.php.net'))) { return PEAR::raiseError('configuration option "php_ini" is not set to php.ini location'); } $ini = $this->_parseIni($phpini); if (PEAR::isError($ini)) { return $ini; } $fp = @fopen($phpini, 'wb'); if (!$fp) { return PEAR::raiseError('cannot open php.ini "' . $phpini . '" for writing'); } $line = 0; if ($type == 'extsrc' || $type == 'extbin') { $search = 'extensions'; $enable = 'extension'; } else { $search = 'zend_extensions'; ob_start(); phpinfo(INFO_GENERAL); $info = ob_get_contents(); ob_end_clean(); $debug = function_exists('leak') ? '_debug' : ''; $ts = preg_match('Thread Safety.+enabled', $info) ? '_ts' : ''; $enable = 'zend_extension' . $debug . $ts; } foreach ($ini[$search] as $line => $extension) { if (in_array($extension, $binaries, true) || in_array( $ini['extension_dir'] . DIRECTORY_SEPARATOR . $extension, $binaries, true)) { // already enabled - assume if one is, all are return true; } } if ($line) { $newini = array_slice($ini['all'], 0, $line); } else { $newini = array(); } foreach ($binaries as $binary) { if ($ini['extension_dir']) { $binary = basename($binary); } $newini[] = $enable . '="' . $binary . '"' . (OS_UNIX ? "\n" : "\r\n"); } $newini = array_merge($newini, array_slice($ini['all'], $line)); foreach ($newini as $line) { fwrite($fp, $line); } fclose($fp); return true; } function disableExtension($binaries, $type) { if (!($phpini = $this->config->get('php_ini', null, 'pear.php.net'))) { return PEAR::raiseError('configuration option "php_ini" is not set to php.ini location'); } $ini = $this->_parseIni($phpini); if (PEAR::isError($ini)) { return $ini; } $line = 0; if ($type == 'extsrc' || $type == 'extbin') { $search = 'extensions'; $enable = 'extension'; } else { $search = 'zend_extensions'; ob_start(); phpinfo(INFO_GENERAL); $info = ob_get_contents(); ob_end_clean(); $debug = function_exists('leak') ? '_debug' : ''; $ts = preg_match('Thread Safety.+enabled', $info) ? '_ts' : ''; $enable = 'zend_extension' . $debug . $ts; } $found = false; foreach ($ini[$search] as $line => $extension) { if (in_array($extension, $binaries, true) || in_array( $ini['extension_dir'] . DIRECTORY_SEPARATOR . $extension, $binaries, true)) { $found = true; break; } } if (!$found) { // not enabled return true; } $fp = @fopen($phpini, 'wb'); if (!$fp) { return PEAR::raiseError('cannot open php.ini "' . $phpini . '" for writing'); } if ($line) { $newini = array_slice($ini['all'], 0, $line); // delete the enable line $newini = array_merge($newini, array_slice($ini['all'], $line + 1)); } else { $newini = array_slice($ini['all'], 1); } foreach ($newini as $line) { fwrite($fp, $line); } fclose($fp); return true; } function _parseIni($filename) { if (file_exists($filename)) { if (filesize($filename) > 300000) { return PEAR::raiseError('php.ini "' . $filename . '" is too large, aborting'); } ob_start(); phpinfo(INFO_GENERAL); $info = ob_get_contents(); ob_end_clean(); $debug = function_exists('leak') ? '_debug' : ''; $ts = preg_match('/Thread Safety.+enabled/', $info) ? '_ts' : ''; $zend_extension_line = 'zend_extension' . $debug . $ts; $all = @file($filename); if (!$all) { return PEAR::raiseError('php.ini "' . $filename .'" could not be read'); } $zend_extensions = $extensions = array(); // assume this is right, but pull from the php.ini if it is found $extension_dir = ini_get('extension_dir'); foreach ($all as $linenum => $line) { $line = trim($line); if (!$line) { continue; } if ($line[0] == ';') { continue; } if (strtolower(substr($line, 0, 13)) == 'extension_dir') { $line = trim(substr($line, 13)); if ($line[0] == '=') { $x = trim(substr($line, 1)); $x = explode(';', $x); $extension_dir = str_replace('"', '', array_shift($x)); continue; } } if (strtolower(substr($line, 0, 9)) == 'extension') { $line = trim(substr($line, 9)); if ($line[0] == '=') { $x = trim(substr($line, 1)); $x = explode(';', $x); $extensions[$linenum] = str_replace('"', '', array_shift($x)); continue; } } if (strtolower(substr($line, 0, strlen($zend_extension_line))) == $zend_extension_line) { $line = trim(substr($line, strlen($zend_extension_line))); if ($line[0] == '=') { $x = trim(substr($line, 1)); $x = explode(';', $x); $zend_extensions[$linenum] = str_replace('"', '', array_shift($x)); continue; } } } return array( 'extensions' => $extensions, 'zend_extensions' => $zend_extensions, 'extension_dir' => $extension_dir, 'all' => $all, ); } else { return PEAR::raiseError('php.ini "' . $filename . '" does not exist'); } } // {{{ doInstall() function doInstall($command, $options, $params) { if (!class_exists('PEAR/PackageFile.php')) { require_once 'PEAR/PackageFile.php'; } if (empty($this->installer)) { $this->installer = &$this->getInstaller($this->ui); } if ($command == 'upgrade' || $command == 'upgrade-all') { $options['upgrade'] = true; } else { $packages = $params; } if (isset($options['installroot']) && isset($options['packagingroot'])) { return $this->raiseError('ERROR: cannot use both --installroot and --packagingroot'); } $reg = &$this->config->getRegistry(); $instreg = &$reg; // instreg used to check if package is installed if (isset($options['packagingroot']) && !isset($options['upgrade'])) { $packrootphp_dir = $this->installer->_prependPath( $this->config->get('php_dir', null, 'pear.php.net'), $options['packagingroot']); $instreg = new PEAR_Registry($packrootphp_dir); // other instreg! if ($this->config->get('verbose') > 2) { $this->ui->outputData('using package root: ' . $options['packagingroot']); } } $abstractpackages = array(); $otherpackages = array(); // parse params PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); foreach($params as $param) { if (strpos($param, 'http://') === 0) { $otherpackages[] = $param; continue; } if (strpos($param, 'channel://') === false && @file_exists($param)) { if (isset($options['force'])) { $otherpackages[] = $param; continue; } $pkg = new PEAR_PackageFile($this->config); $pf = $pkg->fromAnyFile($param, PEAR_VALIDATE_DOWNLOADING); if (PEAR::isError($pf)) { $otherpackages[] = $param; continue; } if ($reg->packageExists($pf->getPackage(), $pf->getChannel()) && version_compare($pf->getVersion(), $reg->packageInfo($pf->getPackage(), 'version', $pf->getChannel()), '<=')) { if ($this->config->get('verbose')) { $this->ui->outputData('Ignoring installed package ' . $reg->parsedPackageNameToString( array('package' => $pf->getPackage(), 'channel' => $pf->getChannel()), true)); } continue; } $otherpackages[] = $param; continue; } $e = $reg->parsePackageName($param, $this->config->get('default_channel')); if (PEAR::isError($e)) { $otherpackages[] = $param; } else { $abstractpackages[] = $e; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?