PageRenderTime 36ms CodeModel.GetById 23ms RepoModel.GetById 1ms 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
  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;img=note" border="0"></TD>
  1442. <TD>
  1443. <span class="green">
  1444. <b>Note:</b> Make sure that PHP has the permission to access the specified<br/>
  1445. directories.<br/><br/>
  1446. </span>
  1447. </TD>
  1448. </TR>
  1449. </table>
  1450. <TABLE border="0">
  1451. <?php
  1452. // Display error messages
  1453. if (isset($GLOBALS['www_errors']) && sizeof($GLOBALS['www_errors']) ) {
  1454. $www_errors = $GLOBALS['www_errors'];
  1455. echo "<tr><td>";
  1456. echo '<span class="red">ERROR(S):</span>';
  1457. echo "</td></tr>";
  1458. foreach ($www_errors as $n => $var) {
  1459. echo "<tr><td>";
  1460. echo '<span class="red">'.$GLOBALS['config_desc'][$n].': </span>';
  1461. echo "</td><td>";
  1462. echo '<span class="red">'.$www_errors[$n].'</span>';
  1463. echo "<br>\n";
  1464. echo "</td></tr>\n";
  1465. }
  1466. }
  1467. foreach ($GLOBALS['config_vars'] as $n => $var) {
  1468. printf('<tr><td>%d. %s</td><td><input type="text" name="config[%s]" value="%s"></td></tr>',
  1469. $n,
  1470. $GLOBALS['config_desc'][$var],
  1471. $var,
  1472. $GLOBALS[$var]);
  1473. }
  1474. ?>
  1475. </TABLE>
  1476. <br/><hr/><br/>
  1477. The following PEAR packages are common ones, and can be installed<br/>
  1478. by go-pear too: <br/>
  1479. <?php echo implode(', ', $GLOBALS['pfc_packages']);?>.<br/>
  1480. <input type="checkbox" name="install_pfc" <?php if($GLOBALS['install_pfc']) echo 'checked';?>> Install those too<br/>
  1481. <br/><br/>
  1482. <table border="0">
  1483. <TR>
  1484. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
  1485. <TD>
  1486. <span class="green">
  1487. <b>Note:</b> Installation might take some time, because go-pear has to download<br/>
  1488. all needed files from pear.php.net. Just be patient and wait for the next<br/>
  1489. page to load.<br/>
  1490. </span>
  1491. </TD>
  1492. </TR>
  1493. </table>
  1494. <br>
  1495. <input type="checkbox" name="BCmode" id="BCmode" checked> Compatibility-Mode for old non-DOM Browsers<br/>
  1496. <script type="text/javascript">
  1497. <!--
  1498. if (document.getElementById('BCmode')) {
  1499. document.getElementById('BCmode').checked = 0;
  1500. };
  1501. // -->
  1502. </script>
  1503. <?php
  1504. if (WINDOWS && phpversion() == '4.1.1') {
  1505. ?>
  1506. <table border="0">
  1507. <TR>
  1508. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
  1509. <TD>
  1510. <span style="color: #ff0000">
  1511. <b>Warning:</b> Your PHP version (4.1.1) might be imcompatible with go-pear due to a bug<br/>
  1512. in your PHP binary. If the installation crashes you might want to update your PHP version.</br>
  1513. </span>
  1514. </TD>
  1515. </TR>
  1516. </table>
  1517. <?php
  1518. }
  1519. ?>
  1520. <br/>
  1521. <input type="submit" value="Install" onClick="javascript: submitButton.value='Downloading and installing ... please wait ...'" name="submitButton">
  1522. </form>
  1523. <?php
  1524. } elseif ($page == 'install') {
  1525. ?>
  1526. <span class="title">Installation Complete - Summary</span><br/>
  1527. <?php
  1528. displayHTMLInstallationSummary($data);
  1529. } elseif ($page == 'preinstall') {
  1530. ?>
  1531. <span class="title">Installation in progress ...</span><br/>
  1532. <br/>
  1533. <script language="javascript">
  1534. <!--
  1535. var progress;
  1536. var downlodprogress;
  1537. progress = 0;
  1538. downloadprogress = 0;
  1539. function setprogress(value)
  1540. {
  1541. progress = value;
  1542. prog = document.getElementById('installation_progress');
  1543. prog.innerHTML = progress + " %";
  1544. progress2 = progress / 10;
  1545. progress2 = Math.floor(progress2);
  1546. for (i=0; i < 10; i++)
  1547. document.getElementById('progress_cell_'+i).style.backgroundColor = "#cccccc";
  1548. switch(progress2)
  1549. {
  1550. case 10:
  1551. document.getElementById('progress_cell_9').style.backgroundColor = "#006600";
  1552. case 9:
  1553. document.getElementById('progress_cell_8').style.backgroundColor = "#006600";
  1554. case 8:
  1555. document.getElementById('progress_cell_7').style.backgroundColor = "#006600";
  1556. case 7:
  1557. document.getElementById('progress_cell_6').style.backgroundColor = "#006600";
  1558. case 6:
  1559. document.getElementById('progress_cell_5').style.backgroundColor = "#006600";
  1560. case 5:
  1561. document.getElementById('progress_cell_4').style.backgroundColor = "#006600";
  1562. case 4:
  1563. document.getElementById('progress_cell_3').style.backgroundColor = "#006600";
  1564. case 3:
  1565. document.getElementById('progress_cell_2').style.backgroundColor = "#006600";
  1566. case 2:
  1567. document.getElementById('progress_cell_1').style.backgroundColor = "#006600";
  1568. case 1:
  1569. document.getElementById('progress_cell_0').style.backgroundColor = "#006600";
  1570. };
  1571. }
  1572. function addprogress(value)
  1573. {
  1574. progress += value;
  1575. setprogress(progress);
  1576. }
  1577. function setdownloadfile(value)
  1578. {
  1579. setdownloadprogress(0);
  1580. prog = document.getElementById('download_file');
  1581. prog.innerHTML = 'Downloading '+value+' ...';
  1582. };
  1583. function setdownloadprogress(value)
  1584. {
  1585. downloadprogress = value;
  1586. prog = document.getElementById('download_progress');
  1587. prog.innerHTML = downloadprogress + " %";
  1588. progress2 = downloadprogress / 10;
  1589. progress2 = Math.floor(progress2);
  1590. for (i=0; i < 10; i++)
  1591. document.getElementById('download_progress_cell_'+i).style.backgroundColor = "#cccccc";
  1592. switch(progress2)
  1593. {
  1594. case 10:
  1595. document.getElementById('download_progress_cell_9').style.backgroundColor = "#006600";
  1596. case 9:
  1597. document.getElementById('download_progress_cell_8').style.backgroundColor = "#006600";
  1598. case 8:
  1599. document.getElementById('download_progress_cell_7').style.backgroundColor = "#006600";
  1600. case 7:
  1601. document.getElementById('download_progress_cell_6').style.backgroundColor = "#006600";
  1602. case 6:
  1603. document.getElementById('download_progress_cell_5').style.backgroundColor = "#006600";
  1604. case 5:
  1605. document.getElementById('download_progress_cell_4').style.backgroundColor = "#006600";
  1606. case 4:
  1607. document.getElementById('download_progress_cell_3').style.backgroundColor = "#006600";
  1608. case 3:
  1609. document.getElementById('download_progress_cell_2').style.backgroundColor = "#006600";
  1610. case 2:
  1611. document.getElementById('download_progress_cell_1').style.backgroundColor = "#006600";
  1612. case 1:
  1613. document.getElementById('download_progress_cell_0').style.backgroundColor = "#006600";
  1614. };
  1615. };
  1616. // -->
  1617. </script>
  1618. <table style="border-width: 1px; border-color: #000000" cellspacing="0" cellpadding="0">
  1619. <tr>
  1620. <td>
  1621. <table border="0">
  1622. <tr>
  1623. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_0">&nbsp;</td>
  1624. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_1">&nbsp;</td>
  1625. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_2">&nbsp;</td>
  1626. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_3">&nbsp;</td>
  1627. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_4">&nbsp;</td>
  1628. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_5">&nbsp;</td>
  1629. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_6">&nbsp;</td>
  1630. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_7">&nbsp;</td>
  1631. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_8">&nbsp;</td>
  1632. <td bgcolor="#cccccc" width="10" height="20" id="progress_cell_9">&nbsp;</td>
  1633. <td bgcolor="#ffffff" width="10" height="20">&nbsp;</td>
  1634. <td bgcolor="#ffffff" height="20" id="installation_progress" class="green">0 %</td>
  1635. </tr>
  1636. </table>
  1637. <br>
  1638. <table border="0">
  1639. <tr>
  1640. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_0">&nbsp;</td>
  1641. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_1">&nbsp;</td>
  1642. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_2">&nbsp;</td>
  1643. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_3">&nbsp;</td>
  1644. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_4">&nbsp;</td>
  1645. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_5">&nbsp;</td>
  1646. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_6">&nbsp;</td>
  1647. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_7">&nbsp;</td>
  1648. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_8">&nbsp;</td>
  1649. <td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_9">&nbsp;</td>
  1650. <td bgcolor="#ffffff" width="10" height="20">&nbsp;</td>
  1651. <td bgcolor="#ffffff" height="20" id="download_progress" class="green">0 %</td>
  1652. <td bgcolor="#ffffff" width="10" height="20">&nbsp;</td>
  1653. <td bgcolor="#ffffff" height="20" id="download_file" class="green"></td>
  1654. </tr>
  1655. </table>
  1656. <br>
  1657. <iframe src="<?php echo basename(__FILE__); ?>?step=install-progress&amp;<?php echo SID;?>" width="700" height="700" frameborder="0" marginheight="0" marginwidth="0"></iframe>
  1658. </td>
  1659. </tr>
  1660. </table>
  1661. <?php
  1662. }
  1663. ?>
  1664. </td>
  1665. </tr>
  1666. </table>
  1667. </td>
  1668. </tr>
  1669. </table>
  1670. </td>
  1671. </tr>
  1672. </table>
  1673. <?php
  1674. displayHTMLFooter();
  1675. }
  1676. // }}}
  1677. // {{{ displayHTMLFooter
  1678. function displayHTMLFooter()
  1679. {
  1680. ?>
  1681. </body>
  1682. </html>
  1683. <?php
  1684. };
  1685. // }}}
  1686. // {{{ displayHTMLInstallationSummary
  1687. function displayHTMLInstallationSummary($data = '')
  1688. {
  1689. $next = NULL;
  1690. $prefix = dirname($GLOBALS['webfrontend_file']);
  1691. $doc_root = strip_magic_quotes($_SERVER['DOCUMENT_ROOT']);
  1692. $file_dir = dirname(__FILE__);
  1693. if ( WINDOWS ) {
  1694. $prefix = str_replace('/', '\\', strtolower($prefix));
  1695. $doc_root = str_replace('/', '\\', strtolower($doc_root));
  1696. $file_dir = str_replace('/', '\\', strtolower($file_dir));
  1697. }
  1698. if ($doc_root && substr($prefix, 0, strlen($doc_root)) == $doc_root) {
  1699. $next = substr($prefix, strlen($doc_root)).'/index.php';
  1700. } else if ($file_dir && substr($prefix, 0, strlen($file_dir)) == $file_dir) {
  1701. $next = substr($prefix, strlen($file_dir)).'/index.php';
  1702. }
  1703. if ($data) {
  1704. echo "<br/>".$data;
  1705. }
  1706. ?>
  1707. <br/>
  1708. <table border="0">
  1709. <TR>
  1710. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
  1711. <TD>
  1712. <span class="green">
  1713. <b>Note:</b> To use PEAR without any problems you need to add your<br/>
  1714. PEAR Installation path (<?php echo $GLOBALS['php_dir']; ?>)<br>
  1715. to your <a href="http://www.php.net/manual/en/configuration.directives.php#ini.include_path">include_path</a>.<br/>
  1716. <br/>
  1717. Using a .htaccess file or directly edit httpd.conf would be working solutions<br/>
  1718. for Apache running servers, too.<br/>
  1719. </span>
  1720. </TD>
  1721. </TR>
  1722. </table>
  1723. <br/>
  1724. For more information about PEAR, see:<br/>
  1725. <a href="http://pear.php.net/faq.php" target="_new" class="green">PEAR FAQ</a><br/>
  1726. <a href="http://pear.php.net/manual/" target="_new" class="green">PEAR Manual</a><br/>
  1727. <br/>
  1728. Thanks for using go-pear!<br/>
  1729. <br/>
  1730. <?php
  1731. if ($next === NULL) {
  1732. ?>
  1733. <table border="0">
  1734. <TR>
  1735. <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
  1736. <TD>
  1737. <span style="color: #ff0000">
  1738. <b>Warning:</b> Go-PEAR was not able to determine the URL to the newly<br/>
  1739. installed Web Frontend of the PEAR Installer. Please access it manually.<br/>
  1740. Since you specified the prefix, you should know how to do so.<br/>
  1741. </span>
  1742. </TD>
  1743. </TR>
  1744. </table>
  1745. <?php
  1746. } else {
  1747. if ($_GET['step'] == 'install-progress') {
  1748. ?>
  1749. <a href="<?php echo $next;?>" class="green" target="_parent">Start Web Frontend of the PEAR Installer &gt;&gt;</a>
  1750. <?php
  1751. } else {
  1752. ?>
  1753. <a href="<?php echo $next;?>" class="green">Start Web Frontend of the PEAR Installer &gt;&gt;</a>
  1754. <?php
  1755. }
  1756. }
  1757. }
  1758. // }}}
  1759. // {{{ strip_magic_quotes
  1760. function strip_magic_quotes($value)
  1761. {
  1762. if (ini_get('magic_quotes_gpc')) {
  1763. return stripslashes($value);
  1764. }
  1765. return $value;
  1766. };
  1767. // }}}
  1768. // {{{ showImage
  1769. function showImage($img)
  1770. {
  1771. $images = array(
  1772. 'smallpear' => array(
  1773. 'type' => 'gif',
  1774. 'data' => 'R0lGODlhEQATAMQAAAAAACqUACiTAC2WAC+YAzKZBTSaBsHgszOZADCYADmcB4TCZp3Ohtfrzd/v1+by4PD47DaaAz+fDUijF2WyOlCoHvT58VqtJPn893y+S/v9+f7//f3+/Pz9+////////ywAAAAAEQATAAAFkqAnjiR5NGXqcdpCoapnMVRdWbEHUROVVROYalHJTCaVAKWTcjAUGckgQY04SJAFMhJJIL5e4a5I6X6/gwlkRIwOzucAY9SYZBRvOCKheIwYFxR5enxCLhVeemAHbBQVg4SMIoCCinsKVyIOdlKKAhQcJFpGiWgFQiIYPxeJCQEEcykcDIgDAwYUkjEWB70NGykhADs=',
  1775. ),
  1776. 'pearlogo' => array(
  1777. 'type' => 'gif',
  1778. '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==',
  1779. ),
  1780. 'note' => array(
  1781. 'type' => 'png',
  1782. 'data' => 'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAAAAADFHGIkAAAAAmJLR0QAAKqNIzIAAAEESURBVHjaZZIhksMwDEV9voWFSwsLA0MLDf8VdARBUUNBQ1FBHcErZ5M0baXJjOPnb0vfLuMMn3H+lWMgBKL89A1Eq9Q9IrwB+gIOsnMPBR8giMclguQfBGS8x5xIoPQxnxqb4LL/eQ4l2AVNONP2ZshLCqJ3qqzWtT5pNgNnLU4OcNbuiqaLmFmHGhJ0TCMC99+f2wphlhaOYjuQVc0IIzLH2BRWfQoWsNSjct8AVop4rF3belTuVAb3MRj6kLrcTwtIy+g03V1vC57t1XrMzqfP5pln5yLTkk7+5UhstvOni1X3ixLEdf2c36+W0Q7kOb48hnSRLI/XdNPfX4kpMkgP5R+elfdkDPprQgAAAEN0RVh0U29mdHdhcmUAQCgjKUltYWdlTWFnaWNrIDQuMi44IDk5LzA4LzAxIGNyaXN0eUBteXN0aWMuZXMuZHVwb250LmNvbZG6IbgAAAAqdEVYdFNpZ25hdHVyZQAzYmQ3NDdjNWU0NTgwNzAwNmIwOTBkZDNlN2EyNmM0NBTTk/oAAAAOdEVYdFBhZ2UAMjR4MjQrMCswclsJMQAAAABJRU5ErkJggg==',
  1783. ),
  1784. );
  1785. Header('Content-Type: image/'.$images[$img]['type']);
  1786. echo base64_decode($images[$img]['data']);
  1787. };
  1788. // }}}
  1789. // {{{ displayHTMLProgress
  1790. function displayHTMLProgress($progress)
  1791. {
  1792. if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) {
  1793. return;
  1794. };
  1795. $msg = ob_get_contents();
  1796. ob_end_clean();
  1797. $msg = explode("\n", $msg);
  1798. foreach($msg as $key => $value) {
  1799. if (preg_match('/ok$/', $value)) {
  1800. $value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
  1801. };
  1802. if (preg_match('/failed$/', $value)) {
  1803. $value = preg_replace('/(failed)$/', '<span style="color: #ff0000">\1</span>', $value);
  1804. };
  1805. if (preg_match('/^install ok:/', $value)) {
  1806. $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
  1807. };
  1808. if (preg_match('/^Warning:/', $value)) {
  1809. $value = '<span style="color: #ff0000">'.$value.'</span>';
  1810. };
  1811. $msg[$key] = $value;
  1812. };
  1813. $msg = implode('<br>', $msg);
  1814. $msg.='<script type="text/javascript"> parent.setprogress('.((int) $progress).'); </script>';
  1815. echo $msg;
  1816. ob_start();
  1817. };
  1818. // }}}
  1819. // {{{ displayHTMLDownloadProgress
  1820. function displayHTMLDownloadProgress($progress)
  1821. {
  1822. if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) {
  1823. return;
  1824. };
  1825. $msg = ob_get_contents();
  1826. ob_end_clean();
  1827. echo '<script type="text/javascript"> parent.setdownloadprogress('.((int) $progress).'); </script>';
  1828. ob_start();
  1829. echo $msg;
  1830. };
  1831. // }}}
  1832. // {{{ displayHTMLSetDownload
  1833. function displayHTMLSetDownload($file)
  1834. {
  1835. if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'])) {
  1836. return;
  1837. };
  1838. $msg = ob_get_contents();
  1839. ob_end_clean();
  1840. echo '<script type="text/javascript"> parent.setdownloadfile("'.$file.'"); </script>';
  1841. ob_start();
  1842. echo $msg;
  1843. };
  1844. // }}}
  1845. // {{{ win32BrowseForFolder
  1846. /*
  1847. * Create a vbs script to browse the getfolder dialog, called
  1848. * by cscript, if it's available.
  1849. * $label is the label text in the header of the dialog box
  1850. *
  1851. * TODO:
  1852. * - Do not show Control panel
  1853. * - Replace WSH with calls to w32 as soon as callbacks work
  1854. * @Author Pierrre-Alain Joye
  1855. */
  1856. function win32BrowseForFolder($label)
  1857. {
  1858. global $ptmp;
  1859. static $wshSaved=false;
  1860. static $cscript='';
  1861. $wsh_browserfolder = 'Option Explicit
  1862. Dim ArgObj, var1, var2, sa, sFld
  1863. Set ArgObj = WScript.Arguments
  1864. Const BIF_EDITBOX = &H10
  1865. Const BIF_NEWDIALOGSTYLE = &H40
  1866. Const BIF_RETURNONLYFSDIRS = &H0001
  1867. Const BIF_DONTGOBELOWDOMAIN = &H0002
  1868. Const BIF_STATUSTEXT = &H0004
  1869. Const BIF_RETURNFSANCESTORS = &H0008
  1870. Const BIF_VALIDATE = &H0020
  1871. Const BIF_BROWSEFORCOMPUTER = &H1000
  1872. Const BIF_BROWSEFORPRINTER = &H2000
  1873. Const BIF_BROWSEINCLUDEFILES = &H4000
  1874. Const OFN_LONGNAMES = &H200000
  1875. Const OFN_NOLONGNAMES = &H40000
  1876. Const ssfDRIVES = &H11
  1877. Const ssfNETWORK = &H12
  1878. Set sa = CreateObject("Shell.Application")
  1879. var1=ArgObj(0)
  1880. Set sFld = sa.BrowseForFolder(0, var1, BIF_EDITBOX + BIF_VALIDATE + BIF_BROWSEINCLUDEFILES + BIF_RETURNFSANCESTORS+BIF_NEWDIALOGSTYLE , ssfDRIVES )
  1881. if not sFld is nothing Then
  1882. if not left(sFld.items.item.path,1)=":" Then
  1883. WScript.Echo sFld.items.item.path
  1884. Else
  1885. WScript.Echo "invalid"
  1886. End If
  1887. Else
  1888. WScript.Echo "cancel"
  1889. End If
  1890. ';
  1891. if( !$wshSaved){
  1892. $cscript = $ptmp.DIRECTORY_SEPARATOR."bf.vbs";
  1893. $fh = fopen($cscript,"wb+");
  1894. fwrite($fh,$wsh_browserfolder,strlen($wsh_browserfolder));
  1895. fclose($fh);
  1896. $wshSaved = true;
  1897. }
  1898. exec('cscript '.$cscript.' "'.$label.'" //noLogo',$arPath);
  1899. if($arPath[0]=='' || $arPath[0]=='cancel'){
  1900. return '';
  1901. } elseif ($arPath[0]=='invalid') {
  1902. echo "Invalid Path.\n";
  1903. return '';
  1904. }
  1905. return $arPath[0];
  1906. }
  1907. // }}}
  1908. // {{{ win32CreateRegEnv
  1909. /*
  1910. * Generates a registry addOn for Win32 platform
  1911. * This addon set PEAR environment variables
  1912. * @Author Pierrre-Alain Joye
  1913. */
  1914. function win32CreateRegEnv()
  1915. {
  1916. global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir;
  1917. $nl = "\r\n";
  1918. $reg ='REGEDIT4'.$nl.
  1919. '[HKEY_CURRENT_USER\Environment]'.$nl.
  1920. '"PHP_PEAR_SYSCONF_DIR"="'.addslashes($prefix).'"'.$nl.
  1921. '"PHP_PEAR_INSTALL_DIR"="'.addslashes($php_dir).'"'.$nl.
  1922. '"PHP_PEAR_DOC_DIR"="'.addslashes($doc_dir).'"'.$nl.
  1923. '"PHP_PEAR_BIN_DIR"="'.addslashes($bin_dir).'"'.$nl.
  1924. '"PHP_PEAR_DATA_DIR"="'.addslashes($data_dir).'"'.$nl.
  1925. '"PHP_PEAR_PHP_BIN"="'.addslashes($php_bin).'"'.$nl.
  1926. '"PHP_PEAR_TEST_DIR"="'.addslashes($test_dir).'"'.$nl;
  1927. $fh = fopen($prefix.DIRECTORY_SEPARATOR.'PEAR_ENV.reg','wb');
  1928. if($fh){
  1929. fwrite($fh, $reg ,strlen($reg));
  1930. fclose($fh);
  1931. echo "
  1932. * WINDOWS ENVIRONMENT VARIABLES *
  1933. For convenience, a REG file is available under $prefix\\PEAR_ENV.reg .
  1934. This file creates ENV variables for the current user.
  1935. Double-click this file to add it to the current user registry.
  1936. ";
  1937. }
  1938. }
  1939. // }}}
  1940. // {{{ win32DetectPHPSAPI
  1941. /*
  1942. * Try to detect the kind of SAPI used by the
  1943. * the given php.exe.
  1944. * @Author Pierrre-Alain Joye
  1945. */
  1946. function win32DetectPHPSAPI()
  1947. {
  1948. global $php_bin,$phpsapiname;
  1949. if (WEBINSTALLER) {
  1950. return $phpsapiname;
  1951. }
  1952. if($php_bin!=''){
  1953. exec($php_bin.' -v', $res);
  1954. if(is_array($res)) {
  1955. if( isset($res[0]) && strpos($res[0],"(cli)")) {
  1956. return 'cli';
  1957. }
  1958. if( isset($res[0]) && strpos($res[0],"cgi")) {
  1959. return 'cgi';
  1960. } else {
  1961. return 'unknown';
  1962. }
  1963. }
  1964. }
  1965. return 'unknown';
  1966. }
  1967. // }}}
  1968. // {{{ getPhpiniPath
  1969. /*
  1970. * Get the php.ini file used with the current
  1971. * process or with the given php.exe
  1972. *
  1973. * Horrible hack, but well ;)
  1974. *
  1975. * Not used yet, will add the support later
  1976. * @Author Pierre-Alain Joye <paj@pearfr.org>
  1977. */
  1978. function getPhpiniPath()
  1979. {
  1980. $pathIni = get_cfg_var('cfg_file_path');
  1981. if( $pathIni && is_file($pathIni) ){
  1982. return $pathIni;
  1983. }
  1984. // Oh well, we can keep this too :)
  1985. // I dunno if get_cfg_var() is safe on every OS
  1986. if (WINDOWS) {
  1987. // on Windows, we can be pretty sure that there is a php.ini
  1988. // file somewhere
  1989. do {
  1990. $php_ini = PHP_CONFIG_FILE_PATH . DIRECTORY_SEPARATOR . 'php.ini';
  1991. if ( @file_exists($php_ini) ) break;
  1992. $php_ini = 'c:\winnt\php.ini';
  1993. if ( @file_exists($php_ini) ) break;
  1994. $php_ini = 'c:\windows\php.ini';
  1995. } while (false);
  1996. } else {
  1997. $php_ini = PHP_CONFIG_FILE_PATH . DIRECTORY_SEPARATOR . 'php.ini';
  1998. }
  1999. if( @is_file($php_ini) ){
  2000. return $php_ini;
  2001. }
  2002. // We re running in hackz&troubles :)
  2003. ob_implicit_flush(false);
  2004. ob_start();
  2005. phpinfo(INFO_GENERAL);
  2006. $strInfo = ob_get_contents ();
  2007. ob_end_clean();
  2008. ob_implicit_flush(true);
  2009. if ( php_sapi_name() != 'cli' ) {
  2010. $strInfo = strip_tags($strInfo,'<td>');
  2011. $arrayInfo = explode("</td>", $strInfo );
  2012. $cli = false;
  2013. } else {
  2014. $arrayInfo = explode("\n",$strInfo);
  2015. $cli = true;
  2016. }
  2017. foreach($arrayInfo as $val){
  2018. if ( strpos($val,"php.ini") ) {
  2019. if($cli){
  2020. list(,$pathIni) = explode('=>',$val);
  2021. } else {
  2022. $pathIni = strip_tags(trim($val) );
  2023. }
  2024. $pathIni = trim($pathIni);
  2025. if(is_file($pathIni)){
  2026. return $pathIni;
  2027. }
  2028. }
  2029. }
  2030. return false;
  2031. }
  2032. // }}}
  2033. // {{{ alterPhpIni
  2034. /*
  2035. * Not optimized, but seems to work, if some nice
  2036. * peardev will test it? :)
  2037. *
  2038. * @Author Pierre-Alain Joye <paj@pearfr.org>
  2039. */
  2040. function alterPhpIni($pathIni='')
  2041. {
  2042. global $php_dir, $prefix;
  2043. $iniSep = WINDOWS?';':':';
  2044. if( $pathIni=='' ){
  2045. $pathIni = getphpinipath();
  2046. }
  2047. $arrayIni = file($pathIni);
  2048. $i=0;
  2049. $found=0;
  2050. // Looks for each active include_path directives
  2051. foreach ( $arrayIni as $iniLine ) {
  2052. $iniLine = trim($iniLine);
  2053. $iniLine = str_replace(array("\n","\r"),array(),$iniLine);
  2054. if( preg_match("/^include_path/",$iniLine) ){
  2055. $foundAt[] = $i;
  2056. $found++;
  2057. }
  2058. $i++;
  2059. }
  2060. if ( $found ) {
  2061. $includeLine = $arrayIni[$foundAt[0]];
  2062. list(,$currentPath)=explode('=',$includeLine);
  2063. $currentPath = trim($currentPath);
  2064. if(substr($currentPath,0,1)=='"'){
  2065. $currentPath = substr($currentPath,1,strlen($currentPath)-2);
  2066. }
  2067. $arrayPath = explode($iniSep, $currentPath);
  2068. if( $arrayPath[0]=='.' ){
  2069. $newPath[0] = '.';
  2070. $newPath[1] = $php_dir;
  2071. array_shift($arrayPath);
  2072. } else {
  2073. $newPath[0] = $php_dir;
  2074. }
  2075. foreach( $arrayPath as $path ){
  2076. $newPath[]= $path;
  2077. }
  2078. } else {
  2079. $newPath[0] = '.';
  2080. $newPath[1] = $php_dir;
  2081. }
  2082. $nl = WINDOWS?"\r\n":"\n";
  2083. $includepath = 'include_path="'.implode($iniSep,$newPath).'"';
  2084. $newInclude = "$nl$nl;***** Added by go-pear$nl".
  2085. $includepath.
  2086. $nl.";*****".
  2087. $nl.$nl;
  2088. $arrayIni[$foundAt[0]] = $newInclude;
  2089. for( $i=1; $i<$found; $i++){
  2090. $arrayIni[$foundAt[$i]]=';'.trim($arrayIni[$foundAt[$i]]);
  2091. }
  2092. $newIni = implode("",$arrayIni);
  2093. if ( !($fh = @fopen($pathIni, "wb+")) ){
  2094. $prefixIni = $prefix.DIRECTORY_SEPARATOR."php.ini-gopear";
  2095. $fh = fopen($prefixIni, "wb+");
  2096. if ( !$fh ) {
  2097. echo
  2098. "
  2099. ******************************************************************************
  2100. WARNING! I cannot write to $pathIni nor in $prefix/php.ini-gopear. Please
  2101. modify manually your php.ini by adding:
  2102. $includepath
  2103. ";
  2104. return false;
  2105. } else {
  2106. fwrite($fh, $newIni, strlen($newIni));
  2107. fclose($fh);
  2108. echo
  2109. "
  2110. ******************************************************************************
  2111. WARNING! I cannot write to $pathIni, but I succesfully created a php.ini
  2112. under <$prefix/php.ini-gopear>. Please replace the file <$pathIni> with
  2113. <$prefixIni> or modify your php.ini by adding:
  2114. $includepath
  2115. ";
  2116. }
  2117. } else {
  2118. fwrite($fh, $newIni, strlen($newIni));
  2119. fclose($fh);
  2120. echo "
  2121. php.ini <$pathIni> include_path updated.
  2122. ";
  2123. }
  2124. return true;
  2125. }
  2126. ?>