mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 09:19:22 +02:00
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
$config_file = BASE . 'config.local.php';
|
|
if(!is_writable($config_file)) { // we can't do anything, just ignore
|
|
return;
|
|
}
|
|
|
|
$content_of_file = trim(file_get_contents($config_file));
|
|
if(strpos($content_of_file, 'highscores_ids_hidden') !== false) { // already present
|
|
return;
|
|
}
|
|
|
|
$query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . ") ORDER BY `id`;");
|
|
|
|
$highscores_ignored_ids = array();
|
|
if($query->rowCount() > 0) {
|
|
foreach($query->fetchAll() as $result)
|
|
$highscores_ignored_ids[] = $result['id'];
|
|
}
|
|
else {
|
|
$highscores_ignored_ids[] = 0;
|
|
}
|
|
|
|
$php_on_end = substr($content_of_file, -2, 2) == '?>';
|
|
$content = PHP_EOL;
|
|
if($php_on_end) {
|
|
$content .= '<?php';
|
|
}
|
|
|
|
$content .= PHP_EOL;
|
|
$content .= '$config[\'highscores_ids_hidden\'] = array(' . implode(', ', $highscores_ignored_ids) . ');';
|
|
$content .= PHP_EOL;
|
|
|
|
if($php_on_end) {
|
|
$content .= '?>';
|
|
}
|
|
|
|
file_put_contents($config_file, $content, FILE_APPEND);
|
|
?>
|