diff --git a/admin/admin_ajax.php b/admin/admin_ajax.php new file mode 100644 index 00000000..af1ce3c2 --- /dev/null +++ b/admin/admin_ajax.php @@ -0,0 +1,67 @@ +getToken()) { + header('Location: ../index.php?msg=Invalid token. Please login.'); + } else if (!$admin->is_admin) { + header('Location: ../index.php?msg=Looks like that you are not administrator :('); + } +} else { + header('Location: ../index.php?msg=Illegal access. Please login.'); +} + +/* + * No protection here, + * I don't think you wanna fuck yourself :( + */ +if (isset($_GET['action'])) { + $action = $_GET['action']; + $user = new user($_GET['uname']); + + if ($action == "upload") { + $type = isset($_GET['type']) ? $_GET['type'] : "skin"; + $file = isset($_FILES['file']) ? $_FILES['file'] : null; + if (!is_null($file)) { + if ($user->setTexture($type, $file)) { + $json['errno'] = 0; + $json['msg'] = "Skin uploaded successfully."; + } else { + $json['errno'] = 1; + $json['msg'] = "Uncaught error."; + } + } else { + utils::raise(1, 'No input file selected'); + } + } else if ($action == "change") { + if (user::checkValidPwd($_POST['passwd'])) { + $user->changePasswd($_POST['passwd']); + $json['errno'] = 0; + $json['msg'] = "Password of ".$_GET['uname']." changed successfully."; + } // Will raise exception if password invalid + } else if ($action == "delete") { + $user->unRegister(); + $json['errno'] = 0; + $json['msg'] = "Account successfully deleted."; + } +} + +echo json_encode($json); diff --git a/admin/index.php b/admin/index.php index ac1d2100..cad3daca 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,10 +1,115 @@ - +getToken()) { + header('Location: ../index.php?msg=Invalid token. Please login.'); + } else if (!$admin->is_admin) { + header('Location: ../index.php?msg=Looks like that you are not administrator :('); + } +} else { + header('Location: ../index.php?msg=Illegal access. Please login.'); +} +?> + +
-