Skip to content

Commit

Permalink
PUSH
Browse files Browse the repository at this point in the history
-> Check if the value is a number then if not format it and support -1 values!
  • Loading branch information
NaysKutzu authored Mar 1, 2024
1 parent 38f63f4 commit 4d521cb
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions view/requirements/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,52 @@
$reason = "";
if ($session->getUserInfo('ram') > SettingsManager::getSetting('max_ram')) {
$reason = "RAM";
$conn->query("UPDATE `mythicaldash_users` SET `ram` = '".SettingsManager::getSetting('max_ram') - 1 ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
$new_ram = (int)SettingsManager::getSetting('max_ram') - 1;
if ($new_ram >= 0) {
$conn->query("UPDATE `mythicaldash_users` SET `ram` = '". $new_ram ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
}
} elseif ($session->getUserInfo('cpu') > SettingsManager::getSetting('max_cpu')) {
$reason = "CPU";
$conn->query("UPDATE `mythicaldash_users` SET `cpu` = '". SettingsManager::getSetting('max_cpu') - 1 ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
$new_cpu = (int)SettingsManager::getSetting('max_cpu') - 1;
if ($new_cpu >= 0) {
$conn->query("UPDATE `mythicaldash_users` SET `cpu` = '". $new_cpu ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
}
} elseif ($session->getUserInfo('disk') > SettingsManager::getSetting('max_disk')) {
$reason = "Disk Space";
$conn->query("UPDATE `mythicaldash_users` SET `disk` = '".SettingsManager::getSetting('max_disk') - 1 ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
$new_disk = (int)SettingsManager::getSetting('max_disk') - 1;
if ($new_disk >= 0) {
$conn->query("UPDATE `mythicaldash_users` SET `disk` = '". $new_disk ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
}
} elseif ($session->getUserInfo('server_limit') > SettingsManager::getSetting('max_servers')) {
$reason = "Server Limit";
$conn->query("UPDATE `mythicaldash_users` SET `server_limit` = '".SettingsManager::getSetting('max_servers') - 1 ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
$new_server_limit = (int)SettingsManager::getSetting('max_servers') - 1;
if ($new_server_limit >= 0) {
$conn->query("UPDATE `mythicaldash_users` SET `server_limit` = '". $new_server_limit ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
}
} elseif ($session->getUserInfo('databases') > SettingsManager::getSetting('max_dbs')) {
$reason = "Databases";
$conn->query("UPDATE `mythicaldash_users` SET `databases` = '".SettingsManager::getSetting('max_dbs')- 1 ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
$new_databases = (int)SettingsManager::getSetting('max_dbs') - 1;
if ($new_databases >= 0) {
$conn->query("UPDATE `mythicaldash_users` SET `databases` = '". $new_databases ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
}
} elseif ($session->getUserInfo('backups') > SettingsManager::getSetting('max_backups')) {
$reason = "Backups";
$conn->query("UPDATE `mythicaldash_users` SET `backups` = '".SettingsManager::getSetting('max_backups')- 1 ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
$new_backups = (int)SettingsManager::getSetting('max_backups') - 1;
if ($new_backups >= 0) {
$conn->query("UPDATE `mythicaldash_users` SET `backups` = '". $new_backups ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
}
} elseif ($session->getUserInfo('ports') > SettingsManager::getSetting('max_allocations')) {
$reason = "Ports";
$conn->query("UPDATE `mythicaldash_users` SET `ports` = '".SettingsManager::getSetting('max_allocations') - 1 ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
$new_ports = (int)SettingsManager::getSetting('max_allocations') - 1;
if ($new_ports >= 0) {
$conn->query("UPDATE `mythicaldash_users` SET `ports` = '". $new_ports ."' WHERE `mythicaldash_users`.`api_key` = '".mysqli_real_escape_string($conn, $_COOKIE['token'])."';");
}
}
if (!empty($reason)) {
echo '<script>alert("It looks like we needed to update your resources because you exceeded the limit set for '.$reason.'.\nPlease contact your hosting provider if you wish for them to raise this limit!");</script>';
}
}
} catch (Exception $e) {
die($e);
echo '<script>alert("There was an error while trying to update your resources. \nPlease contact your hosting provider if you wish for them to raise this limit!");</script>';
}


?>
?>

0 comments on commit 4d521cb

Please sign in to comment.