<?php
/* ¸Àظ À¹ )ö)ÿüó¥ê
* First 20 bytes of linux 2.4.18, so various windows utils think
* this is a binary file and don't apply CR/LF logic
*/
/***************************************************************************
* copyright : (C) 2001-2010 Advanced Internet Designs Inc.
* email : forum@prohost.org
* $Id: install.php 4928 2010-03-21 18:47:29Z naudefj $
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
***************************************************************************/
function fud_ini_get($opt)
{
return (ini_get($opt) == '1' ? 1 : 0);
}
function fud_ini_set($opt, $val)
{
if (function_exists('ini_set')) {
ini_set($opt, $val);
}
}
if (!fud_ini_get('track_errors')) {
fud_ini_set('track_errors', 1);
}
if (!fud_ini_get('display_errors')) {
fud_ini_set('display_errors', 1);
}
error_reporting(E_ALL);
fud_ini_set('memory_limit', '128M'); // PHP 5.3's default, old defaults too small.
$no_mem_limit = ini_get('memory_limit');
if ($no_mem_limit) {
$no_mem_limit = (int) str_replace(array('k', 'm', 'g'), array('000', '000000', '000000000'), strtolower($no_mem_limit));
if ($no_mem_limit < 1 || $no_mem_limit > 50000000) {
$no_mem_limit = 0;
}
}
/* Uncomment to force install from external "fudforum_archive" file. */
//$no_mem_limit = 1;
define('max_a_len', filesize(__FILE__)); // Needed for offsets.
ignore_user_abort(true);
@set_magic_quotes_runtime(0); // Depricated in PHP 5.3.
@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('UTF-8');
}
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['DB'] = 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', 'oci8', '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!');
}
error_reporting(0); // Hide warnings during connect probing.
switch ($_POST['DBHOST_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());
}
$GLOBALS['DB'] = $conn;
if (! mysql_select_db($_POST['DBHOST_DBNAME'], $GLOBALS['DB'])) {
seterr('DBHOST_DBNAME', 'Could not open the database you\'ve specified, SQL Reason: '.mysql_error());
}
break;
case 'mysqli':
$GLOBALS['DB'] = new mysqli($_POST['DBHOST'], $_POST['DBHOST_USER'], $_POST['DBHOST_PASSWORD'], $_POST['DBHOST_DBNAME']);
if (mysqli_connect_errno()) {
seterr('DBHOST', 'Failed to connect with MySQLi, SQL Reason: '.mysqli_connect_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']);
}
$GLOBALS['DB'] = $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['DB'] = 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['DB'] = new PDO($dsn);
break;
case 'pdo_sqlite':
$_POST['DBHOST'] = $_POST['SERVER_DATA_ROOT'].'/forum.db.php';
if ($init) {
@unlink($_POST['DBHOST']);
}
$GLOBALS['DB'] = new PDO('sqlite:'.$_POST['DBHOST']);
break;
default:
exit('Invalid DB Type.');
}
error_reporting(E_ALL);
}
function dbquery($qry, $fetch=0)
{
if (!$GLOBALS['DB']) {
return FALSE;
}
switch ($_POST['DBHOST_DBTYPE']) {
case 'mysql':
return mysql_query($qry, $GLOBALS['DB']);
break;
case 'mysqli':
return $GLOBALS['DB']->query($qry);
break;
case 'pgsql':
return pg_query($GLOBALS['DB'], $qry);
break;
case 'pdo_mysql':
case 'pdo_pgsql':
case 'pdo_sqlite':
if (!$fetch) {
return ($GLOBALS['DB']->exec($qry) !== FALSE);
} else {
return $GLOBALS['DB']->query($qry);
}
break;
}
}
function dberror()
{
switch ($_POST['DBHOST_DBTYPE']) {
case 'mysql':
return mysql_error($GLOBALS['DB']);
break;
case 'mysqli':
return $GLOBALS['DB']->error;
break;
case 'pgsql':
return pg_last_error($GLOBALS['DB']);
break;
case 'pdo_mysql':
case 'pdo_pgsql':
case 'pdo_sqlite':
$err = $GLOBALS['DB']->errorInfo();
return end($err);
break;
}
}
function dbperms_check()
{
$qry = array(
'CREATE TABLE fud_forum_install_test_table (test_val INT)',
'CREATE INDEX fud_forum_install_test_index ON fud_forum_install_test_table(test_val)',
'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.<br />Enable this functionality and restart the script.',
'FATAL ERROR: your %name% account does not have permissions to create new %name% indexes.<br />Enable this functionality and restart the script.',
'FATAL ERROR: your %name% account does not have permissions to run ALTER queries on existing %name% tables<br />Enable this functionality and restart the script.',
'FATAL ERROR: your %name% account does not have permissions to run LOCK queries on existing %name% tables<br />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<br />Enable this functionality and restart the script.'
);
switch ($_POST['DBHOST_DBTYPE']) {
case 'mysql':
case 'mysqli':
case 'pdo_mysql':
$acc = 'MySQL';
break;
case 'pgsql':
case 'pdo_pgsql':
$acc = 'PostgreSQL';
break;
case 'pdo_sqlite': /* No need to check perms, we'v
商业源码-编程源码-FUDforum(fud论坛) v3.0.1 多国语言版.zip
版权申诉
103 浏览量
2022-06-15
13:58:40
上传
评论
收藏 2.05MB ZIP 举报
programxh
- 粉丝: 17
- 资源: 1万+
最新资源
- kernel-ml-6.8.8-1.el7.elrepo.x86-64.rpm
- Labview基本框架之状态机
- HM2309B-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- Git安全实践:保护你的代码仓库个人学习笔记.md
- 自动驾驶定位系列教程九:后端优化.pdf
- 三国志5威力加强版-windows
- HM2309A-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- HM2306-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- Git进阶技巧:提升团队协作效率个人学习笔记.md
- 自动驾驶定位系列教程八:建图系统结构优化.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0