📄 install.php
字号:
<?php
error_reporting ( E_ALL );
define ( 'CHMOD_VALUE', 0777 );
ob_start();
set_magic_quotes_runtime ( 0 );
require_once 'includes/constants.inc.php';
require_once 'includes/db.class.php';
require_once 'includes/functions_base.inc.php';
require_once 'includes/configs.inc.php';
require_once 'includes/mysql.class.php';
// init mysql
extract($UPL['MYSQL'],EXTR_OVERWRITE);
$mysqlDB=new mysqlDB($host,$username,$password,$database,defined('NO_PERSISTENT')?0:$persistent);
if ( get_magic_quotes_gpc ( ) )
{
$_GET = strip_gpc ( $_GET );
$_POST = strip_gpc ( $_POST );
}
function file_perm ( $path )
{
return substr ( sprintf ( '%o', fileperms ( $path ) ), -4);
}
function get_dir_status ( $path )
{
return is_writable ( $path ) ? 'OK (' . file_perm ( $path ) . ')' : 'Please CHMOD ' . $path . ' to 0' . decoct ( CHMOD_VALUE );
}
function get_file_status ( $file )
{
if ( !is_file ( $file ) )
{
if ( !touch ( $file ) )
{
return 'File does not exist and attempt to create it has failed. Please create ' . $file . ' manually.';
}
else
{
return 'OK, file was created.';
}
}
elseif ( is_writable ( $file ) )
{
return 'OK (' . file_perm ( $file ) . ')';
}
else
{
if ( !change_mode ( $file, CHMOD_VALUE ) )
{
return 'File permission changed. Reload this page to re-test.';
}
else
{
return 'Unable to change file permission. Please CHMOD ' . $file;
}
}
}
$step = isset ( $_GET['step'] ) ? $_GET['step'] : 1;
?>
<?php if ( $step == 1 ) : ?>
<h3>The following directories must be CHMODed to writeable (0777, or 0755).</h3>
<table cellspadding="3" cellspacing="1" border="1">
<tr>
<td>Directory description</td>
<td>Path</td>
<td>Status</td>
</tr>
<tr>
<td>Uploader logs</td>
<td><?=LOGS_DIR?></td>
<td><?=get_dir_status(LOGS_DIR)?></td>
</tr>
<tr>
<td>Uploader settings</td>
<td><?=UPLSETTINGS_DIR?></td>
<td><?=get_dir_status(UPLSETTINGS_DIR)?></td>
</tr>
<tr>
</table>
<h3>The Installer will try to CHMOD the following files. If it fails,
you will need to do so manually.</h3>
<table cellspadding="3" cellspacing="1" border="1">
<tr>
<td>File description</td>
<td>Path</td>
<td>Status</td>
</tr>
<tr>
<td>Upload Settings</td>
<td><?=UPLOADER_SETTINGS?></td>
<td><?=get_file_status(UPLOADER_SETTINGS)?></td>
</tr>
<tr>
<td>User Settings</td>
<td><?=USER_SETTINGS?></td>
<td><?=get_file_status(USER_SETTINGS)?></td>
</tr>
<tr>
<td>Public Uploader Settings</td>
<td><?=PUBLIC_SETTINGS?></td>
<td><?=get_file_status(PUBLIC_SETTINGS)?></td>
</tr>
<tr>
<td>Announcements</td>
<td><?=ANNOUNCEMENT_FILE?></td>
<td><?=get_file_status(ANNOUNCEMENT_FILE)?></td>
</tr>
<tr>
<td>Email templates</td>
<td><?=EMAIL_TEMPLATES?></td>
<td><?=get_file_status(EMAIL_TEMPLATES)?></td>
</tr>
</table>
If everything is OK, <a href="install.php?step=2">go to step 2</a>.
<?php endif; ?>
<?php if ( $step == 2 ):
if ( count ( $_POST ) )
{
$settings = $_POST['settings'];
if ( !is_dir ( $settings['userfiles_dir'] ) )
{
exit ( 'Error: Userfiles directory does not exist.' );
}
elseif ( !is_writable ( $settings['userfiles_dir'] ) )
{
exit ( 'Error: Userfiles directory is not writable. Please go back, CHMOD and try again.' );
}
if ( !copy ( DATA_DIR . '/userfiles_htaccess.txt', $settings['userfiles_dir'] . '/.htaccess' ) )
{
print 'Notice: Unable to copy the file data/userfiles_htaccess.txt to the userfiles directory. Please do this manually.';
}
$db = new DB;
if ( $db->open ( UPLOADER_SETTINGS ) )
{
$db->set ( $settings );
$db->save ();
print '<br />Upload settings successfully saved! You will now be take to the next step. <a href="install.php?step=3">Click here go to there right away!</a>';
header ( 'Refresh: 5;url=install.php?step=3' );
}
else exit ( 'Error: Unable to open the uploader settings file.' );
}
else { ?>
These are only the core Uploader settings. For more settings, visit the
admin section after installation. Please make sure all URLs and Paths end with a trailing slash (/).
<form method="post" action="install.php?step=2">
<table cellspadding="3" cellspacing="1" border="1">
<tr>
<td>Uploader URL</td>
<td>
<input type="text" name="settings[uploader_url]" size="50" value="http://<?=$_SERVER['HTTP_HOST']?><?=dirname($_SERVER['PHP_SELF'])?>/" /><br />
Full URL to the uploader directory. Ex: http://mysite.net/uploader/
</td>
</tr>
<tr>
<td>User files directory</td>
<td>
<input type="text" name="settings[userfiles_dir]" size="50" value="<?=@is_dir('files/')?realpath('files/'):''?>/" /><br />
Full path to the user files directory where user accounts will be created. It can be anywhere on your server. The default is the "files" directory
located in the uploader directory. Remember to CHMOD this directory!
</td>
</tr>
<tr>
<td>User files url</td>
<td>
<input type="text" name="settings[userfiles_url]" size="50" value="<?=is_dir('files/')?'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/files/':''?>" /><br />
The full URL to the userfiles directory.
</td>
</tr>
<tr>
<td>Admin email(s)</td>
<td>
<input type="text" name="settings[email]" size="50" /><br />
The email address(es) of the admin. You can enter multiple, just seperate them with a comma.
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="submit" value="Submit" />
</td>
</tr>
</table>
</form>
<?php } endif; ?>
<?php if ( $step == 3 )
{
print '<h3>Trying to create mysql tables:</h3>';
$mysqlDB->query ( 'DROP TABLE IF EXISTS uploader_users;' );
$str = "
CREATE TABLE uploader_users
(
userid MEDIUMINT UNSIGNED AUTO_INCREMENT,
username VARCHAR(64) NOT NULL,
password VARCHAR(32) NOT NULL,
email VARCHAR(255) NOT NULL,
level TINYINT UNSIGNED DEFAULT '0',
max_messages TINYINT(1) DEFAULT '20',
is_activated TINYINT(1) DEFAULT '0',
is_approved TINYINT(1) DEFAULT '0',
is_suspended TINYINT(1) DEFAULT '0',
last_login_time INT DEFAULT '0',
last_login_ip VARCHAR(15),
reg_email VARCHAR(255) DEFAULT '',
reg_date INT UNSIGNED DEFAULT '0',
reg_ip VARCHAR(15) DEFAULT '0.0.0.0',
pref_accepts_pm TINYINT(1) DEFAULT '1',
pref_show_email TINYINT(1) DEFAULT '0',
bw_used DOUBLE UNSIGNED NOT NULL DEFAULT '0',
bw_max INT UNSIGNED NOT NULL,
bw_reset_last INT UNSIGNED DEFAULT '0',
bw_reset_period TINYINT UNSIGNED DEFAULT '30',
bw_reset_auto TINYINT(1) DEFAULT '1',
bw_xfer_rate SMALLINT UNSIGNED DEFAULT '0',
fl_max_storage SMALLINT UNSIGNED DEFAULT '5',
fl_max_filesize MEDIUMINT UNSIGNED DEFAULT '2048',
fl_allowed_types VARCHAR(255),
fl_images_only TINYINT(1) DEFAULT '1',
fl_rename_permission TINYINT(1) DEFAULT '0',
fl_allow_folders TINYINT(1) DEFAULT '1',
fl_max_folders SMALLINT DEFAULT '10',
fl_watermark TINYINT(1) DEFAULT '1',
fl_has_public TINYINT(1) DEFAULT '0',
xtr_admin_comments VARCHAR(255),
xtr_new_email_address VARCHAR(255),
xtr_activation_code VARCHAR(32),
xtr_password_reset_code VARCHAR(32),
xtr_change_email_code VARCHAR(32),
PRIMARY KEY (userid),
KEY (username),
KEY (fl_has_public)
);";
if ( !$mysqlDB->query ( $str ) ) exit ( $mysqlDB->error (__LINE__,__FILE__) );
print 'Table uploader_users created.<br />';
$mysqlDB->query ( 'DROP TABLE IF EXISTS uploader_messages;' );
$str = "
CREATE TABLE uploader_messages
(
messageid INT UNSIGNED AUTO_INCREMENT,
userid MEDIUMINT UNSIGNED NOT NULL,
from_id MEDIUMINT UNSIGNED NOT NULL,
from_username VARCHAR(64) NOT NULL,
subject VARCHAR(255) NOT NULL,
message TEXT DEFAULT '',
folder TINYINT NOT NULL,
date INT UNSIGNED NOT NULL,
is_read TINYINT(1) DEFAULT '0',
PRIMARY KEY (messageid),
KEY(userid)
);";
if ( !$mysqlDB->query ( $str ) ) exit ( $mysqlDB->error (__LINE__,__FILE__) );
print 'Table uploader_messages created.<br />';
$mysqlDB->query ( "DROP TABLE IF EXISTS uploader_puploads" );
$str = "
CREATE TABLE uploader_puploads
(
upload_id INT UNSIGNED AUTO_INCREMENT,
upload_name VARCHAR(64) DEFAULT '',
upload_date INT UNSIGNED NOT NULL,
upload_comments VARCHAR(255) DEFAULT '',
upload_key VARCHAR(32) NOT NULL,
upload_ip VARCHAR(16) NOT NULL,
PRIMARY KEY (upload_id)
);";
if ( !$mysqlDB->query ( $str ) ) exit ( $mysqlDB->error (__LINE__,__FILE__) );
print 'Table uploader_puploads created.<br />';
$mysqlDB->query ( "DROP TABLE IF EXISTS uploader_pfiles" );
$str = "
CREATE TABLE uploader_pfiles
(
file_id INT UNSIGNED AUTO_INCREMENT,
file_name VARCHAR(128) NOT NULL,
file_rname VARCHAR(128) NOT NULL,
file_size INT UNSIGNED NOT NULL,
file_views INT UNSIGNED DEFAULT 0,
file_isimage TINYINT(1) DEFAULT 0,
file_hasthumb TINYINT(1) DEFAULT 0,
upload_id INT UNSIGNED NOT NULL,
PRIMARY KEY (file_id),
KEY(upload_id)
);";
if ( !$mysqlDB->query ( $str ) ) exit ( $mysqlDB->error (__LINE__,__FILE__) );
print 'Table uploader_pfiles created.<br />';
print '<a href="install.php?step=4">Proceed to the next step</a>';
}
?>
<?php if ( $step == 4 ) :
if ( count ( $_POST ) )
{
$userid = 1;
$submit = $_POST['user'];
if ( $submit['password'] != $submit['password2'] )
exit ( 'The passwords you entered do not match. Click Back.' );
$new_user_info = array
(
'userid' => NULL,
'username' => $submit['name'],
'password' => md5 ( $submit['password'] ),
'email' => $submit['email'],
'level' => LEVEL_ADMIN,
'max_messages' => 0,
'is_activated' => 1,
'is_approved' => 1,
'is_suspended' => 0,
'last_login_time' => 0,
'last_login_ip' => '0.0.0.0',
'reg_email' => $submit['email'],
'reg_date' => time(),
'reg_ip' => $_SERVER['REMOTE_ADDR'],
'pref_accepts_pm' => 1,
'pref_show_email' => 1,
'bw_used' => 0,
'bw_max' => 0,
'bw_reset_last' => 0,
'bw_reset_period' => 30,
'bw_reset_auto' => 1,
'bw_xfer_rate' => 0,
'fl_max_storage' => 0,
'fl_max_filesize' => 0,
'fl_allowed_types' => '',
'fl_images_only' => 0,
'fl_rename_permission' => 2,
'fl_allow_folders' => 0,
'fl_max_folders' => 0,
'fl_watermark' => 0,
'xtr_admin_comments' => '',
'xtr_new_email_address' => '',
'xtr_activation_code' => md5 ( get_rand ( 1024 ) ),
'xtr_password_reset_code' => md5 ( get_rand ( 1024 ) ),
'xtr_change_email_code' => md5 ( get_rand ( 1024 ) ),
);
if ( !$mysqlDB->query ( "INSERT INTO uploader_users SET " . $mysqlDB->buildInsertStatement ( $new_user_info ) . ";" ) ) exit ( $mysqlDB->error ( __LINE__, __FILE__ ) );
if ( $mysqlDB->getAffectRowCount ( ) )
{
$userid = $mysqlDB->getInsertId();
$db = new DB;
if ( $db->open ( UPLOADER_SETTINGS ) )
{
$user_root = $db->get ( 'userfiles_dir' ) . "/$userid/";
if ( !make_dir ( $user_root, CHMOD_VALUE ) )
{
exit ( '<h1>Error!</h1><span class="red">Unable to create user directory for the admin. Please go back to Step 1.</span>' );
}
}
else
{
exit ( '<h1>Error!</h1><span class="red">Unable to open the uploader settings file. Please go back to Step 1.</span>' );
}
}
else exit ( 'Could not add admin user to the database.' );
print 'Congrats, installation successful. <a href="install.php?step=5">Click here</a> to remove the installer and login. If the installer fails to remove itself, please delete it manually.';
}
else
{?>
<form method="post" action="install.php?step=4">
<table cellspadding="3" cellspacing="1" border="1">
<tr>
<td>Username</td>
<td><input type="text" name="user[name]" size="50" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="user[password]" size="50" /></td>
</tr>
<tr>
<td>Confirm password</td>
<td><input type="password" name="user[password2]" size="50" /></td>
</tr>
<tr>
<td>Email address</td>
<td><input type="text" name="user[email]" size="50" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Submit" /></td>
</tr>
</table>
</form>
<?php } endif; ?>
<?php if ( $step == 5 )
{
if ( unlink ( 'install.php' ) )
{
header ( 'Location: account.php?action=login' );
}
else
{
exit ( 'Unable to remove install.php, please remove this file manually.' );
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -