mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-24 05:26:19 +00:00
Last Phase before v11 release. New Automation Cleanup
Last Phase before v11 release. New Automation Cleanup
This commit is contained in:
@@ -85,6 +85,24 @@ if (!function_exists('admin_config_template_path')) {
|
||||
$text = str_replace('%CRONTICK%', (string) $cronTick, $text);
|
||||
}
|
||||
|
||||
// Retentiile de curatenie: la fel, editate din ACP, deci orice alt mod
|
||||
// care regenereaza config.php trebuie sa le pastreze.
|
||||
$cleanupDefaults = array(
|
||||
'%CLEANUPREPORTS%' => array('CLEANUP_REPORTS_DAYS', 14),
|
||||
'%CLEANUPCHAT%' => array('CLEANUP_CHAT_DAYS', 7),
|
||||
'%CLEANUPMESSAGES%' => array('CLEANUP_MESSAGES_DAYS', 0),
|
||||
);
|
||||
|
||||
foreach ($cleanupDefaults as $placeholder => $info) {
|
||||
if (strpos($text, $placeholder) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list($constant, $default) = $info;
|
||||
$value = defined($constant) ? (int) constant($constant) : $default;
|
||||
$text = str_replace($placeholder, (string) $value, $text);
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,17 @@ if ($loop > 0 && $loop < $tick) {
|
||||
$loop = 0;
|
||||
}
|
||||
|
||||
// Retentiile de curatenie (0 = regula dezactivata). Limita superioara de 3650
|
||||
// zile (10 ani) e doar ca sa nu se scrie valori absurde in config.
|
||||
$cleanReports = isset($_POST['cleanup_reports']) ? (int) $_POST['cleanup_reports'] : 14;
|
||||
$cleanChat = isset($_POST['cleanup_chat']) ? (int) $_POST['cleanup_chat'] : 7;
|
||||
$cleanMessages = isset($_POST['cleanup_messages']) ? (int) $_POST['cleanup_messages'] : 0;
|
||||
|
||||
foreach (array('cleanReports', 'cleanChat', 'cleanMessages') as $var) {
|
||||
if ($$var < 0) { $$var = 0; }
|
||||
if ($$var > 3650) { $$var = 3650; }
|
||||
}
|
||||
|
||||
$regenerateKey = !empty($_POST['regenerate_key']);
|
||||
|
||||
$cronKey = (defined('CRON_KEY') && CRON_KEY !== '' && CRON_KEY !== '%CRONKEY%')
|
||||
@@ -115,6 +126,18 @@ if (!cron_set_define($config, 'CRON_KEY', "'" . addcslashes($cronKey, "'\\") . "
|
||||
$missing[] = "define('CRON_KEY', '" . addcslashes($cronKey, "'\\") . "');";
|
||||
}
|
||||
|
||||
if (!cron_set_define($config, 'CLEANUP_REPORTS_DAYS', (string) $cleanReports)) {
|
||||
$missing[] = "define('CLEANUP_REPORTS_DAYS', " . $cleanReports . ");";
|
||||
}
|
||||
|
||||
if (!cron_set_define($config, 'CLEANUP_CHAT_DAYS', (string) $cleanChat)) {
|
||||
$missing[] = "define('CLEANUP_CHAT_DAYS', " . $cleanChat . ");";
|
||||
}
|
||||
|
||||
if (!cron_set_define($config, 'CLEANUP_MESSAGES_DAYS', (string) $cleanMessages)) {
|
||||
$missing[] = "define('CLEANUP_MESSAGES_DAYS', " . $cleanMessages . ");";
|
||||
}
|
||||
|
||||
// Server instalat inainte ca aceste constante sa existe: le adaugam dupa
|
||||
// AUTOMATION_LOCK_FILE_NAME (locul lor din template).
|
||||
if (!empty($missing)) {
|
||||
@@ -140,7 +163,7 @@ fwrite($fh, $config);
|
||||
fclose($fh);
|
||||
|
||||
$database->query(
|
||||
"Insert into " . TB_PREFIX . "admin_log values (0," . $id . ",'Changed Cron & Automation Settings'," . time() . ")"
|
||||
"Insert into " . TB_PREFIX . "admin_log values (0," . $id . ",'Changed Cron, Automation & Cleanup Settings'," . time() . ")"
|
||||
);
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=config");
|
||||
|
||||
Reference in New Issue
Block a user