fix typo
This commit is contained in:
41
api.php
41
api.php
@@ -4,12 +4,13 @@ $mysqllogin = json_decode(file_get_contents("secrets/MysqlLogin.json"), false);
|
|||||||
|
|
||||||
$mysqli = new mysqli('localhost', $mysqllogin->DBUser, $mysqllogin->DBPassword, $mysqllogin->DBName);
|
$mysqli = new mysqli('localhost', $mysqllogin->DBUser, $mysqllogin->DBPassword, $mysqllogin->DBName);
|
||||||
|
|
||||||
$action = $_POST["action"];
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$action = $_POST["action"];
|
||||||
|
|
||||||
if($action == "login"){
|
if($action == "login"){
|
||||||
$uname = $_POST["username"];
|
$uname = $_POST["username"];
|
||||||
$pwd = $_POST["password"];
|
$pwd = $_POST["password"];
|
||||||
$stmt1 = $mysqli->prepare("SELECT `Password, ID, FullName, Nickname, CanSeeFullNames, CanSeeOthersComments, IsAdmin FROM Users WHERE Username = %s;");
|
$stmt1 = $mysqli->prepare("SELECT Password, ID, FullName, Nickname, CanSeeFullNames, CanSeeOthersComments, IsAdmin FROM Users WHERE Username = %s;");
|
||||||
$stmt1->bind_param('s', $uname);
|
$stmt1->bind_param('s', $uname);
|
||||||
$stmt1->bind_result($pwdhash, $uid, $fullname, $nick, $fullnamepriv, $otherscommentspriv, $adminpriv);
|
$stmt1->bind_result($pwdhash, $uid, $fullname, $nick, $fullnamepriv, $otherscommentspriv, $adminpriv);
|
||||||
$stmt1->execute();
|
$stmt1->execute();
|
||||||
@@ -30,18 +31,18 @@ if($action == "login"){
|
|||||||
}
|
}
|
||||||
echo "Logged in";
|
echo "Logged in";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action == "logout"){
|
if($action == "logout"){
|
||||||
session_destroy();
|
session_destroy();
|
||||||
echo "Logged out";
|
echo "Logged out";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function processUserRelated($actionin, mysqli $mysqliconn){
|
function processUserRelated($actionin, mysqli $mysqliconn){
|
||||||
|
|
||||||
if($actionin == "setnickname"){
|
if($actionin == "setnickname"){
|
||||||
$newNick = $_POST["newnick"];
|
$newNick = $_POST["newnick"];
|
||||||
@@ -132,10 +133,10 @@ function processUserRelated($actionin, mysqli $mysqliconn){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function processCitationRelated($actionin, mysqli $mysqliconn){
|
function processCitationRelated($actionin, mysqli $mysqliconn){
|
||||||
|
|
||||||
if($actionin == "getcitations"){
|
if($actionin == "getcitations"){
|
||||||
|
|
||||||
@@ -166,10 +167,10 @@ function processCitationRelated($actionin, mysqli $mysqliconn){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function processTagsRelated($actionin, mysqli $mysqliconn){
|
function processTagsRelated($actionin, mysqli $mysqliconn){
|
||||||
|
|
||||||
if($actionin == "createtag"){
|
if($actionin == "createtag"){
|
||||||
|
|
||||||
@@ -184,9 +185,9 @@ function processTagsRelated($actionin, mysqli $mysqliconn){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processSourcesRelated($actionin, mysqli $mysqliconn){
|
function processSourcesRelated($actionin, mysqli $mysqliconn){
|
||||||
|
|
||||||
if($actionin == "createsource"){
|
if($actionin == "createsource"){
|
||||||
|
|
||||||
@@ -201,9 +202,9 @@ function processSourcesRelated($actionin, mysqli $mysqliconn){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processCommentRelated($actionin, mysqli $mysqliconn){
|
function processCommentRelated($actionin, mysqli $mysqliconn){
|
||||||
|
|
||||||
if($actionin == "createcomment"){
|
if($actionin == "createcomment"){
|
||||||
|
|
||||||
@@ -222,9 +223,9 @@ function processCommentRelated($actionin, mysqli $mysqliconn){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_SESSION["loggedin"] == 1){
|
if($_SESSION["loggedin"] == 1){
|
||||||
|
|
||||||
$citationreturn = processCitationRelated($action, $mysqli);
|
$citationreturn = processCitationRelated($action, $mysqli);
|
||||||
if($citationreturn != 0){
|
if($citationreturn != 0){
|
||||||
@@ -255,11 +256,11 @@ if($_SESSION["loggedin"] == 1){
|
|||||||
echo $userreturn;
|
echo $userreturn;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
echo "Not logged in";
|
echo "Not logged in";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user