update install.php to adapt to new table structure
This commit is contained in:
parent
089a967106
commit
cd184d830e
|
|
@ -1,4 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @Author: printempw
|
||||||
|
* @Date: 2016-01-16 23:01:33
|
||||||
|
* @Last Modified by: prpr
|
||||||
|
* @Last Modified time: 2016-01-17 10:18:53
|
||||||
|
*
|
||||||
|
* Create tables automatically
|
||||||
|
*/
|
||||||
|
|
||||||
|
function __autoload($classname) {
|
||||||
|
$filename = "./includes/". $classname .".class.php";
|
||||||
|
include_once($filename);
|
||||||
|
}
|
||||||
|
|
||||||
if (!file_exists("./install.lock")) {
|
if (!file_exists("./install.lock")) {
|
||||||
require "../config.php";
|
require "../config.php";
|
||||||
$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWD);
|
$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWD);
|
||||||
|
|
@ -6,13 +20,13 @@ if (!file_exists("./install.lock")) {
|
||||||
echo "<h2>Blessing Skin Server Install</h2>";
|
echo "<h2>Blessing Skin Server Install</h2>";
|
||||||
|
|
||||||
if (!$con) {
|
if (!$con) {
|
||||||
die ("Can not connect to mysql, check if database info correct in config.php. ".mysql_error());
|
utils::raise('1', "Can not connect to mysql, check if database info correct in config.php. ".mysql_error())
|
||||||
} else {
|
} else {
|
||||||
echo "Succesfully connected to mysql server.<br /><br />";
|
echo "Succesfully connected to mysql server.<br /><br />";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mysql_select_db(DB_NAME, $con)){
|
if(!mysql_select_db(DB_NAME, $con)){
|
||||||
die("Can not select database, please check if database '".DB_NAME."' really exists.");
|
utils::raise('1', "Can not select database, please check if database '".DB_NAME."' really exists.")
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Selected database: ".DB_NAME."<br /><br />";
|
echo "Selected database: ".DB_NAME."<br /><br />";
|
||||||
|
|
@ -21,10 +35,12 @@ if (!file_exists("./install.lock")) {
|
||||||
|
|
||||||
$query = "CREATE TABLE IF NOT EXISTS `users` (
|
$query = "CREATE TABLE IF NOT EXISTS `users` (
|
||||||
`uid` int(11) NOT NULL AUTO_INCREMENT,
|
`uid` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`admin` tinyint(1) NOT NULL DEFAULT '0',
|
|
||||||
`username` varchar(20) NOT NULL,
|
`username` varchar(20) NOT NULL,
|
||||||
`password` varchar(32) NOT NULL,
|
`password` varchar(32) NOT NULL,
|
||||||
`ip` varchar(32) NOT NULL,
|
`ip` varchar(32) NOT NULL,
|
||||||
|
`preference` varchar(32) NOT NULL,
|
||||||
|
`skin_hash` varchar(32) NOT NULL,
|
||||||
|
`cape_hash` varchar(32) NOT NULL,
|
||||||
PRIMARY KEY (`uid`),
|
PRIMARY KEY (`uid`),
|
||||||
UNIQUE KEY `uid` (`uid`)
|
UNIQUE KEY `uid` (`uid`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15;";
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15;";
|
||||||
|
|
@ -37,16 +53,20 @@ if (!file_exists("./install.lock")) {
|
||||||
* username: admin
|
* username: admin
|
||||||
* password: 123456
|
* password: 123456
|
||||||
*/
|
*/
|
||||||
mysql_query("INSERT INTO `users` (`uid`, `admin`, `username`, `password`, `ip`) VALUES(1, 1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '')");
|
mysql_query("INSERT INTO `users` (`uid`, `username`, `password`, `ip`) VALUES(1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '127.0.0.1')");
|
||||||
|
|
||||||
echo "Successfully installed. <a href='../index.php'>Index</a>";
|
echo "Successfully installed. <a href='../index.php'>Index</a>";
|
||||||
|
|
||||||
$lock = fopen("./install.lock", w) or die("Unable to write 'install.lock'.");
|
if ($lock = fopen("./install.lock", w)) {
|
||||||
fwrite($lock, time());
|
fwrite($lock, time());
|
||||||
fclose($lock);
|
fclose($lock);
|
||||||
|
} else {
|
||||||
|
die("Unable to write 'install.lock'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
echo "It seems that you have already installed. <a href='../index.php'>Index</a><br /><br />";
|
echo "It seems that you have already installed. <a href='../index.php'>Index</a><br /><br />";
|
||||||
echo "May you should delete the file 'install.lock' in /admin to unlock installing.";
|
echo "May you should delete the file 'install.lock' in ./admin to unlock installing.";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user