PageRenderTime 70ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/PEAR/go-pear.php

https://bitbucket.org/kucing2k/ediassoc
PHP | 2376 lines | 2010 code | 173 blank | 193 comment | 289 complexity | f8b4f8d3d24fba39c997d8fa4c8a2f2a MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, BSD-2-Clause, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php //; echo; echo "YOU NEED TO RUN THIS SCRIPT WITH PHP NOW!"; echo; echo "Try this: lynx -source http://pear.php.net/go-pear | php -q"; echo; exit # -*- PHP -*-
  2. # +----------------------------------------------------------------------+
  3. # | PHP Version 5 |
  4. # +----------------------------------------------------------------------+
  5. # | Copyright (c) 1997-2005 The PHP Group |
  6. # +----------------------------------------------------------------------+
  7. # | This source file is subject to version 2.02 of the PHP license, |
  8. # | that is bundled with this package in the file LICENSE, and is |
  9. # | available at through the world-wide-web at |
  10. # | http://www.php.net/license/2_02.txt. |
  11. # | If you did not receive a copy of the PHP license and are unable to |
  12. # | obtain it through the world-wide-web, please send a note to |
  13. # | license@php.net so we can mail you a copy immediately. |
  14. # +----------------------------------------------------------------------+
  15. # | Authors: Tomas V.V.Cox <cox@idecnet.com> |
  16. # | Stig Bakken <ssb@php.net> |
  17. # | Christian Dickmann <dickmann@php.net> |
  18. # | Pierre-Alain Joye <pajoye@pearfr.org> |
  19. # | Greg Beaver <cellog@php.net> |
  20. # +----------------------------------------------------------------------+
  21. # $Id: go-pear,v 1.75 2005/02/23 18:58:40 cellog Exp $
  22. #
  23. # Automatically download all the files needed to run the "pear" command
  24. # (the PEAR package installer). Requires PHP 4.1.0 or newer.
  25. #
  26. # Installation: Linux
  27. #
  28. # This script can either be directly launched or passed via lynx like this.
  29. #
  30. # $ lynx -source http://pear.php.net/go-pear | php
  31. #
  32. # The above assumes your php binary is named php and that it's
  33. # executable through your PATH:
  34. #
  35. # Installation: Windows
  36. #
  37. # On Windows, go-pear uses stdin for user input, so you must download
  38. # go-pear first and then run it:
  39. #
  40. # Note: In PHP 4.2.0-4.2.3, the PHP CLI binary is named php-cli.exe while since
  41. # PHP 4.3.0, it's simply named php.exe in the cli/ folder of your PHP directory.
  42. # The CGI is also named php.exe but it sits directly in your PHP directory.
  43. #
  44. # > cli/php -r "readfile('http://pear.php.net/go-pear');" > go-pear
  45. # > cli/php go-pear
  46. #
  47. # In PHP 5.0.0, the PHP CLI binary is php.exe
  48. #
  49. # > php -r "readfile('http://pear.php.net/go-pear');" > go-pear
  50. # > php go-pear
  51. #
  52. # Installation: Notes
  53. #
  54. # - If using the CGI version of PHP, append the -q option to suppress
  55. # headers in the output.
  56. # - By default, go-pear will install a system-wide configuration file. For
  57. # a local install use:
  58. # > php go-pear local
  59. #
  60. # - Once the go-pear script is initiated, you will see instructions on
  61. # how to continue installing PEAR. The first thing you should see is:
  62. #
  63. # Welcome to go-pear!
  64. #
  65. # Installation: Web browser
  66. #
  67. # You can now use go-pear via a webbrowser, thanks to Christian Dickmann. It is
  68. # still beta codes, but feel free to test it:
  69. # 1.: Download the go-pear script by using the "Save target as ..." function
  70. # of your browser here.
  71. #
  72. # 2.: Place the go-pear file somewhere under the document root of your webserver.
  73. # The easiest way is to create a new directory for pear and to put the file in there.
  74. # Be sure your web server is setup to recognize PHP, and that you use an appropriate
  75. # extension. For example, you might name this file gopear.php
  76. #
  77. # 3.: Access go-pear through your webserver and follow the instructions. Please
  78. # make sure that PHP has write access to the dir you want to install PEAR into.
  79. # For example: http://localhost/pear/gopear.php
  80. #
  81. # 4.: After running go-pear you get a link to the Web Frontend of the PEAR installer.
  82. # I suggest bookmarking this link.
  83. #
  84. # 5.: Protect the Web Frontend directory and the go-pear script with a password.
  85. # Use .htaccess on Apache webservers for example.
  86. #
  87. #
  88. $sapi_name = php_sapi_name();
  89. set_time_limit(0);
  90. @ob_end_clean();
  91. ob_implicit_flush(true);
  92. define('WEBINSTALLER', ($sapi_name != 'cli' && !(substr($sapi_name,0,3)=='cgi' && !isset($_SERVER['GATEWAY_INTERFACE']))));
  93. ini_set('track_errors', true);
  94. ini_set('html_errors', WEBINSTALLER);
  95. ini_set('magic_quotes_runtime', false);
  96. error_reporting( E_ALL & ~E_NOTICE);
  97. define('WINDOWS', (substr(PHP_OS, 0, 3) == 'WIN'));
  98. define('GO_PEAR_VER', '0.5.0');
  99. define('WIN32GUI', !WEBINSTALLER && WINDOWS && $sapi_name=='cli' && which('cscript'));
  100. /*
  101. * See bug #23069
  102. */
  103. if ( WEBINSTALLER && WINDOWS ) {
  104. $php_sapi_name = win32DetectPHPSAPI();
  105. if($php_sapi_name=='cgi'){
  106. $msg = nl2br("
  107. Sorry! The PEAR installer actually does not work on Windows platform using CGI and Apache.
  108. Please install the module SAPI (see http://www.php.net/manual/en/install.apache.php for the
  109. instructions) or use the CLI (cli\php.exe) in the console.
  110. ");
  111. displayHTML('error', $msg);
  112. }
  113. }
  114. if (WEBINSTALLER && isset($_GET['action']) && $_GET['action'] == 'img' && isset($_GET['img'])) {
  115. switch ($_GET['img'])
  116. {
  117. case 'note':
  118. case 'pearlogo':
  119. case 'smallpear':
  120. showImage($_GET['img']);
  121. exit;
  122. default:
  123. exit;
  124. };
  125. }
  126. // Check if PHP version is sufficient
  127. if (function_exists("version_compare") && version_compare(phpversion(), "4.2.0",'<')) {
  128. die("Sorry! Your PHP version is too old. PEAR and this script requires at
  129. least PHP 4.2.0 for stable operation.
  130. It may be that you have a newer version of PHP installed in your web
  131. server, but an older version installed as the 'php' command. In this
  132. case, you need to rebuilt PHP from source.
  133. If your source is 4.2.x, you need to run 'configure' with the
  134. --enable-cli option, rebuild and copy sapi/cli/php somewhere.
  135. If your source is 4.3.x or newer, just make sure you don't run
  136. 'configure' with --disable-cli, rebuilt and copy sapi/cli/php.
  137. Please upgrade PHP to a newer version, and try again. See you then.
  138. ");
  139. }
  140. $installer_packages = array(
  141. 'PEAR-stable',
  142. 'Archive_Tar-stable',
  143. 'Console_Getopt-stable',
  144. 'XML_RPC-stable'
  145. );
  146. if (WEBINSTALLER) {
  147. $installer_packages[] = 'Pager';
  148. $installer_packages[] = 'HTML_Template_IT';
  149. $installer_packages[] = 'Net_UserAgent_Detect';
  150. $installer_packages[] = 'PEAR_Frontend_Web-0.4';
  151. // otherwise things will break when PEAR 1.4.0 is out
  152. }
  153. $pfc_packages = array(
  154. 'DB',
  155. 'Net_Socket',
  156. 'Net_SMTP',
  157. 'Mail',
  158. 'XML_Parser',
  159. 'PHPUnit'
  160. );
  161. $config_desc = array(
  162. 'prefix' => 'Installation prefix',
  163. 'bin_dir' => 'Binaries directory',
  164. 'php_dir' => 'PHP code directory ($php_dir)',
  165. 'doc_dir' => 'Documentation base directory',
  166. 'data_dir' => 'Data base directory',
  167. 'test_dir' => 'Tests base directory',
  168. );
  169. if(!WEBINSTALLER && WINDOWS){
  170. $config_desc['php_bin'] = 'php.exe path';
  171. }
  172. if (WEBINSTALLER) {
  173. $config_desc['cache_dir'] = 'PEAR Installer cache directory';
  174. $config_desc['cache_ttl'] = 'Cache TimeToLive';
  175. $config_desc['webfrontend_file'] = 'Filename of WebFrontend';
  176. $config_desc['php_bin'] = "php.exe path, optional (CLI command tools)";
  177. }
  178. if (my_env('HTTP_PROXY')) {
  179. $http_proxy = my_env('HTTP_PROXY');
  180. } elseif (my_env('http_proxy')) {
  181. $http_proxy = my_env('http_proxy');
  182. } else {
  183. $http_proxy = '';
  184. }
  185. register_shutdown_function('bail');
  186. detect_install_dirs();
  187. if (WEBINSTALLER) {
  188. @session_start();
  189. /*
  190. See bug #23069
  191. */
  192. if ( WINDOWS ) {
  193. $php_sapi_name = win32DetectPHPSAPI();
  194. if($php_sapi_name=='cgi'){
  195. $msg = "
  196. Sorry! The PEAR installer actually does not work on Windows platform using CGI and Apache.
  197. Please install the module SAPI (see http://www.php.net/manual/en/install.apache.php for the
  198. instructions) or use the CLI (cli\php.exe) in the console.
  199. ";
  200. displayHTML('error', $msg);
  201. exit();
  202. }
  203. }
  204. if (!isset($_SESSION['go-pear']) || isset($_GET['restart'])) {
  205. $_SESSION['go-pear'] = array(
  206. 'http_proxy' => $http_proxy,
  207. 'config' => array(
  208. 'prefix' => dirname(__FILE__),
  209. 'bin_dir' => $bin_dir,
  210. 'php_bin' => $php_bin,
  211. 'php_dir' => '$prefix/PEAR',
  212. 'doc_dir' => $doc_dir,
  213. 'data_dir' => $data_dir,
  214. 'test_dir' => $test_dir,
  215. 'cache_dir' => '$php_dir/cache',
  216. 'cache_ttl' => 300,
  217. 'webfrontend_file' => '$prefix/index.php',
  218. ),
  219. 'install_pfc' => true,
  220. 'DHTML' => true,
  221. );
  222. }
  223. if (!isset($_GET['step'])) {
  224. $_GET['step'] = 'Welcome';
  225. /* clean up old sessions datas */
  226. session_destroy();
  227. }
  228. if ($_GET['step'] == 'install') {
  229. $_SESSION['go-pear']['http_proxy'] = strip_magic_quotes($_POST['proxy']['host']).':'.strip_magic_quotes($_POST['proxy']['port']);
  230. if ($_SESSION['go-pear']['http_proxy'] == ':') {
  231. $_SESSION['go-pear']['http_proxy'] = '';
  232. };
  233. $www_errors = array();
  234. foreach($_POST['config'] as $key => $value) {
  235. $_POST['config'][$key] = strip_magic_quotes($value);
  236. if($key!='cache_ttl'){
  237. if ( empty($_POST['config'][$key]) ) {
  238. if (WEBINSTALLER && $key!='php_bin' ) {
  239. $www_errors[$key] = 'Please fill this path, you can use $prefix, $php_dir or a full path.';
  240. }
  241. }
  242. }
  243. }
  244. if( sizeof($www_errors)>0){
  245. $_GET['step'] = 'config';
  246. }
  247. $_SESSION['go-pear']['config'] = $_POST['config'];
  248. $_SESSION['go-pear']['install_pfc'] = (isset($_POST['install_pfc']) && $_POST['install_pfc'] == 'on');
  249. $_SESSION['go-pear']['DHTML'] = !($_POST['BCmode'] == "on");
  250. }
  251. $http_proxy = $_SESSION['go-pear']['http_proxy'];
  252. foreach($_SESSION['go-pear']['config'] as $var => $value) {
  253. $$var = $value;
  254. }
  255. $install_pfc = $_SESSION['go-pear']['install_pfc'];
  256. }
  257. if (!WEBINSTALLER) {
  258. $tty = WINDOWS ? @fopen('\con', 'r') : @fopen('/dev/tty', 'r');
  259. if (!$tty) {
  260. $tty = fopen('php://stdin', 'r');
  261. }
  262. $local = isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'local';
  263. if ($local) {
  264. $local = "
  265. Running in local install mode
  266. ";
  267. } elseif (WINDOWS) {
  268. $local = "
  269. Use 'php " . $_SERVER['argv'][0] . " local' to install a local copy of PEAR.
  270. ";
  271. }
  272. print "Welcome to go-pear!
  273. Go-pear will install the 'pear' command and all the files needed by
  274. it. This command is your tool for PEAR installation and maintenance.
  275. $local
  276. Go-pear also lets you download and install the PEAR packages bundled
  277. with PHP: " . implode(', ', $pfc_packages) . ".
  278. If you wish to abort, press Control-C now, or press Enter to continue: ";
  279. fgets($tty, 1024);
  280. print "\n";
  281. print "HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none:";
  282. if (!empty($http_proxy)) {
  283. print " [$http_proxy]";
  284. }
  285. print ": ";
  286. $tmp = trim(fgets($tty, 1024));
  287. if (!empty($tmp)) {
  288. $http_proxy = $tmp;
  289. }
  290. }
  291. $origpwd = getcwd();
  292. $config_vars = array_keys($config_desc);
  293. // make indices run from 1...
  294. array_unshift($config_vars, "");
  295. unset($config_vars[0]);
  296. reset($config_vars);
  297. $desclen = max(array_map('strlen', $config_desc));
  298. $descfmt = "%-{$desclen}s";
  299. $first = key($config_vars);
  300. end($config_vars);
  301. $last = key($config_vars);
  302. if (WEBINSTALLER) {
  303. if ( isset($www_errors) && sizeof($www_errors) ) {
  304. displayHTML('config');
  305. exit();
  306. } else {
  307. if (isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'] == true && $_GET['step'] == 'install') {
  308. $_GET['step'] = 'preinstall';
  309. }
  310. if ($_GET['step'] != 'install' && $_GET['step'] != 'install-progress') {
  311. displayHTML($_GET['step']);
  312. exit;
  313. }
  314. if ($_GET['step'] == 'install-progress') {
  315. displayHTMLHeader();
  316. echo "Starting installation ...<br/>";
  317. }
  318. ob_start();
  319. }
  320. }
  321. $progress = 0;
  322. /*
  323. * Checks PHP SAPI version under windows/CLI
  324. */
  325. if( WINDOWS && !WEBINSTALLER && $php_bin=='') {
  326. print "
  327. We do not find any php.exe, please select the php.exe folder (CLI is
  328. recommanded, usually in c:\php\cli\php.exe)
  329. ";
  330. $php_bin_set = false;
  331. } elseif ( WINDOWS && !WEBINSTALLER && strlen($php_bin) ) {
  332. $php_bin_sapi = win32DetectPHPSAPI();
  333. $php_bin_set = true;
  334. switch($php_bin_sapi){
  335. case 'cli':
  336. break;
  337. case 'cgi':
  338. print "
  339. *NOTICE*
  340. We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI. PEAR commandline
  341. tool works well with it, if you have a CLI php.exe available, we
  342. recommand to use it.
  343. ";
  344. break;
  345. default:
  346. print "
  347. *WARNING*
  348. We found php.exe under $php_bin, it uses an unknown SAPI. PEAR commandline
  349. tool has not been tested with it, if you have a CLI (or CGI) php.exe available,
  350. we strongly recommand to use it.
  351. ";
  352. break;
  353. }
  354. }
  355. ####
  356. # Temp stuff
  357. ####
  358. tmp_dir();
  359. $foo = $ptmp;
  360. $ptmp = tempnam($foo, 'gope');
  361. if (WINDOWS) {
  362. $ptmp = str_replace($foo,'',$ptmp);
  363. $foo=str_replace("\\\\",'/',$foo);
  364. $s = substr($ptmp,0,1);
  365. if($s=="\\" || $s=='/' ){
  366. $ptmp = $foo.'/'.substr($ptmp,1);
  367. } else {
  368. $ptmp = $foo.'/'.$ptmp;
  369. }
  370. }
  371. rm_rf($ptmp);
  372. mkdir_p($ptmp, 0700);
  373. $ok = @chdir($ptmp);
  374. while (!WEBINSTALLER) {
  375. print "
  376. Below is a suggested file layout for your new PEAR installation. To
  377. change individual locations, type the number in front of the
  378. directory. Type 'all' to change all of them or simply press Enter to
  379. accept these locations.
  380. ";
  381. foreach ($config_vars as $n => $var) {
  382. printf("%2d. $descfmt : %s\n", $n, $config_desc[$var], $$var);
  383. }
  384. print "\n$first-$last, 'all' or Enter to continue: ";
  385. $tmp = trim(fgets($tty, 1024));
  386. if ( empty($tmp) ) {
  387. if( WINDOWS && !$php_bin_set ){
  388. echo "**ERROR**
  389. Please, enter the php.exe path.
  390. ";
  391. } else {
  392. break;
  393. }
  394. }
  395. if (isset($config_vars[(int)$tmp])) {
  396. $var = $config_vars[(int)$tmp];
  397. $desc = $config_desc[$var];
  398. $current = $$var;
  399. if(WIN32GUI){
  400. $tmp = win32BrowseForFolder("$desc [$current] :");
  401. } else {
  402. print "$desc [$current] : ";
  403. $tmp = trim(fgets($tty, 1024));
  404. }
  405. $old = $$var;
  406. if(WINDOWS && $var=='php_bin' ){
  407. if(file_exists($tmp.DIRECTORY_SEPARATOR.'php.exe')){
  408. $tmp = $tmp.DIRECTORY_SEPARATOR.'php.exe';
  409. $php_bin_sapi = win32DetectPHPSAPI();
  410. if($php_bin_sapi=='cgi'){
  411. print "
  412. ******************************************************************************
  413. NOTICE! We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI.
  414. PEAR commandline tool works well with it.
  415. If you have a CLI php.exe available, we recommand to use it.
  416. ";
  417. } elseif ($php_bin_sapi=='unknown') {
  418. print "
  419. ******************************************************************************
  420. WARNING! We found php.exe under $php_bin, it uses an $php_bin_sapi SAPI.
  421. PEAR commandline tool has not been tested with it.
  422. If you have a CLI (or CGI) php.exe available, we strongly recommand to use it.
  423. ";
  424. }
  425. echo "php.exe (sapi: $php_bin_sapi) found.\n\n";
  426. $php_bin_set = true;
  427. } else {
  428. echo "**ERROR**: no php.exe found in this folder.\n";
  429. $tmp='';
  430. }
  431. }
  432. if (!empty($tmp) ) {
  433. $$var = $tmp;
  434. }
  435. } elseif ($tmp == 'all') {
  436. foreach ($config_vars as $n => $var) {
  437. $desc = $config_desc[$var];
  438. $current = $$var;
  439. print "$desc [$current] : ";
  440. $tmp = trim(fgets($tty, 1024));
  441. if (!empty($tmp)) {
  442. $$var = $tmp;
  443. }
  444. }
  445. }
  446. }
  447. foreach ($config_vars as $n => $var) {
  448. foreach ($config_vars as $m => $var2) {
  449. $$var = str_replace('$'.$var2, $$var2, $$var);
  450. }
  451. }
  452. foreach ($config_vars as $var) {
  453. $dir = $$var;
  454. if (!preg_match('/_dir$/', $var)) {
  455. continue;
  456. }
  457. if (!@is_dir($dir)) {
  458. if (!mkdir_p($dir)) {
  459. $root = WINDOWS ? 'administrator' : 'root';
  460. bail("Unable to create {$config_desc[$var]} $dir.
  461. Run this script as $root or pick another location.\n");
  462. }
  463. }
  464. }
  465. if (!WEBINSTALLER) {
  466. $msg = "The following PEAR packages are bundled with PHP: " .
  467. implode(', ', $pfc_packages);
  468. print "\n" . wordwrap($msg, 75) . ".\n";
  469. print "Would you like to install these as well? [Y/n] : ";
  470. $install_pfc = !stristr(fgets($tty, 1024), "n");
  471. print "\n";
  472. }
  473. ####
  474. # Download
  475. ####
  476. ini_set("include_path", $ptmp);
  477. if (!extension_loaded('zlib') && !WEBINSTALLER) { // In Web context we could be in multithread env which makes dl() end up with a fatal error.
  478. if (WINDOWS) {
  479. @dl('php_zlib.dll');
  480. } elseif (PHP_OS == 'HP-UX') {
  481. @dl('zlib.sl');
  482. } elseif (PHP_OS == 'AIX') {
  483. @dl('zlib.a');
  484. } else {
  485. @dl('zlib.so');
  486. }
  487. }
  488. if (!extension_loaded('zlib')) {
  489. $urltemplate = 'http://pear.php.net/get/%s?uncompress=yes';
  490. $have_gzip = null;
  491. } else {
  492. $urltemplate = 'http://pear.php.net/get/%s';
  493. $have_gzip = true;
  494. }
  495. print "Loading zlib: ".($have_gzip ? 'ok' : 'failed')."\n";
  496. if (!$have_gzip) {
  497. print "Downloading uncompressed packages\n";
  498. };
  499. if ($install_pfc) {
  500. $to_install = array_merge($installer_packages, $pfc_packages);
  501. } else {
  502. $to_install = $installer_packages;
  503. }
  504. displayHTMLProgress($progress = 5);
  505. if (file_exists(dirname(__FILE__).'/go-pear-bundle') || is_dir(dirname(__FILE__).'/go-pear-bundle')) {
  506. $dh = @opendir(dirname(__FILE__).'/go-pear-bundle');
  507. }
  508. $local_dir = array();
  509. if ($dh) {
  510. while($file = @readdir($dh)) {
  511. if ($file == '.' || $file == '..' || !is_file(dirname(__FILE__).'/go-pear-bundle/'.$file)) {
  512. continue;
  513. };
  514. $local_dir[] = $file;
  515. };
  516. }
  517. foreach ($installer_packages as $pkg) {
  518. foreach($local_dir as $file) {
  519. if (substr($file, 0, strlen(str_replace('-stable', '', $pkg))) == str_replace('-stable', '', $pkg)) {
  520. $pkg = str_replace('-stable', '', $pkg);
  521. echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.');
  522. copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file);
  523. $tarball[$pkg] = $file;
  524. echo "ok\n";
  525. displayHTMLProgress($progress += round(65 / count($to_install)));
  526. continue 2;
  527. };
  528. };
  529. $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.');
  530. print $msg;
  531. $url = sprintf($urltemplate, $pkg);
  532. $pkg = str_replace('-stable', '', $pkg);
  533. $tarball[$pkg] = download_url($url, null, $http_proxy);
  534. print "ok\n";
  535. displayHTMLProgress($progress += round(65 / count($to_install)));
  536. }
  537. print 'Bootstrapping: PEAR...................';
  538. $r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['PEAR'], 5), 0, -4));
  539. $url = "http://cvs.php.net/co.php/pear-core/PEAR.php?p=1&r=$r";
  540. if (in_array('PEAR.php', $local_dir)) {
  541. copy(dirname(__FILE__).'/go-pear-bundle/PEAR.php', 'PEAR.php');
  542. echo "(local) ";
  543. } else {
  544. download_url($url, 'PEAR.php', $http_proxy);
  545. echo "(remote) ";
  546. }
  547. include_once 'PEAR.php';
  548. print "ok\n";
  549. print 'Bootstrapping: Archive_Tar............';
  550. $r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Archive_Tar'], 12), 0, -4));
  551. $url = "http://cvs.php.net/co.php/pear/Archive_Tar/Archive/Tar.php?p=1&r=$r";
  552. mkdir('Archive', 0700);
  553. if (in_array('Tar.php', $local_dir)) {
  554. copy(dirname(__FILE__).'/go-pear-bundle/Tar.php', 'Archive/Tar.php');
  555. echo "(local) ";
  556. } else {
  557. download_url($url, 'Archive/Tar.php', $http_proxy);
  558. echo "(remote) ";
  559. }
  560. print "ok\n";
  561. print 'Bootstrapping: Console_Getopt.........';
  562. $r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Console_Getopt'], 15), 0, -4));
  563. $url = "http://cvs.php.net/co.php/pear-core/Console/Getopt.php?p=1&r=$r";
  564. mkdir('Console', 0700);
  565. if (in_array('Getopt.php', $local_dir)) {
  566. copy(dirname(__FILE__).'/go-pear-bundle/Getopt.php', 'Console/Getopt.php');
  567. echo "(local) ";
  568. } else {
  569. download_url($url, 'Console/Getopt.php', $http_proxy);
  570. echo "(remote) ";
  571. }
  572. print "ok\n";
  573. if ($install_pfc) {
  574. foreach ($pfc_packages as $pkg) {
  575. foreach($local_dir as $file) {
  576. if (substr($file, 0, strlen($pkg)) == $pkg) {
  577. echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.');
  578. copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file);
  579. $tarball[$pkg] = $file;
  580. echo "ok\n";
  581. displayHTMLProgress($progress += round(65 / count($to_install)));
  582. continue 2;
  583. };
  584. };
  585. $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.');
  586. print $msg;
  587. $url = sprintf($urltemplate, $pkg);
  588. $tarball[$pkg] = download_url($url, null, $http_proxy);
  589. print "ok\n";
  590. displayHTMLProgress($progress += round(65 / count($to_install)));
  591. }
  592. }
  593. displayHTMLProgress($progress = 70);
  594. PEAR::setErrorHandling(PEAR_ERROR_DIE, "\n%s\n");
  595. print 'Extracting installer..................';
  596. $dot = strrpos($tarball['PEAR'], '.');
  597. $pkg = substr($tarball['PEAR'], 0, $dot);
  598. $ext = substr($tarball['PEAR'], $dot+1);
  599. include_once 'Archive/Tar.php';
  600. $tar = &new Archive_Tar($tarball['PEAR'], $have_gzip);
  601. if (!$tar->extractModify($ptmp, $pkg)) {
  602. bail("failed!\n");
  603. }
  604. print "ok\n";
  605. $tarball['PEAR'] = 'package.xml'; // :-)
  606. include_once "PEAR.php";
  607. include_once "PEAR/Config.php";
  608. include_once "PEAR/Command.php";
  609. include_once "PEAR/Registry.php";
  610. if (WEBINSTALLER || isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'local') {
  611. $config = &PEAR_Config::singleton($prefix."/pear.conf", '');
  612. } else {
  613. $config = &PEAR_Config::singleton();
  614. };
  615. $config->set('preferred_state', 'stable');
  616. foreach ($config_vars as $var) {
  617. $config->set($var, $$var);
  618. }
  619. $config->store();
  620. $registry = new PEAR_Registry($php_dir);
  621. PEAR_Command::setFrontendType('CLI');
  622. $install = &PEAR_Command::factory('install', $config);
  623. $install_options = array(
  624. 'nodeps' => true,
  625. 'force' => true,
  626. );
  627. foreach ($tarball as $pkg => $src) {
  628. $options = $install_options;
  629. if ($registry->packageExists($pkg)) {
  630. $options['upgrade'] = true;
  631. }
  632. $install->run('install', $options, array($src));
  633. displayHTMLProgress($progress += round(29 / count($tarball)));
  634. }
  635. displayHTMLProgress($progress = 99);
  636. // Base installation finished
  637. ini_restore("include_path");
  638. if (!WEBINSTALLER) {
  639. $sep = WINDOWS ? ';' : ':';
  640. $include_path = explode($sep, ini_get('include_path'));
  641. if (WINDOWS) {
  642. $found = false;
  643. $t = strtolower($php_dir);
  644. foreach($include_path as $path) {
  645. if ($t==strtolower($path)) {
  646. $found = true;
  647. break;
  648. }
  649. }
  650. } else {
  651. $found = in_array($php_dir, $include_path);
  652. }
  653. if (!$found) {
  654. print "
  655. ******************************************************************************
  656. WARNING! The include_path defined in the currently used php.ini does not
  657. contain the PEAR PHP directory you just specified:
  658. <$php_dir>
  659. If the specified directory is also not in the include_path used by
  660. your scripts, you will have problems getting any PEAR packages working.
  661. ";
  662. if ( $php_ini = getPhpiniPath() ) {
  663. print "\n\nWould you like to alter php.ini <$php_ini>? [Y/n] : ";
  664. $alter_phpini = !stristr(fgets($tty, 1024), "n");
  665. if( $alter_phpini ) {
  666. alterPhpIni($php_ini);
  667. } else {
  668. if (WINDOWS) {
  669. print "
  670. Please look over your php.ini file to make sure
  671. $php_dir is in your include_path.";
  672. } else {
  673. print "
  674. I will add a workaround for this in the 'pear' command to make sure
  675. the installer works, but please look over your php.ini or Apache
  676. configuration to make sure $php_dir is in your include_path.
  677. ";
  678. }
  679. }
  680. }
  681. print "
  682. Current include path : ".ini_get('include_path')."
  683. Configured directory : $php_dir
  684. Currently used php.ini (guess) : $php_ini
  685. ";
  686. print "Press Enter to continue: ";
  687. fgets($tty, 1024);
  688. }
  689. $pear_cmd = $bin_dir . DIRECTORY_SEPARATOR . 'pear';
  690. $pear_cmd = WINDOWS ? strtolower($pear_cmd).'.bat' : $pear_cmd;
  691. // check that the installed pear and the one in tha path are the same (if any)
  692. $pear_old = which(WINDOWS ? 'pear.bat' : 'pear', $bin_dir);
  693. if ($pear_old && ($pear_old != $pear_cmd)) {
  694. // check if it is a link or symlink
  695. $islink = WINDOWS ? false : is_link($pear_old) ;
  696. if ($islink && readlink($pear_old) != $pear_cmd) {
  697. print "\n** WARNING! The link $pear_old does not point to the " .
  698. "installed $pear_cmd\n";
  699. } elseif (is_writable($pear_old) && !is_dir($pear_old)) {
  700. rename($pear_old, "{$pear_old}_old");
  701. print "\n** WARNING! Backed up old pear to {$pear_old}_old\n";
  702. } else {
  703. print "\n** WARNING! Old version found at $pear_old, please remove it or ".
  704. "be sure to use the new $pear_cmd command\n";
  705. }
  706. }
  707. print "\nThe 'pear' command is now at your service at $pear_cmd\n";
  708. // Alert the user if the pear cmd is not in PATH
  709. $old_dir = $pear_old ? dirname($pear_old) : false;
  710. if (!which('pear', $old_dir)) {
  711. print "
  712. ** The 'pear' command is not currently in your PATH, so you need to
  713. ** use '$pear_cmd' until you have added
  714. ** '$bin_dir' to your PATH environment variable.
  715. ";
  716. print "Run it without parameters to see the available actions, try 'pear list'
  717. to see what packages are installed, or 'pear help' for help.
  718. For more information about PEAR, see:
  719. http://pear.php.net/faq.php
  720. http://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt?p=1
  721. http://pear.php.net/manual/
  722. Thanks for using go-pear!
  723. ";
  724. }
  725. }
  726. if (WEBINSTALLER) {
  727. print "Writing WebFrontend file ... ";
  728. @unlink($webfrontend_file); //Delete old one
  729. copy ( $doc_dir.DIRECTORY_SEPARATOR.
  730. 'PEAR_Frontend_Web'.DIRECTORY_SEPARATOR.
  731. 'docs'.DIRECTORY_SEPARATOR.
  732. 'example.php',
  733. $webfrontend_file
  734. );
  735. if ($_GET['step'] == 'install-progress') {
  736. displayHTMLProgress($progress = 100);
  737. ob_end_clean();
  738. displayHTMLInstallationSummary();
  739. displayHTMLFooter();
  740. } else {
  741. $out = ob_get_contents();
  742. $out = explode("\n", $out);
  743. foreach($out as $line => $value) {
  744. if (preg_match('/ok$/', $value)) {
  745. $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
  746. };
  747. if (preg_match('/^install ok:/', $value)) {
  748. $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
  749. };
  750. if (preg_match('/^Warning:/', $value)) {
  751. $value = '<span style="color: #ff0000">'.$value.'</span>';
  752. };
  753. $out[$line] = $value;
  754. };
  755. $out = nl2br(implode("\n",$out));
  756. ob_end_clean();
  757. displayHTML('install', $out);
  758. }
  759. // Little hack, this will be fixed in PEAR later
  760. if ( WINDOWS ) {
  761. clearstatcache();
  762. @unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear');
  763. }
  764. exit;
  765. }
  766. // Little hack, this will be fixed in PEAR later
  767. if ( WINDOWS ) {
  768. clearstatcache();
  769. @unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear');
  770. }
  771. if (WINDOWS && !WEBINSTALLER) {
  772. win32CreateRegEnv();
  773. }
  774. // Set of functions following
  775. // {{{ download_url()
  776. function download_url($url, $destfile = null, $proxy = null)
  777. {
  778. $use_suggested_filename = ($destfile === null);
  779. if ($use_suggested_filename) {
  780. $destfile = basename($url);
  781. }
  782. $tmp = parse_url($url);
  783. if (empty($tmp['port'])) {
  784. $tmp['port'] = 80;
  785. }
  786. if (empty($proxy)) {
  787. $fp = fsockopen($tmp['host'], $tmp['port'], $errno, $errstr);
  788. //print "\nconnecting to $tmp[host]:$tmp[port]\n";
  789. } else {
  790. $tmp_proxy = parse_url($proxy);
  791. $phost = $tmp_proxy['host'];
  792. $pport = $tmp_proxy['port'];
  793. $fp = fsockopen($phost, $pport, $errno, $errstr);
  794. //print "\nconnecting to $phost:$pport\n";
  795. }
  796. if (!$fp) {
  797. bail("download of $url failed: $errstr ($errno)\n");
  798. }
  799. if (empty($proxy)) {
  800. $path = $tmp['path'];
  801. } else {
  802. $path = "http://$tmp[host]:$tmp[port]$tmp[path]";
  803. }
  804. if (isset($tmp['query'])) {
  805. $path .= "?$tmp[query]";
  806. }
  807. if (isset($tmp['fragment'])) {
  808. $path .= "#$tmp[fragment]";
  809. }
  810. $request = "GET $path HTTP/1.0\r\nHost: $tmp[host]:$tmp[port]\r\n".
  811. "User-Agent: go-pear\r\n";
  812. if (!empty($proxy) && $tmp_proxy['user'] != '') {
  813. $request .= 'Proxy-Authorization: Basic ' .
  814. base64_encode($tmp_proxy['user'] . ':' . $tmp_proxy['pass']) . "\r\n";
  815. // print "\nauthenticating against proxy with : user = ${tmp_proxy['user']} \n";
  816. // print "and pass = ${tmp_proxy['pass']}\n";
  817. } // if
  818. $request .= "\r\n";
  819. fwrite($fp, $request);
  820. $cdh = "content-disposition:";
  821. $cdhl = strlen($cdh);
  822. $content_length = 0;
  823. while ($line = fgets($fp, 2048)) {
  824. if (trim($line) == '') {
  825. break;
  826. }
  827. if (preg_match('/^Content-Length: (.*)$/i', $line, $matches)) {
  828. $content_length = trim($matches[1]);
  829. };
  830. if ($use_suggested_filename && !strncasecmp($line, $cdh, $cdhl)) {
  831. if (eregi('filename="([^"]+)"', $line, $matches)) {
  832. $destfile = basename($matches[1]);
  833. }
  834. }
  835. }
  836. if ($content_length) {
  837. displayHTMLSetDownload($destfile);
  838. };
  839. $wp = fopen($destfile, "wb");
  840. if (!$wp) {
  841. bail("could not open $destfile for writing\n");
  842. }
  843. $bytes_read = 0;
  844. $progress = 0;
  845. while ($data = fread($fp, 2048)) {
  846. fwrite($wp, $data);
  847. $bytes_read += strlen($data);
  848. if ($content_length != 0 && floor($bytes_read * 10 / $content_length) != $progress) {
  849. $progress = floor($bytes_read * 10 / $content_length);
  850. displayHTMLDownloadProgress($progress * 10);
  851. };
  852. }
  853. fclose($fp);
  854. fclose($wp);
  855. return $destfile;
  856. }
  857. // }}}
  858. // {{{ which()
  859. function which($program, $dont_search_in = false)
  860. {
  861. if (WINDOWS) {
  862. if ($_path=my_env('Path')) {
  863. $dirs = explode(';', $_path);
  864. } else {
  865. $dirs = explode(';', my_env('PATH'));
  866. }
  867. foreach ($dirs as $i => $dir) {
  868. $dirs[$i] = strtolower(realpath($dir));
  869. }
  870. if ($dont_search_in) {
  871. $dont_search_in = strtolower(realpath($dont_search_in));
  872. }
  873. if ($dont_search_in &&
  874. ($key = array_search($dont_search_in, $dirs)) !== false)
  875. {
  876. unset($dirs[$key]);
  877. }
  878. foreach ($dirs as $dir) {
  879. $dir = str_replace('\\\\', '\\', $dir);
  880. if (!strlen($dir)) {
  881. continue;
  882. }
  883. if ($dir{strlen($dir) - 1} != '\\') {
  884. $dir .= '\\';
  885. }
  886. $tmp = $dir . $program;
  887. $info = pathinfo($tmp);
  888. if (in_array(strtolower($info['extension']),
  889. array('exe', 'com', 'bat', 'cmd'))) {
  890. if (file_exists($tmp)) {
  891. return strtolower($tmp);
  892. }
  893. } elseif (file_exists($ret = $tmp . '.exe') ||
  894. file_exists($ret = $tmp . '.com') ||
  895. file_exists($ret = $tmp . '.bat') ||
  896. file_exists($ret = $tmp . '.cmd')) {
  897. return strtolower($ret);
  898. }
  899. }
  900. } else {
  901. $dirs = explode(':', my_env('PATH'));
  902. if ($dont_search_in &&
  903. ($key = array_search($dont_search_in, $dirs)) !== false)
  904. {
  905. unset($dirs[$key]);
  906. }
  907. foreach ($dirs as $dir) {
  908. if (is_executable("$dir/$program")) {
  909. return "$dir/$program";
  910. }
  911. }
  912. }
  913. return false;
  914. }
  915. // }}}
  916. // {{{ bail()
  917. function bail($msg = '')
  918. {
  919. global $ptmp, $origpwd;
  920. if ($ptmp && is_dir($ptmp)) {
  921. chdir($origpwd);
  922. rm_rf($ptmp);
  923. }
  924. if ($msg && WEBINSTALLER) {
  925. $msg = @ob_get_contents() ."\n\n". $msg;
  926. @ob_end_clean();
  927. displayHTML('error', $msg);
  928. exit;
  929. };
  930. if ($msg && !WEBINSTALLER) {
  931. die($msg);
  932. }
  933. }
  934. // }}}
  935. // {{{ mkdir_p()
  936. function mkdir_p($dir, $mode = 0777)
  937. {
  938. if (@is_dir($dir)) {
  939. return true;
  940. }
  941. $parent = dirname($dir);
  942. $ok = true;
  943. if (!@is_dir($parent) && $parent != $dir) {
  944. $ok = mkdir_p(dirname($dir), $mode);
  945. }
  946. if ($ok) {
  947. $ok = @mkdir($dir, $mode);
  948. if (!$ok) {
  949. print "mkdir failed: $dir\n";
  950. }
  951. }
  952. return $ok;
  953. }
  954. // }}}
  955. // {{{ rm_rf()
  956. function rm_rf($path)
  957. {
  958. if (@is_dir($path) && is_writable($path)) {
  959. $dp = opendir($path);
  960. while ($ent = readdir($dp)) {
  961. if ($ent == '.' || $ent == '..') {
  962. continue;
  963. }
  964. $file = $path . DIRECTORY_SEPARATOR . $ent;
  965. if (@is_dir($file)) {
  966. rm_rf($file);
  967. } elseif (is_writable($file)) {
  968. unlink($file);
  969. } else {
  970. echo $file . "is not writable and cannot be removed.
  971. Please fix the permission or select a new path.\n";
  972. }
  973. }
  974. closedir($dp);
  975. return rmdir($path);
  976. } else {
  977. return @unlink($path);
  978. }
  979. }
  980. // }}}
  981. // {{{ tmpdir()
  982. /*
  983. * Fixes for winXP/wrong tmp set by Urs Gehrig (urs@circle.ch)
  984. */
  985. function tmp_dir()
  986. {
  987. global $ptmp, $prefix;
  988. $_temp = false;
  989. if (WINDOWS){
  990. if ( my_env('TEMP') ) {
  991. $_temp = my_env('TEMP');
  992. } elseif ( my_env('TMP') ) {
  993. $_temp = my_env('TMP');
  994. } elseif ( my_env('windir') ) {
  995. $_temp = my_env('windir') . '\temp';
  996. } elseif ( my_env('SystemRoot') ) {
  997. $_temp = my_env('SystemRoot') . '\temp';
  998. }
  999. // handle ugly ENV var like \Temp instead of c:\Temp
  1000. $dirs = explode("\\", realpath($_temp));
  1001. if(strpos($_temp, ":") != 1) {
  1002. unset($_temp);
  1003. $_dirs = array();
  1004. foreach($dirs as $val) {
  1005. if((boolean)$val ) {
  1006. $_dirs[] = str_replace("/", "", $val);
  1007. }
  1008. }
  1009. unset($dirs);
  1010. $dirs = $_dirs;
  1011. array_unshift ($dirs, "c:" );
  1012. $_temp = $dirs[0];
  1013. for($i = 1;$i < count($dirs);$i++) {
  1014. $_temp .= "//" . $dirs[$i];
  1015. }
  1016. }
  1017. $ptmp = $_temp;
  1018. } else {
  1019. $_temp = my_env('TMPDIR');
  1020. if (!$_temp) {
  1021. if (is_writable('/tmp')) {
  1022. $_temp = '/tmp';
  1023. }
  1024. }
  1025. }
  1026. // If for some reason the user has no rights to access to
  1027. // the standard tempdir, we assume that he has the right
  1028. // to access his prefix and choose $prefix/tmp as tempdir
  1029. if (!$_temp) {
  1030. print "System's Tempdir failed, trying to use \$prefix/tmp ...";
  1031. $res = mkdir_p($prefix.'/tmp');
  1032. if (!$res) {
  1033. bail('mkdir '.$prefix.'/tmp'.' ... failed');
  1034. }
  1035. $ptmp = $prefix . '/tmp';
  1036. $_temp = tempnam($prefix.'/tmp', 'gope');
  1037. rm_rf($_temp);
  1038. mkdir_p($_temp, 0700);
  1039. $ok = @chdir($ptmp);
  1040. if (!$ok) { // This should not happen, really ;)
  1041. bail('chdir '.$ptmp.' ... failed');
  1042. }
  1043. print "ok\n";
  1044. // Adjust TEMPDIR envvars
  1045. if (!isset($_ENV)) {
  1046. $_ENV = array();
  1047. };
  1048. $_ENV['TMPDIR'] = $_ENV['TEMP'] = $prefix.'/tmp';
  1049. }
  1050. $ptmp = $_temp;
  1051. }
  1052. // }}}
  1053. // {{{ my_env()
  1054. /*
  1055. (cox) In my system PHP 4.2.1 (both cgi & cli) $_ENV is empty
  1056. but getenv() does work fine
  1057. */
  1058. function my_env($var)
  1059. {
  1060. if (is_array($_ENV) && isset($_ENV[$var])) {
  1061. return $_ENV[$var];
  1062. }
  1063. return getenv($var);
  1064. }
  1065. // }}}
  1066. // {{{ detect_install_dirs()
  1067. function detect_install_dirs($_prefix = null) {
  1068. global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir;
  1069. if (WINDOWS) {
  1070. if ($_prefix === null) {
  1071. $prefix = getcwd();
  1072. } else {
  1073. $prefix = $_prefix;
  1074. }
  1075. if (!@is_dir($prefix)) {
  1076. if (@is_dir('c:\php5')) {
  1077. $prefix = 'c:\php5';
  1078. } elseif (@is_dir('c:\php4')) {
  1079. $prefix = 'c:\php4';
  1080. } elseif (@is_dir('c:\php')) {
  1081. $prefix = 'c:\php';
  1082. }
  1083. }
  1084. $bin_dir = '$prefix';
  1085. $php_dir = '$prefix\pear';
  1086. $doc_dir = '$php_dir\docs';
  1087. $data_dir = '$php_dir\data';
  1088. $test_dir = '$php_dir\tests';
  1089. /*
  1090. * Detects php.exe
  1091. */
  1092. if( $t=getenv('PHP_PEAR_PHP_BIN') ){
  1093. $php_bin = $t;
  1094. } elseif ($t=getenv('PHP_BIN') ) {
  1095. $php_bin = $t;
  1096. } elseif ( $t=which('php') ) {
  1097. $php_bin = $t;
  1098. } elseif ( is_file($prefix.'\cli\php.exe') ) {
  1099. $php_bin = $prefix.'\cli\php.exe';
  1100. } elseif ( is_file($prefix.'\php.exe') ) {
  1101. $php_bin = $prefix.'\php.exe';
  1102. }
  1103. if( $php_bin && !is_file($php_bin) ){
  1104. $php_bin = '';
  1105. } else {
  1106. if(!ereg(":",$php_bin)){
  1107. $php_bin = getcwd().DIRECTORY_SEPARATOR.$php_bin;
  1108. }
  1109. }
  1110. if (!is_file($php_bin)) {
  1111. if (is_file('c:/php/cli/php.exe')) {
  1112. $php_bin = 'c:/php/cli/php.exe';
  1113. } elseif (is_file('c:/php5/php.exe')) {
  1114. $php_bin = 'c:/php5/php.exe';
  1115. } elseif (is_file('c:/php4/cli/php.exe')) {
  1116. $php_bin = 'c:/php4/cli/php.exe';
  1117. }
  1118. }
  1119. } else {
  1120. if ($_prefix === null) {
  1121. $prefix = dirname(PHP_BINDIR);
  1122. } else {
  1123. $prefix = $_prefix;
  1124. }
  1125. $bin_dir = '$prefix/bin';
  1126. $php_dir = '$prefix/share/pear';
  1127. $doc_dir = '$php_dir/docs';
  1128. $data_dir = '$php_dir/data';
  1129. $test_dir = '$php_dir/tests';
  1130. // check if the user has installed PHP with PHP or GNU layout
  1131. if (@is_dir("$prefix/lib/php/.registry")) {
  1132. $php_dir = '$prefix/lib/php';
  1133. } elseif (@is_dir("$prefix/share/pear/lib/.registry")) {
  1134. $php_dir = '$prefix/share/pear/lib';
  1135. $doc_dir = '$prefix/share/pear/docs';
  1136. $data_dir = '$prefix/share/pear/data';
  1137. $test_dir = '$prefix/share/pear/tests';
  1138. } elseif (@is_dir("$prefix/share/php/.registry")) {
  1139. $php_dir = '$prefix/share/php';
  1140. }
  1141. }
  1142. }
  1143. // }}}
  1144. // {{{ displayHTMLHeader
  1145. function displayHTMLHeader()
  1146. {
  1147. ?>
  1148. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  1149. <html>
  1150. <head>
  1151. <title>PEAR :: Installer :: Go-PEAR</title>
  1152. <style type="text/css">
  1153. <!--
  1154. a {
  1155. color:#000000;
  1156. text-decoration: none;
  1157. }
  1158. a:visited {
  1159. color:#000000;
  1160. text-decoration: none;
  1161. }
  1162. a:active {
  1163. color:#000000;
  1164. text-decoration: none;
  1165. }
  1166. a:hover {
  1167. color:#000000;
  1168. text-decoration: underline;
  1169. }
  1170. a.green {
  1171. color:#006600;
  1172. text-decoration: none;
  1173. }
  1174. a.green:visited {
  1175. color:#006600;
  1176. text-decoration: none;
  1177. }
  1178. a.green:active {
  1179. color:#006600;
  1180. text-decoration: none;
  1181. }
  1182. a.green:hover {
  1183. color:#006600;
  1184. text-decoration: underline;
  1185. }
  1186. body, td, th {
  1187. font-family: verdana,arial,helvetica,sans-serif;
  1188. font-size: 90%;
  1189. }
  1190. p {
  1191. font-family: verdana,arial,helvetica,sans-serif;
  1192. }
  1193. th.pack {
  1194. color: #FFFFFF;
  1195. background: #009933;
  1196. text-align: right;
  1197. }
  1198. td.package_info_title {
  1199. color: #006600;
  1200. font-weight: bold;
  1201. }
  1202. th.others {
  1203. color: #006600;
  1204. text-align: left;
  1205. }
  1206. em {
  1207. font-weight: bold;
  1208. font-style: italic;
  1209. }
  1210. .green {
  1211. color: #006600;
  1212. }
  1213. .red {
  1214. color: #006600;
  1215. }
  1216. span.headline {
  1217. font-family: verdana,arial,helvetica,sans-serif;
  1218. font-size: 125%;
  1219. font-weight: bold;
  1220. color: #ffffff;
  1221. }
  1222. span.title {
  1223. font-family: verdana,arial,helvetica,sans-serif;
  1224. font-size: 110%;
  1225. font-weight: bold;
  1226. color: #006600;
  1227. }
  1228. .newsDate {
  1229. font-size: 85%;
  1230. font-style: italic;
  1231. color: #66cc66;
  1232. }
  1233. .compact {
  1234. font-family: arial, helvetica, sans-serif;
  1235. font-size: 90%;
  1236. }
  1237. .menuWhite {
  1238. font-family: verdana,arial,helvetica,sans-serif;
  1239. font-size: 75%;
  1240. color: #ffffff;
  1241. }
  1242. .menuBlack {
  1243. font-family: verdana,arial,helvetica,sans-serif;
  1244. text-decoration: none;
  1245. font-weight: bold;
  1246. font-size: 75%;
  1247. color: #000000;
  1248. }
  1249. .sidebar {
  1250. font-size: 85%;
  1251. }
  1252. code, pre, tt {
  1253. font-family: Courier, "Courier New", monospace;
  1254. font-size: 90%;
  1255. }
  1256. pre.php {
  1257. border-color: black;
  1258. border-style: dashed;
  1259. border-width: 1px;
  1260. background-color: #eeeeee;
  1261. padding: 5px;
  1262. }
  1263. h1 {
  1264. font-family: verdana,arial,helvetica,sans-serif;
  1265. font-size: 140%;
  1266. font-weight: bold;
  1267. color: #006600;
  1268. }
  1269. h2 {
  1270. font-family: verdana,arial,helvetica,sans-serif;
  1271. font-size: 125%;
  1272. font-weight: bold;
  1273. color: #006600;
  1274. }
  1275. h3 {
  1276. font-family: verdana,arial,helvetica,sans-serif;
  1277. font-size: 110%;
  1278. font-weight: bold;
  1279. color: #006600;
  1280. }
  1281. small {
  1282. font-family: verdana,arial,helvetica,sans-serif;
  1283. font-size: 75%;
  1284. }
  1285. a.small {
  1286. font-family: verdana,arial,helvetica,sans-serif;
  1287. font-size: 75%;
  1288. text-decoration: none;
  1289. }
  1290. .tableTitle {
  1291. font-family: verdana,arial,helvetica,sans-serif;
  1292. font-weight: bold;
  1293. }
  1294. .tableExtras {
  1295. font-family: verdana,arial,helvetica,sans-serif;
  1296. font-size: 85%;
  1297. color: #FFFFFF;
  1298. }
  1299. input {
  1300. font-family: verdana,arial,helvetica,sans-serif;
  1301. }
  1302. textarea {
  1303. font-family: verdana,arial,helvetica,sans-serif;
  1304. }
  1305. input.small, select.small {
  1306. font-family: verdana,arial,helvetica,sans-serif;
  1307. font-size: 75%;
  1308. }
  1309. textarea.small {
  1310. font-family: verdana,arial,helvetica,sans-serif;
  1311. font-size: 75%;
  1312. }
  1313. form {
  1314. margin-bottom : 0;
  1315. }
  1316. -->
  1317. </style>
  1318. <meta name="description" content="This is the Web Interface of the PEAR Installer" />
  1319. </head>
  1320. <body topmargin="0" leftmargin="0"
  1321. marginheight="0" marginwidth="0"
  1322. bgcolor="#ffffff"
  1323. text="#000000"
  1324. link="#006600"
  1325. alink="#cccc00"
  1326. vlink="#003300"
  1327. >
  1328. <?php
  1329. }
  1330. // }}}
  1331. // {{{ displayHTML
  1332. function displayHTML($page = 'Welcome', $data = array())
  1333. {
  1334. global $pfc_packages;
  1335. displayHTMLHeader();
  1336. ?>
  1337. <a name="TOP" /></a>
  1338. <table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  1339. <tr bgcolor="#339900">
  1340. <td align="left" width="120">
  1341. <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=pearlogo" width="104" height="50" vspace="2" hspace="5" alt="PEAR">
  1342. </td>
  1343. <td align="left" valign="middle" width="20">
  1344. &nbsp;
  1345. </td>
  1346. <td align="left" valign="middle">
  1347. <span class="Headline">Go-PEAR</span>
  1348. </td>
  1349. </tr>
  1350. <tr bgcolor="#003300"><td colspan="3"></td></tr>
  1351. <tr bgcolor="#006600">
  1352. <td align="right" valign="top" colspan="3">
  1353. <span style="color: #ffffff">Version <?php echo GO_PEAR_VER; ?></span>&nbsp;<br />
  1354. </td>
  1355. </tr>
  1356. <tr bgcolor="#003300"><td colspan="3"></td></tr>
  1357. </table>
  1358. <table cellpadding="0" cellspacing="0" width="100%">
  1359. <tr valign="top">
  1360. <td bgcolor="#f0f0f0" width="100">
  1361. <table width="200" border="0" cellpadding="4" cellspacing="0">
  1362. <tr valign="top">
  1363. <td style="font-size: 90%" align="left" width="200">
  1364. <br><br>
  1365. <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=smallpear" border="0">
  1366. <a href="<?php echo basename(__FILE__); ?>?step=Welcome&restart=1" <?php if ($page == 'Welcome') echo ' class="green"'; ?>>
  1367. Welcome to Go-PEAR
  1368. </a><br/>
  1369. <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=smallpear" border="0">
  1370. <a href="<?php echo basename(__FILE__); ?>?step=config" <?php if ($page == 'config') echo ' class="green"'; ?>>
  1371. Configuration
  1372. </a><br/>
  1373. <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=smallpear" border="0">
  1374. <?php if ($page == 'install') echo '<span class="green">'; ?>
  1375. Complete installation<br/>
  1376. <?php if ($page == 'install') echo '</span>'; ?>
  1377. </td>
  1378. </tr>
  1379. </table>
  1380. </td>
  1381. <td bgcolor="#cccccc" width="1" background="/gifs/checkerboard.gif"></td>
  1382. <td>
  1383. <table width="100%" cellpadding="10" cellspacing="0">
  1384. <tr>
  1385. <td valign="top">
  1386. <table border="0">
  1387. <tr>
  1388. <td width="20">
  1389. </td>
  1390. <td>
  1391. <?php
  1392. if ($page == 'error') {
  1393. ?>
  1394. <span class="title">Error</span><br/>
  1395. <br/>
  1396. <?php
  1397. $value = $data;
  1398. if (preg_match('/ok$/', $value)) {
  1399. $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
  1400. }
  1401. if (preg_match('/failed$/', $value)) {
  1402. $value = preg_replace('/(failed)$/', '<span style="color: #ff0000">\1</span>', $value);
  1403. }
  1404. if (preg_match('/^install ok:/', $value)) {
  1405. $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
  1406. }
  1407. if (preg_match('/^Warning:/', $value)) {
  1408. $value = '<span style="color: #ff0000">'.$value.'</span>';
  1409. }
  1410. echo nl2br($value);
  1411. } elseif ($page == 'Welcome') {
  1412. ?>
  1413. <span class="title">Welcome to go-pear <?php echo GO_PEAR_VER; ?>!</span><br/>
  1414. <br/>
  1415. Go-pear will install the Web Frontend of the PEAR Installer and all the needed <br/>
  1416. files. This frontend is your tool for PEAR installation and maintenance.<br/>
  1417. <br/>
  1418. Go-pear also lets you download and install the PEAR packages bundled<br/>
  1419. with PHP: <?php echo implode(', ', $GLOBALS['pfc_packages']); ?>.<br/>
  1420. <br/>
  1421. <a href="<?php echo basename(__FILE__); ?>?step=config" class="green">Next &gt;&gt;</a>
  1422. <?php
  1423. } elseif ($page == 'config') {
  1424. if (!empty($GLOBALS['http_proxy'])) {
  1425. list($proxy_host, $proxy_port) = explode(':', $GLOBALS['http_proxy']);
  1426. } else {
  1427. $proxy_host = $proxy_port = '';
  1428. }
  1429. ?>
  1430. <form action="<?php echo basename(__FILE__);?>?step=install" method="post">
  1431. <span class="title">Configuration</span><br/>
  1432. <br/>
  1433. HTTP proxy (host:port):
  1434. <input type="text" name="proxy[host]" value="<?php echo $proxy_host;?>">
  1435. <input type="text" name="proxy[port]" value="<?php echo $proxy_port;?>" size="6">
  1436. <br/><br/><hr/><br/>
  1437. Below is a suggested file layout for your new PEAR installation. <br/>
  1438. <br/>
  1439. <table border="0">
  1440. <TR>
  1441. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;i…

Large files files are truncated, but you can click here to view the full file