mirror of
https://github.com/Ratstail91/SANCTUM.git
synced 2025-11-29 02:24:27 +11:00
Merge branch 'dev-php-tweaks' into dev
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
ini_set('display_errors', 'On');
|
||||||
|
|
||||||
function privateKey(){
|
function privateKey(){
|
||||||
return "INSERT PRIVATE KEY";
|
return "<REDACTED>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function throwError($errorName){
|
function throwError($errorName){
|
||||||
@@ -178,10 +180,10 @@ function addhttp($url) {
|
|||||||
|
|
||||||
|
|
||||||
function mysqlConnect() {
|
function mysqlConnect() {
|
||||||
$dbhost = 'INSERT DB HOST';
|
$dbhost = 'localhost';
|
||||||
$dbusername = 'INSERT DB USERNAME';
|
$dbusername = 'root';
|
||||||
$dbpassword = 'INSERT DB PASSWORD';
|
$dbpassword = '<REDACTED>';
|
||||||
$dbtable = 'INSERT DB TABLE';
|
$dbtable = 'discordbot';
|
||||||
|
|
||||||
$userDB = 'user';
|
$userDB = 'user';
|
||||||
$userdataDB = 'userdata';
|
$userdataDB = 'userdata';
|
||||||
@@ -189,7 +191,7 @@ function mysqlConnect() {
|
|||||||
$memberdataDB = 'memberdata';
|
$memberdataDB = 'memberdata';
|
||||||
|
|
||||||
$con = mysqli_connect($dbhost,$dbusername,$dbpassword,$dbtable);
|
$con = mysqli_connect($dbhost,$dbusername,$dbpassword,$dbtable);
|
||||||
if (!$con) { die('Could not connect: ' . mysqli_error());}
|
if (!$con) { die('Could not connect: ' . mysqli_error($con));}
|
||||||
mysqli_select_db($con, "$dbtable")or die("cannot select DB");
|
mysqli_select_db($con, "$dbtable")or die("cannot select DB");
|
||||||
return $con;
|
return $con;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
|
//header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
|
||||||
include_once 'functions.php';
|
include_once 'functions.php';
|
||||||
|
|
||||||
if( isset($_GET['dataToLoad']) ){ $dataToLoad = $_GET['dataToLoad']; } else{ $dataToLoad = ''; };
|
if( isset($_GET['dataType']) ){ $dataToLoad = $_GET['dataType']; } else{ $dataToLoad = ''; };
|
||||||
if( isset($_GET['userid']) ){ $userID = $_GET['userid']; } else{ $userID = ''; };
|
if( isset($_GET['userid']) ){ $userID = $_GET['userid']; } else{ $userID = ''; };
|
||||||
if( isset($_GET['pk']) ){ $privateKey = $_GET['pk']; } else{ $privateKey = ''; };
|
if( isset($_GET['pk']) ){ $privateKey = $_GET['pk']; } else{ $privateKey = ''; };
|
||||||
$sqlterms = '';
|
$sqlterms = '';
|
||||||
@@ -97,7 +97,7 @@ case "lastHostileActive":
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "userStats":
|
case "userStats":
|
||||||
$q = "SELECT strength,speed,stamina,health,maxStamina,maxHealth,wallet,xp,lvl,statPoints,chests FROM users WHERE discordUserID = '$userID';";
|
$q = "SELECT strength,speed,stamina,health,maxStamina,maxHealth,wallet,xp,lvl,statPoints FROM users WHERE discordUserID = '$userID';";
|
||||||
$r2 = mysqli_query($con,$q);
|
$r2 = mysqli_query($con,$q);
|
||||||
if ( $r2 !== false && mysqli_num_rows($r2) > 0 ) {
|
if ( $r2 !== false && mysqli_num_rows($r2) > 0 ) {
|
||||||
while ( $a = mysqli_fetch_assoc($r2) ) {
|
while ( $a = mysqli_fetch_assoc($r2) ) {
|
||||||
@@ -111,15 +111,14 @@ case "userStats":
|
|||||||
$xp=stripslashes($a['xp']);
|
$xp=stripslashes($a['xp']);
|
||||||
$recordedLVL=stripslashes($a['lvl']);
|
$recordedLVL=stripslashes($a['lvl']);
|
||||||
$statPoints=stripslashes($a['statPoints']);
|
$statPoints=stripslashes($a['statPoints']);
|
||||||
$chests=stripslashes($a['chests']);
|
|
||||||
$lvlbase = getLevelBase();
|
$lvlbase = getLevelBase();
|
||||||
$lvl = getLevel($xp,$lvlbase);
|
$lvl = getLevel($xp,$lvlbase);
|
||||||
$lvlpercent = getCurrentLevelProgress($xp,$lvl);
|
$lvlpercent = getCurrentLevelProgress($xp,$lvl);
|
||||||
}
|
}
|
||||||
echo $strength.",".$speed.",".$stamina.",".$health.",".$maxStamina.",".$maxHealth.",".$wallet.",".$xp.",".$recordedLVL.",".$lvlpercent.",".$statPoints.",".$chests;
|
echo "success,".$strength.",".$speed.",".$stamina.",".$health.",".$maxStamina.",".$maxHealth.",".$wallet.",".$xp.",".$recordedLVL.",".$lvlpercent.",".$statPoints;
|
||||||
exit;
|
exit;
|
||||||
} else{
|
} else{
|
||||||
echo "0";
|
echo "failure";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ switch ($dataType) {
|
|||||||
$q = "INSERT INTO userLog (discordUserID, actionType, actionData)
|
$q = "INSERT INTO userLog (discordUserID, actionType, actionData)
|
||||||
VALUES (" . $userID . ", '" . $dataType . "', 'Checked in for $dataToSend crystals.');";
|
VALUES (" . $userID . ", '" . $dataType . "', 'Checked in for $dataToSend crystals.');";
|
||||||
$r2 = mysqli_query($con,$q);
|
$r2 = mysqli_query($con,$q);
|
||||||
echo 1;
|
echo "available";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -127,6 +127,11 @@ switch ($dataType) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "transfer":
|
case "transfer":
|
||||||
|
$q = "SELECT discordUserID FROM users WHERE discordUserID = '$dataToSend' LIMIT 1";
|
||||||
|
$r2 = mysqli_query($con,$q);
|
||||||
|
if ( $r2 == false || mysqli_num_rows($r2) == 0 ) {
|
||||||
|
return "failure";
|
||||||
|
} else {
|
||||||
$q = "UPDATE users SET wallet = wallet - $dataToSend2 WHERE discordUserID = '$userID' LIMIT 1";
|
$q = "UPDATE users SET wallet = wallet - $dataToSend2 WHERE discordUserID = '$userID' LIMIT 1";
|
||||||
$r2 = mysqli_query($con,$q);
|
$r2 = mysqli_query($con,$q);
|
||||||
$q = "UPDATE users SET wallet = wallet + $dataToSend2 WHERE discordUserID = '$dataToSend' LIMIT 1";
|
$q = "UPDATE users SET wallet = wallet + $dataToSend2 WHERE discordUserID = '$dataToSend' LIMIT 1";
|
||||||
@@ -135,9 +140,9 @@ switch ($dataType) {
|
|||||||
$q = "INSERT INTO userLog (discordUserID, actionType, actionData)
|
$q = "INSERT INTO userLog (discordUserID, actionType, actionData)
|
||||||
VALUES (" . $userID . ", '" . $dataType . "', '$userID gave $dataToSend2 crystals to $dataToSend.');";
|
VALUES (" . $userID . ", '" . $dataType . "', '$userID gave $dataToSend2 crystals to $dataToSend.');";
|
||||||
$r2 = mysqli_query($con,$q);
|
$r2 = mysqli_query($con,$q);
|
||||||
echo 1;
|
echo "success";
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "attack":
|
case "attack":
|
||||||
@@ -545,33 +550,29 @@ switch ($dataType) {
|
|||||||
addXp($userID,$dataToSend);
|
addXp($userID,$dataToSend);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case "getLevelUp":
|
case "getLevelUp":
|
||||||
//addXp($userID,$dataToSend);
|
$levelCap = 30;
|
||||||
$levelCap = 30;$levelCapXP = 625;
|
$levelCapXP = 625;
|
||||||
$q = "SELECT xp,lvl,statPoints,chests FROM users WHERE discordUserID = '$userID';";
|
$q = "SELECT xp,lvl,statPoints FROM users WHERE discordUserID = '$userID';";
|
||||||
$r2 = mysqli_query($con,$q);
|
$r2 = mysqli_query($con,$q);
|
||||||
if ( $r2 !== false && mysqli_num_rows($r2) > 0 ) {
|
if ( $r2 && mysqli_num_rows($r2) > 0 ) {
|
||||||
while ( $a = mysqli_fetch_assoc($r2) ) {
|
while ( $a = mysqli_fetch_assoc($r2) ) {
|
||||||
$xp=stripslashes($a['xp']);
|
$xp=stripslashes($a['xp']);
|
||||||
$lvl=stripslashes($a['lvl']);
|
$lvl=stripslashes($a['lvl']);
|
||||||
$statPoints=stripslashes($a['statPoints']);
|
$statPoints=stripslashes($a['statPoints']);
|
||||||
$chests=stripslashes($a['chests']);
|
|
||||||
}
|
}
|
||||||
$lvlbase = getLevelBase();
|
$lvlbase = getLevelBase();
|
||||||
$currentLVL = floor(getLevel($xp,$lvlbase));
|
$currentLVL = floor(getLevel($xp,$lvlbase));
|
||||||
if($currentLVL > $lvl){
|
if($currentLVL > $lvl){
|
||||||
if($currentLVL > $levelCap){
|
if($currentLVL > $levelCap){
|
||||||
$chests += 1;
|
$q = "UPDATE users SET lvl = $levelCap, xp = $levelCapXP WHERE discordUserID = '$userID' LIMIT 1";
|
||||||
$q = "UPDATE users SET lvl = $levelCap,chests = chests + 1,xp = $levelCapXP WHERE discordUserID = '$userID' LIMIT 1";
|
|
||||||
$r2 = mysqli_query($con,$q);
|
$r2 = mysqli_query($con,$q);
|
||||||
}else{
|
}else{
|
||||||
$statPoints += 1;
|
$statPoints += 1;
|
||||||
$q = "UPDATE users SET lvl = lvl + 1,statPoints = statPoints + 1 WHERE discordUserID = '$userID' LIMIT 1";
|
$q = "UPDATE users SET lvl = lvl + 1,statPoints = statPoints + 1 WHERE discordUserID = '$userID' LIMIT 1";
|
||||||
$r2 = mysqli_query($con,$q);
|
$r2 = mysqli_query($con,$q);
|
||||||
$lvl = $lvl + 1;
|
|
||||||
}
|
}
|
||||||
echo "levelup,".$lvl.",".$statPoints.",".$statPoints;
|
echo "levelup,".$currentLVL.",".$statPoints;
|
||||||
} else {
|
} else {
|
||||||
echo "xpadded,".$currentLVL.",".$statPoints;
|
echo "xpadded,".$currentLVL.",".$statPoints;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user