diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 00000000..ac1d2100
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,10 @@
+
+
+
+ Console - Blessing Skin Server 0.1
+
+
+
+ Console
+
+
diff --git a/admin/install.php b/admin/install.php
new file mode 100644
index 00000000..b1d5d794
--- /dev/null
+++ b/admin/install.php
@@ -0,0 +1,52 @@
+Blessing Skin Server Install";
+
+ if (!$con) {
+ die ("Can not connect to mysql, check if database info correct in config.php. ".mysql_error());
+ } else {
+ echo "Succesfully connected to mysql server. ";
+ }
+
+ if(!mysql_select_db(DB_NAME, $con)){
+ die("Can not select database, please check if database '".DB_NAME."' really exists.");
+ }
+
+ echo "Selected database: ".DB_NAME." ";
+
+ echo "Start creating tables... ";
+
+ $query = "CREATE TABLE IF NOT EXISTS `users` (
+ `uid` int(11) NOT NULL AUTO_INCREMENT,
+ `admin` tinyint(1) NOT NULL DEFAULT '0',
+ `username` varchar(20) NOT NULL,
+ `password` varchar(32) NOT NULL,
+ `ip` varchar(32) NOT NULL,
+ PRIMARY KEY (`uid`),
+ UNIQUE KEY `uid` (`uid`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15;";
+
+ if(!mysql_query($query)) {
+ die("Creating tables failed. ".mysql_error());
+ }
+
+ /**
+ * username: admin
+ * password: 123456
+ */
+ mysql_query("INSERT INTO `users` (`uid`, `admin`, `username`, `password`, `ip`) VALUES(1, 1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '')");
+
+ echo "Successfully installed. Index ";
+
+ $lock = fopen("./install.lock", w) or die("Unable to write 'install.lock'.");
+ fwrite($lock, time());
+ fclose($lock);
+
+} else {
+ echo "It seems that you have already installed. Index ";
+ echo "May you should delete the file 'install.lock' in /admin to unlock installing.";
+}
+?>
diff --git a/assets/js/login_utils.js b/assets/js/login_utils.js
index 930b86bb..b73663b6 100755
--- a/assets/js/login_utils.js
+++ b/assets/js/login_utils.js
@@ -2,10 +2,10 @@
$(document).ready(function(){
if (docCookies.hasItem("uname") && docCookies.hasItem("token") && $("#login-reg").html() == 'Register') {
checkToken(docCookies.getItem("token"),function(json) {
- if (json.success == 1) {
+ if (json.success == 1) {
showMsg("alert-success", json.msg);
window.location = "./user.php";
- } else {
+ } else {
showMsg("alert-danger", json.msg);
}
});
@@ -37,10 +37,12 @@ function changeForm(code){
$("#confirm-passwd").show();
$(".login-group").html('Register ');
window.history.pushState(null, null, "./index.php?action=register");
+ document.title = "Register - Blessing Skin Server 0.1";
} else {
$(".login-title").html('Login');
$("#confirm-passwd").hide();
$(".login-group").html(' Remember me
Log in ');
window.history.pushState(null, null, "./index.php?action=login");
+ document.title = "Login - Blessing Skin Server 0.1";
}
}
diff --git a/check.php b/check.php
index dc1f7d74..cf3ee82c 100755
--- a/check.php
+++ b/check.php
@@ -1,23 +1,24 @@
\ No newline at end of file
+?>
diff --git a/config.php b/config.php
index 5cfbc6cf..6c2b83b7 100644
--- a/config.php
+++ b/config.php
@@ -1,16 +1,16 @@
\ No newline at end of file
+?>
diff --git a/connect.php b/connect.php
index ad15df38..64545ce9 100644
--- a/connect.php
+++ b/connect.php
@@ -3,29 +3,29 @@ require "./config.php";
$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWD);
if (!$con) {
- die ("Can not connect to mysql, check if database info correct.".mysql_error());
+ die ("Can not connect to mysql, check if database info correct in config.php. ".mysql_error());
}
mysql_select_db(DB_NAME, $con);
function getToken($uname) {
global $con;
// Simple SQL injection protection
- $uname = strtolower(stripslashes(trim($_POST['uname'])));
+ $uname = strtolower(stripslashes(trim($_POST['uname'])));
$uname = mysql_real_escape_string($uname);
- $query = mysql_query("SELECT * FROM users where username='$uname'", $con);
+ $query = mysql_query("SELECT * FROM users where username='$uname'", $con);
$row = mysql_fetch_array($query);
return md5($row['uname'].$row['passwd'].SALT);
mysql_close($con);
}
function checkToken($uname, $token) {
- $uname = strtolower(stripslashes(trim($_POST['uname'])));
+ $uname = strtolower(stripslashes(trim($_POST['uname'])));
$uname = mysql_real_escape_string($uname);
if ($token != getToken($uname)){
$arr['success'] = 0;
$arr['msg'] = "Invalid Token: ".$token;
} else {
- $arr['success'] = 1;
+ $arr['success'] = 1;
$arr['msg'] = 'Valid Token.';
}
return $arr;
@@ -33,21 +33,21 @@ function checkToken($uname, $token) {
function checkPasswd($uname, $rawPasswd) {
global $con;
- $uname = strtolower(stripslashes(trim($_POST['uname'])));
+ $uname = strtolower(stripslashes(trim($_POST['uname'])));
$uname = mysql_escape_string($uname);
- $query = mysql_query("SELECT * FROM users where username='$uname'", $con);
+ $query = mysql_query("SELECT * FROM users where username='$uname'", $con);
$row = mysql_fetch_array($query);
-
+
if (!$row['password']) {
- $arr['success'] = 0;
+ $arr['success'] = 0;
$arr['msg'] = "Non-existent user.";
} else {
if ($row['password'] == $rawPasswd) {
- $arr['success'] = 1;
- $arr['msg'] = 'Logging in succeed!';
+ $arr['success'] = 1;
+ $arr['msg'] = 'Logging in succeed!';
$arr['token'] = getToken();
} else {
- $arr['success'] = 0;
+ $arr['success'] = 0;
$arr['msg'] = "Incorrect usename or password.";
}
}
@@ -57,26 +57,26 @@ function checkPasswd($uname, $rawPasswd) {
function register($uname, $passwd, $ip) {
global $con;
- $uname = strtolower(stripslashes(trim($_POST['uname'])));
+ $uname = strtolower(stripslashes(trim($_POST['uname'])));
$uname = mysql_real_escape_string($uname);
- $query = mysql_query("SELECT * FROM users where username='$uname'", $con);
+ $query = mysql_query("SELECT * FROM users where username='$uname'", $con);
$row = mysql_fetch_array($query);
-
+
if (!$row['password']) {
-
+
$ipQuery = mysql_query("SELECT * FROM users where ip='$ip'", $con);
$ipRow = mysql_fetch_array($ipQuery);
-
+
if(!$ipRow['username']) {
mysql_query("INSERT INTO users (username, password, ip) VALUES ('$uname', '$passwd', '$ip')", $con);
- $arr['success'] = 1;
+ $arr['success'] = 1;
$arr['msg'] = "Registered successfully.";
} else {
- $arr['success'] = 0;
+ $arr['success'] = 0;
$arr['msg'] = "It seems that you have already register a account with this IP address.";
}
} else {
- $arr['success'] = 0;
+ $arr['success'] = 0;
$arr['msg'] = "User already existed.";
}
return $arr;
diff --git a/index.php b/index.php
index a6b81230..b3e59e87 100755
--- a/index.php
+++ b/index.php
@@ -1,7 +1,10 @@
+
- Blessing Skin Server 0.1
+ Index - Blessing Skin Server 0.1
@@ -67,7 +70,7 @@
-changeForm(1);";
}
@@ -75,4 +78,4 @@ if ($_GET["msg"]) {
echo "";
}?>
-
\ No newline at end of file
+