You can grant this permission by logging on to the server and issuing the following command:
+mkdir '.dirname($temp_dir).' && chmod 0777 '.dirname($temp_dir).'
You can grant this permission by logging on to the server and issuing the following command:
+chmod 0777 '.$temp_dir.'
You can grant this permission by logging on to the server and issuing the following command:
+mkdir '.dirname($dir).' && chmod 0777 '.dirname($dir).'
You can grant this permission by logging on to the server and issuing the following command:
+chmod 0777 '.$dir.'
You can grant this permission by logging on to the server and issuing the following command:
+chmod 0777 '.$dir.'
You can grant this permission by logging on to the server and issuing the following command:
+chmod 0777 '.$file.'
Can\'t use the \'~\' symbol for homedir substitution, write the directory out in full.
'); + } else { + die('Can\'t use the \'~\' symbol for homedir substitution, write the directory out in full.'); + } + } + return $dir; + } + + $home_root = $_ENV['HOME']; + // first strip last slash, if available + if (substr($home_root, -1) == DIRECTORY_SEPARATOR) { + $home_root = substr($home_root, 0, -1); + } + if (strpos($dir, '~/') === 0) { + // eg ~/ = /home/tias/ + $dir = substr_replace($dir, $home_root, 0, 1); + } elseif (strpos($dir, '~') === 0) { + // eg ~tias/ = /home/tias/ + // then delete user-dir + $home_root = dirname($home_root) . DIRECTORY_SEPARATOR; + $dir = substr_replace($dir, $home_root, 0, 1); + } + + return $dir; +} + + +// {{{ download_url() + +function download_url($url, $destfile = null, $proxy = null) +{ + $use_suggested_filename = ($destfile === null); + if ($use_suggested_filename) { + $destfile = basename($url); + } + $tmp = parse_url($url); + if (empty($tmp['port'])) { + $tmp['port'] = 80; + } + if (empty($proxy)) { + $fp = fsockopen($tmp['host'], $tmp['port'], $errno, $errstr); + //print "\nconnecting to $tmp[host]:$tmp[port]\n"; + } else { + $tmp_proxy = parse_url($proxy); + $phost = $tmp_proxy['host']; + $pport = $tmp_proxy['port']; + $fp = fsockopen($phost, $pport, $errno, $errstr); + //print "\nconnecting to $phost:$pport\n"; + } + if (!$fp) { + bail("download of $url failed: $errstr ($errno)\n"); + // If valid URL but error, no CURL extentions installed + } + if (empty($proxy)) { + $path = $tmp['path']; + } else { + $path = "http://$tmp[host]:$tmp[port]$tmp[path]"; + } + if (isset($tmp['query'])) { + $path .= "?$tmp[query]"; + } + if (isset($tmp['fragment'])) { + $path .= "#$tmp[fragment]"; + } + $request = "GET $path HTTP/1.0\r\nHost: $tmp[host]:$tmp[port]\r\n". + "User-Agent: go-pear\r\n"; + + if (!empty($proxy) && $tmp_proxy['user'] != '') { + $request .= 'Proxy-Authorization: Basic ' . + base64_encode($tmp_proxy['user'] . ':' . $tmp_proxy['pass']) . "\r\n"; + } + $request .= "\r\n"; + fwrite($fp, $request); + $cdh = "content-disposition:"; + $cdhl = strlen($cdh); + $content_length = 0; + while ($line = fgets($fp, 2048)) { + if (trim($line) == '') { + break; + } + if (preg_match('/^Content-Length: (.*)$/i', $line, $matches)) { + $content_length = trim($matches[1]); + } + if ($use_suggested_filename && !strncasecmp($line, $cdh, $cdhl)) { + if (eregi('filename="([^"]+)"', $line, $matches)) { + $destfile = basename($matches[1]); + } + } + } + + 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); + }; + } + displayHTMLDownloadProgress(100); + fclose($fp); + fclose($wp); + + displayHTMLSetDownload(''); + return $destfile; +} + +// }}} +// {{{ which() + +function which($program, $dont_search_in = false) +{ + if (WINDOWS) { + if ($_path=my_env('Path')) { + $dirs = explode(';', $_path); + } else { + $dirs = explode(';', my_env('PATH')); + } + foreach ($dirs as $i => $dir) { + $dirs[$i] = strtolower(realpath($dir)); + } + if ($dont_search_in) { + $dont_search_in = strtolower(realpath($dont_search_in)); + } + if ($dont_search_in && + ($key = array_search($dont_search_in, $dirs)) !== false) + { + unset($dirs[$key]); + } + + foreach ($dirs as $dir) { + $dir = str_replace('\\\\', '\\', $dir); + if (!strlen($dir)) { + continue; + } + if ($dir{strlen($dir) - 1} != '\\') { + $dir .= '\\'; + } + $tmp = $dir . $program; + $info = pathinfo($tmp); + if (in_array(strtolower($info['extension']), + array('exe', 'com', 'bat', 'cmd'))) { + if (file_exists($tmp)) { + return strtolower($tmp); + } + } elseif (file_exists($ret = $tmp . '.exe') || + file_exists($ret = $tmp . '.com') || + file_exists($ret = $tmp . '.bat') || + file_exists($ret = $tmp . '.cmd')) { + return strtolower($ret); + } + } + } else { + $dirs = explode(':', my_env('PATH')); + if ($dont_search_in && + ($key = array_search($dont_search_in, $dirs)) !== false) + { + unset($dirs[$key]); + } + foreach ($dirs as $dir) { + if (is_executable("$dir/$program")) { + return "$dir/$program"; + } + } + } + return false; +} + +// }}} +// {{{ bail() + +function bail($msg = '') +{ + global $ptmp, $origpwd; + if ($ptmp && is_dir($ptmp)) { + chdir($origpwd); + rm_rf($ptmp); + } + if ($msg && WEBINSTALLER) { + $msg = @ob_get_contents() ."\n\n". $msg; + @ob_end_clean(); + displayHTML('error', $msg); + exit; + }; + if ($msg && !WEBINSTALLER) { + die($msg); + } +} + +// }}} +// {{{ mkdir_p() + +function mkdir_p($dir, $mode = 0777) +{ + if (@is_dir($dir)) { + return true; + } + + $parent = dirname($dir); + $ok = true; + if (!@is_dir($parent) && $parent != $dir) { + $ok = mkdir_p(dirname($dir), $mode); + } + if ($ok) { + $ok = @mkdir($dir, $mode); + // This is handled in the caller function (eg. webfrontend or not) + //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 (urs@circle.ch) + */ +function temp_dir($default=false) +{ + global $ptmp, $prefix; + + if ($default) { + if (!@is_dir($default)) { + if (!mkdir_p($default)) { + return false; + } + } + + /* try it really, is_writable is buggy with openbasedir */ + $fh = @fopen(realpath($default) . "/test","wb"); + if ($fh) { + // desparately try to set temp dir any possible way, see bug #13167 + $ptmp = $_temp = $temp_dir = $default; + putenv('TMPDIR='.$default); + return true; + } else { + 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'; + } + + // handle ugly ENV var like \Temp instead of c:\Temp + $dirs = explode("\\", realpath($_temp)); + if(strpos($_temp, ":") != 1) { + unset($_temp); + $_dirs = array(); + foreach($dirs as $val) { + if((boolean)$val ) { + $_dirs[] = str_replace("/", "", $val); + } + } + unset($dirs); + $dirs = $_dirs; + array_unshift ($dirs, "c:" ); + $_temp = $dirs[0]; + for($i = 1;$i < count($dirs);$i++) { + $_temp .= "//" . $dirs[$i]; + } + } + $ptmp = $_temp; + } else { + $_temp = my_env('TMPDIR'); + if (!$_temp) { + if (is_writable('/tmp')) { + $_temp = '/tmp'; + } + } + } + + // If for some reason the user has no rights to access to + // the standard tempdir, we assume that he has the right + // to access his prefix and choose $prefix/tmp as tempdir + if (!$_temp || !is_writable($_temp)) { + print "System's Tempdir failed, trying to use \$prefix/tmp ..."; + $res = mkdir_p($prefix.'/tmp'); + if (!$res) { + bail('mkdir '.$prefix.'/tmp'.' ... failed'); + } + + $ptmp = $prefix . '/tmp'; + $_temp = tempnam($prefix.'/tmp', 'gope'); + + rm_rf($_temp); + mkdir_p($_temp, 0700); + $ok = @chdir($ptmp); + + if (!$ok) { // This should not happen, really ;) + bail('chdir '.$ptmp.' ... failed'); + } + + print "ok\n"; + + // Adjust TEMPDIR envvars + if (!isset($_ENV)) { + $_ENV = array(); + } + $_ENV['TMPDIR'] = $_ENV['TEMP'] = $prefix.'/tmp'; + } else { + $_temp = tempnam($_temp.'/tmp', 'gope'); + } + $temp_dir = $ptmp = $_temp; + return true; +} + +// }}} +// {{{ 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() + +function detect_install_dirs($_prefix = null) { + global $temp_dir, $prefix, $bin_dir, $php_dir, $php_bin, $doc_dir, $data_dir, $test_dir; + if (WINDOWS) { + if ($_prefix === null) { + $prefix = getcwd(); + } else { + $prefix = $_prefix; + } + + 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); + $prefix = dirname(__FILE__); + } else { + $prefix = $_prefix; + } + $bin_dir = '$prefix/bin'; + #$php_dir = '$prefix/share/pear'; + $php_dir = '$prefix/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() +{ +?> + + + +|
+ |
+ + + | ++ Go-PEAR Installer + | +
|
+ Version + |
+ ||
+
|
+ + |
+
|
+
+
+ Installation Completed ! +
+ +|
+
+ Note: To use PEAR without any problems you need to add your + PEAR Installation path () + to your include_path. + + Using a .htaccess file or directly edit httpd.conf would be working solutions + for Apache running servers, too. + + |
+
|
+
+ Warning: Can not determine the URL of the freshly installed Web Frontend + (file: ). + Please access it manually ! + + |
+