📄 remote.php
字号:
@$installed['version'], @$desc, @$info['deps'], ); } foreach ($local_pkgs as $name) { $info = $reg->packageInfo($name); $data['data']['Local'][] = array( $info['package'], '', $info['version'], $info['summary'], @$info['release_deps'] ); } $this->ui->outputData($data, $command); return true; } // }}} // {{{ doSearch() function doSearch($command, $options, $params) { if ((!isset($params[0]) || empty($params[0])) && (!isset($params[1]) || empty($params[1]))) { return $this->raiseError('no valid search string supplied'); }; $r = new PEAR_Remote($this->config); $reg = new PEAR_Registry($this->config->get('php_dir')); $available = $r->call('package.listAll', true, false); if (PEAR::isError($available)) { return $this->raiseError($available); } $data = array( 'caption' => 'Matched packages:', 'border' => true, 'headline' => array('Package', 'Stable/(Latest)', 'Local'), ); foreach ($available as $name => $info) { $found = (!empty($params[0]) && stristr($name, $params[0]) !== false); if (!$found && !(isset($params[1]) && !empty($params[1]) && (stristr($info['summary'], $params[1]) !== false || stristr($info['description'], $params[1]) !== false))) { continue; }; $installed = $reg->packageInfo($name); $desc = $info['summary']; if (isset($params[$name])) $desc .= "\n\n".$info['description']; $unstable = ''; if ($info['unstable']) { $unstable = '/(' . $info['unstable'] . $info['state'] . ')'; } if (!isset($info['stable']) || !$info['stable']) { $info['stable'] = 'none'; } $data['data'][$info['category']][] = array( $name, $info['stable'] . $unstable, $installed['version'], $desc, ); } if (!isset($data['data'])) { return $this->raiseError('no packages found'); } $this->ui->outputData($data, $command); return true; } // }}} // {{{ doDownload() function doDownload($command, $options, $params) { //$params[0] -> The package to download if (count($params) != 1) { return PEAR::raiseError("download expects one argument: the package to download"); } $server = $this->config->get('master_server'); if (!ereg('^http://', $params[0])) { $getoption = isset($options['nocompress'])&&$options['nocompress']==1?'?uncompress=on':''; $pkgfile = "http://$server/get/$params[0]".$getoption; } else { $pkgfile = $params[0]; } $this->bytes_downloaded = 0; $saved = PEAR_Common::downloadHttp($pkgfile, $this->ui, '.', array(&$this, 'downloadCallback')); if (PEAR::isError($saved)) { return $this->raiseError($saved); } $fname = basename($saved); $this->ui->outputData("File $fname downloaded ($this->bytes_downloaded bytes)", $command); return true; } function downloadCallback($msg, $params = null) { if ($msg == 'done') { $this->bytes_downloaded = $params; } } // }}} // {{{ doListUpgrades() function doListUpgrades($command, $options, $params) { include_once "PEAR/Registry.php"; $remote = new PEAR_Remote($this->config); if (empty($params[0])) { $state = $this->config->get('preferred_state'); } else { $state = $params[0]; } $caption = 'Available Upgrades'; if (empty($state) || $state == 'any') { $latest = $remote->call("package.listLatestReleases"); } else { $latest = $remote->call("package.listLatestReleases", $state); $caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')'; } $caption .= ':'; if (PEAR::isError($latest)) { return $latest; } $reg = new PEAR_Registry($this->config->get('php_dir')); $inst = array_flip($reg->listPackages()); $data = array( 'caption' => $caption, 'border' => 1, 'headline' => array('Package', 'Local', 'Remote', 'Size'), ); foreach ((array)$latest as $pkg => $info) { $package = strtolower($pkg); if (!isset($inst[$package])) { // skip packages we don't have installed continue; } extract($info); $pkginfo = $reg->packageInfo($package); $inst_version = $pkginfo['version']; $inst_state = $pkginfo['release_state']; if (version_compare("$version", "$inst_version", "le")) { // installed version is up-to-date continue; } if ($filesize >= 20480) { $filesize += 1024 - ($filesize % 1024); $fs = sprintf("%dkB", $filesize / 1024); } elseif ($filesize > 0) { $filesize += 103 - ($filesize % 103); $fs = sprintf("%.1fkB", $filesize / 1024.0); } else { $fs = " -"; // XXX center instead } $data['data'][] = array($pkg, "$inst_version ($inst_state)", "$version ($state)", $fs); } if (empty($data['data'])) { $this->ui->outputData('No upgrades available'); } else { $this->ui->outputData($data, $command); } return true; } // }}} // {{{ doClearCache() function doClearCache($command, $options, $params) { $cache_dir = $this->config->get('cache_dir'); $verbose = $this->config->get('verbose'); $output = ''; if (!($dp = @opendir($cache_dir))) { return $this->raiseError("opendir($cache_dir) failed: $php_errormsg"); } if ($verbose >= 1) { $output .= "reading directory $cache_dir\n"; } $num = 0; while ($ent = readdir($dp)) { if (preg_match('/^xmlrpc_cache_[a-z0-9]{32}$/', $ent)) { $path = $cache_dir . DIRECTORY_SEPARATOR . $ent; $ok = @unlink($path); if ($ok) { if ($verbose >= 2) { $output .= "deleted $path\n"; } $num++; } elseif ($verbose >= 1) { $output .= "failed to delete $path\n"; } } } closedir($dp); if ($verbose >= 1) { $output .= "$num cache entries cleared\n"; } $this->ui->outputData(rtrim($output), $command); return $num; } // }}}}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -