Go Pear
Go Pear
$sapi_name = php_sapi_name();
$safe_mode = (bool)ini_get('safe_mode');
if (!$safe_mode) {
set_time_limit(0);
}
@ob_end_clean();
ob_implicit_flush(true);
define('WEBINSTALLER', ($sapi_name != 'cli' && !(substr($sapi_name,0,3)=='cgi'
&& !isset($_SERVER['GATEWAY_INTERFACE']))));
ini_set('track_errors', true);
ini_set('html_errors', WEBINSTALLER);
ini_set('magic_quotes_runtime', false);
error_reporting( E_ALL & ~E_NOTICE);
if (!function_exists('file_get_contents')) {
function file_get_contents($filename)
{
$fp = fopen($filename, 'rb');
$ret = '';
while (!feof($fp)) {
$ret .= fread($fp, 8092);;
}
return $ret;
}
}
/*
* See bug #23069
*/
if ( WEBINSTALLER && WINDOWS ) {
$php_sapi_name = win32DetectPHPSAPI();
if($php_sapi_name=='cgi'){
$msg = nl2br("
Sorry! The PEAR installer actually does not work on Windows platform using CGI and
Apache.
Please install the module SAPI (see
http://www.php.net/manual/en/install.apache.php for the
instructions) or use the CLI (cli\php.exe) in the console.
");
displayHTML('error', $msg);
}
}
It may be that you have a newer version of PHP installed in your web
server, but an older version installed as the 'php' command. In this
case, you need to rebuilt PHP from source.
If your source is 4.3.x or newer, just make sure you don't run
'configure' with --disable-cli, rebuilt and copy sapi/cli/php.
Please upgrade PHP to a newer version, and try again. See you then.
");
}
$installer_packages = array(
'PEAR-stable',
'Archive_Tar-stable',
'Console_Getopt-stable',
'XML_RPC-stable'
);
if (WEBINSTALLER) {
$installer_packages[] = 'HTML_Template_IT-stable';
$installer_packages[] = 'Net_UserAgent_Detect-stable';
$installer_packages[] = 'PEAR_Frontend_Web-alpha';
}
$pfc_packages = array(
'MDB2',
'Net_Socket',
'Net_SMTP',
'Mail',
'XML_Parser',
'PHPUnit'
);
$config_desc = array(
'prefix' => 'Installation prefix',
'bin_dir' => 'Binaries directory',
'php_dir' => 'PHP code directory ($php_dir)',
'doc_dir' => 'Documentation base directory',
'data_dir' => 'Data base directory',
'test_dir' => 'Tests base directory',
'temp_dir' => 'Temporary files directory'
);
if (WEBINSTALLER) {
$config_desc['cache_dir'] = 'PEAR Installer cache directory';
$config_desc['cache_ttl'] = 'Cache TimeToLive';
$config_desc['webfrontend_file'] = 'Filename of WebFrontend';
$config_desc['php_bin'] = "php.exe path, optional (CLI command tools)";
}
if (my_env('HTTP_PROXY')) {
$http_proxy = my_env('HTTP_PROXY');
} elseif (my_env('http_proxy')) {
$http_proxy = my_env('http_proxy');
} else {
$http_proxy = '';
}
register_shutdown_function('bail');
detect_install_dirs();
if (WEBINSTALLER) {
@session_start();
/*
See bug #23069
*/
if ( WINDOWS ) {
$php_sapi_name = win32DetectPHPSAPI();
if($php_sapi_name=='cgi'){
$msg = "
Sorry! The PEAR installer actually does not work on Windows platform using CGI
and Apache.
Please install the module SAPI (see
http://www.php.net/manual/en/install.apache.php for the
instructions) or use the CLI (cli\php.exe) in the console.
";
displayHTML('error', $msg);
exit();
}
}
if (!isset($_SESSION['go-pear']) || isset($_GET['restart'])) {
$_SESSION['go-pear'] = array(
'http_proxy' => $http_proxy,
'config' => array(
'prefix' => dirname(__FILE__),
'bin_dir' => $bin_dir,
'php_bin' => $php_bin,
'php_dir' => '$prefix/PEAR',
'doc_dir' => $doc_dir,
'data_dir' => $data_dir,
'test_dir' => $test_dir,
'temp_dir' => '$prefix/temp',
'cache_dir' => '$php_dir/cache',
'cache_ttl' => 300,
'webfrontend_file' => '$prefix/index.php',
),
'install_pfc' => true,
'DHTML' => true,
);
}
if (!isset($_GET['step'])) {
$_GET['step'] = 'Welcome';
/* clean up old sessions datas */
session_destroy();
}
if ($_GET['step'] == 'install') {
$_SESSION['go-pear']['http_proxy'] =
strip_magic_quotes($_POST['proxy']['host']).':'.strip_magic_quotes($_POST['proxy']
['port']);
if ($_SESSION['go-pear']['http_proxy'] == ':') {
$_SESSION['go-pear']['http_proxy'] = '';
};
$www_errors = array();
foreach($_POST['config'] as $key => $value) {
$_POST['config'][$key] = strip_magic_quotes($value);
if($key!='cache_ttl'){
if ( empty($_POST['config'][$key]) ) {
if (WEBINSTALLER && $key!='php_bin' ) {
$www_errors[$key] = 'Please fill this path, you can use
$prefix, $php_dir or a full path.';
}
}
}
}
if( sizeof($www_errors)>0){
$_GET['step'] = 'config';
}
$_SESSION['go-pear']['config'] = $_POST['config'];
$_SESSION['go-pear']['install_pfc'] = (isset($_POST['install_pfc']) &&
$_POST['install_pfc'] == 'on');
$_SESSION['go-pear']['DHTML'] = isset($_POST['BCmode']) ? false : true;
}
$http_proxy = $_SESSION['go-pear']['http_proxy'];
foreach($_SESSION['go-pear']['config'] as $var => $value) {
$$var = $value;
}
$install_pfc = $_SESSION['go-pear']['install_pfc'];
}
if (!WEBINSTALLER) {
$tty = WINDOWS ? @fopen('\con', 'r') : @fopen('/dev/tty', 'r');
if (!$tty) {
$tty = fopen('php://stdin', 'r');
}
Go-pear will install the 'pear' command and all the files needed by
it. This command is your tool for PEAR installation and maintenance.
$local
Go-pear also lets you download and install the PEAR packages bundled
with PHP: " . implode(', ', $pfc_packages) . ".
If you wish to abort, press Control-C now, or press Enter to continue: ";
fgets($tty, 1024);
print "\n";
if (!empty($http_proxy)) {
print " [$http_proxy]";
}
print ": ";
$tmp = trim(fgets($tty, 1024));
if (!empty($tmp)) {
$http_proxy = $tmp;
}
}
$origpwd = getcwd();
$config_vars = array_keys($config_desc);
if (WEBINSTALLER) {
if ( isset($www_errors) && sizeof($www_errors) ) {
displayHTML('config');
exit();
} else {
if (isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML']
== true && $_GET['step'] == 'install') {
$_GET['step'] = 'preinstall';
}
if ($_GET['step'] != 'install' && $_GET['step'] != 'install-progress') {
displayHTML($_GET['step']);
exit;
}
if ($_GET['step'] == 'install-progress') {
displayHTMLHeader();
echo "Starting installation ...<br/>";
}
ob_start();
}
}
$progress = 0;
/*
* Checks PHP SAPI version under windows/CLI
*/
if( WINDOWS && !WEBINSTALLER && $php_bin=='') {
print "
We do not find any php.exe, please select the php.exe folder (CLI is
recommanded, usually in c:\php\cli\php.exe)
";
$php_bin_set = false;
} elseif ( WINDOWS && !WEBINSTALLER && strlen($php_bin) ) {
$php_bin_sapi = win32DetectPHPSAPI();
$php_bin_set = true;
switch($php_bin_sapi){
case 'cli':
break;
case 'cgi':
print "
*NOTICE*
We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI. PEAR commandline
tool works well with it, if you have a CLI php.exe available, we
recommand to use it.
";
break;
default:
print "
*WARNING*
We found php.exe under $php_bin, it uses an unknown SAPI. PEAR commandline
tool has not been tested with it, if you have a CLI (or CGI) php.exe available,
we strongly recommand to use it.
";
break;
}
}
while (!WEBINSTALLER) {
print "
Below is a suggested file layout for your new PEAR installation. To
change individual locations, type the number in front of the
directory. Type 'all' to change all of them or simply press Enter to
accept these locations.
";
";
} else {
break;
}
}
if (isset($config_vars[(int)$tmp])) {
$var = $config_vars[(int)$tmp];
$desc = $config_desc[$var];
$current = $$var;
if(WIN32GUI){
$tmp = win32BrowseForFolder("$desc [$current] :");
} else {
print "$desc [$current] : ";
$tmp = trim(fgets($tty, 1024));
}
$old = $$var;
if(WINDOWS && $var=='php_bin' ){
if(file_exists($tmp.DIRECTORY_SEPARATOR.'php.exe')){
$tmp = $tmp.DIRECTORY_SEPARATOR.'php.exe';
$php_bin_sapi = win32DetectPHPSAPI();
if($php_bin_sapi=='cgi'){
print "
******************************************************************************
NOTICE! We found php.exe under $php_bin, it uses a $php_bin_sapi SAPI.
PEAR commandline tool works well with it.
If you have a CLI php.exe available, we recommand to use it.
";
} elseif ($php_bin_sapi=='unknown') {
print "
******************************************************************************
WARNING! We found php.exe under $php_bin, it uses an $php_bin_sapi SAPI.
PEAR commandline tool has not been tested with it.
If you have a CLI (or CGI) php.exe available, we strongly recommand to use it.
";
}
echo "php.exe (sapi: $php_bin_sapi) found.\n\n";
$php_bin_set = true;
} else {
echo "**ERROR**: no php.exe found in this folder.\n";
$tmp='';
}
}
if (!empty($tmp) ) {
$$var = $tmp;
}
} elseif ($tmp == 'all') {
foreach ($config_vars as $n => $var) {
$desc = $config_desc[$var];
$current = $$var;
print "$desc [$current] : ";
$tmp = trim(fgets($tty, 1024));
if (!empty($tmp)) {
$$var = $tmp;
}
}
}
}
####
# Temp stuff
####
if (!empty($temp_dir)) {
$_found = temp_dir($temp_dir);
} else {
$_found = temp_dir();
}
if (!$_found) {
print "
******************************************************************************
FATAL ERROR! We cannot initialize the temp directory. Please be sure to give
full write access to this directory and the install directory.
";
if (!empty($temp_dir)) {
print "'$temp_dir' was given.";
}
exit();
}
$foo = $ptmp;
if (WINDOWS) {
$ptmp = str_replace($foo,'',$ptmp);
$foo = str_replace("\\\\",'/',$foo);
$s = substr($ptmp,0,1);
if($s == "\\" || $s == '/' ){
$ptmp = $foo . '/' . substr($ptmp,1);
} else {
$ptmp = $foo . '/' . $ptmp;
}
}
rm_rf($ptmp);
mkdir_p($ptmp, 0700);
$ok = @chdir($ptmp);
if (!preg_match('/_dir$/', $var)) {
continue;
}
if (!@is_dir($dir)) {
if (!mkdir_p($dir)) {
$root = WINDOWS ? 'administrator' : 'root';
bail("Unable to create {$config_desc[$var]} $dir.
Run this script as $root or pick another location.\n");
}
}
}
if (!WEBINSTALLER) {
$msg = "The following PEAR packages are bundled with PHP: " .
implode(', ', $pfc_packages);
print "\n" . wordwrap($msg, 75) . ".\n";
print "Would you like to install these as well? [Y/n] : ";
$install_pfc = !stristr(fgets($tty, 1024), "n");
print "\n";
}
####
# Download
####
set_include_path($ptmp);
if (!$have_gzip) {
print "Downloading uncompressed packages\n";
};
if ($install_pfc) {
$to_install = array_merge($installer_packages, $pfc_packages);
} else {
$to_install = $installer_packages;
}
displayHTMLProgress($progress = 5);
if (file_exists(dirname(__FILE__).'/go-pear-bundle') ||
is_dir(dirname(__FILE__).'/go-pear-bundle')) {
$dh = @opendir(dirname(__FILE__).'/go-pear-bundle');
} else {
$dh = false;
}
$local_dir = array();
if ($dh) {
while($file = @readdir($dh)) {
if ($file == '.' || $file == '..' || !is_file(dirname(__FILE__).'/go-pear-
bundle/'.$file)) {
continue;
}
$file_pkg = substr($file, 0, strpos($file, '-'));
$local_dir[$file_pkg] = $file;
}
}
$url = 'http://cvs.php.net/viewcvs.cgi/pear-core/PEAR.php?view=co&pathrev=' .
$rev;
if (in_array('PEAR.php', $local_dir)) {
copy(dirname(__FILE__).'/go-pear-bundle/PEAR.php', 'PEAR.php');
echo "(local) ";
} else {
download_url($url, 'PEAR.php', $http_proxy);
echo "(remote) ";
}
include_once 'PEAR.php';
print "ok\n";
if (in_array('Tar.php', $local_dir)) {
copy(dirname(__FILE__).'/go-pear-bundle/Tar.php', 'Archive/Tar.php');
echo "(local) ";
} else {
download_url($url, 'Archive/Tar.php', $http_proxy);
echo "(remote) ";
}
print "ok\n";
if ($install_pfc) {
foreach ($pfc_packages as $pkg) {
foreach($local_dir as $file) {
if (substr($file, 0, strlen($pkg)) == $pkg) {
echo str_pad("Using local package: $pkg",
max(38,21+strlen($pkg)+4), '.');
copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file);
$tarball[$pkg] = $file;
echo "ok\n";
displayHTMLProgress($progress += round(65 / count($to_install)));
continue 2;
};
};
displayHTMLProgress($progress = 70);
PEAR::setErrorHandling(PEAR_ERROR_DIE, "\n%s\n");
print 'Extracting installer..................';
$dot = strrpos($tarball['PEAR'], '.');
$pkg = substr($tarball['PEAR'], 0, $dot);
$ext = substr($tarball['PEAR'], $dot + 1);
include_once 'Archive/Tar.php';
include_once "PEAR.php";
include_once "PEAR/Config.php";
include_once "PEAR/Command.php";
include_once "PEAR/Registry.php";
$config->set('preferred_state', 'stable');
foreach ($config_vars as $var) {
$config->set($var, $$var);
}
$config->set('download_dir', $temp_dir . '/download');
$config->set('temp_dir', $temp_dir);
$config->store();
$install_options = array(
'nodeps' => true,
'force' => true,
);
displayHTMLProgress($progress = 99);
ini_restore("include_path");
if (!WEBINSTALLER) {
$sep = WINDOWS ? ';' : ':';
$include_path = explode($sep, ini_get('include_path'));
if (WINDOWS) {
$found = false;
$t = strtolower($php_dir);
foreach($include_path as $path) {
if ($t==strtolower($path)) {
$found = true;
break;
}
}
} else {
$found = in_array($php_dir, $include_path);
}
if (!$found) {
print "
******************************************************************************
WARNING! The include_path defined in the currently used php.ini does not
contain the PEAR PHP directory you just specified:
<$php_dir>
If the specified directory is also not in the include_path used by
your scripts, you will have problems getting any PEAR packages working.
";
if ( $php_ini = getPhpiniPath() ) {
print "\n\nWould you like to alter php.ini <$php_ini>? [Y/n] : ";
$alter_phpini = !stristr(fgets($tty, 1024), "n");
if( $alter_phpini ) {
alterPhpIni($php_ini);
} else {
if (WINDOWS) {
print "
Please look over your php.ini file to make sure
$php_dir is in your include_path.";
} else {
print "
I will add a workaround for this in the 'pear' command to make sure
the installer works, but please look over your php.ini or Apache
configuration to make sure $php_dir is in your include_path.
";
}
}
}
print "
Current include path : ".ini_get('include_path')."
Configured directory : $php_dir
Currently used php.ini (guess) : $php_ini
";
// check that the installed pear and the one in tha path are the same (if any)
$pear_old = which(WINDOWS ? 'pear.bat' : 'pear', $bin_dir);
if ($pear_old && ($pear_old != $pear_cmd)) {
// check if it is a link or symlink
$islink = WINDOWS ? false : is_link($pear_old) ;
if ($islink && readlink($pear_old) != $pear_cmd) {
print "\n** WARNING! The link $pear_old does not point to the " .
"installed $pear_cmd\n";
} elseif (is_writable($pear_old) && !is_dir($pear_old)) {
rename($pear_old, "{$pear_old}_old");
print "\n** WARNING! Backed up old pear to {$pear_old}_old\n";
} else {
print "\n** WARNING! Old version found at $pear_old, please remove it
or ".
"be sure to use the new $pear_cmd command\n";
}
}
";
print "Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.
http://pear.php.net/faq.php
http://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt?p=1
http://pear.php.net/manual/
";
}
}
if (WEBINSTALLER) {
print "Writing WebFrontend file ... ";
@unlink($webfrontend_file); //Delete old one
copy ( $doc_dir.DIRECTORY_SEPARATOR.
'PEAR_Frontend_Web'.DIRECTORY_SEPARATOR.
'docs'.DIRECTORY_SEPARATOR.
'example.php',
$webfrontend_file
);
if ($_GET['step'] == 'install-progress') {
displayHTMLProgress($progress = 100);
ob_end_clean();
displayHTMLInstallationSummary();
displayHTMLFooter();
} else {
$out = ob_get_contents();
displayHTML('install', $out);
}
// Little hack, this will be fixed in PEAR later
if ( WINDOWS ) {
clearstatcache();
@unlink($bin_dir.DIRECTORY_SEPARATOR.'.tmppear');
}
exit;
}
// {{{ download_url()
if ($content_length) {
displayHTMLSetDownload($destfile);
};
$wp = fopen($destfile, "wb");
if (!$wp) {
bail("could not open $destfile for writing\n");
}
$bytes_read = 0;
$progress = 0;
while ($data = fread($fp, 2048)) {
fwrite($wp, $data);
$bytes_read += strlen($data);
if ($content_length != 0 && floor($bytes_read * 10 / $content_length) !=
$progress) {
$progress = floor($bytes_read * 10 / $content_length);
displayHTMLDownloadProgress($progress * 10);
};
}
fclose($fp);
fclose($wp);
return $destfile;
}
// }}}
// {{{ which()
// }}}
// {{{ bail()
// }}}
// {{{ mkdir_p()
$parent = dirname($dir);
$ok = true;
if (!@is_dir($parent) && $parent != $dir) {
$ok = mkdir_p(dirname($dir), $mode);
}
if ($ok) {
$ok = @mkdir($dir, $mode);
if (!$ok) {
print "mkdir failed: <$dir>\n";
}
}
return $ok;
}
// }}}
// {{{ rm_rf()
function rm_rf($path)
{
if (@is_dir($path) && is_writable($path)) {
$dp = opendir($path);
while ($ent = readdir($dp)) {
if ($ent == '.' || $ent == '..') {
continue;
}
$file = $path . DIRECTORY_SEPARATOR . $ent;
if (@is_dir($file)) {
rm_rf($file);
} elseif (is_writable($file)) {
unlink($file);
} else {
echo $file . "is not writable and cannot be removed.
Please fix the permission or select a new path.\n";
}
}
closedir($dp);
return rmdir($path);
} else {
return @unlink($path);
}
}
// }}}
// {{{ tmpdir()
/*
* Fixes for winXP/wrong tmp set by Urs Gehrig ([email protected])
*/
function temp_dir($default=false)
{
global $ptmp, $prefix;
if ($default) {
if (!@is_dir($default)) {
if (!mkdir_p($default)) {
return false;
}
}
$_temp = false;
if (WINDOWS){
if ( my_env('TEMP') ) {
$_temp = my_env('TEMP');
} elseif ( my_env('TMP') ) {
$_temp = my_env('TMP');
} elseif ( my_env('windir') ) {
$_temp = my_env('windir') . '\temp';
} elseif ( my_env('SystemRoot') ) {
$_temp = my_env('SystemRoot') . '\temp';
}
rm_rf($_temp);
mkdir_p($_temp, 0700);
$ok = @chdir($ptmp);
print "ok\n";
// }}}
// {{{ my_env()
/*
(cox) In my system PHP 4.2.1 (both cgi & cli) $_ENV is empty
but getenv() does work fine
*/
function my_env($var)
{
if (is_array($_ENV) && isset($_ENV[$var])) {
return $_ENV[$var];
}
return getenv($var);
}
// }}}
// {{{ detect_install_dirs()
if (!@is_dir($prefix)) {
if (@is_dir('c:\php5')) {
$prefix = 'c:\php5';
} elseif (@is_dir('c:\php4')) {
$prefix = 'c:\php4';
} elseif (@is_dir('c:\php')) {
$prefix = 'c:\php';
}
}
$bin_dir = '$prefix';
$php_dir = '$prefix\pear';
$doc_dir = '$php_dir\docs';
$data_dir = '$php_dir\data';
$test_dir = '$php_dir\tests';
$temp_dir = '$prefix\temp';
/*
* Detects php.exe
*/
if( $t=getenv('PHP_PEAR_PHP_BIN') ){
$php_bin = $t;
} elseif ($t=getenv('PHP_BIN') ) {
$php_bin = $t;
} elseif ( $t=which('php') ) {
$php_bin = $t;
} elseif ( is_file($prefix.'\cli\php.exe') ) {
$php_bin = $prefix.'\cli\php.exe';
} elseif ( is_file($prefix.'\php.exe') ) {
$php_bin = $prefix.'\php.exe';
}
if( $php_bin && !is_file($php_bin) ){
$php_bin = '';
} else {
if(!ereg(":",$php_bin)){
$php_bin = getcwd().DIRECTORY_SEPARATOR.$php_bin;
}
}
if (!is_file($php_bin)) {
if (is_file('c:/php/cli/php.exe')) {
$php_bin = 'c:/php/cli/php.exe';
} elseif (is_file('c:/php5/php.exe')) {
$php_bin = 'c:/php5/php.exe';
} elseif (is_file('c:/php4/cli/php.exe')) {
$php_bin = 'c:/php4/cli/php.exe';
}
}
} else {
if ($_prefix === null) {
$prefix = dirname(PHP_BINDIR);
} else {
$prefix = $_prefix;
}
$bin_dir = '$prefix/bin';
$php_dir = '$prefix/share/pear';
$doc_dir = '$php_dir/docs';
$data_dir = '$php_dir/data';
$test_dir = '$php_dir/tests';
$temp_dir = '$prefix/temp';
// check if the user has installed PHP with PHP or GNU layout
if (@is_dir("$prefix/lib/php/.registry")) {
$php_dir = '$prefix/lib/php';
} elseif (@is_dir("$prefix/share/pear/lib/.registry")) {
$php_dir = '$prefix/share/pear/lib';
$doc_dir = '$prefix/share/pear/docs';
$data_dir = '$prefix/share/pear/data';
$test_dir = '$prefix/share/pear/tests';
} elseif (@is_dir("$prefix/share/php/.registry")) {
$php_dir = '$prefix/share/php';
}
}
}
// }}}
// {{{ displayHTMLHeader
function displayHTMLHeader()
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>PEAR :: Installer :: Go-PEAR</title>
<style type="text/css">
<!--
a {
color:#000000;
text-decoration: none;
}
a:visited {
color:#000000;
text-decoration: none;
}
a:active {
color:#000000;
text-decoration: none;
}
a:hover {
color:#000000;
text-decoration: underline;
}
a.green {
color:#006600;
text-decoration: none;
}
a.green:visited {
color:#006600;
text-decoration: none;
}
a.green:active {
color:#006600;
text-decoration: none;
}
a.green:hover {
color:#006600;
text-decoration: underline;
}
body, td, th {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 90%;
}
p {
font-family: verdana,arial,helvetica,sans-serif;
}
th.pack {
color: #FFFFFF;
background: #009933;
text-align: right;
}
td.package_info_title {
color: #006600;
font-weight: bold;
}
th.others {
color: #006600;
text-align: left;
}
em {
font-weight: bold;
font-style: italic;
}
.green {
color: #006600;
}
.red {
color: #006600;
}
span.headline {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 125%;
font-weight: bold;
color: #ffffff;
}
span.title {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 110%;
font-weight: bold;
color: #006600;
}
.newsDate {
font-size: 85%;
font-style: italic;
color: #66cc66;
}
.compact {
font-family: arial, helvetica, sans-serif;
font-size: 90%;
}
.menuWhite {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 75%;
color: #ffffff;
}
.menuBlack {
font-family: verdana,arial,helvetica,sans-serif;
text-decoration: none;
font-weight: bold;
font-size: 75%;
color: #000000;
}
.sidebar {
font-size: 85%;
}
code, pre, tt {
font-family: Courier, "Courier New", monospace;
font-size: 90%;
}
pre.php {
border-color: black;
border-style: dashed;
border-width: 1px;
background-color: #eeeeee;
padding: 5px;
}
h1 {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 140%;
font-weight: bold;
color: #006600;
}
h2 {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 125%;
font-weight: bold;
color: #006600;
}
h3 {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 110%;
font-weight: bold;
color: #006600;
}
small {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 75%;
}
a.small {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 75%;
text-decoration: none;
}
.tableTitle {
font-family: verdana,arial,helvetica,sans-serif;
font-weight: bold;
}
.tableExtras {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 85%;
color: #FFFFFF;
}
input {
font-family: verdana,arial,helvetica,sans-serif;
}
textarea {
font-family: verdana,arial,helvetica,sans-serif;
}
input.small, select.small {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 75%;
}
textarea.small {
font-family: verdana,arial,helvetica,sans-serif;
font-size: 75%;
}
form {
margin-bottom : 0;
}
-->
</style>
<meta name="description" content="This is the Web Interface of the PEAR
Installer" />
</head>
// }}}
// {{{ displayHTML
displayHTMLHeader();
?>
<a name="TOP" /></a>
<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
<tr bgcolor="#339900">
<td align="left" width="120">
<img src="<?php echo basename(__FILE__); ?>?action=img&img=pearlogo"
width="104" height="50" vspace="2" hspace="5" alt="PEAR">
</td>
<td align="left" valign="middle" width="20">
</td>
<td align="left" valign="middle">
<span class="Headline">Go-PEAR</span>
</td>
</tr>
<tr bgcolor="#006600">
<td align="right" valign="top" colspan="3">
<span style="color: #ffffff">Version <?php echo GO_PEAR_VER; ?
></span> <br />
</td>
</tr>
</td>
</tr>
</table>
</td>
<td bgcolor="#cccccc" width="1" background="/gifs/checkerboard.gif"></td>
<td>
<table width="100%" cellpadding="10" cellspacing="0">
<tr>
<td valign="top">
<table border="0">
<tr>
<td width="20">
</td>
<td>
<?php
if ($page == 'error') {
?>
<span class="title">Error</span><br/>
<br/>
<?php
$value = $data;
if (preg_match('/ok$/', $value)) {
$value = preg_replace('/(ok)$/', '<span class="green">\1</span>',
$value);
}
if (preg_match('/failed$/', $value)) {
$value = preg_replace('/(failed)$/', '<span style="color:
#ff0000">\1</span>', $value);
}
if (preg_match('/^install ok:/', $value)) {
$value = preg_replace('/^(install ok:)/', '<span
class="green">\1</span>', $value);
}
if (preg_match('/^Warning:/', $value)) {
$value = '<span style="color: #ff0000">'.$value.'</span>';
}
echo nl2br($value);
} elseif ($page == 'Welcome') {
?>
<span class="title">Welcome to go-pear <?php echo GO_PEAR_VER; ?
>!</span><br/>
<br/>
Go-pear will install the Web Frontend of the PEAR Installer and all
the needed <br/>
files. This frontend is your tool for PEAR installation and
maintenance.<br/>
<br/>
Go-pear also lets you download and install the PEAR packages
bundled<br/>
with PHP: <?php echo implode(', ', $GLOBALS['pfc_packages']); ?>.<br/>
<br/>
<a href="<?php echo basename(__FILE__); ?>?step=config"
class="green">Next >></a>
<?php
} elseif ($page == 'config') {
if (!empty($GLOBALS['http_proxy'])) {
list($proxy_host, $proxy_port) = explode(':', $GLOBALS['http_proxy']);
} else {
$proxy_host = $proxy_port = '';
}
?>
<form action="<?php echo basename(__FILE__);?>?step=install"
method="post">
<span class="title">Configuration</span><br/>
<br/>
HTTP proxy (host:port):
<input type="text" name="proxy[host]" value="<?php echo
$proxy_host;?>">
<input type="text" name="proxy[port]" value="<?php echo
$proxy_port;?>" size="6">
<br/><br/><hr/><br/>
Below is a suggested file layout for your new PEAR installation. <br/>
<br/>
<table border="0">
<TR>
<TD valign="top"><img src="<?php echo basename(__FILE__); ?
>?action=img&img=note" border="0"></TD>
<TD>
<span class="green">
<b>Note:</b> Make sure that PHP has the permission to access
the specified<br/>
directories.<br/><br/>
</span>
</TD>
</TR>
</table>
<TABLE border="0">
<?php
// Display error messages
if (isset($GLOBALS['www_errors']) && sizeof($GLOBALS['www_errors']) ) {
$www_errors = $GLOBALS['www_errors'];
echo "<tr><td>";
echo '<span class="red">ERROR(S):</span>';
echo "</td></tr>";
foreach ($www_errors as $n => $var) {
echo "<tr><td>";
echo '<span class="red">'.$GLOBALS['config_desc'][$n].': </span>';
echo "</td><td>";
echo '<span class="red">'.$www_errors[$n].'</span>';
echo "<br>\n";
echo "</td></tr>\n";
}
}
<?php
if (WINDOWS && phpversion() == '4.1.1') {
?>
<table border="0">
<TR>
<TD valign="top"><img src="<?php echo
basename(__FILE__); ?>?action=img&img=note" border="0"></TD>
<TD>
<span style="color: #ff0000">
<b>Warning:</b> Your PHP version (4.1.1) might be
imcompatible with go-pear due to a bug<br/>
in your PHP binary. If the installation crashes you
might want to update your PHP version.</br>
</span>
</TD>
</TR>
</table>
<?php
}
?>
<br/>
<input type="submit" value="Install" onClick="javascript:
submitButton.value='Downloading and installing ... please wait ...'"
name="submitButton">
</form>
<?php
} elseif ($page == 'install') {
?>
<span class="title">Installation Complete - Summary</span><br/>
<?php
displayHTMLInstallationSummary($data);
} elseif ($page == 'preinstall') {
?>
<span class="title">Installation in progress ...</span><br/>
<br/>
<script language="javascript">
<!--
var progress;
var downlodprogress;
progress = 0;
downloadprogress = 0;
function setprogress(value)
{
progress = value;
prog = document.getElementById('installation_progress');
prog.innerHTML = progress + " %";
progress2 = progress / 10;
progress2 = Math.floor(progress2);
for (i=0; i < 10; i++)
document.getElementById('progress_cell_'+i).style.backgrou
ndColor = "#cccccc";
switch(progress2)
{
case 10:
document.getElementById('progress_cell_9').style.backg
roundColor = "#006600";
case 9:
document.getElementById('progress_cell_8').style.backg
roundColor = "#006600";
case 8:
document.getElementById('progress_cell_7').style.backg
roundColor = "#006600";
case 7:
document.getElementById('progress_cell_6').style.backg
roundColor = "#006600";
case 6:
document.getElementById('progress_cell_5').style.backg
roundColor = "#006600";
case 5:
document.getElementById('progress_cell_4').style.backg
roundColor = "#006600";
case 4:
document.getElementById('progress_cell_3').style.backg
roundColor = "#006600";
case 3:
document.getElementById('progress_cell_2').style.backg
roundColor = "#006600";
case 2:
document.getElementById('progress_cell_1').style.backg
roundColor = "#006600";
case 1:
document.getElementById('progress_cell_0').style.backg
roundColor = "#006600";
};
}
function addprogress(value)
{
progress += value;
setprogress(progress);
}
function setdownloadfile(value)
{
setdownloadprogress(0);
prog = document.getElementById('download_file');
prog.innerHTML = 'Downloading '+value+' ...';
};
function setdownloadprogress(value)
{
downloadprogress = value;
prog = document.getElementById('download_progress');
prog.innerHTML = downloadprogress + " %";
progress2 = downloadprogress / 10;
progress2 = Math.floor(progress2);
for (i=0; i < 10; i++)
document.getElementById('download_progress_cell_'+i).style
.backgroundColor = "#cccccc";
switch(progress2)
{
case 10:
document.getElementById('download_progress_cell_9').st
yle.backgroundColor = "#006600";
case 9:
document.getElementById('download_progress_cell_8').st
yle.backgroundColor = "#006600";
case 8:
document.getElementById('download_progress_cell_7').st
yle.backgroundColor = "#006600";
case 7:
document.getElementById('download_progress_cell_6').st
yle.backgroundColor = "#006600";
case 6:
document.getElementById('download_progress_cell_5').st
yle.backgroundColor = "#006600";
case 5:
document.getElementById('download_progress_cell_4').st
yle.backgroundColor = "#006600";
case 4:
document.getElementById('download_progress_cell_3').st
yle.backgroundColor = "#006600";
case 3:
document.getElementById('download_progress_cell_2').st
yle.backgroundColor = "#006600";
case 2:
document.getElementById('download_progress_cell_1').st
yle.backgroundColor = "#006600";
case 1:
document.getElementById('download_progress_cell_0').st
yle.backgroundColor = "#006600";
};
};
// -->
</script>
<table style="border-width: 1px; border-color: #000000"
cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0">
<tr>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_0"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_1"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_2"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_3"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_4"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_5"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_6"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_7"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_8"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="progress_cell_9"> </td>
<td bgcolor="#ffffff" width="10" height="20"> </td>
<td bgcolor="#ffffff" height="20" id="installation_progress"
class="green">0 %</td>
</tr>
</table>
<br>
<table border="0">
<tr>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_0"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_1"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_2"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_3"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_4"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_5"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_6"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_7"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_8"> </td>
<td bgcolor="#cccccc" width="10" height="20"
id="download_progress_cell_9"> </td>
<td bgcolor="#ffffff" width="10" height="20"> </td>
<td bgcolor="#ffffff" height="20" id="download_progress"
class="green">0 %</td>
<td bgcolor="#ffffff" width="10" height="20"> </td>
<td bgcolor="#ffffff" height="20" id="download_file"
class="green"></td>
</tr>
</table>
<br>
<iframe src="<?php echo basename(__FILE__); ?>?step=install-
progress&<?php echo SID;?>" width="700" height="700" frameborder="0"
marginheight="0" marginwidth="0"></iframe>
</td>
</tr>
</table>
<?php
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
displayHTMLFooter();
}
// }}}
// {{{ displayHTMLFooter
function displayHTMLFooter()
{
?>
</body>
</html>
<?php
};
// }}}
// {{{ displayHTMLInstallationSummary
if ($data) {
echo "<br/>".$data;
}
?>
<br/>
<table border="0">
<TR>
<TD valign="top"><img src="<?php echo basename(__FILE__); ?
>?action=img&img=note" border="0"></TD>
<TD>
<span class="green">
<b>Note:</b> To use PEAR without any problems you need to add
your<br/>
PEAR Installation path (<?php echo $GLOBALS['php_dir']; ?>)<br>
to your <a
href="http://www.php.net/manual/en/configuration.directives.php#ini.include_path">
include_path</a>.<br/>
<br/>
Using a .htaccess file or directly edit httpd.conf would be
working solutions<br/>
for Apache running servers, too.<br/>
</span>
</TD>
</TR>
</table>
<br/>
For more information about PEAR, see:<br/>
<a href="http://pear.php.net/faq.php" target="_new" class="green">PEAR
FAQ</a><br/>
<a href="http://pear.php.net/manual/" target="_new" class="green">PEAR
Manual</a><br/>
<br/>
Thanks for using go-pear!<br/>
<br/>
<?php
if ($next === NULL) {
?>
<table border="0">
<TR>
<TD valign="top"><img src="<?php echo
basename(__FILE__); ?>?action=img&img=note" border="0"></TD>
<TD>
<span style="color: #ff0000">
<b>Warning:</b> Go-PEAR was not able to determine the
URL to the newly<br/>
installed Web Frontend of the PEAR Installer. Please
access it manually.<br/>
Since you specified the prefix, you should know how to
do so.<br/>
</span>
</TD>
</TR>
</table>
<?php
} else {
if ($_GET['step'] == 'install-progress') {
?>
<a href="<?php echo $next;?>" class="green"
target="_parent">Start Web Frontend of the PEAR Installer >></a>
<?php
} else {
?>
<a href="<?php echo $next;?>" class="green">Start Web
Frontend of the PEAR Installer >></a>
<?php
}
}
}
// }}}
// {{{ strip_magic_quotes
function strip_magic_quotes($value)
{
if (ini_get('magic_quotes_gpc')) {
return stripslashes($value);
}
return $value;
};
// }}}
// {{{ showImage
function showImage($img)
{
$images = array(
'smallpear' => array(
'type' => 'gif',
'data' =>
'R0lGODlhEQATAMQAAAAAACqUACiTAC2WAC+YAzKZBTSaBsHgszOZADCYADmcB4TCZp3Ohtfrzd/v1+by4
PD47DaaAz+fDUijF2WyOlCoHvT58VqtJPn893y+S/v9+f7//f3+/Pz9+////////ywAAAAAEQATAAAFkqA
njiR5NGXqcdpCoapnMVRdWbEHUROVVROYalHJTCaVAKWTcjAUGckgQY04SJAFMhJJIL5e4a5I6X6/gwlkR
IwOzucAY9SYZBRvOCKheIwYFxR5enxCLhVeemAHbBQVg4SMIoCCinsKVyIOdlKKAhQcJFpGiWgFQiIYPxe
JCQEEcykcDIgDAwYUkjEWB70NGykhADs=',
),
'pearlogo' => array(
'type' => 'gif',
'data' =>
'R0lGODlhaAAyAMT/AMDAwP3+/TWaAvD47Pj89vz++zebBDmcBj6fDEekFluvKmu3PvX68ujz4XvBS8Lgr
NXqxeHw1ZnPaa/dgvv9+cLqj8LmltD2msnuls3xmszwmf7+/f///wAAAAAAAAAAACH5BAEAAAAALAAAAAB
oADIAQAX/ICCOZGmeaKqubOtWWjwJphLLgH1XUu//C1Jisfj9YLEKQnSY3GaixWQqQTkYHM4AMulNLJFC9
pEwIW/odKU8cqTfsWoTTtcomU4ZjbR4ZP+AgYKCG0EiZ1AuiossEhwEXRMEg5SVWQ6MmZqKWD0QlqCUEHu
bpaYlExwRPRZioZZVp7KzKQoSDxANDLsNXA5simd2FcQYb4YAc2jEU80TmAAIztPCMcjKdg4OEsZJmwIWW
QPQI4ikIwtoVQnddgrv8PFlCWgYCwkI+fp5dkvJ/IlUKMCy6tYrDhNIIKLFEAWCTxse+ABD4SClWA0zovA
jcUJFi6EwahxZwoGqHhFA/4IqoICkyxQSKkbo0gDkuBXV4FRAJkRCnTgi2P28IcEfk5xpWppykFJVuScmE
vDTEETAVJ6bEpypcADPkz3pvKVAICHChkC7siQ08zVqu4Q6hgIFEFZuEn/KMgRUkaBmAQs+cEHgIiHVH5E
AFpIgW4+NT6LnaqhDwe/Ov7YOmWZp4MkiAWBIl0kAVsJWuzcYpdiNgddc0E8cKBAu/FElBwagMb88ZZKDR
AkWJtkWhHh3wwUbKHQJN3wQAaXGR2LpArv5oFHRR34C7Mf6oLXZNfqBgNI7oOLhj1f8PaGpygHQ0xtP8MD
VKwYTSKcgxr9/hS6/pCCAAg5M4B9/sWh1YP9/XSgQWRML/idBfKUc4IBET9lFjggKhDYZAELZJYEBI2BDB
3ouNBEABwE8gAwiCcSYgAKqPdEVAG7scM8BPPZ4AIlM+OgjAgpMhRE24OVoBwsIFEGFA7ZkQQBWienWxmR
a7XDjKZXhBdAeSmKQwgLuUVLICa6VEKIGcK2mQWoVZHCBXJblJUFkY06yAXlGsPIHBEYdYiWHb+WQBgaIJ
qqoHFNpgMGB7dT5ZQuG/WbBAIAUEEFNfwxAWpokTIXJAWdgoJ9kRFG2g5eDRpXSBpEIF0oEQFaZhDbaSFA
NRgqcJoEDRARLREtxOQpsPO906ZUeJgjQB6dZUPBAdwcF8KLXXRVQaKFcsRRLJ6vMiiCNKxRE8ECZKgUA3
Va4arOAAqdGRWO7uMZH5AL05gvsjQbg6y4NCjQ1kw8TVGcbdoKGKx8j3bGH7nARBArqwi0gkFJBrZiXBQR
bHoIgnhSjcEBKfD7c3HMhz+JIQSY3t8GGKW+SUhfUajxGzKd0IoHBNkNQK86ZYEqdzYA8AHQpqXRUm80oH
s1CAgMoBxzRqvzs9CIKECC1JBp7enUpfXHApwVYNAfo16c4IrYPLVdSAJVob7IAtCBFQGHcs/RRdiUDPHA
33oADEAIAOw==',
),
'note' => array(
'type' => 'png',
'data' =>
'iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAAAAADFHGIkAAAAAmJLR0QAAKqNIzIAAAEESURBVHjaZZIhk
sMwDEV9voWFSwsLA0MLDf8VdARBUUNBQ1FBHcErZ5M0baXJjOPnb0vfLuMMn3H+lWMgBKL89A1Eq9Q9Irw
B+gIOsnMPBR8giMclguQfBGS8x5xIoPQxnxqb4LL/eQ4l2AVNONP2ZshLCqJ3qqzWtT5pNgNnLU4OcNbui
qaLmFmHGhJ0TCMC99+f2wphlhaOYjuQVc0IIzLH2BRWfQoWsNSjct8AVop4rF3belTuVAb3MRj6kLrcTwt
Iy+g03V1vC57t1XrMzqfP5pln5yLTkk7+5UhstvOni1X3ixLEdf2c36+W0Q7kOb48hnSRLI/XdNPfX4kpM
kgP5R+elfdkDPprQgAAAEN0RVh0U29mdHdhcmUAQCgjKUltYWdlTWFnaWNrIDQuMi44IDk5LzA4LzAxIGN
yaXN0eUBteXN0aWMuZXMuZHVwb250LmNvbZG6IbgAAAAqdEVYdFNpZ25hdHVyZQAzYmQ3NDdjNWU0NTgwN
zAwNmIwOTBkZDNlN2EyNmM0NBTTk/oAAAAOdEVYdFBhZ2UAMjR4MjQrMCswclsJMQAAAABJRU5ErkJggg=
=',
),
);
Header('Content-Type: image/'.$images[$img]['type']);
echo base64_decode($images[$img]['data']);
};
// }}}
// {{{ displayHTMLProgress
function displayHTMLProgress($progress)
{
if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-
pear']['DHTML'])) {
return;
};
$msg = ob_get_contents();
ob_end_clean();
echo $msg;
ob_start();
};
// }}}
// {{{ displayHTMLDownloadProgress
function displayHTMLDownloadProgress($progress)
{
if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-
pear']['DHTML'])) {
return;
};
$msg = ob_get_contents();
ob_end_clean();
// }}}
// {{{ displayHTMLSetDownload
function displayHTMLSetDownload($file)
{
if (!(WEBINSTALLER && isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-
pear']['DHTML'])) {
return;
};
$msg = ob_get_contents();
ob_end_clean();
ob_start();
echo $msg;
};
// }}}
// {{{ win32BrowseForFolder
/*
* Create a vbs script to browse the getfolder dialog, called
* by cscript, if it's available.
* $label is the label text in the header of the dialog box
*
* TODO:
* - Do not show Control panel
* - Replace WSH with calls to w32 as soon as callbacks work
* @Author Pierrre-Alain Joye
*/
function win32BrowseForFolder($label)
{
global $ptmp;
static $wshSaved=false;
static $cscript='';
$wsh_browserfolder = 'Option Explicit
Dim ArgObj, var1, var2, sa, sFld
Set ArgObj = WScript.Arguments
Const BIF_EDITBOX = &H10
Const BIF_NEWDIALOGSTYLE = &H40
Const BIF_RETURNONLYFSDIRS = &H0001
Const BIF_DONTGOBELOWDOMAIN = &H0002
Const BIF_STATUSTEXT = &H0004
Const BIF_RETURNFSANCESTORS = &H0008
Const BIF_VALIDATE = &H0020
Const BIF_BROWSEFORCOMPUTER = &H1000
Const BIF_BROWSEFORPRINTER = &H2000
Const BIF_BROWSEINCLUDEFILES = &H4000
Const OFN_LONGNAMES = &H200000
Const OFN_NOLONGNAMES = &H40000
Const ssfDRIVES = &H11
Const ssfNETWORK = &H12
Set sa = CreateObject("Shell.Application")
var1=ArgObj(0)
Set sFld = sa.BrowseForFolder(0, var1, BIF_EDITBOX + BIF_VALIDATE +
BIF_BROWSEINCLUDEFILES + BIF_RETURNFSANCESTORS+BIF_NEWDIALOGSTYLE , ssfDRIVES )
if not sFld is nothing Then
if not left(sFld.items.item.path,1)=":" Then
WScript.Echo sFld.items.item.path
Else
WScript.Echo "invalid"
End If
Else
WScript.Echo "cancel"
End If
';
if( !$wshSaved){
$cscript = $ptmp.DIRECTORY_SEPARATOR."bf.vbs";
$fh = fopen($cscript,"wb+");
fwrite($fh,$wsh_browserfolder,strlen($wsh_browserfolder));
fclose($fh);
$wshSaved = true;
}
exec('cscript '.$cscript.' "'.$label.'" //noLogo',$arPath);
if($arPath[0]=='' || $arPath[0]=='cancel'){
return '';
} elseif ($arPath[0]=='invalid') {
echo "Invalid Path.\n";
return '';
}
return $arPath[0];
}
// }}}
// {{{ win32CreateRegEnv
/*
* Generates a registry addOn for Win32 platform
* This addon set PEAR environment variables
* @Author Pierrre-Alain Joye
*/
function win32CreateRegEnv()
{
global $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir,
$temp_dir;
$nl = "\r\n";
$reg ='REGEDIT4'.$nl.
'[HKEY_CURRENT_USER\Environment]'.$nl.
'"PHP_PEAR_SYSCONF_DIR"="'.addslashes($prefix).'"'.$nl.
'"PHP_PEAR_INSTALL_DIR"="'.addslashes($php_dir).'"'.$nl.
'"PHP_PEAR_DOC_DIR"="'.addslashes($doc_dir).'"'.$nl.
'"PHP_PEAR_BIN_DIR"="'.addslashes($bin_dir).'"'.$nl.
'"PHP_PEAR_DATA_DIR"="'.addslashes($data_dir).'"'.$nl.
'"PHP_PEAR_PHP_BIN"="'.addslashes($php_bin).'"'.$nl.
'"PHP_PEAR_TEST_DIR"="'.addslashes($test_dir).'"'.$nl;
$fh = fopen($prefix.DIRECTORY_SEPARATOR.'PEAR_ENV.reg','wb');
if($fh){
fwrite($fh, $reg ,strlen($reg));
fclose($fh);
echo "
";
}
}
// }}}
// {{{ win32DetectPHPSAPI
/*
* Try to detect the kind of SAPI used by the
* the given php.exe.
* @Author Pierrre-Alain Joye
*/
function win32DetectPHPSAPI()
{
global $php_bin,$php_sapi_name;
if (WEBINSTALLER) {
return $php_sapi_name;
}
if($php_bin!=''){
exec($php_bin.' -v', $res);
if(is_array($res)) {
if( isset($res[0]) && strpos($res[0],"(cli)")) {
return 'cli';
}
if( isset($res[0]) && strpos($res[0],"cgi")) {
return 'cgi';
} else {
return 'unknown';
}
}
}
return 'unknown';
}
// }}}
// {{{ getPhpiniPath
/*
* Get the php.ini file used with the current
* process or with the given php.exe
*
* Horrible hack, but well ;)
*
* Not used yet, will add the support later
* @Author Pierre-Alain Joye <[email protected]>
*/
function getPhpiniPath()
{
$pathIni = get_cfg_var('cfg_file_path');
if( $pathIni && is_file($pathIni) ){
return $pathIni;
}
if( @is_file($php_ini) ){
return $php_ini;
}
// We re running in hackz&troubles :)
ob_implicit_flush(false);
ob_start();
phpinfo(INFO_GENERAL);
$strInfo = ob_get_contents ();
ob_end_clean();
ob_implicit_flush(true);
if ( php_sapi_name() != 'cli' ) {
$strInfo = strip_tags($strInfo,'<td>');
$arrayInfo = explode("</td>", $strInfo );
$cli = false;
} else {
$arrayInfo = explode("\n",$strInfo);
$cli = true;
}
foreach($arrayInfo as $val){
if ( strpos($val,"php.ini") ) {
if($cli){
list(,$pathIni) = explode('=>',$val);
} else {
$pathIni = strip_tags(trim($val) );
}
$pathIni = trim($pathIni);
if(is_file($pathIni)){
return $pathIni;
}
}
}
return false;
}
// }}}
// {{{ alterPhpIni
/*
* Not optimized, but seems to work, if some nice
* peardev will test it? :)
*
* @Author Pierre-Alain Joye <[email protected]>
*/
function alterPhpIni($pathIni='')
{
global $php_dir, $prefix;
$iniSep = WINDOWS?';':':';
if( $pathIni=='' ){
$pathIni = getphpinipath();
}
$arrayIni = file($pathIni);
$i=0;
$found=0;
if ( $found ) {
$includeLine = $arrayIni[$foundAt[0]];
list(,$currentPath)=explode('=',$includeLine);
$currentPath = trim($currentPath);
if(substr($currentPath,0,1)=='"'){
$currentPath = substr($currentPath,1,strlen($currentPath)-2);
}
$arrayIni[$foundAt[0]] = $newInclude;
$newIni = implode("",$arrayIni);
if ( !($fh = @fopen($pathIni, "wb+")) ){
$prefixIni = $prefix.DIRECTORY_SEPARATOR."php.ini-gopear";
$fh = fopen($prefixIni, "wb+");
if ( !$fh ) {
echo
"
******************************************************************************
WARNING! I cannot write to $pathIni nor in $prefix/php.ini-gopear. Please
modify manually your php.ini by adding:
$includepath
";
return false;
} else {
fwrite($fh, $newIni, strlen($newIni));
fclose($fh);
echo
"
******************************************************************************
WARNING! I cannot write to $pathIni, but I succesfully created a php.ini
under <$prefix/php.ini-gopear>. Please replace the file <$pathIni> with
<$prefixIni> or modify your php.ini by adding:
$includepath
";
}
} else {
fwrite($fh, $newIni, strlen($newIni));
fclose($fh);
echo "
php.ini <$pathIni> include_path updated.
";
}
return true;
}