PageRenderTime 69ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/go-pear.php

http://ebpls.googlecode.com/
PHP | 2374 lines | 2008 code | 173 blank | 193 comment | 289 complexity | c0e661318d62d8f35213ff9045fda690 MD5 | raw 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-2004 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.71 2004/10/25 04:18:17 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';
  151. }
  152. $pfc_packages = array(
  153. 'DB',
  154. 'Net_Socket',
  155. 'Net_SMTP',
  156. 'Mail',
  157. 'XML_Parser',
  158. 'PHPUnit'
  159. );
  160. $config_desc = array(
  161. 'prefix' => 'Installation prefix',
  162. 'bin_dir' => 'Binaries directory',
  163. 'php_dir' => 'PHP code directory ($php_dir)',
  164. 'doc_dir' => 'Documentation base directory',
  165. 'data_dir' => 'Data base directory',
  166. 'test_dir' => 'Tests base directory',
  167. );
  168. if(!WEBINSTALLER && WINDOWS){
  169. $config_desc['php_bin'] = 'php.exe path';
  170. }
  171. if (WEBINSTALLER) {
  172. $config_desc['cache_dir'] = 'PEAR Installer cache directory';
  173. $config_desc['cache_ttl'] = 'Cache TimeToLive';
  174. $config_desc['webfrontend_file'] = 'Filename of WebFrontend';
  175. $config_desc['php_bin'] = "php.exe path, optional (CLI command tools)";
  176. }
  177. if (my_env('HTTP_PROXY')) {
  178. $http_proxy = my_env('HTTP_PROXY');
  179. } elseif (my_env('http_proxy')) {
  180. $http_proxy = my_env('http_proxy');
  181. } else {
  182. $http_proxy = '';
  183. }
  184. register_shutdown_function('bail');
  185. detect_install_dirs();
  186. if (WEBINSTALLER) {
  187. @session_start();
  188. /*
  189. See bug #23069
  190. */
  191. if ( WINDOWS ) {
  192. $php_sapi_name = win32DetectPHPSAPI();
  193. if($php_sapi_name=='cgi'){
  194. $msg = "
  195. Sorry! The PEAR installer actually does not work on Windows platform using CGI and Apache.
  196. Please install the module SAPI (see http://www.php.net/manual/en/install.apache.php for the
  197. instructions) or use the CLI (cli\php.exe) in the console.
  198. ";
  199. displayHTML('error', $msg);
  200. exit();
  201. }
  202. }
  203. if (!isset($_SESSION['go-pear']) || isset($_GET['restart'])) {
  204. $_SESSION['go-pear'] = array(
  205. 'http_proxy' => $http_proxy,
  206. 'config' => array(
  207. 'prefix' => dirname(__FILE__),
  208. 'bin_dir' => $bin_dir,
  209. 'php_bin' => $php_bin,
  210. 'php_dir' => '$prefix/PEAR',
  211. 'doc_dir' => $doc_dir,
  212. 'data_dir' => $data_dir,
  213. 'test_dir' => $test_dir,
  214. 'cache_dir' => '$php_dir/cache',
  215. 'cache_ttl' => 300,
  216. 'webfrontend_file' => '$prefix/index.php',
  217. ),
  218. 'install_pfc' => true,
  219. 'DHTML' => true,
  220. );
  221. }
  222. if (!isset($_GET['step'])) {
  223. $_GET['step'] = 'Welcome';
  224. /* clean up old sessions datas */
  225. session_destroy();
  226. }
  227. if ($_GET['step'] == 'install') {
  228. $_SESSION['go-pear']['http_proxy'] = strip_magic_quotes($_POST['proxy']['host']).':'.strip_magic_quotes($_POST['proxy']['port']);
  229. if ($_SESSION['go-pear']['http_proxy'] == ':') {
  230. $_SESSION['go-pear']['http_proxy'] = '';
  231. };
  232. $www_errors = array();
  233. foreach($_POST['config'] as $key => $value) {
  234. $_POST['config'][$key] = strip_magic_quotes($value);
  235. if($key!='cache_ttl'){
  236. if ( empty($_POST['config'][$key]) ) {
  237. if (WEBINSTALLER && $key!='php_bin' ) {
  238. $www_errors[$key] = 'Please fill this path, you can use $prefix, $php_dir or a full path.';
  239. }
  240. }
  241. }
  242. }
  243. if( sizeof($www_errors)>0){
  244. $_GET['step'] = 'config';
  245. }
  246. $_SESSION['go-pear']['config'] = $_POST['config'];
  247. $_SESSION['go-pear']['install_pfc'] = (isset($_POST['install_pfc']) && $_POST['install_pfc'] == 'on');
  248. $_SESSION['go-pear']['DHTML'] = !($_POST['BCmode'] == "on");
  249. }
  250. $http_proxy = $_SESSION['go-pear']['http_proxy'];
  251. foreach($_SESSION['go-pear']['config'] as $var => $value) {
  252. $$var = $value;
  253. }
  254. $install_pfc = $_SESSION['go-pear']['install_pfc'];
  255. }
  256. if (!WEBINSTALLER) {
  257. $tty = WINDOWS ? @fopen('\con', 'r') : @fopen('/dev/tty', 'r');
  258. if (!$tty) {
  259. $tty = fopen('php://stdin', 'r');
  260. }
  261. $local = isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'local';
  262. if ($local) {
  263. $local = "
  264. Running in local install mode
  265. ";
  266. } elseif (WINDOWS) {
  267. $local = "
  268. Use 'php " . $_SERVER['argv'][0] . " local' to install a local copy of PEAR.
  269. ";
  270. }
  271. print "Welcome to go-pear!
  272. Go-pear will install the 'pear' command and all the files needed by
  273. it. This command is your tool for PEAR installation and maintenance.
  274. $local
  275. Go-pear also lets you download and install the PEAR packages bundled
  276. with PHP: " . implode(', ', $pfc_packages) . ".
  277. If you wish to abort, press Control-C now, or press Enter to continue: ";
  278. fgets($tty, 1024);
  279. print "\n";
  280. print "HTTP proxy (http://user:password@proxy.myhost.com:port), or Enter for none:";
  281. if (!empty($http_proxy)) {
  282. print " [$http_proxy]";
  283. }
  284. print ": ";
  285. $tmp = trim(fgets($tty, 1024));
  286. if (!empty($tmp)) {
  287. $http_proxy = $tmp;
  288. }
  289. }
  290. $origpwd = getcwd();
  291. $config_vars = array_keys($config_desc);
  292. // make indices run from 1...
  293. array_unshift($config_vars, "");
  294. unset($config_vars[0]);
  295. reset($config_vars);
  296. $desclen = max(array_map('strlen', $config_desc));
  297. $descfmt = "%-{$desclen}s";
  298. $first = key($config_vars);
  299. end($config_vars);
  300. $last = key($config_vars);
  301. if (WEBINSTALLER) {
  302. if ( isset($www_errors) && sizeof($www_errors) ) {
  303. displayHTML('config');
  304. exit();
  305. } else {
  306. if (isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'] == true && $_GET['step'] == 'install') {
  307. $_GET['step'] = 'preinstall';
  308. }
  309. if ($_GET['step'] != 'install' && $_GET['step'] != 'install-progress') {
  310. displayHTML($_GET['step']);
  311. exit;
  312. }
  313. if ($_GET['step'] == 'install-progress') {
  314. displayHTMLHeader();
  315. echo "Starting installation ...<br/>";
  316. }
  317. ob_start();
  318. }
  319. }
  320. $progress = 0;
  321. /*
  322. * Checks PHP SAPI version under windows/CLI
  323. */
  324. if( WINDOWS && !WEBINSTALLER && $php_bin=='') {
  325. print "
  326. We do not find any php.exe, please select the php.exe folder (CLI is
  327. recommanded, usually in c:\php\cli\php.exe)
  328. ";
  329. $php_bin_set = false;
  330. } elseif ( WINDOWS && !WEBINSTALLER && strlen($php_bin) ) {
  331. $php_bin_sapi = win32DetectPHPSAPI();
  332. $php_bin_set = true;
  333. switch($php_bin_sapi){
  334. case 'cli':
  335. break;
  336. case 'cgi':
  337. print "
  338. *NOTICE*
  339. We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI. PEAR commandline
  340. tool works well with it, if you have a CLI php.exe available, we
  341. recommand to use it.
  342. ";
  343. break;
  344. default:
  345. print "
  346. *WARNING*
  347. We found php.exe under $php_bin, it uses an unknown SAPI. PEAR commandline
  348. tool has not been tested with it, if you have a CLI (or CGI) php.exe available,
  349. we strongly recommand to use it.
  350. ";
  351. break;
  352. }
  353. }
  354. ####
  355. # Temp stuff
  356. ####
  357. tmp_dir();
  358. $foo = $ptmp;
  359. $ptmp = tempnam($foo, 'gope');
  360. if (WINDOWS) {
  361. $ptmp = str_replace($foo,'',$ptmp);
  362. $foo=str_replace("\\\\",'/',$foo);
  363. $s = substr($ptmp,0,1);
  364. if($s=="\\" || $s=='/' ){
  365. $ptmp = $foo.'/'.substr($ptmp,1);
  366. } else {
  367. $ptmp = $foo.'/'.$ptmp;
  368. }
  369. }
  370. rm_rf($ptmp);
  371. mkdir_p($ptmp, 0700);
  372. $ok = @chdir($ptmp);
  373. while (!WEBINSTALLER) {
  374. print "
  375. Below is a suggested file layout for your new PEAR installation. To
  376. change individual locations, type the number in front of the
  377. directory. Type 'all' to change all of them or simply press Enter to
  378. accept these locations.
  379. ";
  380. foreach ($config_vars as $n => $var) {
  381. printf("%2d. $descfmt : %s\n", $n, $config_desc[$var], $$var);
  382. }
  383. print "\n$first-$last, 'all' or Enter to continue: ";
  384. $tmp = trim(fgets($tty, 1024));
  385. if ( empty($tmp) ) {
  386. if( WINDOWS && !$php_bin_set ){
  387. echo "**ERROR**
  388. Please, enter the php.exe path.
  389. ";
  390. } else {
  391. break;
  392. }
  393. }
  394. if (isset($config_vars[(int)$tmp])) {
  395. $var = $config_vars[(int)$tmp];
  396. $desc = $config_desc[$var];
  397. $current = $$var;
  398. if(WIN32GUI){
  399. $tmp = win32BrowseForFolder("$desc [$current] :");
  400. } else {
  401. print "$desc [$current] : ";
  402. $tmp = trim(fgets($tty, 1024));
  403. }
  404. $old = $$var;
  405. if(WINDOWS && $var=='php_bin' ){
  406. if(file_exists($tmp.DIRECTORY_SEPARATOR.'php.exe')){
  407. $tmp = $tmp.DIRECTORY_SEPARATOR.'php.exe';
  408. $php_bin_sapi = win32DetectPHPSAPI();
  409. if($php_bin_sapi=='cgi'){
  410. print "
  411. ******************************************************************************
  412. NOTICE! We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI.
  413. PEAR commandline tool works well with it.
  414. If you have a CLI php.exe available, we recommand to use it.
  415. ";
  416. } elseif ($php_bin_sapi=='unknown') {
  417. print "
  418. ******************************************************************************
  419. WARNING! We found php.exe under $php_bin, it uses an $php_bin_sapi SAPI.
  420. PEAR commandline tool has not been tested with it.
  421. If you have a CLI (or CGI) php.exe available, we strongly recommand to use it.
  422. ";
  423. }
  424. echo "php.exe (sapi: $php_bin_sapi) found.\n\n";
  425. $php_bin_set = true;
  426. } else {
  427. echo "**ERROR**: no php.exe found in this folder.\n";
  428. $tmp='';
  429. }
  430. }
  431. if (!empty($tmp) ) {
  432. $$var = $tmp;
  433. }
  434. } elseif ($tmp == 'all') {
  435. foreach ($config_vars as $n => $var) {
  436. $desc = $config_desc[$var];
  437. $current = $$var;
  438. print "$desc [$current] : ";
  439. $tmp = trim(fgets($tty, 1024));
  440. if (!empty($tmp)) {
  441. $$var = $tmp;
  442. }
  443. }
  444. }
  445. }
  446. foreach ($config_vars as $n => $var) {
  447. foreach ($config_vars as $m => $var2) {
  448. $$var = str_replace('$'.$var2, $$var2, $$var);
  449. }
  450. }
  451. foreach ($config_vars as $var) {
  452. $dir = $$var;
  453. if (!preg_match('/_dir$/', $var)) {
  454. continue;
  455. }
  456. if (!@is_dir($dir)) {
  457. if (!mkdir_p($dir)) {
  458. $root = WINDOWS ? 'administrator' : 'root';
  459. bail("Unable to create {$config_desc[$var]} $dir.
  460. Run this script as $root or pick another location.\n");
  461. }
  462. }
  463. }
  464. if (!WEBINSTALLER) {
  465. $msg = "The following PEAR packages are bundled with PHP: " .
  466. implode(', ', $pfc_packages);
  467. print "\n" . wordwrap($msg, 75) . ".\n";
  468. print "Would you like to install these as well? [Y/n] : ";
  469. $install_pfc = !stristr(fgets($tty, 1024), "n");
  470. print "\n";
  471. }
  472. ####
  473. # Download
  474. ####
  475. ini_set("include_path", $ptmp);
  476. if (!extension_loaded('zlib') && !WEBINSTALLER) { // In Web context we could be in multithread env which makes dl() end up with a fatal error.
  477. if (WINDOWS) {
  478. @dl('php_zlib.dll');
  479. } elseif (PHP_OS == 'HP-UX') {
  480. @dl('zlib.sl');
  481. } elseif (PHP_OS == 'AIX') {
  482. @dl('zlib.a');
  483. } else {
  484. @dl('zlib.so');
  485. }
  486. }
  487. if (!extension_loaded('zlib')) {
  488. $urltemplate = 'http://pear.php.net/get/%s?uncompress=yes';
  489. $have_gzip = null;
  490. } else {
  491. $urltemplate = 'http://pear.php.net/get/%s';
  492. $have_gzip = true;
  493. }
  494. print "Loading zlib: ".($have_gzip ? 'ok' : 'failed')."\n";
  495. if (!$have_gzip) {
  496. print "Downloading uncompressed packages\n";
  497. };
  498. if ($install_pfc) {
  499. $to_install = array_merge($installer_packages, $pfc_packages);
  500. } else {
  501. $to_install = $installer_packages;
  502. }
  503. displayHTMLProgress($progress = 5);
  504. if (file_exists(dirname(__FILE__).'/go-pear-bundle') || is_dir(dirname(__FILE__).'/go-pear-bundle')) {
  505. $dh = @opendir(dirname(__FILE__).'/go-pear-bundle');
  506. }
  507. $local_dir = array();
  508. if ($dh) {
  509. while($file = @readdir($dh)) {
  510. if ($file == '.' || $file == '..' || !is_file(dirname(__FILE__).'/go-pear-bundle/'.$file)) {
  511. continue;
  512. };
  513. $local_dir[] = $file;
  514. };
  515. }
  516. foreach ($installer_packages as $pkg) {
  517. foreach($local_dir as $file) {
  518. if (substr($file, 0, strlen(str_replace('-stable', '', $pkg))) == str_replace('-stable', '', $pkg)) {
  519. $pkg = str_replace('-stable', '', $pkg);
  520. echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.');
  521. copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file);
  522. $tarball[$pkg] = $file;
  523. echo "ok\n";
  524. displayHTMLProgress($progress += round(65 / count($to_install)));
  525. continue 2;
  526. };
  527. };
  528. $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.');
  529. print $msg;
  530. $url = sprintf($urltemplate, $pkg);
  531. $pkg = str_replace('-stable', '', $pkg);
  532. $tarball[$pkg] = download_url($url, null, $http_proxy);
  533. print "ok\n";
  534. displayHTMLProgress($progress += round(65 / count($to_install)));
  535. }
  536. print 'Bootstrapping: PEAR...................';
  537. $r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['PEAR'], 5), 0, -4));
  538. $url = "http://cvs.php.net/co.php/pear-core/PEAR.php?p=1&r=$r";
  539. if (in_array('PEAR.php', $local_dir)) {
  540. copy(dirname(__FILE__).'/go-pear-bundle/PEAR.php', 'PEAR.php');
  541. echo "(local) ";
  542. } else {
  543. download_url($url, 'PEAR.php', $http_proxy);
  544. echo "(remote) ";
  545. }
  546. include_once 'PEAR.php';
  547. print "ok\n";
  548. print 'Bootstrapping: Archive_Tar............';
  549. $r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Archive_Tar'], 12), 0, -4));
  550. $url = "http://cvs.php.net/co.php/pear/Archive_Tar/Archive/Tar.php?p=1&r=$r";
  551. mkdir('Archive', 0700);
  552. if (in_array('Tar.php', $local_dir)) {
  553. copy(dirname(__FILE__).'/go-pear-bundle/Tar.php', 'Archive/Tar.php');
  554. echo "(local) ";
  555. } else {
  556. download_url($url, 'Archive/Tar.php', $http_proxy);
  557. echo "(remote) ";
  558. }
  559. print "ok\n";
  560. print 'Bootstrapping: Console_Getopt.........';
  561. $r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Console_Getopt'], 15), 0, -4));
  562. $url = "http://cvs.php.net/co.php/pear-core/Console/Getopt.php?p=1&r=$r";
  563. mkdir('Console', 0700);
  564. if (in_array('Getopt.php', $local_dir)) {
  565. copy(dirname(__FILE__).'/go-pear-bundle/Getopt.php', 'Console/Getopt.php');
  566. echo "(local) ";
  567. } else {
  568. download_url($url, 'Console/Getopt.php', $http_proxy);
  569. echo "(remote) ";
  570. }
  571. print "ok\n";
  572. if ($install_pfc) {
  573. foreach ($pfc_packages as $pkg) {
  574. foreach($local_dir as $file) {
  575. if (substr($file, 0, strlen($pkg)) == $pkg) {
  576. echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.');
  577. copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file);
  578. $tarball[$pkg] = $file;
  579. echo "ok\n";
  580. displayHTMLProgress($progress += round(65 / count($to_install)));
  581. continue 2;
  582. };
  583. };
  584. $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.');
  585. print $msg;
  586. $url = sprintf($urltemplate, $pkg);
  587. $tarball[$pkg] = download_url($url, null, $http_proxy);
  588. print "ok\n";
  589. displayHTMLProgress($progress += round(65 / count($to_install)));
  590. }
  591. }
  592. displayHTMLProgress($progress = 70);
  593. PEAR::setErrorHandling(PEAR_ERROR_DIE, "\n%s\n");
  594. print 'Extracting installer..................';
  595. $dot = strrpos($tarball['PEAR'], '.');
  596. $pkg = substr($tarball['PEAR'], 0, $dot);
  597. $ext = substr($tarball['PEAR'], $dot+1);
  598. include_once 'Archive/Tar.php';
  599. $tar = &new Archive_Tar($tarball['PEAR'], $have_gzip);
  600. if (!$tar->extractModify($ptmp, $pkg)) {
  601. bail("failed!\n");
  602. }
  603. print "ok\n";
  604. $tarball['PEAR'] = 'package.xml'; // :-)
  605. include_once "PEAR.php";
  606. include_once "PEAR/Config.php";
  607. include_once "PEAR/Command.php";
  608. include_once "PEAR/Registry.php";
  609. if (WEBINSTALLER || isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'local') {
  610. $config = &PEAR_Config::singleton($prefix."/pear.conf", '');
  611. } else {
  612. $config = &PEAR_Config::singleton();
  613. };
  614. $config->set('preferred_state', 'stable');
  615. foreach ($config_vars as $var) {
  616. $config->set($var, $$var);
  617. }
  618. $config->store();
  619. $registry = new PEAR_Registry($php_dir);
  620. PEAR_Command::setFrontendType('CLI');
  621. $install = &PEAR_Command::factory('install', $config);
  622. $install_options = array(
  623. 'nodeps' => true,
  624. 'force' => true,
  625. );
  626. foreach ($tarball as $pkg => $src) {
  627. $options = $install_options;
  628. if ($registry->packageExists($pkg)) {
  629. $options['upgrade'] = true;
  630. }
  631. $install->run('install', $options, array($src));
  632. displayHTMLProgress($progress += round(29 / count($tarball)));
  633. }
  634. displayHTMLProgress($progress = 99);
  635. // Base installation finished
  636. ini_restore("include_path");
  637. if (!WEBINSTALLER) {
  638. $sep = WINDOWS ? ';' : ':';
  639. $include_path = explode($sep, ini_get('include_path'));
  640. if (WINDOWS) {
  641. $found = false;
  642. $t = strtolower($php_dir);
  643. foreach($include_path as $path) {
  644. if ($t==strtolower($path)) {
  645. $found = true;
  646. break;
  647. }
  648. }
  649. } else {
  650. $found = in_array($php_dir, $include_path);
  651. }
  652. if (!$found) {
  653. print "
  654. ******************************************************************************
  655. WARNING! The include_path defined in the currently used php.ini does not
  656. contain the PEAR PHP directory you just specified:
  657. <$php_dir>
  658. If the specified directory is also not in the include_path used by
  659. your scripts, you will have problems getting any PEAR packages working.
  660. ";
  661. if ( $php_ini = getPhpiniPath() ) {
  662. print "\n\nWould you like to alter php.ini <$php_ini>? [Y/n] : ";
  663. $alter_phpini = !stristr(fgets($tty, 1024), "n");
  664. if( $alter_phpini ) {
  665. alterPhpIni($php_ini);
  666. } else {
  667. if (WINDOWS) {
  668. print "
  669. Please look over your php.ini file to make sure
  670. $php_dir is in your include_path.";
  671. } else {
  672. print "
  673. I will add a workaround for this in the 'pear' command to make sure
  674. the installer works, but please look over your php.ini or Apache
  675. configuration to make sure $php_dir is in your include_path.
  676. ";
  677. }
  678. }
  679. }
  680. print "
  681. Current include path : ".ini_get('include_path')."
  682. Configured directory : $php_dir
  683. Currently used php.ini (guess) : $php_ini
  684. ";
  685. print "Press Enter to continue: ";
  686. fgets($tty, 1024);
  687. }
  688. $pear_cmd = $bin_dir . DIRECTORY_SEPARATOR . 'pear';
  689. $pear_cmd = WINDOWS ? strtolower($pear_cmd).'.bat' : $pear_cmd;
  690. // check that the installed pear and the one in tha path are the same (if any)
  691. $pear_old = which(WINDOWS ? 'pear.bat' : 'pear', $bin_dir);
  692. if ($pear_old && ($pear_old != $pear_cmd)) {
  693. // check if it is a link or symlink
  694. $islink = WINDOWS ? false : is_link($pear_old) ;
  695. if ($islink && readlink($pear_old) != $pear_cmd) {
  696. print "\n** WARNING! The link $pear_old does not point to the " .
  697. "installed $pear_cmd\n";
  698. } elseif (is_writable($pear_old) && !is_dir($pear_old)) {
  699. rename($pear_old, "{$pear_old}_old");
  700. print "\n** WARNING! Backed up old pear to {$pear_old}_old\n";
  701. } else {
  702. print "\n** WARNING! Old version found at $pear_old, please remove it or ".
  703. "be sure to use the new $pear_cmd command\n";
  704. }
  705. }
  706. print "\nThe 'pear' command is now at your service at $pear_cmd\n";
  707. // Alert the user if the pear cmd is not in PATH
  708. $old_dir = $pear_old ? dirname($pear_old) : false;
  709. if (!which('pear', $old_dir)) {
  710. print "
  711. ** The 'pear' command is not currently in your PATH, so you need to
  712. ** use '$pear_cmd' until you have added
  713. ** '$bin_dir' to your PATH environment variable.
  714. ";
  715. print "Run it without parameters to see the available actions, try 'pear list'
  716. to see what packages are installed, or 'pear help' for help.
  717. For more information about PEAR, see:
  718. http://pear.php.net/faq.php
  719. http://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt?p=1
  720. http://pear.php.net/manual/
  721. Thanks for using go-pear!
  722. ";
  723. }
  724. }
  725. if (WEBINSTALLER) {
  726. print "Writing WebFrontend file ... ";
  727. @unlink($webfrontend_file); //Delete old one
  728. copy ( $doc_dir.DIRECTORY_SEPARATOR.
  729. 'PEAR_Frontend_Web'.DIRECTORY_SEPARATOR.
  730. 'docs'.DIRECTORY_SEPARATOR.
  731. 'example.php',
  732. $webfrontend_file
  733. );
  734. if ($_GET['step'] == 'install-progress') {
  735. displayHTMLProgress($progress = 100);
  736. ob_end_clean();
  737. displayHTMLInstallationSummary();
  738. displayHTMLFooter();
  739. } else {
  740. $out = ob_get_contents();
  741. $out = explode("\n", $out);
  742. foreach($out as $line => $value) {
  743. if (preg_match('/ok$/', $value)) {
  744. $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
  745. };
  746. if (preg_match('/^install ok:/', $value)) {
  747. $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
  748. };
  749. if (preg_match('/^Warning:/', $value)) {
  750. $value = '<span style="color: #ff0000">'.$value.'</span>';
  751. };
  752. $out[$line] = $value;
  753. };
  754. $out = nl2br(implode("\n",$out));
  755. ob_end_clean();
  756. displayHTML('install', $out);
  757. }
  758. // Little hack, this will be fixed in PEAR later
  759. if ( WINDOWS ) {
  760. clearstatcache();
  761. @unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear');
  762. }
  763. exit;
  764. }
  765. // Little hack, this will be fixed in PEAR later
  766. if ( WINDOWS ) {
  767. clearstatcache();
  768. @unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear');
  769. }
  770. if (WINDOWS && !WEBINSTALLER) {
  771. win32CreateRegEnv();
  772. }
  773. // Set of functions following
  774. // {{{ download_url()
  775. function download_url($url, $destfile = null, $proxy = null)
  776. {
  777. $use_suggested_filename = ($destfile === null);
  778. if ($use_suggested_filename) {
  779. $destfile = basename($url);
  780. }
  781. $tmp = parse_url($url);
  782. if (empty($tmp['port'])) {
  783. $tmp['port'] = 80;
  784. }
  785. if (empty($proxy)) {
  786. $fp = fsockopen($tmp['host'], $tmp['port'], $errno, $errstr);
  787. //print "\nconnecting to $tmp[host]:$tmp[port]\n";
  788. } else {
  789. $tmp_proxy = parse_url($proxy);
  790. $phost = $tmp_proxy['host'];
  791. $pport = $tmp_proxy['port'];
  792. $fp = fsockopen($phost, $pport, $errno, $errstr);
  793. //print "\nconnecting to $phost:$pport\n";
  794. }
  795. if (!$fp) {
  796. bail("download of $url failed: $errstr ($errno)\n");
  797. }
  798. if (empty($proxy)) {
  799. $path = $tmp['path'];
  800. } else {
  801. $path = "http://$tmp[host]:$tmp[port]$tmp[path]";
  802. }
  803. if (isset($tmp['query'])) {
  804. $path .= "?$tmp[query]";
  805. }
  806. if (isset($tmp['fragment'])) {
  807. $path .= "#$tmp[fragment]";
  808. }
  809. $request = "GET $path HTTP/1.0\r\nHost: $tmp[host]:$tmp[port]\r\n".
  810. "User-Agent: go-pear\r\n";
  811. if (!empty($proxy) && $tmp_proxy['user'] != '') {
  812. $request .= 'Proxy-Authorization: Basic ' .
  813. base64_encode($tmp_proxy['user'] . ':' . $tmp_proxy['pass']) . "\r\n";
  814. // print "\nauthenticating against proxy with : user = ${tmp_proxy['user']} \n";
  815. // print "and pass = ${tmp_proxy['pass']}\n";
  816. } // if
  817. $request .= "\r\n";
  818. fwrite($fp, $request);
  819. $cdh = "content-disposition:";
  820. $cdhl = strlen($cdh);
  821. $content_length = 0;
  822. while ($line = fgets($fp, 2048)) {
  823. if (trim($line) == '') {
  824. break;
  825. }
  826. if (preg_match('/^Content-Length: (.*)$/i', $line, $matches)) {
  827. $content_length = trim($matches[1]);
  828. };
  829. if ($use_suggested_filename && !strncasecmp($line, $cdh, $cdhl)) {
  830. if (eregi('filename="([^"]+)"', $line, $matches)) {
  831. $destfile = basename($matches[1]);
  832. }
  833. }
  834. }
  835. if ($content_length) {
  836. displayHTMLSetDownload($destfile);
  837. };
  838. $wp = fopen($destfile, "wb");
  839. if (!$wp) {
  840. bail("could not open $destfile for writing\n");
  841. }
  842. $bytes_read = 0;
  843. $progress = 0;
  844. while ($data = fread($fp, 2048)) {
  845. fwrite($wp, $data);
  846. $bytes_read += strlen($data);
  847. if ($content_length != 0 && floor($bytes_read * 10 / $content_length) != $progress) {
  848. $progress = floor($bytes_read * 10 / $content_length);
  849. displayHTMLDownloadProgress($progress * 10);
  850. };
  851. }
  852. fclose($fp);
  853. fclose($wp);
  854. return $destfile;
  855. }
  856. // }}}
  857. // {{{ which()
  858. function which($program, $dont_search_in = false)
  859. {
  860. if (WINDOWS) {
  861. if ($_path=my_env('Path')) {
  862. $dirs = explode(';', $_path);
  863. } else {
  864. $dirs = explode(';', my_env('PATH'));
  865. }
  866. foreach ($dirs as $i => $dir) {
  867. $dirs[$i] = strtolower(realpath($dir));
  868. }
  869. if ($dont_search_in) {
  870. $dont_search_in = strtolower(realpath($dont_search_in));
  871. }
  872. if ($dont_search_in &&
  873. ($key = array_search($dont_search_in, $dirs)) !== false)
  874. {
  875. unset($dirs[$key]);
  876. }
  877. foreach ($dirs as $dir) {
  878. $dir = str_replace('\\\\', '\\', $dir);
  879. if (!strlen($dir)) {
  880. continue;
  881. }
  882. if ($dir{strlen($dir) - 1} != '\\') {
  883. $dir .= '\\';
  884. }
  885. $tmp = $dir . $program;
  886. $info = pathinfo($tmp);
  887. if (in_array(strtolower($info['extension']),
  888. array('exe', 'com', 'bat', 'cmd'))) {
  889. if (file_exists($tmp)) {
  890. return strtolower($tmp);
  891. }
  892. } elseif (file_exists($ret = $tmp . '.exe') ||
  893. file_exists($ret = $tmp . '.com') ||
  894. file_exists($ret = $tmp . '.bat') ||
  895. file_exists($ret = $tmp . '.cmd')) {
  896. return strtolower($ret);
  897. }
  898. }
  899. } else {
  900. $dirs = explode(':', my_env('PATH'));
  901. if ($dont_search_in &&
  902. ($key = array_search($dont_search_in, $dirs)) !== false)
  903. {
  904. unset($dirs[$key]);
  905. }
  906. foreach ($dirs as $dir) {
  907. if (is_executable("$dir/$program")) {
  908. return "$dir/$program";
  909. }
  910. }
  911. }
  912. return false;
  913. }
  914. // }}}
  915. // {{{ bail()
  916. function bail($msg = '')
  917. {
  918. global $ptmp, $origpwd;
  919. if ($ptmp && is_dir($ptmp)) {
  920. chdir($origpwd);
  921. rm_rf($ptmp);
  922. }
  923. if ($msg && WEBINSTALLER) {
  924. $msg = @ob_get_contents() ."\n\n". $msg;
  925. @ob_end_clean();
  926. displayHTML('error', $msg);
  927. exit;
  928. };
  929. if ($msg && !WEBINSTALLER) {
  930. die($msg);
  931. }
  932. }
  933. // }}}
  934. // {{{ mkdir_p()
  935. function mkdir_p($dir, $mode = 0777)
  936. {
  937. if (@is_dir($dir)) {
  938. return true;
  939. }
  940. $parent = dirname($dir);
  941. $ok = true;
  942. if (!@is_dir($parent) && $parent != $dir) {
  943. $ok = mkdir_p(dirname($dir), $mode);
  944. }
  945. if ($ok) {
  946. $ok = @mkdir($dir, $mode);
  947. if (!$ok) {
  948. print "mkdir failed: $dir\n";
  949. }
  950. }
  951. return $ok;
  952. }
  953. // }}}
  954. // {{{ rm_rf()
  955. function rm_rf($path)
  956. {
  957. if (@is_dir($path) && is_writable($path)) {
  958. $dp = opendir($path);
  959. while ($ent = readdir($dp)) {
  960. if ($ent == '.' || $ent == '..') {
  961. continue;
  962. }
  963. $file = $path . DIRECTORY_SEPARATOR . $ent;
  964. if (@is_dir($file)) {
  965. rm_rf($file);
  966. } elseif (is_writable($file)) {
  967. unlink($file);
  968. } else {
  969. echo $file . "is not writable and cannot be removed.
  970. Please fix the permission or select a new path.\n";
  971. }
  972. }
  973. closedir($dp);
  974. return rmdir($path);
  975. } else {
  976. return @unlink($path);
  977. }
  978. }
  979. // }}}
  980. // {{{ tmpdir()
  981. /*
  982. * Fixes for winXP/wrong tmp set by Urs Gehrig (urs@circle.ch)
  983. */
  984. function tmp_dir()
  985. {
  986. global $ptmp;
  987. $_temp = false;
  988. if (WINDOWS){
  989. if ( my_env('TEMP') ) {
  990. $_temp = my_env('TEMP');
  991. } elseif ( my_env('TMP') ) {
  992. $_temp = my_env('TMP');
  993. } elseif ( my_env('windir') ) {
  994. $_temp = my_env('windir') . '\temp';
  995. } elseif ( my_env('SystemRoot') ) {
  996. $_temp = my_env('SystemRoot') . '\temp';
  997. }
  998. // handle ugly ENV var like \Temp instead of c:\Temp
  999. $dirs = explode("\\", realpath($_temp));
  1000. if(strpos($_temp, ":") != 1) {
  1001. unset($_temp);
  1002. $_dirs = array();
  1003. foreach($dirs as $val) {
  1004. if((boolean)$val ) {
  1005. $_dirs[] = str_replace("/", "", $val);
  1006. }
  1007. }
  1008. unset($dirs);
  1009. $dirs = $_dirs;
  1010. array_unshift ($dirs, "c:" );
  1011. $_temp = $dirs[0];
  1012. for($i = 1;$i < count($dirs);$i++) {
  1013. $_temp .= "//" . $dirs[$i];
  1014. }
  1015. }
  1016. $ptmp = $_temp;
  1017. } else {
  1018. $_temp = my_env('TMPDIR');
  1019. if (!$_temp) {
  1020. if (is_writable('/tmp')) {
  1021. $_temp = '/tmp';
  1022. }
  1023. }
  1024. }
  1025. // If for some reason the user has no rights to access to
  1026. // the standard tempdir, we assume that he has the right
  1027. // to access his prefix and choose $prefix/tmp as tempdir
  1028. if (!$_temp) {
  1029. print "System's Tempdir failed, trying to use \$prefix/tmp ...";
  1030. $res = mkdir_p($prefix.'/tmp');
  1031. if (!$res) {
  1032. bail('mkdir '.$prefix.'/tmp'.' ... failed');
  1033. }
  1034. $_temp = tempnam($prefix.'/tmp', 'gope');
  1035. rm_rf($_temp);
  1036. mkdir_p($_temp, 0700);
  1037. $ok = @chdir($ptmp);
  1038. if (!$ok) { // This should not happen, really ;)
  1039. bail('chdir '.$ptmp.' ... failed');
  1040. }
  1041. print "ok\n";
  1042. // Adjust TEMPDIR envvars
  1043. if (!isset($_ENV)) {
  1044. $_ENV = array();
  1045. };
  1046. $_ENV['TMPDIR'] = $_ENV['TEMP'] = $prefix.'/tmp';
  1047. }
  1048. $ptmp = $_temp;
  1049. }
  1050. // }}}
  1051. // {{{ my_env()
  1052. /*
  1053. (cox) In my system PHP 4.2.1 (both cgi & cli) $_ENV is empty
  1054. but getenv() does work fine
  1055. */
  1056. function my_env($var)
  1057. {
  1058. if (is_array($_ENV) && isset($_ENV[$var])) {
  1059. return $_ENV[$var];
  1060. }
  1061. return getenv($var);
  1062. }
  1063. // }}}
  1064. // {{{ detect_install_dirs()
  1065. function detect_install_dirs($_prefix = null) {
  1066. global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir;
  1067. if (WINDOWS) {
  1068. if ($_prefix === null) {
  1069. $prefix = getcwd();
  1070. } else {
  1071. $prefix = $_prefix;
  1072. }
  1073. if (!@is_dir($prefix)) {
  1074. if (@is_dir('c:\php5')) {
  1075. $prefix = 'c:\php5';
  1076. } elseif (@is_dir('c:\php4')) {
  1077. $prefix = 'c:\php4';
  1078. } elseif (@is_dir('c:\php')) {
  1079. $prefix = 'c:\php';
  1080. }
  1081. }
  1082. $bin_dir = '$prefix';
  1083. $php_dir = '$prefix\pear';
  1084. $doc_dir = '$php_dir\docs';
  1085. $data_dir = '$php_dir\data';
  1086. $test_dir = '$php_dir\tests';
  1087. /*
  1088. * Detects php.exe
  1089. */
  1090. if( $t=getenv('PHP_PEAR_PHP_BIN') ){
  1091. $php_bin = $t;
  1092. } elseif ($t=getenv('PHP_BIN') ) {
  1093. $php_bin = $t;
  1094. } elseif ( $t=which('php') ) {
  1095. $php_bin = $t;
  1096. } elseif ( is_file($prefix.'\cli\php.exe') ) {
  1097. $php_bin = $prefix.'\cli\php.exe';
  1098. } elseif ( is_file($prefix.'\php.exe') ) {
  1099. $php_bin = $prefix.'\php.exe';
  1100. }
  1101. if( $php_bin && !is_file($php_bin) ){
  1102. $php_bin = '';
  1103. } else {
  1104. if(!ereg(":",$php_bin)){
  1105. $php_bin = getcwd().DIRECTORY_SEPARATOR.$php_bin;
  1106. }
  1107. }
  1108. if (!is_file($php_bin)) {
  1109. if (is_file('c:/php/cli/php.exe')) {
  1110. $php_bin = 'c:/php/cli/php.exe';
  1111. } elseif (is_file('c:/php5/php.exe')) {
  1112. $php_bin = 'c:/php5/php.exe';
  1113. } elseif (is_file('c:/php4/cli/php.exe')) {
  1114. $php_bin = 'c:/php4/cli/php.exe';
  1115. }
  1116. }
  1117. } else {
  1118. if ($_prefix === null) {
  1119. $prefix = dirname(PHP_BINDIR);
  1120. } else {
  1121. $prefix = $_prefix;
  1122. }
  1123. $bin_dir = '$prefix/bin';
  1124. $php_dir = '$prefix/share/pear';
  1125. $doc_dir = '$php_dir/docs';
  1126. $data_dir = '$php_dir/data';
  1127. $test_dir = '$php_dir/tests';
  1128. // check if the user has installed PHP with PHP or GNU layout
  1129. if (@is_dir("$prefix/lib/php/.registry")) {
  1130. $php_dir = '$prefix/lib/php';
  1131. } elseif (@is_dir("$prefix/share/pear/lib/.registry")) {
  1132. $php_dir = '$prefix/share/pear/lib';
  1133. $doc_dir = '$prefix/share/pear/docs';
  1134. $data_dir = '$prefix/share/pear/data';
  1135. $test_dir = '$prefix/share/pear/tests';
  1136. } elseif (@is_dir("$prefix/share/php/.registry")) {
  1137. $php_dir = '$prefix/share/php';
  1138. }
  1139. }
  1140. }
  1141. // }}}
  1142. // {{{ displayHTMLHeader
  1143. function displayHTMLHeader()
  1144. {
  1145. ?>
  1146. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  1147. <html>
  1148. <head>
  1149. <title>PEAR :: Installer :: Go-PEAR</title>
  1150. <style type="text/css">
  1151. <!--
  1152. a {
  1153. color:#000000;
  1154. text-decoration: none;
  1155. }
  1156. a:visited {
  1157. color:#000000;
  1158. text-decoration: none;
  1159. }
  1160. a:active {
  1161. color:#000000;
  1162. text-decoration: none;
  1163. }
  1164. a:hover {
  1165. color:#000000;
  1166. text-decoration: underline;
  1167. }
  1168. a.green {
  1169. color:#006600;
  1170. text-decoration: none;
  1171. }
  1172. a.green:visited {
  1173. color:#006600;
  1174. text-decoration: none;
  1175. }
  1176. a.green:active {
  1177. color:#006600;
  1178. text-decoration: none;
  1179. }
  1180. a.green:hover {
  1181. color:#006600;
  1182. text-decoration: underline;
  1183. }
  1184. body, td, th {
  1185. font-family: verdana,arial,helvetica,sans-serif;
  1186. font-size: 90%;
  1187. }
  1188. p {
  1189. font-family: verdana,arial,helvetica,sans-serif;
  1190. }
  1191. th.pack {
  1192. color: #FFFFFF;
  1193. background: #009933;
  1194. text-align: right;
  1195. }
  1196. td.package_info_title {
  1197. color: #006600;
  1198. font-weight: bold;
  1199. }
  1200. th.others {
  1201. color: #006600;
  1202. text-align: left;
  1203. }
  1204. em {
  1205. font-weight: bold;
  1206. font-style: italic;
  1207. }
  1208. .green {
  1209. color: #006600;
  1210. }
  1211. .red {
  1212. color: #006600;
  1213. }
  1214. span.headline {
  1215. font-family: verdana,arial,helvetica,sans-serif;
  1216. font-size: 125%;
  1217. font-weight: bold;
  1218. color: #ffffff;
  1219. }
  1220. span.title {
  1221. font-family: verdana,arial,helvetica,sans-serif;
  1222. font-size: 110%;
  1223. font-weight: bold;
  1224. color: #006600;
  1225. }
  1226. .newsDate {
  1227. font-size: 85%;
  1228. font-style: italic;
  1229. color: #66cc66;
  1230. }
  1231. .compact {
  1232. font-family: arial, helvetica, sans-serif;
  1233. font-size: 90%;
  1234. }
  1235. .menuWhite {
  1236. font-family: verdana,arial,helvetica,sans-serif;
  1237. font-size: 75%;
  1238. color: #ffffff;
  1239. }
  1240. .menuBlack {
  1241. font-family: verdana,arial,helvetica,sans-serif;
  1242. text-decoration: none;
  1243. font-weight: bold;
  1244. font-size: 75%;
  1245. color: #000000;
  1246. }
  1247. .sidebar {
  1248. font-size: 85%;
  1249. }
  1250. code, pre, tt {
  1251. font-family: Courier, "Courier New", monospace;
  1252. font-size: 90%;
  1253. }
  1254. pre.php {
  1255. border-color: black;
  1256. border-style: dashed;
  1257. border-width: 1px;
  1258. background-color: #eeeeee;
  1259. padding: 5px;
  1260. }
  1261. h1 {
  1262. font-family: verdana,arial,helvetica,sans-serif;
  1263. font-size: 140%;
  1264. font-weight: bold;
  1265. color: #006600;
  1266. }
  1267. h2 {
  1268. font-family: verdana,arial,helvetica,sans-serif;
  1269. font-size: 125%;
  1270. font-weight: bold;
  1271. color: #006600;
  1272. }
  1273. h3 {
  1274. font-family: verdana,arial,helvetica,sans-serif;
  1275. font-size: 110%;
  1276. font-weight: bold;
  1277. color: #006600;
  1278. }
  1279. small {
  1280. font-family: verdana,arial,helvetica,sans-serif;
  1281. font-size: 75%;
  1282. }
  1283. a.small {
  1284. font-family: verdana,arial,helvetica,sans-serif;
  1285. font-size: 75%;
  1286. text-decoration: none;
  1287. }
  1288. .tableTitle {
  1289. font-family: verdana,arial,helvetica,sans-serif;
  1290. font-weight: bold;
  1291. }
  1292. .tableExtras {
  1293. font-family: verdana,arial,helvetica,sans-serif;
  1294. font-size: 85%;
  1295. color: #FFFFFF;
  1296. }
  1297. input {
  1298. font-family: verdana,arial,helvetica,sans-serif;
  1299. }
  1300. textarea {
  1301. font-family: verdana,arial,helvetica,sans-serif;
  1302. }
  1303. input.small, select.small {
  1304. font-family: verdana,arial,helvetica,sans-serif;
  1305. font-size: 75%;
  1306. }
  1307. textarea.small {
  1308. font-family: verdana,arial,helvetica,sans-serif;
  1309. font-size: 75%;
  1310. }
  1311. form {
  1312. margin-bottom : 0;
  1313. }
  1314. -->
  1315. </style>
  1316. <meta name="description" content="This is the Web Interface of the PEAR Installer" />
  1317. </head>
  1318. <body topmargin="0" leftmargin="0"
  1319. marginheight="0" marginwidth="0"
  1320. bgcolor="#ffffff"
  1321. text="#000000"
  1322. link="#006600"
  1323. alink="#cccc00"
  1324. vlink="#003300"
  1325. >
  1326. <?php
  1327. }
  1328. // }}}
  1329. // {{{ displayHTML
  1330. function displayHTML($page = 'Welcome', $data = array())
  1331. {
  1332. global $pfc_packages;
  1333. displayHTMLHeader();
  1334. ?>
  1335. <a name="TOP" /></a>
  1336. <table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  1337. <tr bgcolor="#339900">
  1338. <td align="left" width="120">
  1339. <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=pearlogo" width="104" height="50" vspace="2" hspace="5" alt="PEAR">
  1340. </td>
  1341. <td align="left" valign="middle" width="20">
  1342. &nbsp;
  1343. </td>
  1344. <td align="left" valign="middle">
  1345. <span class="Headline">Go-PEAR</span>
  1346. </td>
  1347. </tr>
  1348. <tr bgcolor="#003300"><td colspan="3"></td></tr>
  1349. <tr bgcolor="#006600">
  1350. <td align="right" valign="top" colspan="3">
  1351. <span style="color: #ffffff">Version <?php echo GO_PEAR_VER; ?></span>&nbsp;<br />
  1352. </td>
  1353. </tr>
  1354. <tr bgcolor="#003300"><td colspan="3"></td></tr>
  1355. </table>
  1356. <table cellpadding="0" cellspacing="0" width="100%">
  1357. <tr valign="top">
  1358. <td bgcolor="#f0f0f0" width="100">
  1359. <table width="200" border="0" cellpadding="4" cellspacing="0">
  1360. <tr valign="top">
  1361. <td style="font-size: 90%" align="left" width="200">
  1362. <br><br>
  1363. <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=smallpear" border="0">
  1364. <a href="<?php echo basename(__FILE__); ?>?step=Welcome&restart=1" <?php if ($page == 'Welcome') echo ' class="green"'; ?>>
  1365. Welcome to Go-PEAR
  1366. </a><br/>
  1367. <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=smallpear" border="0">
  1368. <a href="<?php echo basename(__FILE__); ?>?step=config" <?php if ($page == 'config') echo ' class="green"'; ?>>
  1369. Configuration
  1370. </a><br/>
  1371. <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=smallpear" border="0">
  1372. <?php if ($page == 'install') echo '<span class="green">'; ?>
  1373. Complete installation<br/>
  1374. <?php if ($page == 'install') echo '</span>'; ?>
  1375. </td>
  1376. </tr>
  1377. </table>
  1378. </td>
  1379. <td bgcolor="#cccccc" width="1" background="/gifs/checkerboard.gif"></td>
  1380. <td>
  1381. <table width="100%" cellpadding="10" cellspacing="0">
  1382. <tr>
  1383. <td valign="top">
  1384. <table border="0">
  1385. <tr>
  1386. <td width="20">
  1387. </td>
  1388. <td>
  1389. <?php
  1390. if ($page == 'error') {
  1391. ?>
  1392. <span class="title">Error</span><br/>
  1393. <br/>
  1394. <?php
  1395. $value = $data;
  1396. if (preg_match('/ok$/', $value)) {
  1397. $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
  1398. }
  1399. if (preg_match('/failed$/', $value)) {
  1400. $value = preg_replace('/(failed)$/', '<span style="color: #ff0000">\1</span>', $value);
  1401. }
  1402. if (preg_match('/^install ok:/', $value)) {
  1403. $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
  1404. }
  1405. if (preg_match('/^Warning:/', $value)) {
  1406. $value = '<span style="color: #ff0000">'.$value.'</span>';
  1407. }
  1408. echo nl2br($value);
  1409. } elseif ($page == 'Welcome') {
  1410. ?>
  1411. <span class="title">Welcome to go-pear <?php echo GO_PEAR_VER; ?>!</span><br/>
  1412. <br/>
  1413. Go-pear will install the Web Frontend of the PEAR Installer and all the needed <br/>
  1414. files. This frontend is your tool for PEAR installation and maintenance.<br/>
  1415. <br/>
  1416. Go-pear also lets you download and install the PEAR packages bundled<br/>
  1417. with PHP: <?php echo implode(', ', $GLOBALS['pfc_packages']); ?>.<br/>
  1418. <br/>
  1419. <a href="<?php echo basename(__FILE__); ?>?step=config" class="green">Next &gt;&gt;</a>
  1420. <?php
  1421. } elseif ($page == 'config') {
  1422. if (!empty($GLOBALS['http_proxy'])) {
  1423. list($proxy_host, $proxy_port) = explode(':', $GLOBALS['http_proxy']);
  1424. } else {
  1425. $proxy_host = $proxy_port = '';
  1426. }
  1427. ?>
  1428. <form action="<?php echo basename(__FILE__);?>?step=install" method="post">
  1429. <span class="title">Configuration</span><br/>
  1430. <br/>
  1431. HTTP proxy (host:port):
  1432. <input type="text" name="proxy[host]" value="<?php echo $proxy_host;?>">
  1433. <input type="text" name="proxy[port]" value="<?php echo $proxy_port;?>" size="6">
  1434. <br/><br/><hr/><br/>
  1435. Below is a suggested file layout for your new PEAR installation. <br/>
  1436. <br/>
  1437. <table border="0">
  1438. <TR>
  1439. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
  1440. <TD>
  1441. <span class="green">
  1442. <b>Note:</b> Make sure that PHP has the permission to access the specified<br/>
  1443. directories.<br/><br/>
  1444. </span>
  1445. </TD>
  1446. </TR>
  1447. </table>
  1448. <TABLE border="0">
  1449. <?php
  1450. // Display error messages
  1451. if (isset($GLOBALS['www_errors']) && sizeof($GLOBALS['www_errors']) ) {
  1452. $www_errors = $GLOBALS['www_errors'];
  1453. echo "<tr><td>";
  1454. echo '<span class="red">ERROR(S):</span>';
  1455. echo "</td></tr>";
  1456. foreach ($www_errors as $n => $var) {
  1457. echo "<tr><td>";
  1458. echo '<span class="red">'.$GLOBALS['config_desc'][$n].': </span>';
  1459. echo "</td><td>";
  1460. echo '<span class="red">'.$www_errors[$n].'</span>';
  1461. echo "<br>\n";
  1462. echo "</td></tr>\n";
  1463. }
  1464. }
  1465. foreach ($GLOBALS['config_vars'] as $n => $var) {
  1466. printf('<tr><td>%d. %s</td><td><input type="text" name="config[%s]" value="%s"></td></tr>',
  1467. $n,
  1468. $GLOBALS['config_desc'][$var],
  1469. $var,
  1470. $GLOBALS[$var]);
  1471. }
  1472. ?>
  1473. </TABLE>
  1474. <br/><hr/><br/>
  1475. The following PEAR packages are common ones, and can be installed<br/>
  1476. by go-pear too: <br/>
  1477. <?php echo implode(', ', $GLOBALS['pfc_packages']);?>.<br/>
  1478. <input type="checkbox" name="install_pfc" <?php if($GLOBALS['install_pfc']) echo 'checked';?>> Install those too<br/>
  1479. <br/><br/>
  1480. <table border="0">
  1481. <TR>
  1482. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
  1483. <TD>
  1484. <span class="green">
  1485. <b>Note:</b> Installation might take some time, because go-pear has to download<br/>
  1486. all needed files from pear.php.net. Just be patient and wait for the next<br/>
  1487. page to load.<br/>
  1488. </span>
  1489. </TD>
  1490. </TR>
  1491. </table>
  1492. <br>
  1493. <input type="checkbox" name="BCmode" id="BCmode" checked> Compatibility-Mode for old non-DOM Browsers<br/>
  1494. <script type="text/javascript">
  1495. <!--
  1496. if (document.getElementById('BCmode')) {
  1497. document.getElementById('BCmode').checked = 0;
  1498. };
  1499. // -->
  1500. </script>
  1501. <?php
  1502. if (WINDOWS && phpversion() == '4.1.1') {
  1503. ?>
  1504. <table border="0">
  1505. <TR>
  1506. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
  1507. <TD>
  1508. <span style="color: #ff0000">
  1509. <b>Warning:</b> Your PHP version (4.1.1) might be imcompatible with go-pear due to a bug<br/>
  1510. in your PHP binary. If the installation crashes you might want to update your PHP version.</br>
  1511. </span>
  1512. </TD>
  1513. </TR>
  1514. </table>
  1515. <?php
  1516. }
  1517. ?>
  1518. <br/>
  1519. <input type="submit" value="Install" onClick="javascript: submitButton.value='Downloading and installing ... please wait ...'" name="submitButton">
  1520. </form>
  1521. <?php
  1522. } elseif ($page == 'install') {
  1523. ?>
  1524. <span class="title">Installation Complete - Summary</span><br/>
  1525. <?php
  1526. displayHTMLInstallationSummary($data);
  1527. } elseif ($page == 'preinstall') {
  1528. ?>
  1529. <span class="title">Installation in progress ...</span><br/>
  1530. <br/>
  1531. <script language="javascript">
  1532. <!--
  1533. var progress;
  1534. var downlodprogress;
  1535. progress = 0;
  1536. downloadprogress = 0;
  1537. function setprogress(value)
  1538. {
  1539. progress = value;
  1540. prog = document.getElementById('installation_progress');
  1541. prog.innerHTML = progress + " %";
  1542. progress2 = progress / 10;
  1543. progress2 = Math.floor(progress2);
  1544. for (i=0; i < 10; i++)
  1545. document.getElementById('progress_cell_'+i).style.backgroundColor = "#cccccc";
  1546. switch(progress2)
  1547. {
  1548. case 10:
  1549. document.getElementById('progress_cell_9').style.backgroundColor = "#006600";
  1550. case 9:
  1551. document.getElementById('progress_cell_8').style.backgroundColor = "#006600";
  1552. case 8:
  1553. document.getElementById('progress_cell_7').style.backgroundColor = "#006600";
  1554. case 7:
  1555. document.getElementById('progress_cell_6').style.backgroundColor = "#006600";
  1556. case 6:
  1557. document.getElementById('progress_cell_5').style.backgroundColor = "#006600";
  1558. case 5:
  1559. document.getElementById('progress_cell_4').style.backgroundColor = "#006600";
  1560. case 4:
  1561. document.getElementById('progress_cell_3').style.backgroundColor = "#006600";
  1562. case 3:
  1563. document.getElementById('progress_cell_2').style.backgroundColor = "#006600";
  1564. case 2:
  1565. document.getElementById('progress_cell_1').style.backgroundColor = "#006600";
  1566. case 1:
  1567. document.getElementById('progress_cell_0').style.backgroundColor = "#006600";
  1568. };
  1569. }
  1570. function addprogress(value)
  1571. {
  1572. progress += value;
  1573. setprogress(progress);
  1574. }
  1575. function setdownloadfile(value)
  1576. {
  1577. setdownloadprogress(0);
  1578. prog = document.getElementById('download_file');
  1579. prog.innerHTML = 'Downloading '+value+' ...';
  1580. };
  1581. function setdownloadprogress(value)
  1582. {
  1583. downloadprogress = value;
  1584. prog = document.getElementById('download_progress');
  1585. prog.innerHTML = downloadprogress + " %";
  1586. progress2 = downloadprogress / 10;
  1587. progress2 = Math.floor(progress2);
  1588. for (i=0; i < 10; i++)
  1589. document.getElementById('download_progress_cell_'+i).style.backgroundColor = "#cccccc";
  1590. switch(progress2)
  1591. {
  1592. case 10:
  1593. document.getElementById('download_progress_cell_9').style.backgroundColor = "#006600";
  1594. case 9:
  1595. document.getElementById('download_progress_cell_8').style.backgroundColor = "#006600";
  1596. case 8:
  1597. document.getElementById('download_progress_cell_7').style.backgroundColor = "#006600";
  1598. case 7:
  1599. document.getElementById('download_progress_cell_6').style.backgroundColor = "#006600";
  1600. case 6:
  1601. document.getElementById('download_progress_cell_5').style.backgroundColor = "#006600";
  1602. case 5:
  1603. document.getElementById('download_progress_cell_4').style.backgroundColor = "#006600";
  1604. case 4:
  1605. document.getElementById('download_progress_cell_3').style.backgroundColor = "#006600";
  1606. case 3:
  1607. document.getElementById('download_progress_cell_2').style.backgroundColor = "#006600";
  1608. case 2:
  1609. document.getElementById('download_progress_cell_1').style.backgroundColor = "#006600";
  1610. case 1:
  1611. document.getElementById('download_progress_cell_0').style.backgroundColor = "#006600";
  1612. };
  1613. };
  1614. // -->
  1615. </script>
  1616. <table style="border-width: 1px; border-color: #000000" cellspacing="0" cellpadding="0">
  1617. <tr>
  1618. <td>
  1619. <table border="0">
  1620. <tr>
  1621. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_0">&nbsp;</td>
  1622. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_1">&nbsp;</td>
  1623. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_2">&nbsp;</td>
  1624. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_3">&nbsp;</td>
  1625. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_4">&nbsp;</td>
  1626. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_5">&nbsp;</td>
  1627. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_6">&nbsp;</td>
  1628. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_7">&nbsp;</td>
  1629. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_8">&nbsp;</td>
  1630. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_9">&nbsp;</td>
  1631. <td bgcolor="#ffffff" width="10" height="20">&nbsp;</td>
  1632. <td bgcolor="#ffffff" height="20" id="installation_progress" class="green">0 %</td>
  1633. </tr>
  1634. </table>
  1635. <br>
  1636. <table border="0">
  1637. <tr>
  1638. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_0">&nbsp;</td>
  1639. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_1">&nbsp;</td>
  1640. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_2">&nbsp;</td>
  1641. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_3">&nbsp;</td>
  1642. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_4">&nbsp;</td>
  1643. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_5">&nbsp;</td>
  1644. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_6">&nbsp;</td>
  1645. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_7">&nbsp;</td>
  1646. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_8">&nbsp;</td>
  1647. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_9">&nbsp;</td>
  1648. <td bgcolor="#ffffff" width="10" height="20">&nbsp;</td>
  1649. <td bgcolor="#ffffff" height="20" id="download_progress" class="green">0 %</td>
  1650. <td bgcolor="#ffffff" width="10" height="20">&nbsp;</td>
  1651. <td bgcolor="#ffffff" height="20" id="download_file" class="green"></td>
  1652. </tr>
  1653. </table>
  1654. <br>
  1655. <iframe src="<?php echo basename(__FILE__); ?>?step=install-progress&amp;<?php echo SID;?>" width="700" height="700" frameborder="0" marginheight="0" marginwidth="0"></iframe>
  1656. </td>
  1657. </tr>
  1658. </table>
  1659. <?php
  1660. }
  1661. ?>
  1662. </td>
  1663. </tr>
  1664. </table>
  1665. </td>
  1666. </tr>
  1667. </table>
  1668. </td>
  1669. </tr>
  1670. </table>
  1671. <?php
  1672. displayHTMLFooter();
  1673. }
  1674. // }}}
  1675. // {{{ displayHTMLFooter
  1676. function displayHTMLFooter()
  1677. {
  1678. ?>
  1679. </body>
  1680. </html>
  1681. <?php
  1682. };
  1683. // }}}
  1684. // {{{ displayHTMLInstallationSummary
  1685. function displayHTMLInstallationSummary($data = '')
  1686. {
  1687. $next = NULL;
  1688. $prefix = dirname($GLOBALS['webfrontend_file']);
  1689. $doc_root = strip_magic_quotes($_SERVER['DOCUMENT_ROOT']);
  1690. $file_dir = dirname(__FILE__);
  1691. if ( WINDOWS ) {
  1692. $prefix = str_replace('/', '\\', strtolower($prefix));
  1693. $doc_root = str_replace('/', '\\', strtolower($doc_root));
  1694. $file_dir = str_replace('/', '\\', strtolower($file_dir));
  1695. }
  1696. if ($doc_root && substr($prefix, 0, strlen($doc_root)) == $doc_root) {
  1697. $next = substr($prefix, strlen($doc_root)).'/index.php';
  1698. } else if ($file_dir && substr($prefix, 0, strlen($file_dir)) == $file_dir) {
  1699. $next = substr($prefix, strlen($file_dir)).'/index.php';
  1700. }
  1701. if ($data) {
  1702. echo "<br/>".$data;
  1703. }
  1704. ?>
  1705. <br/>
  1706. <table border="0">
  1707. <TR>
  1708. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
  1709. <TD>
  1710. <span class="green">
  1711. <b>Note:</b> To use PEAR without any problems you need to add your<br/>
  1712. PEAR Installation path (<?php echo $GLOBALS['php_dir']; ?>)<br>
  1713. to your <a href="http://www.php.net/manual/en/configuration.directives.php#ini.include_path">include_path</a>.<br/>
  1714. <br/>
  1715. Using a .htaccess file or directly edit httpd.conf would be working solutions<br/>
  1716. for Apache running servers, too.<br/>
  1717. </span>
  1718. </TD>
  1719. </TR>
  1720. </table>
  1721. <br/>
  1722. For more information about PEAR, see:<br/>
  1723. <a href="http://pear.php.net/faq.php" target="_new" class="green">PEAR FAQ</a><br/>
  1724. <a href="http://pear.php.net/manual/" target="_new" class="green">PEAR Manual</a><br/>
  1725. <br/>
  1726. Thanks for using go-pear!<br/>
  1727. <br/>
  1728. <?php
  1729. if ($next === NULL) {
  1730. ?>
  1731. <table border="0">
  1732. <TR>
  1733. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
  1734. <TD>
  1735. <span style="color: #ff0000">
  1736. <b>Warning:</b> Go-PEAR was not able to determine the URL to the newly<br/>
  1737. installed Web Frontend of the PEAR Installer. Please access it manually.<br/>
  1738. Since you specified the prefix, you should know how to do so.<br/>
  1739. </span>
  1740. </TD>
  1741. </TR>
  1742. </table>
  1743. <?php
  1744. } else {
  1745. if ($_GET['step'] == 'install-progress') {
  1746. ?>
  1747. <a href="<?php echo $next;?>" class="green" target="_parent">Start Web Frontend of the PEAR Installer &gt;&gt;</a>
  1748. <?php
  1749. } else {
  1750. ?>
  1751. <a href="<?php echo $next;?>" class="green">Start Web Frontend of the PEAR Installer &gt;&gt;</a>
  1752. <?php
  1753. }
  1754. }
  1755. }
  1756. // }}}
  1757. // {{{ strip_magic_quotes
  1758. function strip_magic_quotes($value)
  1759. {
  1760. if (ini_get('magic_quotes_gpc')) {
  1761. return stripslashes($value);
  1762. }
  1763. return $value;
  1764. };
  1765. // }}}
  1766. // {{{ showImage
  1767. function showImage($img)
  1768. {
  1769. $images = array(
  1770. 'smallpear' => array(
  1771. 'type' => 'gif',
  1772. 'data' => 'R0lGODlhEQATAMQAAAAAACqUACiTAC2WAC+YAzKZBTSaBsHgszOZADCYADmcB4TCZp3Ohtfrzd/v1+by4PD47DaaAz+fDUijF2WyOlCoHvT58VqtJPn893y+S/v9+f7//f3+/Pz9+////////ywAAAAAEQATAAAFkqAnjiR5NGXqcdpCoapnMVRdWbEHUROVVROYalHJTCaVAKWTcjAUGckgQY04SJAFMhJJIL5e4a5I6X6/gwlkRIwOzucAY9SYZBRvOCKheIwYFxR5enxCLhVeemAHbBQVg4SMIoCCinsKVyIOdlKKAhQcJFpGiWgFQiIYPxeJCQEEcykcDIgDAwYUkjEWB70NGykhADs=',
  1773. ),
  1774. 'pearlogo' => array(
  1775. 'type' => 'gif',
  1776. 'data' => 'R0lGODlhaAAyAMT/AMDAwP3+/TWaAvD47Pj89vz++zebBDmcBj6fDEekFluvKmu3PvX68ujz4XvBS8LgrNXqxeHw1ZnPaa/dgvv9+cLqj8LmltD2msnuls3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAABoADIAQAX/ICCOZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4AMulNLJFC9pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1AuiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHubpaYlExwRPRZioZZVp7KzKQoSDxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIWWQPQI4ikIwtoVQnddgrv8PFlCWgYCwkI+fp5dkvJ/IlUKMCy6tYrDhNIIKLFEAWCTxse+ABD4SClWA0zovAjcUJFi6EwahxZwoGqHhFA/4IqoICkyxQSKkbo0gDkuBXV4FRAJkRCnTgi2P28IcEfk5xpWppykFJVuScmEvDTEETAVJ6bEpypcADPkz3pvKVAICHChkC7siQ08zVqu4Q6hgIFEFZuEn/KMgRUkaBmAQs+cEHgIiHVH5EAFpIgW4+NT6LnaqhDwe/Ov7YOmWZp4MkiAWBIl0kAVsJWuzcYpdiNgddc0E8cKBAu/FElBwagMb88ZZKDRAkWJtkWhHh3wwUbKHQJN3wQAaXGR2LpArv5oFHRR34C7Mf6oLXZNfqBgNI7oOLhj1f8PaGpygHQ0xtP8MDVKwYTSKcgxr9/hS6/pCCAAg5M4B9/sWh1YP9/XSgQWRML/idBfKUc4IBET9lFjggKhDYZAELZJYEBI2BDB3ouNBEABwE8gAwiCcSYgAKqPdEVAG7scM8BPPZ4AIlM+OgjAgpMhRE24OVoBwsIFEGFA7ZkQQBWienWxmRa7XDjKZXhBdAeSmKQwgLuUVLICa6VEKIGcK2mQWoVZHCBXJblJUFkY06yAXlGsPIHBEYdYiWHb+WQBgaIJqqoHFNpgMGB7dT5ZQuG/WbBAIAUEEFNfwxAWpokTIXJAWdgoJ9kRFG2g5eDRpXSBpEIF0oEQFaZhDbaSFANRgqcJoEDRARLREtxOQpsPO906ZUeJgjQB6dZUPBAdwcF8KLXXRVQaKFcsRRLJ6vMiiCNKxRE8ECZKgUA3Va4arOAAqdGRWO7uMZH5AL05gvsjQbg6y4NCjQ1kw8TVGcbdoKGKx8j3bGH7nARBArqwi0gkFJBrZiXBQRbHoIgnhSjcEBKfD7c3HMhz+JIQSY3t8GGKW+SUhfUajxGzKd0IoHBNkNQK86ZYEqdzYA8AHQpqXRUm80oHs1CAgMoBxzRqvzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQGHcs/RRdiUDPHA33oADEAIAOw==',
  1777. ),
  1778. 'note' => array(
  1779. 'type' => 'png',
  1780. 'data' => 'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAAAAADFHGIkAAAAAmJLR0QAAKqNIzIAAAEESURBVHjaZZIhksMwDEV9voWFSwsLA0MLDf8VdARBUUNBQ1FBHcErZ5M0baXJjOPnb0vfLuMMn3H+lWMgBKL89A1Eq9Q9IrwB+gIOsnMPBR8giMclguQfBGS8x5xIoPQxnxqb4LL/eQ4l2AVNONP2ZshLCqJ3qqzWtT5pNgNnLU4OcNbuiqaLmFmHGhJ0TCMC99+f2wphlhaOYjuQVc0IIzLH2BRWfQoWsNSjct8AVop4rF3belTuVAb3MRj6kLrcTwtIy+g03V1vC57t1XrMzqfP5pln5yLTkk7+5UhstvOni1X3ixLEdf2c36+W0Q7kOb48hnSRLI/XdNPfX4kpMkgP5R+elfdkDPprQgAAAEN0RVh0U29mdHdhcmUAQCgjKUltYWdlTWFnaWNrIDQuMi44IDk5LzA4LzAxIGNyaXN0eUBteXN0aWMuZXMuZHVwb250LmNvbZG6IbgAAAAqdEVYdFNpZ25hdHVyZQAzYmQ3NDdjNWU0NTgwNzAwNmIwOTBkZDNlN2EyNmM0NBTTk/oAAAAOdEVYdFBhZ2UAMjR4MjQrMCswclsJMQAAAABJRU5ErkJggg==',
  1781. ),
  1782. );
  1783. Header('Content-Type: image/'.$images[$img]['type']);
  1784. echo base64_decode($images[$img]['data']);
  1785. };
  1786. // }}}
  1787. // {{{ displayHTMLProgress
  1788. function displayHTMLProgress($progress)
  1789. {
  1790. if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) {
  1791. return;
  1792. };
  1793. $msg = ob_get_contents();
  1794. ob_end_clean();
  1795. $msg = explode("\n", $msg);
  1796. foreach($msg as $key => $value) {
  1797. if (preg_match('/ok$/', $value)) {
  1798. $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
  1799. };
  1800. if (preg_match('/failed$/', $value)) {
  1801. $value = preg_replace('/(failed)$/', '<span style="color: #ff0000">\1</span>', $value);
  1802. };
  1803. if (preg_match('/^install ok:/', $value)) {
  1804. $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
  1805. };
  1806. if (preg_match('/^Warning:/', $value)) {
  1807. $value = '<span style="color: #ff0000">'.$value.'</span>';
  1808. };
  1809. $msg[$key] = $value;
  1810. };
  1811. $msg = implode('<br>', $msg);
  1812. $msg.='<script type="text/javascript"> parent.setprogress('.((int) $progress).'); </script>';
  1813. echo $msg;
  1814. ob_start();
  1815. };
  1816. // }}}
  1817. // {{{ displayHTMLDownloadProgress
  1818. function displayHTMLDownloadProgress($progress)
  1819. {
  1820. if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) {
  1821. return;
  1822. };
  1823. $msg = ob_get_contents();
  1824. ob_end_clean();
  1825. echo '<script type="text/javascript"> parent.setdownloadprogress('.((int) $progress).'); </script>';
  1826. ob_start();
  1827. echo $msg;
  1828. };
  1829. // }}}
  1830. // {{{ displayHTMLSetDownload
  1831. function displayHTMLSetDownload($file)
  1832. {
  1833. if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) {
  1834. return;
  1835. };
  1836. $msg = ob_get_contents();
  1837. ob_end_clean();
  1838. echo '<script type="text/javascript"> parent.setdownloadfile("'.$file.'"); </script>';
  1839. ob_start();
  1840. echo $msg;
  1841. };
  1842. // }}}
  1843. // {{{ win32BrowseForFolder
  1844. /*
  1845. * Create a vbs script to browse the getfolder dialog, called
  1846. * by cscript, if it's available.
  1847. * $label is the label text in the header of the dialog box
  1848. *
  1849. * TODO:
  1850. * - Do not show Control panel
  1851. * - Replace WSH with calls to w32 as soon as callbacks work
  1852. * @Author Pierrre-Alain Joye
  1853. */
  1854. function win32BrowseForFolder($label)
  1855. {
  1856. global $ptmp;
  1857. static $wshSaved=false;
  1858. static $cscript='';
  1859. $wsh_browserfolder = 'Option Explicit
  1860. Dim ArgObj, var1, var2, sa, sFld
  1861. Set ArgObj = WScript.Arguments
  1862. Const BIF_EDITBOX = &H10
  1863. Const BIF_NEWDIALOGSTYLE = &H40
  1864. Const BIF_RETURNONLYFSDIRS = &H0001
  1865. Const BIF_DONTGOBELOWDOMAIN = &H0002
  1866. Const BIF_STATUSTEXT = &H0004
  1867. Const BIF_RETURNFSANCESTORS = &H0008
  1868. Const BIF_VALIDATE = &H0020
  1869. Const BIF_BROWSEFORCOMPUTER = &H1000
  1870. Const BIF_BROWSEFORPRINTER = &H2000
  1871. Const BIF_BROWSEINCLUDEFILES = &H4000
  1872. Const OFN_LONGNAMES = &H200000
  1873. Const OFN_NOLONGNAMES = &H40000
  1874. Const ssfDRIVES = &H11
  1875. Const ssfNETWORK = &H12
  1876. Set sa = CreateObject("Shell.Application")
  1877. var1=ArgObj(0)
  1878. Set sFld = sa.BrowseForFolder(0, var1, BIF_EDITBOX + BIF_VALIDATE + BIF_BROWSEINCLUDEFILES + BIF_RETURNFSANCESTORS+BIF_NEWDIALOGSTYLE , ssfDRIVES )
  1879. if not sFld is nothing Then
  1880. if not left(sFld.items.item.path,1)=":" Then
  1881. WScript.Echo sFld.items.item.path
  1882. Else
  1883. WScript.Echo "invalid"
  1884. End If
  1885. Else
  1886. WScript.Echo "cancel"
  1887. End If
  1888. ';
  1889. if( !$wshSaved){
  1890. $cscript = $ptmp.DIRECTORY_SEPARATOR."bf.vbs";
  1891. $fh = fopen($cscript,"wb+");
  1892. fwrite($fh,$wsh_browserfolder,strlen($wsh_browserfolder));
  1893. fclose($fh);
  1894. $wshSaved = true;
  1895. }
  1896. exec('cscript '.$cscript.' "'.$label.'" //noLogo',$arPath);
  1897. if($arPath[0]=='' || $arPath[0]=='cancel'){
  1898. return '';
  1899. } elseif ($arPath[0]=='invalid') {
  1900. echo "Invalid Path.\n";
  1901. return '';
  1902. }
  1903. return $arPath[0];
  1904. }
  1905. // }}}
  1906. // {{{ win32CreateRegEnv
  1907. /*
  1908. * Generates a registry addOn for Win32 platform
  1909. * This addon set PEAR environment variables
  1910. * @Author Pierrre-Alain Joye
  1911. */
  1912. function win32CreateRegEnv()
  1913. {
  1914. global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir;
  1915. $nl = "\r\n";
  1916. $reg ='REGEDIT4'.$nl.
  1917. '[HKEY_CURRENT_USER\Environment]'.$nl.
  1918. '"PHP_PEAR_SYSCONF_DIR"="'.addslashes($prefix).'"'.$nl.
  1919. '"PHP_PEAR_INSTALL_DIR"="'.addslashes($php_dir).'"'.$nl.
  1920. '"PHP_PEAR_DOC_DIR"="'.addslashes($doc_dir).'"'.$nl.
  1921. '"PHP_PEAR_BIN_DIR"="'.addslashes($bin_dir).'"'.$nl.
  1922. '"PHP_PEAR_DATA_DIR"="'.addslashes($data_dir).'"'.$nl.
  1923. '"PHP_PEAR_PHP_BIN"="'.addslashes($php_bin).'"'.$nl.
  1924. '"PHP_PEAR_TEST_DIR"="'.addslashes($test_dir).'"'.$nl;
  1925. $fh = fopen($prefix.DIRECTORY_SEPARATOR.'PEAR_ENV.reg','wb');
  1926. if($fh){
  1927. fwrite($fh, $reg ,strlen($reg));
  1928. fclose($fh);
  1929. echo "
  1930. * WINDOWS ENVIRONMENT VARIABLES *
  1931. For convenience, a REG file is available under $prefix\\PEAR_ENV.reg .
  1932. This file creates ENV variables for the current user.
  1933. Double-click this file to add it to the current user registry.
  1934. ";
  1935. }
  1936. }
  1937. // }}}
  1938. // {{{ win32DetectPHPSAPI
  1939. /*
  1940. * Try to detect the kind of SAPI used by the
  1941. * the given php.exe.
  1942. * @Author Pierrre-Alain Joye
  1943. */
  1944. function win32DetectPHPSAPI()
  1945. {
  1946. global $php_bin,$phpsapiname;
  1947. if (WEBINSTALLER) {
  1948. return $phpsapiname;
  1949. }
  1950. if($php_bin!=''){
  1951. exec($php_bin.' -v', $res);
  1952. if(is_array($res)) {
  1953. if( isset($res[0]) && strpos($res[0],"(cli)")) {
  1954. return 'cli';
  1955. }
  1956. if( isset($res[0]) && strpos($res[0],"cgi")) {
  1957. return 'cgi';
  1958. } else {
  1959. return 'unknown';
  1960. }
  1961. }
  1962. }
  1963. return 'unknown';
  1964. }
  1965. // }}}
  1966. // {{{ getPhpiniPath
  1967. /*
  1968. * Get the php.ini file used with the current
  1969. * process or with the given php.exe
  1970. *
  1971. * Horrible hack, but well ;)
  1972. *
  1973. * Not used yet, will add the support later
  1974. * @Author Pierre-Alain Joye <paj@pearfr.org>
  1975. */
  1976. function getPhpiniPath()
  1977. {
  1978. $pathIni = get_cfg_var('cfg_file_path');
  1979. if( $pathIni && is_file($pathIni) ){
  1980. return $pathIni;
  1981. }
  1982. // Oh well, we can keep this too :)
  1983. // I dunno if get_cfg_var() is safe on every OS
  1984. if (WINDOWS) {
  1985. // on Windows, we can be pretty sure that there is a php.ini
  1986. // file somewhere
  1987. do {
  1988. $php_ini = PHP_CONFIG_FILE_PATH . DIRECTORY_SEPARATOR . 'php.ini';
  1989. if ( @file_exists($php_ini) ) break;
  1990. $php_ini = 'c:\winnt\php.ini';
  1991. if ( @file_exists($php_ini) ) break;
  1992. $php_ini = 'c:\windows\php.ini';
  1993. } while (false);
  1994. } else {
  1995. $php_ini = PHP_CONFIG_FILE_PATH . DIRECTORY_SEPARATOR . 'php.ini';
  1996. }
  1997. if( @is_file($php_ini) ){
  1998. return $php_ini;
  1999. }
  2000. // We re running in hackz&troubles :)
  2001. ob_implicit_flush(false);
  2002. ob_start();
  2003. phpinfo(INFO_GENERAL);
  2004. $strInfo = ob_get_contents ();
  2005. ob_end_clean();
  2006. ob_implicit_flush(true);
  2007. if ( php_sapi_name() != 'cli' ) {
  2008. $strInfo = strip_tags($strInfo,'<td>');
  2009. $arrayInfo = explode("</td>", $strInfo );
  2010. $cli = false;
  2011. } else {
  2012. $arrayInfo = explode("\n",$strInfo);
  2013. $cli = true;
  2014. }
  2015. foreach($arrayInfo as $val){
  2016. if ( strpos($val,"php.ini") ) {
  2017. if($cli){
  2018. list(,$pathIni) = explode('=>',$val);
  2019. } else {
  2020. $pathIni = strip_tags(trim($val) );
  2021. }
  2022. $pathIni = trim($pathIni);
  2023. if(is_file($pathIni)){
  2024. return $pathIni;
  2025. }
  2026. }
  2027. }
  2028. return false;
  2029. }
  2030. // }}}
  2031. // {{{ alterPhpIni
  2032. /*
  2033. * Not optimized, but seems to work, if some nice
  2034. * peardev will test it? :)
  2035. *
  2036. * @Author Pierre-Alain Joye <paj@pearfr.org>
  2037. */
  2038. function alterPhpIni($pathIni='')
  2039. {
  2040. global $php_dir, $prefix;
  2041. $iniSep = WINDOWS?';':':';
  2042. if( $pathIni=='' ){
  2043. $pathIni = getphpinipath();
  2044. }
  2045. $arrayIni = file($pathIni);
  2046. $i=0;
  2047. $found=0;
  2048. // Looks for each active include_path directives
  2049. foreach ( $arrayIni as $iniLine ) {
  2050. $iniLine = trim($iniLine);
  2051. $iniLine = str_replace(array("\n","\r"),array(),$iniLine);
  2052. if( preg_match("/^include_path/",$iniLine) ){
  2053. $foundAt[] = $i;
  2054. $found++;
  2055. }
  2056. $i++;
  2057. }
  2058. if ( $found ) {
  2059. $includeLine = $arrayIni[$foundAt[0]];
  2060. list(,$currentPath)=explode('=',$includeLine);
  2061. $currentPath = trim($currentPath);
  2062. if(substr($currentPath,0,1)=='"'){
  2063. $currentPath = substr($currentPath,1,strlen($currentPath)-2);
  2064. }
  2065. $arrayPath = explode($iniSep, $currentPath);
  2066. if( $arrayPath[0]=='.' ){
  2067. $newPath[0] = '.';
  2068. $newPath[1] = $php_dir;
  2069. array_shift($arrayPath);
  2070. } else {
  2071. $newPath[0] = $php_dir;
  2072. }
  2073. foreach( $arrayPath as $path ){
  2074. $newPath[]= $path;
  2075. }
  2076. } else {
  2077. $newPath[0] = '.';
  2078. $newPath[1] = $php_dir;
  2079. }
  2080. $nl = WINDOWS?"\r\n":"\n";
  2081. $includepath = 'include_path="'.implode($iniSep,$newPath).'"';
  2082. $newInclude = "$nl$nl;***** Added by go-pear$nl".
  2083. $includepath.
  2084. $nl.";*****".
  2085. $nl.$nl;
  2086. $arrayIni[$foundAt[0]] = $newInclude;
  2087. for( $i=1; $i<$found; $i++){
  2088. $arrayIni[$foundAt[$i]]=';'.trim($arrayIni[$foundAt[$i]]);
  2089. }
  2090. $newIni = implode("",$arrayIni);
  2091. if ( !($fh = @fopen($pathIni, "wb+")) ){
  2092. $prefixIni = $prefix.DIRECTORY_SEPARATOR."php.ini-gopear";
  2093. $fh = fopen($prefixIni, "wb+");
  2094. if ( !$fh ) {
  2095. echo
  2096. "
  2097. ******************************************************************************
  2098. WARNING! I cannot write to $pathIni nor in $prefix/php.ini-gopear. Please
  2099. modify manually your php.ini by adding:
  2100. $includepath
  2101. ";
  2102. return false;
  2103. } else {
  2104. fwrite($fh, $newIni, strlen($newIni));
  2105. fclose($fh);
  2106. echo
  2107. "
  2108. ******************************************************************************
  2109. WARNING! I cannot write to $pathIni, but I succesfully created a php.ini
  2110. under <$prefix/php.ini-gopear>. Please replace the file <$pathIni> with
  2111. <$prefixIni> or modify your php.ini by adding:
  2112. $includepath
  2113. ";
  2114. }
  2115. } else {
  2116. fwrite($fh, $newIni, strlen($newIni));
  2117. fclose($fh);
  2118. echo "
  2119. php.ini <$pathIni> include_path updated.
  2120. ";
  2121. }
  2122. return true;
  2123. }
  2124. ?>