Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
315 changes: 154 additions & 161 deletions install.php

Large diffs are not rendered by default.

103 changes: 70 additions & 33 deletions jobs/calc_serverstats.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,71 @@
<?PHP
/**
* Provides an array with every available version which is sorted descending.
* E.g. return[0] = latest version
*/
function getAvailableVersions() {
// read all git tags
$url = "https://api.github.com/repos/Newcomer1989/TSN-Ranksystem/git/refs/tags";
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "TSN Ranksystem");
$r=curl_exec($ch);
curl_close($ch);
$json = json_decode($r);

// extract all versions
$versions=array();
foreach($json as $obj) {
$tag = substr($obj->ref, 10);
if (preg_match("/^[0-9]+\.[0-9]+\.[0-9]+.*/", $tag)) {
array_push($versions,$tag);
}
}

// sort descending
function s($a,$b) {
return version_compare($b, $a);
}
usort($versions, "s");

return $versions
}

function sendUsageData($cfg) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ts-n.net/ranksystem/'.$cfg['version_update_channel']);
curl_setopt($ch, CURLOPT_REFERER, 'TSN Ranksystem');
curl_setopt($ch, CURLOPT_USERAGENT,
$cfg['version_current_using'].";".
php_uname("s").";".
php_uname("r").";".
phpversion().";".
$dbtype.";".
$cfg['teamspeak_host_address'].";".
$cfg['teamspeak_voice_port'].";".
__DIR__.";".
$total_user.";".
$user_today.";".
$user_week.";".
$user_month.";".
$user_quarter.";".
$total_online_week.";".
$total_online_month.";".
$total_active_time.";".
$total_inactive_time.";".
$cfg['temp_ts_version'].";".
$cfg['temp_db_version']
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_exec($ch);
curl_close($ch);
}

function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_cache,$phpcommand,$lang) {
$starttime = microtime(true);
$nowtime = time();
Expand Down Expand Up @@ -381,39 +448,9 @@ function calc_serverstats($ts3,$mysqlcon,&$cfg,$dbname,$dbtype,$serverinfo,&$db_

if ($db_cache['job_check']['get_version']['timestamp'] < ($nowtime - 43199)) {
$db_cache['job_check']['get_version']['timestamp'] = $nowtime;
enter_logfile($cfg,6,"Get the latest Ranksystem Version.");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ts-n.net/ranksystem/'.$cfg['version_update_channel']);
curl_setopt($ch, CURLOPT_REFERER, 'TSN Ranksystem');
curl_setopt($ch, CURLOPT_USERAGENT,
$cfg['version_current_using'].";".
php_uname("s").";".
php_uname("r").";".
phpversion().";".
$dbtype.";".
$cfg['teamspeak_host_address'].";".
$cfg['teamspeak_voice_port'].";".
__DIR__.";".
$total_user.";".
$user_today.";".
$user_week.";".
$user_month.";".
$user_quarter.";".
$total_online_week.";".
$total_online_month.";".
$total_active_time.";".
$total_inactive_time.";".
$cfg['temp_ts_version'].";".
$cfg['temp_db_version']
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$cfg['version_latest_available'] = curl_exec($ch);
curl_close($ch);

sendUsageData($cfg);
$cfg['versions_available'] = getAvailableVersions();

if(version_compare($cfg['version_latest_available'], $cfg['version_current_using'], '>') && $cfg['version_latest_available'] != NULL) {
enter_logfile($cfg,4,$lang['upinf']);
Expand Down
4 changes: 3 additions & 1 deletion jobs/check_db.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?PHP
require_once('./../other/_constants.php');

function check_db($mysqlcon,$lang,&$cfg,$dbname) {
$cfg['version_latest_available'] = '1.3.15';
enter_logfile($cfg,5,"Check Ranksystem database for updates...");
Expand Down Expand Up @@ -30,7 +32,7 @@ function check_double_cldbid($mysqlcon,$cfg,$dbname) {
function set_new_version($mysqlcon,$cfg,$dbname) {
if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('version_current_using','{$cfg['version_latest_available']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) {
enter_logfile($cfg,1," An error happens due updating the Ranksystem Database:".print_r($mysqlcon->errorInfo(), true));
shutdown($mysqlcon,$cfg,1," Check the database connection and properties in other/dbconfig.php and check also the database permissions.");
shutdown($mysqlcon,$cfg,1," Check the database connection and properties in '".DB_CONFIG."' and check also the database permissions.");
} else {
$cfg['version_current_using'] = $cfg['version_latest_available'];
enter_logfile($cfg,4," Database successfully updated!");
Expand Down
40 changes: 38 additions & 2 deletions jobs/update_rs.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
<?PHP
function update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand,$norotate=NULL) {
require_once('./../other/_constants.php');

function getUpdateVersion($cfg, $level) {
$current=explode('.', $cfg['version_current_using']);

switch(strtolower($level)) {
case 'none':
$matches = array($cfg['version_current_using']);
case 'major':
$matches = array($cfg['versions_available'][0]);
break;
case 'minor':
preg_match($current[0], $cfg['versions_available'], $matches);
break;
case 'patch':
preg_match($current[0].$current[1], $cfg['versions_available'], $matches);
break;
default:
$matches = array(getUpdateVersion($cfg, 'major');
}

return $matches[0];
}

function update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand,$norotate=NULL,$mode='default') {
$nowtime = time();
$sqlexec = '';
$norotate = true;
Expand All @@ -8,6 +32,18 @@ function update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand,$norotate=NULL) {
$countbackuperr = 0;

$tables = array('addons_config','cfg_params','groups','job_check','server_usage','stats_server','stats_user','user','user_snapshot');

// check update mode
if ($mode == 'default') {
$mode = getenv('UPDATE_MODE', true) ?: getenv('UPDATE_MODE');
}
$current_version=$cfg['version_current_using'];
$next_version=getUpdateVersion($cfg, $mode);

enter_logfile($cfg,4," Update mode: ".$mode." updating from ".$current_version." to ".$next_version,$norotate);
if (compare_version($cfg['version_current_using'], $next_version, '>=')) {
return($sqlexec);
}

foreach ($tables as $table) {
try {
Expand Down Expand Up @@ -111,7 +147,7 @@ function update_rs($mysqlcon,$lang,$cfg,$dbname,$phpcommand,$norotate=NULL) {
if(!is_dir(substr(__DIR__,0,-4).$thisFileName)) {
$contents = $zip->getFromName($thisFileName);
$updateThis = '';
if($thisFileName == 'other/dbconfig.php' || $thisFileName == 'install.php' || $thisFileName == 'other/phpcommand.php' || $thisFileName == 'logs/autostart_deactivated') {
if($thisFileName == DB_CONFIG || $thisFileName == 'install.php' || $thisFileName == 'other/phpcommand.php' || $thisFileName == 'logs/autostart_deactivated') {
enter_logfile($cfg,5," Did not touch ".$thisFileName,$norotate);
} else {
if(($updateThis = fopen(substr(__DIR__,0,-4).'/'.$thisFileName, 'w')) === false) {
Expand Down
5 changes: 3 additions & 2 deletions languages/core_ar_العربية_arab.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?PHP
require_once('./../other/_constants.php');
$lang = array();
$lang['achieve'] = "Achievement";
$lang['adduser'] = "User %s (unique Client-ID: %s; Client-database-ID %s) is unknown -> added to the Ranksystem now.";
Expand Down Expand Up @@ -60,7 +61,7 @@
$lang['insterr2'] = "%1\$s is needed but seems not to be installed. Install <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> and try it again!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr3'] = "PHP %1\$s function is needed to be enabled but seems to be disabled. Please enable the PHP <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> function and try it again!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr4'] = "Your PHP version (%s) is below 5.5.0. Update your PHP and try it again!";
$lang['isntwicfg'] = "Can't save the database configuration! Please edit the 'other/dbconfig.php' with a chmod 740 (on windows 'full access') and try again after.";
$lang['isntwicfg'] = "Can't save the database configuration! Please edit the '".DB_CONFIG."' with a chmod 740 (on windows 'full access') and try again after.";
$lang['isntwicfg2'] = "Configurate Webinterface";
$lang['isntwichm'] = "Write Permissions failed on folder \"%s\". Please give them a chmod 740 (on windows 'full access') and try to start the Ranksystem again.";
$lang['isntwiconf'] = "Open the %s to configure the Ranksystem!";
Expand Down Expand Up @@ -408,7 +409,7 @@
$lang['wiconferr'] = "There is an error in the configuration of the Ranksystem. Please go to the webinterface and correct the rank settings!";
$lang['widaform'] = "نظام التاريخ";
$lang['widaformdesc'] = "اختر كيفية ضهور التاريخ.<br><br>Example:<br>%a ايام, %h ساعات, %i دقائق, %s ثوان";
$lang['widbcfgerr'] = "'other/dbconfig.php'خلل عند حفظ تعديلات قاعدة البيانات فشل الاتصال مع ";
$lang['widbcfgerr'] = "'".DB_CONFIG."'خلل عند حفظ تعديلات قاعدة البيانات فشل الاتصال مع '";
$lang['widbcfgsuc'] = "تعديلات قاعدة البيانات حفظت بنجاح";
$lang['widbg'] = "Log-Level";
$lang['widbgdesc'] = "Set up the Log-Level of the Ranksystem. With this you can decide, how much information should be written to the file \"ranksystem.log\"<br><br>The higher the Log-Level, the more information you'll get.<br><br>Changing the Log-Level will take effect with the next restart of the Ranksystem bot.<br><br>Please don't let the Ranksystem running longer on \"6 - DEBUG\" this could impair your filesystem!";
Expand Down
5 changes: 3 additions & 2 deletions languages/core_az_Azərbaycan_az.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?PHP
require_once('./../other/_constants.php');
$lang = array();
$lang['achieve'] = "Nail olmaq";
$lang['adduser'] = "%s istifadəçisi % (unikal Müştəri-ID: %s; Müştəri bazası ID %s) bilinmir -> indi Ranks Sisteminə əlavə edildi";
Expand Down Expand Up @@ -60,7 +61,7 @@
$lang['insterr2'] = "%1\$s tələb olunur, lakin quraşdırılmamışdır. Yüklə <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> və yenidən cəhd edin!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr3'] = "PHP %1\$s function is needed to be enabled but seems to be disabled. Please enable the PHP <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> function and try it again!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr4'] = "PHP versiyanız (%s) 5.5.0-dən aşağıdır. PHP-ni yeniləyin və yenidən cəhd edin!";
$lang['isntwicfg'] = "Verilənlər bazası konfiqurasiyasını saxlaya bilmir! Tam yazma icazələrini təyin edin 'other/dbconfig.php' (Linux: chmod 740; Windows: 'full access') və sonra yenidən cəhd edin.";
$lang['isntwicfg'] = "Verilənlər bazası konfiqurasiyasını saxlaya bilmir! Tam yazma icazələrini təyin edin '".DB_CONFIG."' (Linux: chmod 740; Windows: 'full access') və sonra yenidən cəhd edin.";
$lang['isntwicfg2'] = "Veb-interfeysin konfiqurasiyası";
$lang['isntwichm'] = "\"%s\" qovluğunda qeyd icazəsi yoxdur. Tam hüquqlar verin (Linux: chmod 740; Windows: 'full access') və Ranksystem'i yenidən başlatmağa çalışın.";
$lang['isntwiconf'] = "Ranksystem'i konfiqurasiya etmək üçün %s açın!";
Expand Down Expand Up @@ -408,7 +409,7 @@
$lang['wiconferr'] = "Ranksystem-in konfiqurasiyasında bir səhv var. Veb-interfeysə keçin və rank parametrləri düzəlt!";
$lang['widaform'] = "Tarix formatı";
$lang['widaformdesc'] = "Göstərilən tarix formatını seçin.<br><br>Məsələn:<br>%a gün, %h saat, %i dəqiqə, %s saniyə";
$lang['widbcfgerr'] = "Verilənlər bazası konfiqurasiyaları qənaət edərkən səhv baş verdi! 'other/dbconfig.php' bağlantısı uğursuz oldu.";
$lang['widbcfgerr'] = "Verilənlər bazası konfiqurasiyaları qənaət edərkən səhv baş verdi! '".DB_CONFIG."' bağlantısı uğursuz oldu.";
$lang['widbcfgsuc'] = "Verilənlər bazası konfiqurasiyaları uğurla qeyd edildi.";
$lang['widbg'] = "Log Səviyyəsi";
$lang['widbgdesc'] = "Sıralama sistemi log səviyyəsi seçin. Bununla siz \"ranksystem.log\" faylına neçə məlumatın yazılmasına qərar verə bilərsiniz.<br><br>Giriş səviyyəsinin nə qədər yüksək olduğu halda daha çox məlumat alacaqsınız.<br><br>Giriş Səviyyəsinin dəyişdirilməsi Ranksystem botun yenidən başlaması ilə qüvvəyə çatır.<br><br>Xahiş edirik Ranksystem-ın \"6 - DEBUG\" üzərindən daha uzun müddət çalışmasına imkan verməyin, bu sizin fayl sisteminizə zərbə vuracaq!";
Expand Down
5 changes: 3 additions & 2 deletions languages/core_cz_Čeština_cz.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?PHP
require_once('./../other/_constants.php');
$lang = array();
$lang['achieve'] = "Achievement";
$lang['adduser'] = "Uživatel %s (unique Client-ID: %s; Client-database-ID %s) ještě není v databázi -> přidán do Ranksystem.";
Expand Down Expand Up @@ -60,7 +61,7 @@
$lang['insterr2'] = "%1\$s je potřebný k instalaci, ale není nainstalován! Nainstalujte ho pomocí <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> a zkuste to znovu!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr3'] = "PHP %1\$s function is needed to be enabled but seems to be disabled. Please enable the PHP <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> function and try it again!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr4'] = "Vaše PHP verze (%s) je nižší než 5.5.0. Prosím aktulizujte PHP a zkuste to znovu!";
$lang['isntwicfg'] = "Nemohu uložit konfiguraci do databáze! Prosím přidělte všechna práva souboru 'other/dbconfig.php' (Linux: chmod 740; Windows: 'full access') a zkuste to znovu!";
$lang['isntwicfg'] = "Nemohu uložit konfiguraci do databáze! Prosím přidělte všechna práva souboru '".DB_CONFIG."' (Linux: chmod 740; Windows: 'full access') a zkuste to znovu!";
$lang['isntwicfg2'] = "Nakonfigurujte webinterface";
$lang['isntwichm'] = "Práva pro zápis do složky \"%s\" nejsou plná! Prosím přidělte všechna práva pomocí (Linux: chmod 740; Windows: 'full access') a aktulizujte (obnovte- F5) stránku.";
$lang['isntwiconf'] = "Otevřete %s pro nastavení Ranksystemu.";
Expand Down Expand Up @@ -408,7 +409,7 @@
$lang['wiconferr'] = "Došlo k chybě v konfiguraci systému Ranks. Přejděte na webové rozhraní a opravte nastavení jádra. Zvláště zkontrolujte konfiguraci 'rank'!";
$lang['widaform'] = "Časový formát";
$lang['widaformdesc'] = "Vyberte formát zobrazení data.<br><br>Příklad:<br>% a dny,% h hodiny,% i mins,% s secs";
$lang['widbcfgerr'] = "Chyba při ukládání konfigurací databáze! Připojení selhalo nebo chyba zápisu pro 'other / dbconfig.php'";
$lang['widbcfgerr'] = "Chyba při ukládání konfigurací databáze! Připojení selhalo nebo chyba zápisu pro '".DB_CONFIG."'";
$lang['widbcfgsuc'] = "Databázové konfigurace byly úspěšně uloženy.";
$lang['widbg'] = "Log-Level";
$lang['widbgdesc'] = "Set up the Log-Level of the Ranksystem. With this you can decide, how much information should be written to the file \"ranksystem.log\"<br><br>The higher the Log-Level, the more information you'll get.<br><br>Changing the Log-Level will take effect with the next restart of the Ranksystem bot.<br><br>Please don't let the Ranksystem running longer on \"6 - DEBUG\" this could impair your filesystem!";
Expand Down
5 changes: 3 additions & 2 deletions languages/core_de_Deutsch_de.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?PHP
require_once('./../other/_constants.php');
$lang = array();
$lang['achieve'] = "Errungenschaft";
$lang['adduser'] = "User %s (eindeutige Client-ID: %s; Client-Datenbank-ID: %s) ist bisher unbekannt -> wurde nun zum Ranksystem hinzugefügt.";
Expand Down Expand Up @@ -60,7 +61,7 @@
$lang['insterr2'] = "%1\$s wird benötigt, scheint jedoch nicht installiert zu sein. Installiere <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> und versuche es erneut!<br>Pfad zur PHP Konfig-Datei, sofern definiert und diese geladen wurde: %3\$s";
$lang['insterr3'] = "Die PHP Funktion %1\$s wird benötigt, scheint jedoch deaktiviert zu sein. Bitte aktiviere PHP <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> und versuche es erneut!<br>Pfad zur PHP Konfig-Datei, sofern definiert und diese geladen wurde: %3\$s";
$lang['insterr4'] = "Deine PHP Version (%s) ist unter 5.5.0. Aktualisiere dein PHP und versuche es erneut!";
$lang['isntwicfg'] = "Die Datenbankkonfigurationen konnten nicht gespeichert werden! Bitte versehe die 'other/dbconfig.php' mit einem chmod 740 (für Windows 'Vollzugriff') und versuche es anschließend erneut.";
$lang['isntwicfg'] = "Die Datenbankkonfigurationen konnten nicht gespeichert werden! Bitte versehe die '".DB_CONFIG."' mit einem chmod 740 (für Windows 'Vollzugriff') und versuche es anschließend erneut.";
$lang['isntwicfg2'] = "Konfiguriere Webinterface";
$lang['isntwichm'] = "Schreibrechte fehlen für Verzeichnis \"%s\". Bitte setze auf dieses einen chmod 740 (für Windows 'Vollzugriff') und starte anschließend das Ranksystem erneut.";
$lang['isntwiconf'] = "Öffne das %s um das Ranksystem zu konfigurieren!";
Expand Down Expand Up @@ -409,7 +410,7 @@
$lang['wiconferr'] = "Es ist ein Fehler in der Konfiguration des Ranksystems. Bitte prüfe im Webinterface die Rank-Einstellungen auf Richtigkeit!";
$lang['widaform'] = "Datumsformat";
$lang['widaformdesc'] = "Gebe ein Datumsformat zur Anzeige vor.<br><br>Beispiel:<br>%a Tage, %h Std., %i Min., %s Sek.";
$lang['widbcfgerr'] = "Fehler beim Speichern der Datenbank Einstellungen! Verbindung zur Datenbank oder speichern der 'other/dbconfig.php' nicht möglich.";
$lang['widbcfgerr'] = "Fehler beim Speichern der Datenbank Einstellungen! Verbindung zur Datenbank oder speichern der '".DB_CONFIG."' nicht möglich.";
$lang['widbcfgsuc'] = "Datenbank Einstellungen erfolgreich gespeichert.";
$lang['widbg'] = "Log-Level";
$lang['widbgdesc'] = "Bestimme das Log-Level des Ranksystems. Damit wird festgelegt, wie viele Informationen in die Datei \"ranksystem.log\" geschrieben werden sollen.<br><br>Je höher das Log-Level, desto mehr Informationen werden ausgegeben.<br><br>Ein Wechsel des Log-Levels wird mit dem nächsten Neustart des Ranksystem Bots wirksam.<br><br>Bitte lasse das Ranksystem nicht längere Zeit unter \"6 - DEBUG\" laufen. Dies könnte das Dateisystem beeinträchtigen!";
Expand Down
Loading