'CUBRID',*/ 'ibm_db2'=>'IBM DB2', 'interbase'=>'Firebird', 'mysql'=>'MySQL', 'mysqli'=>'MySQL Improved', 'oci8'=>'Oracle', 'pgsql'=>'PostgreSQL', 'sqlsrv' => 'SQL Server (Microsoft)', 'pdo_mysql'=>'PDO: MySQL', 'pdo_pgsql'=>'PDO: PostgreSQL', 'pdo_sqlite'=>'PDO: SQLite', 'pdo_sqlsrv'=>'PDO: SQL Server (Microsoft)');
foreach ($supported_databases as $driver => $name) {
if (!$module_status[$driver]) {
unset($supported_databases[$driver]); // Remove DBs that's not available.
}
}
return $supported_databases;
}
/** Create a directory.
* Basically the same as fud_mkdir() in include/fs.inc, but we need it before it can be included.
*/
function __mkdir($dir)
{
$u = umask(0);
if (@is_dir($dir)) {
return 1;
} else if (file_exists($dir)) {
unlink($dir);
}
$ret = (@mkdir($dir, 0755) || @mkdir(dirname($dir, 0755)));
umask($u);
return $ret;
}
function is_wr($path)
{
while ($path && $path != '/') {
if (@is_writeable($path)) {
return 1;
}
$path = dirname($path);
}
return 0;
}
function validate_url($url)
{
global $_POST;
if (!$url) {
return 0;
}
if (($u = @parse_url($url)) && isset($u['host'])) {
$_POST['WWW_ROOT'] = $url;
if (substr($_POST['WWW_ROOT'], -1) != '/') {
$_POST['WWW_ROOT'] .= '/';
}
$u['host'] = preg_replace('/[\[\]]/', '', $u['host']); // Remove IPv6 brackets. i.e. [::1]
if ($u['host'] != 'localhost' && !filter_var($u['host'], FILTER_VALIDATE_IP)) {
$_POST['COOKIE_DOMAIN'] = preg_replace('!^www\.!i', '.', $u['host']);
$_POST['COOKIE_PATH'] = $u['path'];
} else {
$_POST['COOKIE_PATH'] = '/';
}
return 1;
}
return 0;
}
function fix_slashes(&$val)
{
if (!empty($val)) {
$val = str_replace('\\', '/', $val);
if (substr($val, -1) != '/') {
$val .= '/';
}
}
return $val;
}
function decompress_archive($data_root, $web_root)
{
$clean = array('PHP_OPEN_TAG'=>'', 'PHP_OPEN_ASP_TAG'=>'<%');
// CLI doesn't automatically change the CWD to the one the started script resides in.
chdir(dirname(__FILE__));
// Try to download the fudforum_archive if not available.
if (!file_exists('./fudforum_archive')) {
$archive_url = 'https://raw.githubusercontent.com/fudforum/FUDforum/master/fudforum_archive';
@file_put_contents('./fudforum_archive', fopen($archive_url, 'r'));
}
/* Install from './fudforum_archive' file. */
$fp = fopen('./fudforum_archive', 'rb') or die('The install script requires a "fudforum_archive" file to run. Please download it and retry again.');
$checksum = fread($fp, 32);
$tmp = fread($fp, 20000);
fseek($fp, (ftell($fp) - 20000), SEEK_SET);
if (strpos($tmp, 'RAW_PHP_OPEN_TAG') !== FALSE) { /* No compression. */
unset($clean['PHP_OPEN_TAG']); $clean['RAW_PHP_OPEN_TAG'] = '';
$data = '';
while (($tmp = fgets($fp))) {
$data .= strtr($tmp, $clean);
}
} else {
$data_len = (int) fread($fp, 10);
// Data should be @ least 100k.
if ($data_len > 100000) {
$data = gzuncompress(strtr(fread($fp, $data_len), $clean), $data_len);
}
}
fclose($fp);
if (empty($data) || md5($data) != $checksum) {
exit("Archive did not pass the checksum test, it is corrupt!
\nIf you've encountered this error it means that you've:
- downloaded a corrupt 'fudforum_archive' file
- uploaded the archive to your server in ASCII and not BINARY mode
- your FTP Server/Decompression software/Operating System added un-needed cartrige return ('\\r') characters to the archive.
\n");
}
$pos = 0;
do {
$end = strpos($data, "\n", $pos+1);
$meta_data = explode('//', substr($data, $pos, ($end-$pos)));
$pos = $end;
if (!isset($meta_data[3]) || $meta_data[3] == '/install') {
continue;
}
if (!strncmp($meta_data[3], 'install/forum_data', 18)) {
$path = $data_root . substr($meta_data[3], 18);
} else if (!strncmp($meta_data[3], 'install/www_root', 16)) {
$path = $web_root . substr($meta_data[3], 16);
} else {
continue;
}
$path .= '/'. $meta_data[1];
$path = str_replace('//', '/', $path);
if (isset($meta_data[5])) {
$file = substr($data, ($pos + 1), $meta_data[5]);
if (md5($file) != $meta_data[4]) {
exit('ERROR: file '. $meta_data[1] .' was not read properly from archive');
}
if ($path == $web_root .'.htaccess' && @file_exists($path)) {
define('old_htaccess', 1);
continue;
}
if (defined('fud_debug')) echo "Extracting $path\n";
$fp = @fopen($path, 'wb');
if (!$fp) {
if (basename($path) != '.htaccess') {
exit('Couldn\'t open '. $path .' for write.');
}
}
// TODO: Good place for substitutions before we write the file.
fwrite($fp, $file);
fclose($fp);
@chmod($path, 0644);
} else {
if (substr($path, -1) == '/') {
$path = preg_replace('!/+$!', '', $path);
}
if (!__mkdir($path)) {
exit('ERROR: failed creating directory '. $path);
}
}
} while (($pos = strpos($data, "\n//", $pos)) !== false);
}
function get_server_uid_gid()
{
if ($GLOBALS['module_status']['posix']) {
$u = posix_getpwuid(posix_getuid());
$g = posix_getgrgid($u['gid']);
return '('. $u['name'] .'/'. $g['name'] .')';
}
return;
}
function check_primary_dir($dir, $type)
{
if (!__mkdir($dir)) {
seterr($type, 'Failed to create "'. $dir .'". Please create it manually and grant read/write permissions to the web-server user '. get_server_uid_gid());
return 1;
}
if (!@is_writable($dir)) {
seterr($type, 'Directory "'. $dir .'" exists, but the installation script is unable to write to the directory. Please grant read/write permissions to the web-server user '. get_server_uid_gid());
return 1;
}
if (SAFE_MODE) {
if (($safe = $st = @stat($dir))) {
if (!ini_get('safe_mode_gid')) {
$safe = (getmyuid() == $st['uid']);
} else {
$safe = (getmygid() == $st['gid']);
}
}
if (!$safe && basename(__FILE__) != 'install.php') {
seterr($type, 'Safe mode limitations prevent the installation script from writing to "'. $dir .'". Please grant read/write permissions to the web-server user '. get_server_uid_gid());
return 1;
}
}
if (open_basedir) {
$safe = 1;
foreach (explode(PATH_SEPARATOR, open_basedir) as $d) {
if (!strncasecmp($dir, $d, strlen($d))) {
$safe = 0;
break;
}
}
if ($safe) {
seterr($type, 'open_basedir limitations "'. open_basedir .'" prevent the installation script from writing to "'. $dir .'". Please modify the open_basedir directive to include the specified directory');
return 1;
}
}
}
function htaccess_handler($web_root, $ht_pass)
{
if (!fud_ini_get('allow_url_fopen') || strncmp(PHP_SAPI, 'apache', 6)) {
unlink($ht_pass);
return;
}
/* Opening a connection to itself should not take more then 5 seconds. */
fud_ini_set('default_socket_timeout', 5);
if (@fopen($web_root .'blank.gif', 'r') === FALSE) {
unlink($ht_pass);
}
}
function page_header()
{
if (php_sapi_name() == 'cli') return;
?>
FUDforum Installation Wizard
';
echo '';
echo '';
}
?>
';
?> |
FUDforum Installation Wizard |
|