50000000) { $no_mem_limit = 0; } } define('max_a_len', filesize(__FILE__)); // needed for offsets ignore_user_abort(true); set_magic_quotes_runtime(0); @set_time_limit(600); $url_test = fud_ini_get('allow_url_fopen'); /* uncomment the line below if the installer stalls after the 1st page */ // $url_test = 0; /* opening a connection to itself should not take more then 5 seconds */ fud_ini_set("default_socket_timeout", 5); /* Determine SafeMode limitations */ define('SAFE_MODE', fud_ini_get('safe_mode')); /* Determine open_basedir limitations */ define('open_basedir', ini_get('open_basedir')); /* determine if magic_guotes_gpc are off */ $magic_guotes_gpc = get_magic_quotes_gpc(); /* mbstring hackery, necessary if function overload is enabled */ if (extension_loaded('mbstring') && ini_get("mbstring.func_overload") > 0) { mb_internal_encoding('ASCII'); } if (!isset($_SERVER['PATH_TRANSLATED'])) { $_SERVER['PATH_TRANSLATED'] = isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : realpath(__FILE__); } $module_status = module_check(); if (strncmp(PHP_SAPI, 'apache', 6)) { define('file_perms', 0644); define('dir_perms', 0755); } else { define('file_perms', 0600); define('dir_perms', 0711); } /* we need this for PDO in 5.0+ */ if (version_compare(PHP_VERSION, '5.0.0', '>=')) { function ex_handle($ex) { seterr('DBHOST', $ex->getMessage()); } set_exception_handler('ex_handle'); $GLOBALS['PDO'] = null; function pdo_fetch($res) { return $res->fetch(PDO_FETCH_NUM); } } function module_check() { $status = array(); foreach (array('zlib', 'mysql', 'pdo_mysql', 'pdo_pgsql', 'pdo_sqlite', 'pgsql', 'pcre', 'pspell', 'posix') as $m) { $status[$m] = extension_loaded($m); } return $status; } function initdb($init=0) { if (preg_match('![^A-Za-z0-9_]!', $_POST['DBHOST_TBL_PREFIX'])) { exit("Corrupted database prefix!"); } switch ($_POST['DBTYPE']) { case 'mysql': if (!($conn = mysql_connect($_POST['DBHOST'], $_POST['DBHOST_USER'], $_POST['DBHOST_PASSWORD']))) { seterr('DBHOST', 'Failed to connect to the MySQL Server, SQL Reason: '.mysql_error()); } define('__FUD_SQL_LNK__', $conn); if (!mysql_select_db($_POST['DBHOST_DBNAME'], __FUD_SQL_LNK__)) { seterr('DBHOST_DBNAME', 'Could not open the database you\'ve specified, SQL Reason: '.mysql_error()); } break; case 'pgsql': $connect_str = ''; $vals = array('DBHOST' => 'host', 'DBHOST_USER' => 'user', 'DBHOST_PASSWORD' => 'password', 'DBHOST_DBNAME' => 'dbname'); foreach ($vals as $k => $v) { if (!empty($_POST[$k])) { $connect_str .= ' '.$v.'='.$_POST[$k]; } } if (!($conn = pg_connect(ltrim($connect_str)))) { seterr('DBHOST', 'Failed to establish database connection to '.$_POST['DBHOST']); } define('__FUD_SQL_LNK__', $conn); break; case 'pdo_mysql': if ($_POST['DBHOST']{0} == ':') { $host = 'unix_socket='.substr($_POST['DBHOST'], 1); } else { $host = 'host='.$_POST['DBHOST']; } $dsn = 'mysql:'.$host.';dbname='.$_POST['DBHOST_DBNAME']; $GLOBALS['PDO'] = new PDO($dsn, $_POST['DBHOST_USER'], $_POST['DBHOST_PASSWORD']); break; case 'pdo_pgsql': $dsn = 'pgsql:'; $vals = array('DBHOST' => 'host', 'DBHOST_USER' => 'user', 'DBHOST_PASSWORD' => 'password', 'DBHOST_DBNAME' => 'dbname'); foreach ($vals as $k => $v) { if (!empty($_POST[$k])) { $dsn .= $v.'='.$_POST[$k].' '; } } $GLOBALS['PDO'] = new PDO($dsn); break; case 'pdo_sqlite': $_POST['DBHOST'] = $_POST['SERVER_DATA_ROOT'].'/forum.db.php'; if ($init) { @unlink($_POST['DBHOST']); } $GLOBALS['PDO'] = new PDO('sqlite:'.$_POST['DBHOST']); break; default: exit("Invalid DB Type."); } } function dbquery($qry, $fetch=0) { if (!defined('__FUD_SQL_LNK__') && !$GLOBALS['PDO']) { return FALSE; } switch ($_POST['DBTYPE']) { case 'mysql': return mysql_query($qry, __FUD_SQL_LNK__); break; case 'pgsql': return pg_query(__FUD_SQL_LNK__, $qry); break; case 'pdo_mysql': case 'pdo_pgsql': case 'pdo_sqlite': if (!$fetch) { return ($GLOBALS['PDO']->exec($qry) !== FALSE); } else { return $GLOBALS['PDO']->query($qry); } break; } } function dberror() { switch ($_POST['DBTYPE']) { case 'mysql': return mysql_error(__FUD_SQL_LNK__); break; case 'pgsql': return pg_last_error(__FUD_SQL_LNK__); break; case 'pdo_mysql': case 'pdo_pgsql': case 'pdo_sqlite': $err = $GLOBALS['PDO']->errorInfo(); return end($err); break; } } function dbperms_check() { $qry = array( 'CREATE TABLE fud_forum_install_test_table (test_val INT)', 'ALTER TABLE fud_forum_install_test_table ADD test_val2 INT', array( 'mysql' => 'LOCK TABLES fud_forum_install_test_table WRITE', 'pgsql' => 'BEGIN WORK; COMMIT WORK' ), 'DROP TABLE fud_forum_install_test_table' ); $err = array( 'FATAL ERROR: your %name% account does not have permissions to create new %name% tables.
Enable this functionality and restart the script.', 'FATAL ERROR: your %name% account does not have permissions to run ALTER queries on existing %name% tables
Enable this functionality and restart the script.', 'FATAL ERROR: your %name% account does not have permissions to run LOCK queries on existing %name% tables
Enable this functionality and restart the script.', 'FATAL ERROR: your %name% account does not have permissions to run DROP TABLE queries on existing %name% tables
Enable this functionality and restart the script.' ); switch ($_POST['DBTYPE']) { case 'mysql': case 'pdo_mysql': $acc = 'MySQL'; break; case 'pgsql': case 'pdo_pgsql': $acc = 'PostgreSQL'; break; case 'pdo_sqlite': /* no need to check perms, we've got our own DB */ return; default: exit("Invalid DB Type."); } @dbquery('DROP /*!10000 TABLE IF EXISTS */fud_forum_install_test_table'); foreach ($qry as $k => $v) { if (is_array($v)) { $key = strpos($_POST['DBTYPE'], 'mysql') !== FALSE ? 'mysql' : 'pgsql'; $v = $v[$key]; } if (!dbquery($v)) { seterr('DBHOST', str_replace('%name%', $acc, $err[$k])); } } } function make_into_query($data) { return trim(str_replace('{SQL_TABLE_PREFIX}', $_POST['DBHOST_TBL_PREFIX'], preg_replace('!\s+!', ' ', preg_replace('!\#.*$!s', '', $data)))); } function change_global_settings($list) { $settings = file_get_contents($GLOBALS['INCLUDE'] . 'GLOBALS.php'); foreach ($list as $k => $v) { if (($p = strpos($settings, '$' . $k)) === false) { $pos = strpos($settings, '$ADMIN_EMAIL'); if (is_int($v)) { $settings = substr_replace($settings, "\${$k}\t= {$v};\n\t", $p, 0); } else { $v = addcslashes($v, '\\"$'); $settings = substr_replace($settings, "\${$k}\t= \"{$v}\";\n\t", $p, 0); } } else { $p = strpos($settings, '=', $p) + 1; $e = $p + strrpos(substr($settings, $p, (strpos($settings, "\n", $p) - $p)), ';'); if (is_int($v)) { $settings = substr_replace($settings, ' '.$v, $p, ($e - $p)); } else { $v = addcslashes($v, '\\"$'); $settings = substr_replace($settings, ' "'.$v.'"', $p, ($e - $p)); } } } $fp = fopen($GLOBALS['INCLUDE'].'GLOBALS.php', 'w'); fwrite($fp, $settings); fclose($fp); } /* un-quote the string if it is quotes */ if ($magic_guotes_gpc) { function strip_quotes(&$var) { $var = stripslashes($var); } if (!empty($_GET)) { array_walk($_GET, 'strip_quotes'); } if (!empty($_POST)) { array_walk($_POST, 'strip_quotes'); } } /* Perform various sanity checks, which check for required components */ if (!count($_POST)) { /* php version check */ if (!version_compare(PHP_VERSION, '4.3.0', '>=')) { ?> Your php version () is older then the minimum required version (4.3.0). Please install the newer version and try again.
The reasons for this restriction are numerous, most important ones being security & performance. You need to chmod the file 666 (-rw-rw-rw-), so that the installer can modify itself. This is needed to avoid problems since your PHP installation enforces memory limit setting. The installer is missing the data archive, append the archive to the installer and try again. 200000) { /* zlib check */ if (($zl = ($fsize < 3500000)) && !$module_status['zlib']) { ?> zlib extension required to decompress the archive is not loaded. Please recompile your PHP with zlib support or load the zlib extension, in the event this is not possible download the non-zlib version of the install or upgrade script from FUDforum's website at: http://fud.prohost.org/forum/. FUDforum can utilize either MySQL PosgreSQL or SQLite database to store it's data, unfortunately, your PHP does not have support for either one. Please install or load the appropriate database extension and then re-run the install script. PCRE (Perl Compatible Regular Expression) extension required for proper forum operation is not avaliable, please load or install this extension and then re-run the installer. Please make sure that the intaller has permission to write to the current directory ('.getcwd().')'; if (!SAFE_MODE) { echo '
or create a "fudforum_archive" file inside the current directory and make it writable to the webserver.'; } exit(''); } if (defined('__COMPILER_HALT_OFFSET__')) { /* PHP 5.1 with halt support */ $fp2 = fopen(__FILE__, 'rb'); $main = stream_get_contents($fp2, __COMPILER_HALT_OFFSET__ + 4); /* 4 == " ?>\n" */ fwrite($fp, stream_get_contents($fp2, max_a_len, __COMPILER_HALT_OFFSET__ + 4)); } else { $main = ''; $l = strlen(""); $fp2 = fopen(__FILE__, 'rb'); while (($line = fgets($fp2))) { $main .= $line; if (!strncmp($line, "", $l)) { break; } } while (($tmp = fread($fp2, 20000))) { fwrite($fp, $tmp); } } fclose($fp); fclose($fp2); $fp = fopen(__FILE__, "wb"); fwrite($fp, $main); fclose($fp); unset($main, $tmp); } } /* determine directory separator */ $WINDOWS = DIRECTORY_SEPARATOR != '/'; function __mkdir($dir) { if (@is_dir($dir)) { @chmod($dir, dir_perms); return 1; } else if (file_exists($dir)) { unlink($dir); } $ret = (mkdir($dir, dir_perms) || mkdir(dirname($dir), dir_perms)); return $ret; } function draw_row($title, $var, $def, $descr=NULL) { echo ''.$title.''.($descr ? '
'.$descr.'' : '').''.(isset($GLOBALS['errors'][$var]) ? $GLOBALS['errors'][$var] : '').''; } function draw_row_sel($title, $var, $opt_list, $val_list, $descr=NULL, $def=NULL) { $val_list = explode("\n", $val_list); $opt_list = explode("\n", $opt_list); if (($c = count($val_list)) != count($opt_list)) { exit('Value list does not match option count'); } echo ''.$title.''.($descr ? '
'.$descr.'' : '').''; } function draw_dialog_start($title, $help) { ?>
'; if ($section != 'stor_path') { echo ''; } else { echo ''; } echo '
 
'; } } function seterr($name, $text) { $GLOBALS['errors'][$name] = ''.$text.'
'; } function chkslash(&$val) { if (!empty($val)) { $last_char = substr($val, -1); if ($last_char != '/' && $last_char != '\\') { $val .= DIRECTORY_SEPARATOR; } } return $val; } function decompress_archive($data_root, $web_root) { $clean = array('PHP_OPEN_TAG'=>''<%'); if ($GLOBALS['no_mem_limit']) { $size = filesize("./fudforum_archive"); $fp = fopen("./fudforum_archive", "rb"); $checksum = fread($fp, 32); $tmp = fread($fp, 20000); fseek($fp, (ftell($fp) - 20000), SEEK_SET); if (strpos($tmp, 'RAW_PHP_OPEN_TAG') !== FALSE) { unset($clean['PHP_OPEN_TAG']); $clean['RAW_PHP_OPEN_TAG'] = '\n" */ $p = 0; } else { $data = file_get_contents(__FILE__); $p = strpos($data, "") + strlen("") + 1; } $checksum = substr($data, $p, 32); $data = substr($data, $p + 32); if (strpos($data, 'RAW_PHP_OPEN_TAG') !== FALSE) { /* no compression */ unset($clean['PHP_OPEN_TAG']); $clean['RAW_PHP_OPEN_TAG'] = '\nIf you've encountered this error it means that you've:
\n    downloaded a corrupt archive
\n    uploaded the archive in ASCII and not BINARY mode
\n    your FTP Server/Decompression software/Operating System added un-needed cartrige return ('\r') characters to the archive, resulting in archive corruption.
\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; } $fp = @fopen($path, 'wb'); if (!$fp) { if (basename($path) != '.htaccess') { exit('Couldn\'t open '.$path.' for write'); } } fwrite($fp, $file); fclose($fp); @chmod($path, file_perms); } else { if (substr($path, -1) == '/') { $path = preg_replace('!/+$!', '', $path); } if (!__mkdir($path)) { exit('ERROR: failed creating '.$path.' directory'); } } } while (($pos = strpos($data, "\n//", $pos)) !== false); } /* win32 does not have symlinks, so we use this crude emulation */ if ($WINDOWS) { function fud_symlink($src, $dest) { if (!($fp = fopen($dest, 'wb'))) { return FALSE; } fwrite($fp, ''); fclose($fp); } } 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_perimary_dir($dir, $type) { if (!__mkdir($dir)) { seterr($type, 'Install script failed to create "'.$dir.'". Create it manually and chmod it 777 or make it\'s user/group same as the web-server '.get_server_uid_gid()); return 1; } if (!@is_writable($dir)) { seterr($type, 'Directory "'.$dir.'" exist, however install script has no permission to write to this directory. Chmod it 777 or make it\'s user/group same as the '.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 limitation prevents the install script from writing to "'.$dir.'". Please make sure that this directory is owned by the same user/group same as the web-server '.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 limitation "'.open_basedir.'" prevents the install script from writing to "'.$dir.'". Please ensure that the specified directory is inside the directories listed in the open_basedir directive'); 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); } } $section = isset($_POST['section']) ? $_POST['section'] : (isset($_GET['section']) ? $_GET['section'] : ''); switch ($section) { case 'stor_path': if (isset($_GET['sfh'])) { $_POST['SERVER_ROOT'] = $_GET['SERVER_ROOT']; $_POST['SERVER_DATA_ROOT'] = $_GET['SERVER_DATA_ROOT']; $_POST['WWW_ROOT'] = $_GET['WWW_ROOT']; } $SERVER_ROOT = str_replace('\\', '/', $_POST['SERVER_ROOT']); $SERVER_DATA_ROOT = str_replace('\\', '/', $_POST['SERVER_DATA_ROOT']); $WWW_ROOT = $_POST['WWW_ROOT']; if (substr($WWW_ROOT, -1) != '/') { $WWW_ROOT .= '/'; } chkslash($SERVER_ROOT); chkslash($SERVER_DATA_ROOT); $_POST['SERVER_ROOT'] = $SERVER_ROOT; $_POST['SERVER_DATA_ROOT'] = $SERVER_DATA_ROOT; $_POST['WWW_ROOT'] = $WWW_ROOT; $err = check_perimary_dir($SERVER_ROOT, 'SERVER_ROOT'); if ($SERVER_ROOT != $SERVER_DATA_ROOT) { if (check_perimary_dir($SERVER_DATA_ROOT, 'SERVER_DATA_ROOT') && !$err) { $err = 1; } } if (!$err) { if (SAFE_MODE && !isset($_GET['sfh'])) { $s = realpath(__FILE__); $d = dirname($s) . '/install_safe.php'; if (!copy($s, $d)) { exit('Failed to copy "'.$s.'" to "'.$d.'"'); } header('Location: install_safe.php?SERVER_ROOT='.urlencode($SERVER_ROOT).'&SERVER_DATA_ROOT='.urlencode($SERVER_DATA_ROOT).'&WWW_ROOT='.urlencode($WWW_ROOT).'§ion=stor_path&sfh=1'); exit; } /* try to ensure that SERVER_ROOT resolves to WWW_ROOT */ if (fud_ini_get('allow_url_fopen') && !empty($_POST['url_check'])) { $check_tm = time(); $fp = fopen($SERVER_ROOT . 'WWW_ROOT_CHECK', 'wb'); fwrite($fp, $check_tm); fclose($fp); if (($d = @file_get_contents($WWW_ROOT . 'WWW_ROOT_CHECK')) != $check_tm) { seterr('WWW_ROOT', 'Your WWW_ROOT does not correspond with the SERVER_ROOT path you have specified. (unable to retrive: '.$WWW_ROOT.'WWW_ROOT_CHECK, on disk as: '.$SERVER_ROOT.'WWW_ROOT_CHECK, received data: '.$d.' w/error: ' . $php_errormsg); } unlink($SERVER_ROOT . 'WWW_ROOT_CHECK'); } } if (!isset($GLOBALS['errors'])) { decompress_archive($SERVER_DATA_ROOT, $SERVER_ROOT); /* verify that all the important directories exist (old php bug) */ foreach (array('include', 'errors', 'messages', 'files', 'template', 'tmp', 'cache', 'errors/.nntp', 'errors/.mlist') as $v) { if (!__mkdir($SERVER_DATA_ROOT . $v)) { exit('FATAL ERROR: Couldn\'t create "'.$SERVER_DATA_ROOT . $v.'".
You can try creating it manually. If you do, be sure to chmod the directory 777.'); } } /* determine if this host can support .htaccess directives */ if (!defined('old_htaccess') && $url_test) { htaccess_handler($WWW_ROOT, $SERVER_ROOT . '.htaccess'); } else if (!defined('old_htaccess') && !$url_test) { @unlink($SERVER_ROOT . '.htaccess'); } $INCLUDE = $SERVER_DATA_ROOT.'include/'; $ERROR_PATH = $SERVER_DATA_ROOT.'errors/'; $MSG_STORE_DIR = $SERVER_DATA_ROOT.'messages/'; $FILE_STORE = $SERVER_DATA_ROOT.'files/'; $TMP = $SERVER_DATA_ROOT.'tmp/'; $FORUM_SETTINGS_PATH = $SERVER_DATA_ROOT.'cache/'; @chmod($INCLUDE . 'GLOBALS.php', file_perms); touch($ERROR_PATH . 'FILE_LOCK'); /* ensure we don't have any bogus symlinks (re-installing over old forum) */ @unlink($SERVER_ROOT . 'GLOBALS.php'); @unlink($SERVER_ROOT . 'adm/GLOBALS.php'); @unlink($SERVER_DATA_ROOT . 'scripts/GLOBALS.php'); /* make symlinks to GLOBALS.php */ if (!$WINDOWS) { symlink($INCLUDE . 'GLOBALS.php', $SERVER_ROOT . 'GLOBALS.php'); symlink($INCLUDE . 'GLOBALS.php', $SERVER_ROOT . 'adm/GLOBALS.php'); symlink($INCLUDE . 'GLOBALS.php', $SERVER_DATA_ROOT . 'scripts/GLOBALS.php'); } else { fud_symlink($INCLUDE . 'GLOBALS.php', $SERVER_ROOT . 'GLOBALS.php'); fud_symlink($INCLUDE . 'GLOBALS.php', $SERVER_ROOT . 'adm/GLOBALS.php'); fud_symlink($INCLUDE . 'GLOBALS.php', $SERVER_DATA_ROOT . 'scripts/GLOBALS.php'); } $url_parts = parse_url($WWW_ROOT); /* default bitmask values */ $FUD_OPT_1 = 1744762047; if (!$module_status['pspell']) { $FUD_OPT_1 ^= 2097152; } $FUD_OPT_2 = 695668799 | 8388608; change_global_settings(array( 'INCLUDE' => $INCLUDE, 'ERROR_PATH' => $ERROR_PATH, 'MSG_STORE_DIR' => $MSG_STORE_DIR, 'FILE_STORE' => $FILE_STORE, 'TMP' => $TMP, 'WWW_ROOT' => $WWW_ROOT, 'WWW_ROOT_DISK' => $SERVER_ROOT, 'FORUM_SETTINGS_PATH' => $FORUM_SETTINGS_PATH, 'COOKIE_NAME' => 'fud_session_'.time(), 'FUD_OPT_2' => $FUD_OPT_2, 'FUD_OPT_1' => $FUD_OPT_1, 'COOKIE_PATH' => $url_parts['path'], 'DATA_DIR' => $SERVER_DATA_ROOT)); $section = 'db'; } break; case 'db': if (empty($_POST['DBHOST_TBL_PREFIX']) || preg_match('![^A-Za-z0-9_]!', $_POST['DBHOST_TBL_PREFIX'])) { seterr('DBHOST_TBL_PREFIX', 'SQL prefix cannot be empty or contain non A-Za-z0-9_ characters'); } else { /* verify that we can connect to database & validate version @ the same time*/ initdb(1); if (($r = dbquery('SELECT VERSION()', 1)) && $_POST['DBTYPE'] != 'pdo_sqlite') { switch ($_POST['DBTYPE']) { case 'mysql': $val = mysql_fetch_row($r); break; case 'pgsql': $val = pg_fetch_row($r); break; case 'pdo_mysql': case 'pdo_pgsql': $val = array($r->fetchColumn()); break; } if ($val && preg_match('!([3-8]\.[0-9]+(?:\.[0-9]+)?)!', ($val ? $val[0] : null), $m)) { $version = $m[1]; } else { $version = 0; } if (($_POST['DBTYPE'] == 'mysql' || $_POST['DBTYPE'] == 'pdo_mysql') && !version_compare($version, '3.23.0', '>=')) { seterr('DBHOST', 'The specified MySQL server is running version "'.$version.'", which is older then the minimum required version "3.23.0"'); } else if (($_POST['DBTYPE'] == 'pgsql' || $_POST['DBTYPE'] == 'pdo_pgsql') && !version_compare($version, '7.2.0', '>=')) { seterr('DBHOST', 'The specified PostgreSQL server is running version "'.$version.'", which is older then the minimum required version "7.2.0"'); } } unset($r); if (!isset($GLOBALS['errors'])) { dbperms_check(); } if (!isset($GLOBALS['errors'])) { $tables = $def_data = array(); if ($_POST['DBTYPE'] == 'pgsql' || $_POST['DBTYPE'] == 'pdo_pgsql') { /* remove possibly conflicting tables & sequences */ $drop = array('r'=>array(), 'S'=>array()); $c = dbquery("select relname,relkind from pg_class WHERE relkind IN('r','S') AND relname LIKE '".str_replace('_', '\\\\_', $_POST['DBHOST_TBL_PREFIX'])."%'", 1); $f = $_POST['DBTYPE'] == 'pgsql' ? 'pg_fetch_row' : 'pdo_fetch'; while ($r = $f($c)) { $drop[$r[1]][] = $r[0]; } unset($c); if ($drop['r'] && !dbquery('DROP TABLE '.implode(',', $drop['r']))) { echo dberror(); } if ($drop['S']) { @dbquery('DROP SEQUENCE '.implode(',', $drop['S'])); } unset($drop); } $tbl = glob($_POST['SERVER_DATA_ROOT'] . 'sql/*.tbl', GLOB_NOSORT); $sql = glob($_POST['SERVER_DATA_ROOT'] . 'sql/*.sql', GLOB_NOSORT); if (!$tbl || !$sql) { seterr('DBHOST_DBNAME', "Failed to get a list of table defenitions and/or base table data from: '{$_POST['SERVER_DATA_ROOT']}sql/'\n"); } /* import tables */ foreach ($tbl as $t) { foreach (explode(';', preg_replace('!#.*?\n!s', '', file_get_contents($t))) as $q) { $q = trim($q); if ($_POST['DBTYPE'] != 'mysql' && $_POST['DBTYPE'] != 'pdo_mysql') { if (!strncmp($q, 'DROP TABLE IF EXISTS', strlen('DROP TABLE IF EXISTS')) || !strncmp($q, 'ALTER TABLE', strlen('ALTER TABLE'))) { continue; } $rep = array('BINARY'=>'', 'INT NOT NULL AUTO_INCREMENT'=> ($_POST['DBTYPE'] == 'pdo_sqlite' ? 'INTEGER' : 'SERIAL')); $q = strtr($q, $rep); } else if (version_compare($version, '4.1.2', '>=') && !strncmp($q, 'CREATE TABLE', strlen('CREATE TABLE'))) { /* because mysql with InnoDB table refuses to resolve indexes correctly, we need to force MyISAM table type */ if (strpos($q, 'thread_view') !== false) { $q .= ' ENGINE=MyISAM ' ; } /* for MySQL 4.1.2+ we need to specify a default charset */ $q .= " DEFAULT CHARACTER SET latin1"; } if (($q = make_into_query(trim($q)))) { if (!dbquery($q)) { seterr('DBHOST_DBNAME', 'Failed to create table "'.basename($t, '.tbl').'" ("'.$q.'"), SQL Reason: '.dberror()); break 2; } } } } if (!isset($GLOBALS['errors'])) { /* import table data */ foreach ($sql as $t) { foreach (explode(";\n", file_get_contents($t)) as $q) { if (strpos($q, 'UNIX_TIMESTAMP') !== false) { $q = str_replace('UNIX_TIMESTAMP', time(), $q); } if (($q = make_into_query(trim($q)))) { if (!dbquery($q)) { seterr('DBHOST_DBNAME', 'Failed to import default data ("'.$q.'") into table '.basename($t, '.sql').', SQL Reason: '.dberror()); break 2; } } } } if (!isset($GLOBALS['errors'])) { $INCLUDE = $_POST['SERVER_DATA_ROOT'] . 'include/'; change_global_settings(array( 'DBHOST' => $_POST['DBHOST'], 'DBHOST_USER' => $_POST['DBHOST_USER'], 'DBHOST_PASSWORD' => $_POST['DBHOST_PASSWORD'], 'DBHOST_DBNAME' => $_POST['DBHOST_DBNAME'], 'DBHOST_TBL_PREFIX' => $_POST['DBHOST_TBL_PREFIX'] )); if (!strncmp($_POST['DBTYPE'], 'pdo_', 4)) { change_global_settings(array('DBHOST_DBTYPE' => $_POST['DBTYPE'])); } $section = 'cookies'; } } } } break; case 'cookies': if (empty($_POST['COOKIE_DOMAIN'])) { seterr('COOKIE_DOMAIN', 'You must enter a cookie domain in order for cookies to work properly.'); } else { $INCLUDE = $_POST['SERVER_DATA_ROOT'] . 'include/'; if ($_POST['COOKIE_DOMAIN'] == 'localhost' || ip2long($_POST['COOKIE_DOMAIN']) > 0) { $_POST['COOKIE_DOMAIN'] = ''; } change_global_settings(array('COOKIE_DOMAIN' => $_POST['COOKIE_DOMAIN'])); $section = 'language'; } break; case 'language': list($la, $lc, $lp) = explode('::', $_POST['LANGUAGE']); initdb(); dbquery("DELETE FROM ".$_POST['DBHOST_TBL_PREFIX']."themes"); if (!dbquery("INSERT INTO ".$_POST['DBHOST_TBL_PREFIX']."themes(id, name, theme, lang, locale, theme_opt, pspell_lang) VALUES(1, 'default', 'default', '".addslashes($la)."', '".addslashes($lc)."', 3, '".addslashes($lp)."')")) { echo dberror(); } else { $section = 'admin'; } break; case 'admin': if (empty($_POST['ROOT_PASS'])) { seterr('ROOT_PASS', 'You must enter a password for the administrator account.'); } else if ($_POST['ROOT_PASS'] != $_POST['ROOT_PASS_C']) { seterr('ROOT_PASS', 'Your passwords do not match.'); } if (empty($_POST['ROOT_LOGIN'])) { seterr('ROOT_LOGIN', 'You must enter a user name for the administrator account.'); } if (empty($_POST['ADMIN_EMAIL'])) { seterr('ADMIN_EMAIL', 'You must enter a valid email address for the administrator account.'); } if(!isset($GLOBALS['errors'])) { initdb(); dbquery("DELETE FROM ".$_POST['DBHOST_TBL_PREFIX']."users WHERE id > 1"); if (!dbquery("INSERT INTO ".$_POST['DBHOST_TBL_PREFIX']."users (login, alias, passwd, name, email, users_opt, join_date, theme) VALUES('".addslashes($_POST['ROOT_LOGIN'])."', '".addslashes(htmlspecialchars($_POST['ROOT_LOGIN']))."', '".md5($_POST['ROOT_PASS'])."', 'Administrator', '".addslashes($_POST['ADMIN_EMAIL'])."', 5405687, ".time().", 1)")) { seterr('ROOT_LOGIN', dberror()); } else { $INCLUDE = $_POST['SERVER_DATA_ROOT'] . 'include/'; change_global_settings(array( 'ADMIN_EMAIL' => $_POST['ADMIN_EMAIL'], 'NOTIFY_FROM' => $_POST['ADMIN_EMAIL'] )); $section = 'done'; } } break; } ?>
Step 1 of 5 ', 'First, you need to specify the directories where the forum files will be stored. In order for the forum installation to work you need to chmod the directories Server Root & Forum Data Root in such a way that the webserver can write to them. I suggest chmoding the directories to 777.
If you have shell access, you can change the directory permission by typing "chmod 777 directory_name"
In CuteFTP, you can chmod a directory by selecting it and then pressing Ctrl+Shift+A. In the Manual checkbox, enter 777 and then press OK.
In WS_FTP, right-click on the directory and choose the chmod UNIX option. In the dialog, select all the checkboxes and click OK. This will chmod the directory 777.
'); } else { draw_dialog_start('
SAFEMODE is ENABLED!

PATH OF SYSTEM FILES AND DIRECTORIES    Step 1 of 5', ' Your PHP has SAFE MODE enabled. Pay careful attention to the intructions below:

Due to the brain dead nature of PHP\'s safemode we can not install the forum in a directory created by you. Therefor you must install the forum into a directory, which does not yet exist, so that the install script can be the one to create it and thus bypass the safe_mode checks.
For example, if you wanted to install your forum to "/my/home/dir/www/forum", you will need to make sure that "/my/home/dir/www/forum" does not exist and that the file permissions of "/my/home/dir/www" allow install script to create "forum" directory inside "/my/home/dir/www". '); if (!count($_POST)) { $WWW_ROOT .= 'forum/'; $SERVER_ROOT .= 'forum/'; $SERVER_DATA_ROOT = $SERVER_ROOT; } } draw_row('Server Root', 'SERVER_ROOT', $SERVER_ROOT, 'The path on the server where the browseable files of the forum (*.php) will be stored.'); draw_row('Forum Data Root', 'SERVER_DATA_ROOT', $SERVER_DATA_ROOT, 'The path on the server where the NON-browseable files of the forum will be stored.'); draw_row('Forum WWW Root', 'WWW_ROOT', $WWW_ROOT, 'This is the URL of your forum, and should point to the forum\'s front page. This is also the URL people will need to use to get to your forum.'); echo 'URL Check
Turn off this check if you are getting errors pertaining WWW Root not matching Server Root and are certain that the paths indicated are correct.'; break; case 'db': draw_dialog_start('Database Settings    Step 2 of 5', 'FUDforum uses the database to store much of the data used in the forum. Please use the form below to enter information that will allow FUDforum to access the database (leave all but the table prefix empty if using SQLite). It is recommended you create a separate database for the forum.'); $types = array('mysql'=>'MySQL','pgsql'=>'PostgreSQL','pdo_mysql'=>'PDO: MySQL','pdo_pgsql'=>'PDO: PostgreSQL','pdo_sqlite'=>'PDO: SQLite'); foreach ($types as $k => $v) { if (!$module_status[$k]) { unset($types[$k]); } } reset($types); // work-around for a bug in some PHP versions if (count($types) > 1) { draw_row_sel('Database Type','DBTYPE', implode("\n", $types), implode("\n", array_keys($types)), '', (isset($_POST['DBTYPE']) ? $_POST['DBTYPE'] : 'mysql')); } else { echo 'Database TypeUsing '.current($types).''; } if (isset($_POST['DBHOST'])) { $DBHOST = $_POST['DBHOST']; $DBHOST_USER = $_POST['DBHOST_USER']; $DBHOST_PASSWORD = $_POST['DBHOST_PASSWORD']; $DBHOST_DBNAME = $_POST['DBHOST_DBNAME']; $DBHOST_TBL_PREFIX = $_POST['DBHOST_TBL_PREFIX']; } else { $DBHOST = $DBHOST_USER = $DBHOST_PASSWORD = $DBHOST_DBNAME = ''; $DBHOST_TBL_PREFIX = 'fud26_'; } if (count($types) > 1 || !isset($types['pdo_sqlite'])) { // if using sqlite, don't show non-relavent settings draw_row('Host', 'DBHOST', $DBHOST, 'The IP address (or unix domain socket) of the database server.'); draw_row('User', 'DBHOST_USER', $DBHOST_USER, 'The user name for the database you intend to use the system with.'); draw_row('Password', 'DBHOST_PASSWORD', $DBHOST_PASSWORD, 'The password for the user name.'); draw_row('Database', 'DBHOST_DBNAME', $DBHOST_DBNAME, 'The name of the database where forum data will be stored.'); } else { echo ''; } draw_row('FUDforum SQL Table Prefix', 'DBHOST_TBL_PREFIX', $DBHOST_TBL_PREFIX, 'A string of text that will be appended to each table name.'); break; case 'cookies': if (isset($_POST['COOKIE_DOMAIN'])) { $COOKIE_DOMAIN = $_POST['COOKIE_DOMAIN']; } else { $url_parts = parse_url($_POST['WWW_ROOT']); $COOKIE_DOMAIN = preg_replace('!^www\.!i', '.', $url_parts['host']); } draw_dialog_start('Cookie Domain    Step 3 of 5', 'The domain of the cookie that will be used by the forum.'); draw_row('Cookie Domain', 'COOKIE_DOMAIN', $COOKIE_DOMAIN); break; case 'language': draw_dialog_start('Forum Language    Step 4 of 5', 'Choose the language for your forum.
If the language you require is not avaliable, please go to FUDforum\'s website and read about translating the forum to other languages.'); if (!defined('GLOB_NOSORT')) { /* pre PHP 4.3.3 hack for Windows & FreeBSD */ define('GLOB_NOSORT', 0); } $selnames = $selopts = ''; foreach (glob($_POST['SERVER_DATA_ROOT'].'thm/default/i18n/*', GLOB_ONLYDIR|GLOB_NOSORT) as $f) { if (file_exists($f . '/locale')) { $name = basename($f); $selnames .= $name . "\n"; $selopts .= $name . '::' . trim(file_get_contents($f . '/locale')) . '::' . @trim(file_get_contents($f . '/pspell_lang')) . "\n"; } } draw_row_sel('Language', 'LANGUAGE', rtrim($selnames), rtrim($selopts), NULL, 'english::C::en'); break; case 'admin': draw_dialog_start('Admin Account    Step 5 of 5', 'This creates the "root" user account, which is an unrestricted account that can do anything on the forum. You must use this account to edit & customize the forum.'); if (!isset($_POST['ROOT_LOGIN'])) { $ROOT_LOGIN = 'admin'; $ROOT_PASS = $ROOT_PASS_C = ''; $ADMIN_EMAIL = get_current_user() . '@' . strtok($_SERVER['SERVER_NAME'],':'); // some servers include the port in here } else { $ROOT_LOGIN = $_POST['ROOT_LOGIN']; $ROOT_PASS = $_POST['ROOT_PASS']; $ROOT_PASS_C = $_POST['ROOT_PASS_C']; $ADMIN_EMAIL = $_POST['ADMIN_EMAIL']; } draw_row('Login Name', 'ROOT_LOGIN', $ROOT_LOGIN); draw_row('Admin Password', 'ROOT_PASS', $ROOT_PASS); draw_row('Confirm Password', 'ROOT_PASS_C', $ROOT_PASS_C); draw_row('Admin Email', 'ADMIN_EMAIL', $ADMIN_EMAIL); break; case 'done': $GLOBALS['WWW_ROOT_DISK'] = $_POST['SERVER_ROOT']; $GLOBALS['DATA_DIR'] = $_POST['SERVER_DATA_ROOT']; $GLOBALS['INCLUDE'] = $_POST['SERVER_DATA_ROOT'] . '/include/'; $GLOBALS['WWW_ROOT'] = $_POST['WWW_ROOT']; $GLOBALS['DBHOST_TBL_PREFIX'] = $_POST['DBHOST_TBL_PREFIX']; $GLOBALS['FUD_OPT_2'] = 8388608; define('__dbtype__', $_POST['DBTYPE']); if (!strncmp($_POST['DBTYPE'], 'pdo_', 4)) { $GLOBALS['DBHOST_DBTYPE'] = $_POST['DBTYPE']; } else { $GLOBALS['DBHOST_DBTYPE'] = ''; } $lang = strtok($_POST['LANGUAGE'], '::'); require($_POST['SERVER_DATA_ROOT'] . 'include/compiler.inc'); compile_all('default', $lang); draw_dialog_start('Installation Complete', 'You have now completed the basic installation of the forum. To continue configuring your forum, you must login and use the administrator control panel. Clicking "Finished" will take you to the login form. After you login, you will be taken to the administrator control panel.
Before you do, however, you must delete this install.php script, because it can be used to overwrite your forum. You will not be able to login until you do. '); /* Remove the install_safe for safe_mode users, because they will not be able to remove it themselves */ if (SAFE_MODE) { unlink(__FILE__); } if ($no_mem_limit) { unlink("./fudforum_archive"); } echo ('
'); break; } draw_dialog_end($section); /* display some system information on the 1st page of the installer */ if ($section == 'stor_path') { ?>
'; } if (fud_ini_get('register_globals')) { echo ''; } if ($magic_guotes_gpc) { echo ''; } ?>
System Information
PHP Version:
Open_basedir restriction:
You will not be able to use PHP to create files outside of the specified directories.
'.open_basedir.'
Register Globals:
For performance & security reasons we recommend keeping this option OFF.
enabled
Magic quotes gpc:
For performance reasons we recommend keeping this option OFF.
enabled
MySQL Extension:
Interface to the MySQL server, which is the recommended database for FUDforum.
enabled' : 'disabled'); ?>
PostgreSQL Extension:
Interface to the PostgreSQL server.
enabled' : 'disabled'); ?>
PCRE Extension:
Perl Compatible Regular Expression (required).
enabled' : 'disabled'); ?>
Zlib Extension:
zlib extension is optional, however we recommend enabling it. This extension allow you to compress your forum backups as well as use zlib compression for your pages.
enabled' : 'disabled'); ?>
Pspell Extension:
Pspell extension is optional, this extension is needed by the FUDforum's built-in spellchecker. If you want to allow users to spell check their messages, enable this extension.
enabled' : 'disabled'); ?>
'; if (isset($_POST['WWW_ROOT']) && $section != 'stor_path') { echo ''; } if (isset($_POST['LANGUAGE'])) { echo ''; } switch ($section) { case 'cookies': case 'language': case 'admin': case 'done': echo ' '; break; } ?>