From 704c5d8b494e02bfb6f1361232a545673b83de23 Mon Sep 17 00:00:00 2001 From: Partur-dev Date: Sun, 1 May 2022 16:03:00 +0300 Subject: [PATCH] cp config --- config/cp.php | 7 +++++ tools/cron/fixcps.php | 69 +++++++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 config/cp.php diff --git a/config/cp.php b/config/cp.php new file mode 100644 index 000000000..6ac9cad17 --- /dev/null +++ b/config/cp.php @@ -0,0 +1,7 @@ + diff --git a/tools/cron/fixcps.php b/tools/cron/fixcps.php index 12ebacc41..d94e839d5 100644 --- a/tools/cron/fixcps.php +++ b/tools/cron/fixcps.php @@ -21,11 +21,12 @@ $cplog = ""; $people = array(); include "../../incl/lib/connection.php"; +include "../../config/cp.php"; //getting users $query = $db->prepare("UPDATE users LEFT JOIN ( - SELECT usersTable.userID, (IFNULL(starredTable.starred, 0) + IFNULL(featuredTable.featured, 0) + (IFNULL(epicTable.epic,0)*2)) as CP FROM ( + SELECT usersTable.userID, ((IFNULL(starredTable.starred, 0)*:star_cp) + (IFNULL(featuredTable.featured, 0)*:featured_cp) + (IFNULL(epicTable.epic,0)*:epic_cp)) as CP FROM ( SELECT userID FROM users ) AS usersTable LEFT JOIN @@ -43,7 +44,7 @@ ) calculated ON users.userID = calculated.userID SET users.creatorPoints = IFNULL(calculated.CP, 0)"); -$query->execute(); +$query->execute([":star_cp" => $star_cp, ":featured_cp" => $featured_cp, ":epic_cp" => $epic_cp]); echo "Calculated base CP
"; /* CP SHARING @@ -54,13 +55,13 @@ foreach($result as $level){ $deservedcp = 0; if($level["starStars"] != 0){ - $deservedcp++; + $deservedcp += $star_cp; } if($level["starFeatured"] != 0){ - $deservedcp++; + $deservedcp += $featured_cp; } if($level["starEpic"] != 0){ - $deservedcp += 2; + $deservedcp += $epic_cp; } $query = $db->prepare("SELECT userID FROM cpshares WHERE levelID = :levelID"); $query->execute([':levelID' => $level["levelID"]]); @@ -75,39 +76,43 @@ /* NOW to update GAUNTLETS CP */ -$query = $db->prepare("SELECT level1,level2,level3,level4,level5 FROM gauntlets"); -$query->execute(); -$result = $query->fetchAll(); -//getting gauntlets -foreach($result as $gauntlet){ - //getting lvls - for($x = 1; $x < 6; $x++){ - $query = $db->prepare("SELECT userID, levelID FROM levels WHERE levelID = :levelID"); - $query->execute([':levelID' => $gauntlet["level".$x]]); - $result = $query->fetch(); - //getting users - if($result["userID"] != ""){ - $cplog .= $result["userID"] . " - +1\r\n"; - $people[$result["userID"]] += 1; +if ($gauntlets_cp != 0) { + $query = $db->prepare("SELECT level1,level2,level3,level4,level5 FROM gauntlets"); + $query->execute(); + $result = $query->fetchAll(); + //getting gauntlets + foreach($result as $gauntlet){ + //getting lvls + for($x = 1; $x < 6; $x++){ + $query = $db->prepare("SELECT userID, levelID FROM levels WHERE levelID = :levelID"); + $query->execute([':levelID' => $gauntlet["level".$x]]); + $result = $query->fetch(); + //getting users + if($result["userID"] != ""){ + $cplog .= $result["userID"] . " - +$gauntlets_cp\r\n"; + $people[$result["userID"]] += $gauntlets_cp; + } } } } /* NOW to update DAILY CP */ -$query = $db->prepare("SELECT levelID FROM dailyfeatures WHERE timestamp < :time"); -$query->execute([':time' => time()]); -$result = $query->fetchAll(); -//getting gauntlets -foreach($result as $daily){ - //getting lvls - $query = $db->prepare("SELECT userID, levelID FROM levels WHERE levelID = :levelID"); - $query->execute([':levelID' => $daily["levelID"]]); - $result = $query->fetch(); - //getting users - if($result["userID"] != ""){ - $people[$result["userID"]] += 1; - $cplog .= $result["userID"] . " - +1\r\n"; +if ($daily_cp != 0) { + $query = $db->prepare("SELECT levelID FROM dailyfeatures WHERE timestamp < :time"); + $query->execute([':time' => time()]); + $result = $query->fetchAll(); + //getting gauntlets + foreach($result as $daily){ + //getting lvls + $query = $db->prepare("SELECT userID, levelID FROM levels WHERE levelID = :levelID"); + $query->execute([':levelID' => $daily["levelID"]]); + $result = $query->fetch(); + //getting users + if($result["userID"] != ""){ + $people[$result["userID"]] += $daily_cp; + $cplog .= $result["userID"] . " - +$daily_cp\r\n"; + } } } /*