Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cp config #828

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config/cp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$star_cp = 1;
$featured_cp = 1;
$epic_cp = 2;
$gauntlets_cp = 1; // 0 - disabled
$daily_cp = 1; // 0 - disabled
?>
69 changes: 37 additions & 32 deletions tools/cron/fixcps.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<br>";
/*
CP SHARING
Expand All @@ -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"]]);
Expand All @@ -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";
}
}
}
/*
Expand Down