-
-
Save aikar/94bb39f7e3d122dad21f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$lastMonth = strtotime('last month'); | |
if (date('d') < 5) { | |
$lastMonth = strtotime('last month'); | |
} else { | |
$lastMonth = strtotime('this month'); | |
} | |
$history_table = date('Y_n', $lastMonth); | |
$sql = [ | |
"CREATE TABLE IF NOT EXISTS minecraft.leader_texp_month_$history_table LIKE minecraft.leader_texp_month;", | |
"INSERT IGNORE INTO minecraft.leader_texp_month_$history_table SELECT * FROM minecraft.leader_texp_month;", | |
"UPDATE user SET texp_month = 0 WHERE user_id >= 0;", | |
"CREATE TABLE IF NOT EXISTS xenforo.user_ref_count_$history_table LIKE xenforo.user_ref_count;", | |
"INSERT IGNORE INTO xenforo.user_ref_count_$history_table SELECT u.username, m.user_group_id as `group`, u.referral_month_count | |
FROM xenforo.xf_user u | |
JOIN minecraft.user m ON (u.username = m.name) | |
WHERE referral_month_count > 0 | |
AND m.last_login > UNIX_TIMESTAMP() - (60*60*24*30)", | |
"UPDATE xenforo.xf_user SET referral_month_count = 0 WHERE user_id >= 0" | |
]; | |
$refLeaders = []; | |
$refs = Database::getRows("SELECT username, referral_month_count FROM xenforo.xf_user ORDER BY referral_month_count DESC LIMIT 15"); | |
foreach ($refs as $ref) { | |
$refLeaders[] = $ref['username'] . ' ' . $ref['referral_month_count']; | |
} | |
$refLeaders = join("\n", $refLeaders); | |
Core::output("Ref Leaders: " . $refLeaders); | |
mail('krysyyjane9191', "Monthly Referral Leaders for $history_table", $refLeaders); | |
foreach ($sql as $query) { | |
Database::query($query); | |
} | |
Core::output("TEXP/Refs Reset"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment