Skip to content

Commit

Permalink
Issue Newcomer1989#818: Add option to enable/disable auto-updater
Browse files Browse the repository at this point in the history
- Adds an option to enable/disable the auto-updater (defaults to enabled)
- Adds a new cfg param to the database
- Only load and run the auto-updater if enabled
  • Loading branch information
Sebi94nbg committed Jul 15, 2023
1 parent 7633da2 commit a55bb70
Show file tree
Hide file tree
Showing 19 changed files with 117 additions and 34 deletions.
3 changes: 2 additions & 1 deletion install.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
('teamspeak_voice_port', '9987'),
('version_current_using', '{$rsversion}'),
('version_latest_available', '{$rsversion}'),
('enable_auto_updater', 'true'),
('version_update_channel', 'stable'),
('webinterface_access_count', '0'),
('webinterface_access_last', '0'),
Expand Down Expand Up @@ -1072,4 +1073,4 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
});
</script>
</body>
</html>
</html>
39 changes: 24 additions & 15 deletions jobs/bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/check_db.php');
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/handle_messages.php');
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/event_userenter.php');
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/update_rs.php');
if ($cfg['enable_auto_updater']) {
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/update_rs.php');
}
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/reset_rs.php');
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'jobs/db_ex_imp.php');
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'libs/smarty/Smarty.class.php');
Expand All @@ -73,27 +75,34 @@
}
enter_logfile(9,"Database Version: ".$mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION));

enter_logfile(9,"Starting connection test to the Ranksystem update-server (may need a few seconds)...");
$update_server = fsockopen('193.70.102.252', 443, $errno, $errstr, 10);
if(!$update_server) {
enter_logfile(2," Connection to Ranksystem update-server failed: $errstr ($errno)");
enter_logfile(3," This connection is neccessary to receive updates for the Ranksystem!");
enter_logfile(3," Please whitelist the IP 193.70.102.252 (TCP port 443) on your network (firewall)");
} else {
enter_logfile(9," Connection test successful");
if ($cfg['enable_auto_updater']) {
enter_logfile(9,"Starting connection test to the Ranksystem update-server (may need a few seconds)...");
$update_server = fsockopen('ts-n.net', 443, $errno, $errstr, 10);
if(!$update_server) {
enter_logfile(2," Connection to Ranksystem update-server failed: $errstr ($errno)");
enter_logfile(3," This connection is neccessary to receive updates for the Ranksystem!");
enter_logfile(3," Please whitelist the IP 193.70.102.252 (TCP port 443) on your network (firewall).");
enter_logfile(3," Alternative, disable the auto-updater in the settings and manually update the Ranksystem.");
} else {
enter_logfile(9," Connection test successful");
}
enter_logfile(9,"Starting connection test to the Ranksystem update-server [done]");
}
enter_logfile(9,"Starting connection test to the Ranksystem update-server [done]");

$cfg['temp_updatedone'] = check_db($mysqlcon,$lang,$cfg,$dbname);
$cfg['temp_db_version'] = $mysqlcon->getAttribute(PDO::ATTR_SERVER_VERSION);
$cfg['temp_last_botstart'] = time();
$cfg['temp_reconnect_attempts'] = 0;
$cfg['temp_ts_no_reconnection'] = 0;
enter_logfile(4,"Check Ranksystem files for updates...");
if(isset($cfg['version_current_using']) && isset($cfg['version_latest_available']) && $cfg['version_latest_available'] != NULL && version_compare($cfg['version_latest_available'], $cfg['version_current_using'], '>')) {
update_rs($mysqlcon,$lang,$cfg,$dbname);

if ($cfg['enable_auto_updater']) {
enter_logfile(4,"Check Ranksystem files for updates...");
if(isset($cfg['version_current_using']) && isset($cfg['version_latest_available']) && $cfg['version_latest_available'] != NULL && version_compare($cfg['version_latest_available'], $cfg['version_current_using'], '>')) {
update_rs($mysqlcon,$lang,$cfg,$dbname);
}
enter_logfile(4,"Check Ranksystem files for updates [done]");
}
enter_logfile(4,"Check Ranksystem files for updates [done]");

enter_logfile(9,"Ranksystem Version: ".$cfg['version_current_using']." (on Update-Channel: ".$cfg['version_update_channel'].")");
enter_logfile(4,"Loading addons...");
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'other/load_addons_config.php');
Expand Down Expand Up @@ -552,4 +561,4 @@ function run_bot(&$cfg) {
while(1) {
run_bot($cfg);
}
?>
?>
7 changes: 5 additions & 2 deletions jobs/calc_serverstats.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
}
}
}
$sqlexec .= update_rs($mysqlcon,$lang,$cfg,$dbname);

if ($cfg['enable_auto_updater']) {
$sqlexec .= update_rs($mysqlcon,$lang,$cfg,$dbname);
}
}
$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`=$nowtime WHERE `job_name`='get_version';\nUPDATE `$dbname`.`cfg_params` SET `value`='{$cfg['version_latest_available']}' WHERE `param`='version_latest_available';\n";
}
Expand All @@ -491,4 +494,4 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_
enter_logfile(6,"calc_serverstats needs: ".(number_format(round((microtime(true) - $starttime), 5),5)));
return($sqlexec);
}
?>
?>
8 changes: 7 additions & 1 deletion jobs/check_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,16 @@ function check_writable($cfg,$mysqlcon) {
$updatedone = TRUE;
}

if(version_compare($cfg['version_current_using'], '1.3.24', '<')) {
if($mysqlcon->exec("INSERT IGNORE INTO `$dbname`.`cfg_params` (`param`, `value`) VALUES ('enable_auto_updater', true)") === false) { } else {
enter_logfile(4," [1.3.24] Add option to enable/disable the auto-updater");
}
}

$cfg = set_new_version($mysqlcon,$cfg,$dbname);
}
enter_logfile(5,"Check Ranksystem database for updates [done]");
if(isset($updatedone) && $updatedone === TRUE) return TRUE;
return FALSE;
}
?>
?>
4 changes: 3 additions & 1 deletion languages/core_ar_العربية_arab.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@
$lang['wits3voicedesc'] = "TeamSpeak 3 voice port<br>Default is 9987 (UDP)<br>This is the port, you uses also to connect with the TS3 Client.";
$lang['witsz'] = "Log-Size";
$lang['witszdesc'] = "Set up the filesize of the log, at which the logfile will be rotated, when exceeded.<br><br>Define your value in Mebibyte.<br><br>When you increase the value, be sure, you have enough space on this partition. Too big logfiles could bring perfomance issues!<br><br>On changing this value, the logfile size will be checked with the next restart of the bot. Is the filesize bigger than the defined value, the logfile will be rotated immediately.";
$lang['wiautoupdater'] = "Auto-Updater";
$lang['wiautoupdaterdesc'] = "Enable this so that this software updates itself automatically on a regular basis.";
$lang['wiupch'] = "Update-Channel";
$lang['wiupch0'] = "stable";
$lang['wiupch1'] = "beta";
Expand All @@ -705,4 +707,4 @@
$lang['wiverifydesc'] = "Enter here the channel-ID of the verification channel.<br><br>This channel need to be set up <u>manual</u> on your TeamSpeak server. Name, permissions and other properties could be defined for your choice; only user should be possible to join this channel!<br><br>The verification is done by the respective user himself on the statistics-page (/stats/). This is only necessary if the website visitor can't automatically be matched/related with the TeamSpeak user.<br><br>To verify the TeamSpeak user, he has to be in the verification channel. There he is able to receive a token with which he can verify himself for the statistics page.";
$lang['wivlang'] = "Language";
$lang['wivlangdesc'] = "Choose a default language for the Ranksystem.<br><br>The language is also selectable on the websites for the users and will be stored for the session.";
?>
?>
4 changes: 3 additions & 1 deletion languages/core_az_Azərbaycan_az.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@
$lang['wits3voicedesc'] = "TeamSpeak 3 səs portu<br>standart is 9987 (UDP)<br>Bu port, TS3 Müştərisi ilə əlaqə yaratmaq üçün də istifadə edirsiniz.";
$lang['witsz'] = "Log-Ölçüsü";
$lang['witszdesc'] = "Günlük faylının döndüyü gündüz faylını qurduqda, aşdıqda.<br><br>Mebibyte'də dəyərinizi təyin edin.<br><br>Qiyməti artırdığınız zaman, əmin olun ki, bu bölmədə kifayət qədər yer var. Çox böyük logfiles mükəmməl məsələlər gətirə bilər!<br><br>Bu dəyəri dəyişdikdə, logfile ölçüsü botun yenidən başlaması ilə yoxlanacaq. Belirtilən dəyərdən daha böyük olan fayllar, gündəmi dərhal qaytarılacaq.";
$lang['wiautoupdater'] = "Auto-Updater";
$lang['wiautoupdaterdesc'] = "Enable this so that this software updates itself automatically on a regular basis.";
$lang['wiupch'] = "Kanal Yeniləmə";
$lang['wiupch0'] = "sabit";
$lang['wiupch1'] = "beta";
Expand All @@ -705,4 +707,4 @@
$lang['wiverifydesc'] = "Burada doğrulama kanalının kanal ID daxil edin.<br><br>Bu kanalın qurulması lazımdır. <u>Əl ilə</u> qurmalısız. Ad, icazələr və digər xüsusiyyətlər sizin seçiminizlə müəyyənləşdirilə bilər; yalnız istifadəçi bu kanala qoşulmalıdır!<br><br>Verifikasiya statistik məlumat səhifəsində müvafiq istifadəçi tərəfindən həyata keçirilir (/stats/). Bu, yalnız veb interfeysin istifadəçisinin, TeamSpeak istifadəçisiyle avtomatik olaraq eşleşmemesi / uyğunlaşmaması lazımdır.<br><br>TeamSpeak istifadəçisini yoxlamaq üçün yoxlama kanalında olmalıdır. O, özü statistika səhifəsi üçün özünü təsdiqləyə biləcək bir möcüzə ala bilir.";
$lang['wivlang'] = "Dil";
$lang['wivlangdesc'] = "Rank Sistemi üçün standart bir dil seçin.<br><br>Dil, həmçinin istifadəçilər üçün saytlarda seçilə bilər və sessiya üçün saxlanacaq.";
?>
?>
4 changes: 3 additions & 1 deletion languages/core_cz_Čeština_cz.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@
$lang['wits3voicedesc'] = "TeamSpeak 3 voice port<br>Defaultně je 9987 (UDP)<br>Toto je port, který používáš při připojení na TS3 server v TS3 klientu.";
$lang['witsz'] = "Velikost-logu";
$lang['witszdesc'] = "Nastavte maximální velikost log souboru pro automatické rotování logů .<br><br>Hodnotu definujete v Mebibytech.<br><br>Zvolením příliš vysoké hodnoty může dojít k vyčerpání volného prostoru pro logy na disku. Velké soubory mohou zároveň nepříznívě ovlivňovat výkon systému!<br><br> Změna bude akceptována až po restartování Bota. Pokud je nově zvolená velikost logu menší než je aktuální velikost log souboru, dojde k jeho automatickému orotování.";
$lang['wiautoupdater'] = "Auto-Updater";
$lang['wiautoupdaterdesc'] = "Enable this so that this software updates itself automatically on a regular basis.";
$lang['wiupch'] = "Update-Channel";
$lang['wiupch0'] = "stabilni";
$lang['wiupch1'] = "beta";
Expand All @@ -706,4 +708,4 @@
$lang['wiverifydesc'] = "Enter here the channel-ID of the verification channel.<br><br>This channel need to be set up <u>manual</u> on your TeamSpeak server. Name, permissions and other properties could be defined for your choice; only user should be possible to join this channel!<br><br>The verification is done by the respective user himself on the statistics-page (/stats/). This is only necessary if the website visitor can't automatically be matched/related with the TeamSpeak user.<br><br>To verify the TeamSpeak user, he has to be in the verification channel. There he is able to receive a token with which he can verify himself for the statistics page.";
$lang['wivlang'] = "Jazyk";
$lang['wivlangdesc'] = "Nastavte hlavní jazyk pro Ranksystem<br><br>Jazyk můžete kdykoliv změnit.";
?>
?>
4 changes: 3 additions & 1 deletion languages/core_de_Deutsch_de.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@
$lang['wits3voicedesc'] = "TeamSpeak 3 Voice-Port<br><br>Standard ist 9987 (UDP)<br><br>Dieser Port wird auch zum Verbinden vom TS3 Client genutzt.";
$lang['witsz'] = "Log-Größe";
$lang['witszdesc'] = "Definiere eine Dateigröße, bei der die Logdatei rotiert wird.<br><br>Gebe den Wert in Mebibyte (MiB) an.<br><br>Wenn du den Wert erhöhst, achte darauf, dass ausreichend Speicherplatz auf der Partition verfügbar ist.<br>Beachte: Zu große Logdateien können zu Performance-Problemen führen!<br><br>Beim Ändern dieses Wertes wird beim nächsten Neustart des Bots die Größe der Logdatei überprüft. Ist die Datei größer als der definierte Wert, wird die Logdatei sofort rotiert.";
$lang['wiautoupdater'] = "Auto-Updater";
$lang['wiautoupdaterdesc'] = "Aktiviere dies, damit sich diese Software regelmäßig automatisch aktualisiert.";
$lang['wiupch'] = "Update-Channel";
$lang['wiupch0'] = "Stable";
$lang['wiupch1'] = "Beta";
Expand All @@ -705,4 +707,4 @@
$lang['wiverifydesc'] = "Hier ist die Channel Datenbank-ID des Verifizierungs-Channels zu hinterlegen.<br><br>Dieser Channel ist <u>manuell</u> auf dem TeamSpeak Server anzulegen. Name, Berechtigungen und sonstige Eigenschaften können nach Belieben gesetzt werden; lediglich sollten User ihn betreten können! ;-)<br><br>Die Verifizierung erfolgt durch den jeweiligen Benutzer selbst auf der Ranksystem Statistik-Seite (/stats/). Sie ist nur dann erforderlich, wenn eine Zuordnung des Webseitenbesuchers mit dem TeamSpeak-User nicht automatisch erfolgen kann.<br><br>Für die Verifizierung muss sich der User auf dem TeamSpeak Server in den Verifizierungs-Channel begeben. Dort kann er den Token empfangen, mit welchem er sich für die Statistik-Seite verifiziert.";
$lang['wivlang'] = "Sprache";
$lang['wivlangdesc'] = "Wähle die Standard-Sprache des Ranksystems.<br>Sie ist relevant für das Webinterface, die Statistik-Seite und insbesondere für die Ranksystem-Log.<br><br>Die Sprache kann über die Webseite durch jeden Besucher übersteuert werden und wird dann für die laufende Sitzung gespeichert (Session-Cookie).";
?>
?>
4 changes: 3 additions & 1 deletion languages/core_en_english_gb.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@
$lang['wits3voicedesc'] = "TeamSpeak 3 voice port<br>Default is 9987 (UDP)<br>This is the port, you use also to connect with the TS3 Client.";
$lang['witsz'] = "Log-Size";
$lang['witszdesc'] = "Set up the filesize of the log, at which the logfile will be rotated, when exceeded.<br><br>Define your value in Mebibyte.<br><br>When you increase the value, be sure, you have enough space on this partition. Too big logfiles could bring perfomance issues!<br><br>On changing this value, the logfile size will be checked with the next restart of the bot. Is the filesize bigger than the defined value, the logfile will be rotated immediately.";
$lang['wiautoupdater'] = "Auto-Updater";
$lang['wiautoupdaterdesc'] = "Enable this so that this software updates itself automatically on a regular basis.";
$lang['wiupch'] = "Update-Channel";
$lang['wiupch0'] = "stable";
$lang['wiupch1'] = "beta";
Expand All @@ -705,4 +707,4 @@
$lang['wiverifydesc'] = "Enter here the channel-ID of the verification channel.<br><br>This channel needs to be set up <u>manually</u> on your TeamSpeak server. Name, permissions and other properties could be defined of your choice; only the user should be possible to join this channel!<br><br>The verification is done by the respective user himself on the statistics-page (/stats/). This is only necessary if the website visitor can't automatically be matched/related to the TeamSpeak user.<br><br>To verify the TeamSpeak user, he has to be in the verification channel. There he is able to receive a token with which he can verify himself for the statistics page.";
$lang['wivlang'] = "Language";
$lang['wivlangdesc'] = "Choose a default language for the Ranksystem.<br><br>The language is also selectable on the websites for the users and will be stored for the session.";
?>
?>
4 changes: 3 additions & 1 deletion languages/core_es_español_es.php
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@
$lang['wits3voicedesc'] = "Puerto de voz TeamSpeak 3<br>El valor predeterminado es 9987 (UDP)<br>Este es el puerto, también lo usa para conectarse con el cliente TS3.";
$lang['witsz'] = "Log-Size";
$lang['witszdesc'] = "Set up the filesize of the log, at which the logfile will be rotated, when exceeded.<br><br>Define your value in Mebibyte.<br><br>When you increase the value, be sure, you have enough space on this partition. Too big logfiles could bring perfomance issues!<br><br>On changing this value, the logfile size will be checked with the next restart of the bot. Is the filesize bigger than the defined value, the logfile will be rotated immediately.";
$lang['wiautoupdater'] = "Auto-Updater";
$lang['wiautoupdaterdesc'] = "Enable this so that this software updates itself automatically on a regular basis.";
$lang['wiupch'] = "Update-Channel";
$lang['wiupch0'] = "stable";
$lang['wiupch1'] = "beta";
Expand All @@ -704,4 +706,4 @@
$lang['wiverifydesc'] = "Ingrese aquí el ID de canal del canal de verificación.<br><br>Este canal debe ser configurado <u>manualmente</u> en tu servidor TeamSpeak. Nombre, permisos y otras propiedades podrían definirse para su elección; solo el usuario debería ser posible unirse a este canal!<br><br>La verificación la realiza el propio usuario en la página de estadísticas.(/stats/). Esto solo es necesario si el visitante del sitio web no puede ser emparejado / relacionado automáticamente con el usuario de TeamSpeak.<br><br>To verify the TeamSpeak user, he has to be in the verification channel. Allí puede recibir un token con el que puede verificarse a sí mismo para la página de estadísticas.";
$lang['wivlang'] = "Idioma";
$lang['wivlangdesc'] = "Elija un idioma predeterminado para el Ranksystem.<br><br>El idioma también se puede seleccionar en los sitios web para los usuarios y se almacenará para la sesión.";
?>
?>
4 changes: 3 additions & 1 deletion languages/core_fr_français_fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@
$lang['wits3voicedesc'] = "Port vocal TeamSpeak 3<br>La valeur par défaut est 9987 (UDP)<br>Il s'agit du port, que vous utilisez également pour vous connecter avec le logiciel client TS3.";
$lang['witsz'] = "Log-Size";
$lang['witszdesc'] = "Set up the filesize of the log, at which the logfile will be rotated, when exceeded.<br><br>Define your value in Mebibyte.<br><br>When you increase the value, be sure, you have enough space on this partition. Too big logfiles could bring perfomance issues!<br><br>On changing this value, the logfile size will be checked with the next restart of the bot. Is the filesize bigger than the defined value, the logfile will be rotated immediately.";
$lang['wiautoupdater'] = "Auto-Updater";
$lang['wiautoupdaterdesc'] = "Enable this so that this software updates itself automatically on a regular basis.";
$lang['wiupch'] = "Update-Channel";
$lang['wiupch0'] = "stable";
$lang['wiupch1'] = "beta";
Expand All @@ -703,4 +705,4 @@
$lang['wiverifydesc'] = "Enter here the channel-ID of the verification channel.<br><br>This channel need to be set up <u>manual</u> on your TeamSpeak server. Name, permissions and other properties could be defined for your choice; only user should be possible to join this channel!<br><br>The verification is done by the respective user himself on the statistics-page (/stats/). This is only necessary if the website visitor can't automatically be matched/related with the TeamSpeak user.<br><br>To verify the TeamSpeak user, he has to be in the verification channel. There he is able to receive a token with which he can verify himself for the statistics page.";
$lang['wivlang'] = "Langue";
$lang['wivlangdesc'] = "Choisissez une langue par défaut pour le Ranksystem.<br><br>La langue est également sélectionnable sur le site web pour les utilisateurs et sera stockée pour sa session.";
?>
?>
Loading

0 comments on commit a55bb70

Please sign in to comment.