Game impl update

This commit is contained in:
Astrologies 2021-12-31 03:02:35 -05:00
parent 340660d1d0
commit 9f6a68d526
3 changed files with 36 additions and 2 deletions

View File

@ -238,6 +238,34 @@ namespace Alphaland\Games {
return false;
}
public static function RemovePersonalBuildServerRank(int $placeid, int $userid)
{
$remove = $GLOBALS['pdo']->prepare("DELETE FROM personal_build_ranks WHERE placeid = :pid AND userid = :uid");
$remove->bindParam(":pid", $placeid, PDO::PARAM_INT);
$remove->bindParam(":uid", $userid, PDO::PARAM_INT);
$remove->execute();
if ($remove->rowCount() > 0) {
return true;
}
return false;
}
public static function GetPersonalBuildServerRank(int $placeid, int $userid)
{
if ($userid == Asset::GetAssetInfo($placeid)->CreatorId) {
return 255;
} else {
$rank = $GLOBALS['pdo']->prepare("SELECT * FROM personal_build_ranks WHERE placeid = :pid AND userid = :uid");
$rank->bindParam(":pid", $placeid, PDO::PARAM_INT);
$rank->bindParam(":uid", $userid, PDO::PARAM_INT);
$rank->execute();
if ($rank->rowCount() > 0) {
return $rank->fetch(PDO::FETCH_OBJ)->rank;
}
}
return 10; //no rank. consider them Visitor rank
}
public static function PersonalBuildRankToName($rank)
{
switch ($rank)

View File

@ -6,6 +6,9 @@ Alphaland 2021
*/
//headers
use Alphaland\Games\Game;
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
header("access-control-allow-credentials: true");
@ -21,7 +24,7 @@ $userid = $_GET['userId'];
$userInfo = array(
"data" => array(
"Rank" => getBuildServerRank($placeid, $userid),
"Rank" => Game::GetPersonalBuildServerRank($placeid, $userid),
)
);

View File

@ -64,7 +64,10 @@ else
else if ($removeuser)
{
$userid = $data->userid;
$message = removePBSUser($assetid, $userid);
$message = null;
if (Game::RemovePersonalBuildServerRank($assetid, $userid)) {
$message = true;
}
}
else if ($whitelistuser)
{