release 1.3.22

This commit is contained in:
Newcomer1989
2023-02-01 20:44:58 +01:00
parent b96e32b713
commit f7d7aedc5a
100 changed files with 5710 additions and 1435 deletions

View File

@@ -1,8 +1,233 @@
<?PHP
function check_shutdown($cfg) {
if(!file_exists($cfg['logs_path']."pid")) {
shutdown(NULL,$cfg,4,"Received signal to stop!");
function bot_check() {
$output = array();
if (check_bot_process() == FALSE) {
if (!file_exists($GLOBALS['autostart'])) {
if (file_exists($GLOBALS['pidfile'])) {
unlink($GLOBALS['pidfile']);
}
$output = bot_start();
} else {
$output['rc'] = 1;
$output['msg'] = "Starting the Ranksystem Bo failed! Autostart is deactivated. Use start command instead.";
$output['loglvl'] = 3;
}
} else {
$output['rc'] = 0;
$output['msg'] = "The Ranksystem Bot seems to be running.";
$output['loglvl'] = 4;
}
return $output;
}
function bot_restart() {
$output = array();
$result = bot_stop();
if($result['rc'] != 0) {
$output['rc'] = $result['rc'];
$output['msg'] = $result['msg'];
$output['loglvl'] = $result['loglvl'];
$output['ranksystemlog'] = $result['ranksystemlog'];
return $output;
}
$result = bot_start();
if($result['rc'] != 0) {
$output['rc'] = $result['rc'];
$output['msg'] = $result['msg'];
$output['loglvl'] = $result['loglvl'];
$output['ranksystemlog'] = $result['ranksystemlog'];
return $output;
}
$output['rc'] = 0;
$output['msg'] = "Ranksystem Bot successfully restarted!";
$output['loglvl'] = 4;
usleep(80000);
$output['log'] = getlog('40',explode(',',"CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG,NONE"),NULL,NULL);
return $output;
}
function bot_start() {
$output = array();
if (check_log_permissions() === TRUE) {
if (check_bot_process() == FALSE) {
if (substr(php_uname(), 0, 7) == "Windows") {
try {
$WshShell = new COM("WScript.Shell");
} catch (Exception $e) {
$output['rc'] = 1;
$output['msg'] = "Error due loading the PHP COM module (wrong server configuration!): ".$e->getMessage();
$output['loglvl'] = 3;
}
try {
$wcmd = "cmd /C ".$GLOBALS['phpcommand']." ".dirname(__DIR__).DIRECTORY_SEPARATOR."jobs".DIRECTORY_SEPARATOR."bot.php";
$oExec = $WshShell->Run($wcmd, 0, false);
} catch (Exception $e) {
$output['rc'] = 1;
$output['msg'] = "Error due starting the Ranksystem Bot (exec command enabled?): ".$e->getMessage();
$output['loglvl'] = 3;
}
try {
exec("wmic process where \"Name LIKE \"%php%\" AND CommandLine LIKE \"%bot.php%\"\" get ProcessId", $pid);
} catch (Exception $e) {
$output['rc'] = 1;
$output['msg'] = "Error due getting process list (wmic command enabled?): ".$e->getMessage();
$output['loglvl'] = 3;
}
if(isset($pid[1]) && is_numeric($pid[1])) {
exec("echo ".$pid[1]." > ".$GLOBALS['pidfile']);
if (file_exists($GLOBALS['autostart'])) {
unlink($GLOBALS['autostart']);
}
$output['rc'] = 0;
$output['msg'] = "Ranksystem Bot successfully started!";
$output['loglvl'] = 4;
usleep(80000);
$output['log'] = getlog('40',explode(',',"CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG,NONE"),NULL,NULL);
} else {
$output['rc'] = 1;
$output['msg'] = "Starting the Ranksystem Bot failed!";
$output['loglvl'] = 3;
}
} else {
exec($GLOBALS['phpcommand']." ".dirname(__DIR__).DIRECTORY_SEPARATOR."jobs".DIRECTORY_SEPARATOR."bot.php >/dev/null 2>&1 & echo $! > ".$GLOBALS['pidfile']);
if (check_bot_process() == FALSE) {
$output['rc'] = 1;
$output['msg'] = "Starting the Ranksystem Bot failed!";
$output['loglvl'] = 3;
} else {
if (file_exists($GLOBALS['autostart'])) {
unlink($GLOBALS['autostart']);
}
$output['rc'] = 0;
$output['msg'] = "Ranksystem Bot successfully started!";
$output['loglvl'] = 4;
usleep(80000);
$output['log'] = getlog('40',explode(',',"CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG,NONE"),NULL,NULL);
}
}
} else {
$output['rc'] = 0;
$output['msg'] = "The Ranksystem is already running.";
$output['loglvl'] = 4;
}
} else {
$output['rc'] = 1;
$output['msg'] = check_log_permissions()." Canceled start request!";
$output['loglvl'] = 3;
}
return $output;
}
function bot_stop() {
$output = array();
if (check_log_permissions() === TRUE) {
if (check_bot_process() == FALSE) {
if(is_file($GLOBALS['pidfile'])) {
unlink($GLOBALS['pidfile']);
}
$output['rc'] = 0;
$output['msg'] = "The Ranksystem seems not to be running.";
$output['loglvl'] = 4;
} else {
$pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile']));
unlink($GLOBALS['pidfile']);
$count_check=0;
while (check_bot_process($pid) == TRUE) {
sleep(1);
$count_check ++;
if($count_check > 10) {
if (substr(php_uname(), 0, 7) == "Windows") {
exec("taskkill /F /PID ".$pid);
} else {
exec("kill -9 ".$pid);
}
$output['rc'] = 1;
$output['msg'] = "Stop command received! Bot does not react, process killed!";
$output['loglvl'] = 3;
break;
}
}
if (check_bot_process($pid) == TRUE) {
$output['rc'] = 1;
$output['msg'] = "Stopping the Ranksystem Bot failed!";
$output['loglvl'] = 3;
} else {
file_put_contents($GLOBALS['autostart'],"");
$output['rc'] = 0;
$output['msg'] = "Ranksystem Bot successfully stopped!";
$output['loglvl'] = 4;
usleep(80000);
$output['log'] = getlog('40',explode(',',"CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG,NONE"),NULL,NULL);
}
}
} else {
$output['rc'] = 1;
$output['msg'] = check_log_permissions()." Canceled stop request!";
$output['loglvl'] = 3;
}
return $output;
}
function check_bot_process($pid = NULL) {
if (substr(php_uname(), 0, 7) == "Windows") {
if(!empty($pid)) {
exec("wmic process where \"processid=".$pid."\" get processid 2>nul", $result);
if(isset($result[1]) && is_numeric($result[1])) {
return TRUE;
} else {
return FALSE;
}
} else {
if (file_exists($GLOBALS['pidfile'])) {
$pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile']));
exec("wmic process where \"processid=".$pid."\" get processid 2>nul", $result);
if(isset($result[1]) && is_numeric($result[1])) {
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
} else {
if(!empty($pid)) {
$result = str_replace(array("\r", "\n"), '', shell_exec("ps ".$pid));
if (strstr($result, $pid)) {
return TRUE;
} else {
return FALSE;
}
} else {
if (file_exists($GLOBALS['pidfile'])) {
$check_pid = str_replace(array("\r", "\n"), '', file_get_contents($GLOBALS['pidfile']));
$result = str_replace(array("\r", "\n"), '', shell_exec("ps ".$check_pid));
if (strstr($result, $check_pid)) {
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
}
}
function check_log_permissions() {
if(!is_writable($GLOBALS['logpath'])) {
return "!!!! Logs folder is not writable !!!!";
} elseif(file_exists($GLOBALS['logfile']) && !is_writable($GLOBALS['logfile'])) {
return "!!!! Log file is not writable !!!!";
} else {
return TRUE;
}
}
function check_shutdown() {
if(!file_exists($GLOBALS['pidfile'])) {
shutdown(NULL,4,"Received signal to stop!");
}
}
@@ -69,9 +294,9 @@ function db_connect($dbtype, $dbhost, $dbname, $dbuser, $dbpass, $exit=NULL, $pe
}
}
function enter_logfile($cfg,$loglevel,$logtext,$norotate = false) {
if($loglevel!=9 && $loglevel > $cfg['logs_debug_level']) return;
$file = $cfg['logs_path'].'ranksystem.log';
function enter_logfile($loglevel,$logtext,$norotate = false) {
if($loglevel!=9 && $loglevel > $GLOBALS['logs_debug_level']) return;
$file = $GLOBALS['logfile'];
switch ($loglevel) {
case 1: $loglevel = " CRITICAL "; break;
case 2: $loglevel = " ERROR "; break;
@@ -82,23 +307,23 @@ function enter_logfile($cfg,$loglevel,$logtext,$norotate = false) {
default:$loglevel = " NONE ";
}
$loghandle = fopen($file, 'a');
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($cfg['logs_timezone']))->format("Y-m-d H:i:s.u ").$loglevel.$logtext."\n");
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($GLOBALS['logs_timezone']))->format("Y-m-d H:i:s.u ").$loglevel.$logtext."\n");
fclose($loghandle);
if($norotate == false && filesize($file) > ($cfg['logs_rotation_size'] * 1048576)) {
if($norotate == false && filesize($file) > ($GLOBALS['logs_rotation_size'] * 1048576)) {
$loghandle = fopen($file, 'a');
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($cfg['logs_timezone']))->format("Y-m-d H:i:s.u ")." NOTICE Logfile filesie of 5 MiB reached.. Rotate logfile.\n");
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($GLOBALS['logs_timezone']))->format("Y-m-d H:i:s.u ")." NOTICE Logfile filesie of 5 MiB reached.. Rotate logfile.\n");
fclose($loghandle);
$file2 = "$file.old";
if(file_exists($file2)) unlink($file2);
rename($file, $file2);
$loghandle = fopen($file, 'a');
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($cfg['logs_timezone']))->format("Y-m-d H:i:s.u ")." NOTICE Rotated logfile...\n");
fwrite($loghandle, DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($GLOBALS['logs_timezone']))->format("Y-m-d H:i:s.u ")." NOTICE Rotated logfile...\n");
fclose($loghandle);
}
}
function error_handling($msg,$type = NULL) {
if(strstr($type, '#') && strstr($msg, '#####')) {
if(is_string($msg) && is_string($type) && strstr($type, '#') && strstr($msg, '#####')) {
$type_arr = explode('#', $type);
$msg_arr = explode('#####', $msg);
$cnt = 0;
@@ -126,6 +351,17 @@ function error_handling($msg,$type = NULL) {
}
}
function exception_client_code($code) {
switch ($code) {
case 1:
return "1 - Channel Exception";
case 2:
return "2 - ServerGroup Exception";
case 3:
return "3 - Client Exception";
}
}
function getclientip() {
if (!empty($_SERVER['HTTP_CLIENT_IP']))
return $_SERVER['HTTP_CLIENT_IP'];
@@ -143,10 +379,10 @@ function getclientip() {
return false;
}
function getlog($cfg,$number_lines,$filters,$filter2,$inactivefilter = NULL) {
function getlog($number_lines,$filters,$filter2,$inactivefilter = NULL) {
$lines=array();
if(file_exists($cfg['logs_path']."ranksystem.log")) {
$fp = fopen($cfg['logs_path']."ranksystem.log", "r");
if(file_exists($GLOBALS['logfile'])) {
$fp = fopen($GLOBALS['logfile'], "r");
$buffer=array();
while($line = fgets($fp, 4096)) {
array_push($buffer, htmlspecialchars($line));
@@ -192,11 +428,11 @@ function getlog($cfg,$number_lines,$filters,$filter2,$inactivefilter = NULL) {
return $lines;
}
function get_language($cfg) {
function get_language() {
$rspathhex = get_rspath();
if(isset($_GET["lang"])) {
if(is_dir(substr(__DIR__,0,-5).'languages/')) {
foreach(scandir(substr(__DIR__,0,-5).'languages/') as $file) {
if(is_dir($GLOBALS['langpath'])) {
foreach(scandir($GLOBALS['langpath']) as $file) {
if ('.' === $file || '..' === $file || is_dir($file)) continue;
$sep_lang = preg_split("/[._]/", $file);
if(isset($sep_lang[0]) && $sep_lang[0] == 'core' && isset($sep_lang[1]) && strlen($sep_lang[1]) == 2 && isset($sep_lang[4]) && strtolower($sep_lang[4]) == 'php') {
@@ -212,26 +448,268 @@ function get_language($cfg) {
if(isset($_SESSION[$rspathhex.'language'])) {
return $_SESSION[$rspathhex.'language'];
}
if(isset($cfg['default_language'])) {
return $cfg['default_language'];
if(isset($GLOBALS['default_language'])) {
return $GLOBALS['default_language'];
}
return "en";
}
function get_percentage($max_value, $value) {
return (round(($value/$max_value)*100));
if($max_value>0) {
return (round(($value/$max_value)*100));
} else {
return 0;
}
}
function get_rspath() {
return 'rs_'.dechex(crc32(__DIR__)).'_';
}
function get_style($default_style) {
$rspathhex = get_rspath();
if(isset($_GET["style"])) {
if(is_dir($GLOBALS['stylepath'])) {
foreach(scandir($GLOBALS['stylepath']) as $folder) {
if ('.' === $folder || '..' === $folder) continue;
if(is_dir($GLOBALS['stylepath'].DIRECTORY_SEPARATOR.$folder)) {
foreach(scandir($GLOBALS['stylepath'].DIRECTORY_SEPARATOR.$folder) as $file) {
if ('.' === $file || '..' === $file || is_dir($file)) continue;
$sep_style = preg_split("/[._]/", $file);
if($file == "ST.css") {
$_SESSION[$rspathhex.'style'] = $folder;
return $folder;
}
}
}
}
}
}
if(isset($_SESSION[$rspathhex.'style'])) {
return $_SESSION[$rspathhex.'style'];
}
if(isset($default_style)) {
return $default_style;
}
return NULL;
}
function human_readable_size($bytes,$lang) {
$size = array($lang['size_byte'],$lang['size_kib'],$lang['size_mib'],$lang['size_gib'],$lang['size_tib'],$lang['size_pib'],$lang['size_eib'],$lang['size_zib'],$lang['size_yib']);
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.2f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor];
}
function list_rankup($cfg,$lang,$sqlhisgroup,$value,$adminlogin,$nation,$grpcount,$rank = NULL) {
$return = '<tr>';
if ($cfg['stats_column_rank_switch'] == 1 || $adminlogin == 1) {
if($value['except'] == 2 || $value['except'] == 3) {
$return .= '<td></td>';
} else {
$return .= '<td>'.$value['rank'].'</td>';
}
}
if ($adminlogin == 1) {
$return .= '<td><a href="//tsviewer.com/index.php?page=search&action=ausgabe_user&nickname='.htmlspecialchars($value['name']).'" target="_blank">'.htmlspecialchars($value['name']).'</a></td>';
} elseif ($cfg['stats_column_client_name_switch'] == 1) {
$return .= '<td>'.htmlspecialchars($value['name']).'</td>';
}
if ($adminlogin == 1) {
$return .= '<td><a href="//ts3index.com/?page=searchclient&uid='.$value['uuid'].'" target="_blank">'.$value['uuid'].'</a></td>';
} elseif ($cfg['stats_column_unique_id_switch'] == 1) {
$return .= '<td>'.$value['uuid'].'</td>';
}
if ($cfg['stats_column_client_db_id_switch'] == 1 || $adminlogin == 1)
$return .= '<td>'.$value['cldbid'].'</td>';
if ($cfg['stats_column_last_seen_switch'] == 1 || $adminlogin == 1) {
if ($value['online'] == 1) {
$return .= '<td class="text-success">online</td>';
} else {
$return .= '<td>'.date('Y-m-d H:i:s',$value['lastseen']).'</td>';
}
}
if ($cfg['stats_column_nation_switch'] == 1 || $adminlogin == 1) {
if(strtoupper($value['nation']) == 'XX' || $value['nation'] == NULL) {
$return .= '<td><i class="fas fa-question-circle" title="'.$lang['unknown'].'"></i></td>';
} else {
$return .= '<td><span class="flag-icon flag-icon-'.strtolower(htmlspecialchars($value['nation'])).'" title="'.$value['nation'].' - '.$nation[$value['nation']].'"></span></td>';
}
}
if ($cfg['stats_column_version_switch'] == 1 || $adminlogin == 1) {
$return .= '<td>'.htmlspecialchars($value['version']).'</td>';
}
if ($cfg['stats_column_platform_switch'] == 1 || $adminlogin == 1) {
$return .= '<td>'.htmlspecialchars($value['platform']).'</td>';
}
if ($cfg['stats_column_online_time_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['count'])) {
$return .= '<td title="'.number_format($value['count'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['count']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_idle_time_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['idle'])) {
$return .= '<td title="'.number_format($value['idle'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['idle']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_active_time_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['count']) && is_numeric($value['idle'])) {
$return .= '<td title="'.number_format(($value['count'])-$value['idle'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".(round($value['count'])-round($value['idle'])));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_online_day_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['count_day'])) {
$return .= '<td title="'.number_format($value['count_day'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['count_day']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_idle_day_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['idle_day'])) {
$return .= '<td title="'.number_format($value['idle_day'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['idle_day']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_active_day_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['active_day'])) {
$return .= '<td title="'.number_format($value['active_day'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['active_day']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_online_week_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['count_week'])) {
$return .= '<td title="'.number_format($value['count_week'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['count_week']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_idle_week_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['idle_week'])) {
$return .= '<td title="'.number_format($value['idle_week'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['idle_week']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_active_week_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['active_week'])) {
$return .= '<td title="'.number_format($value['active_week'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['active_week']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_online_month_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['count_month'])) {
$return .= '<td title="'.number_format($value['count_month'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['count_month']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_idle_month_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['idle_month'])) {
$return .= '<td title="'.number_format($value['idle_month'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['idle_month']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_active_month_switch'] == 1 || $adminlogin == 1) {
if (is_numeric($value['active_month'])) {
$return .= '<td title="'.number_format($value['active_month'],0,",",".").' '.$lang['time_sec'].'">';
$dtF = new DateTime("@0");
$dtT = new DateTime("@".round($value['active_month']));
$return .= $dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} else {
$return .= '<td>'.$lang['unknown'].'</td>';
}
}
if ($cfg['stats_column_current_server_group_switch'] == 1 || $adminlogin == 1) {
if ($value['grpid'] == 0) {
$return .= '<td></td>';
} elseif(isset($sqlhisgroup[$value['grpid']]) && $sqlhisgroup[$value['grpid']]['iconid'] != 0) {
$return .= '<td title="'.$lang['wigrpt2'].' ID: '.$value['grpid'].'"><img src="../tsicons/'.$sqlhisgroup[$value['grpid']]['iconid'].'.'.$sqlhisgroup[$value['grpid']]['ext'].'" width="16" height="16" alt="groupicon"><span class="item-margin">'.$sqlhisgroup[$value['grpid']]['sgidname'].'</span></td>';
} elseif(isset($sqlhisgroup[$value['grpid']])) {
$return .= '<td title="'.$lang['wigrpt2'].' ID: '.$value['grpid'].'">'.$sqlhisgroup[$value['grpid']]['sgidname'].'</td>';
} else {
$return .= '<td><i>'.$lang['unknown'].'</i></td>';
}
}
if ($cfg['stats_column_current_group_since_switch'] == 1 || $adminlogin == 1) {
if ($value['grpsince'] == 0) {
$return .= '<td></td>';
} else {
$return .= '<td>'.date('Y-m-d H:i:s',$value['grpsince']).'</td>';
}
}
if ($cfg['stats_column_next_rankup_switch'] == 1 || $adminlogin == 1) {
$return .= '<td title="';
if (($value['except'] == 0 || $value['except'] == 1) && $value['nextup'] > 0) {
$dtF = new DateTime("@0");
$dtT = new DateTime("@".$value['nextup']);
$return .= number_format($value['nextup'],0,",",".").' '.$lang['time_sec'].'">'.$dtF->diff($dtT)->format($cfg['default_date_format']).'</td>';
} elseif ($value['except'] == 0 || $value['except'] == 1) {
$return .= '0 '.$lang['time_sec'].'">0</td>';
} elseif ($value['except'] == 2 || $value['except'] == 3) {
$return .= '0 '.$lang['time_sec'].'">0</td>';
} else {
$return .= $lang['errukwn'].'</td>';
}
}
if ($cfg['stats_column_next_server_group_switch'] == 1 || $adminlogin == 1) {
if ($grpcount == count($cfg['rankup_definition']) && $value['nextup'] == 0 && $cfg['stats_show_clients_in_highest_rank_switch'] == 1 || $grpcount == count($cfg['rankup_definition']) && $value['nextup'] == 0 && $adminlogin == 1) {
$return .= '<td><em>'.$lang['highest'].'</em></td>';
} elseif ($value['except'] == 2 || $value['except'] == 3) {
$return .= '<td><em>'.$lang['listexcept'].'</em></td>';
} elseif (isset($sqlhisgroup[$rank['group']]) && $sqlhisgroup[$rank['group']]['iconid'] != 0) {
$return .= '<td title="'.$lang['wigrpt2'].' ID: '.$rank['group'].'"><img src="../tsicons/'.$sqlhisgroup[$rank['group']]['iconid'].'.'.$sqlhisgroup[$rank['group']]['ext'].'" width="16" height="16" alt="missed_icon"><span class="item-margin">'.$sqlhisgroup[$rank['group']]['sgidname'].'</span></td>';
} elseif (isset($sqlhisgroup[$rank['group']])) {
$return .= '<td title="'.$lang['wigrpt2'].' ID: '.$rank['group'].'">'.$sqlhisgroup[$rank['group']]['sgidname'].'</td>';
} else {
$return .= '<td></td>';
}
}
return $return;
}
function mime2extension($mimetype) {
$mimearr = [
'image/bmp' => 'bmp',
@@ -258,7 +736,7 @@ function mime2extension($mimetype) {
}
function pagination($keysort,$keyorder,$user_pro_seite,$seiten_anzahl_gerundet,$seite,$getstring) {
$pagination = '<nav><div class="text-center"><ul class="pagination"><li><a href="?sort='.$keysort.'&amp;order='.$keyorder.'&amp;seite=1&amp;user='.$user_pro_seite.'&amp;search='.$getstring.'" aria-label="backward"><span aria-hidden="true"><span class="fas fa-caret-square-left" aria-hidden="true"></span>&nbsp;</span></a></li>';
$pagination = '<nav><div class="text-center"><ul class="pagination"><li><a href="?sort='.$keysort.'&amp;order='.$keyorder.'&amp;seite=1&amp;user='.$user_pro_seite.'&amp;search='.$getstring.'" aria-label="backward"><span aria-hidden="true"><span class="fas fa-caret-square-left fa-fw" aria-hidden="true"></span></span></a></li>';
for($a=0; $a < $seiten_anzahl_gerundet; $a++) {
$b = $a + 1;
if($seite == $b) {
@@ -267,7 +745,7 @@ function pagination($keysort,$keyorder,$user_pro_seite,$seiten_anzahl_gerundet,$
$pagination .= '<li><a href="?sort='.$keysort.'&amp;order='.$keyorder.'&amp;seite='.$b.'&amp;user='.$user_pro_seite.'&amp;search='.$getstring.'">'.$b.'</a></li>';
}
}
$pagination .= '<li><a href="?sort='.$keysort.'&amp;order='.$keyorder.'&amp;seite='.$seiten_anzahl_gerundet.'&amp;user='.$user_pro_seite.'&amp;search='.$getstring.'" aria-label="forward"><span aria-hidden="true">&nbsp;<span class="fas fa-caret-square-right" aria-hidden="true"></span></span></a></li></ul></div></nav>';
$pagination .= '<li><a href="?sort='.$keysort.'&amp;order='.$keyorder.'&amp;seite='.$seiten_anzahl_gerundet.'&amp;user='.$user_pro_seite.'&amp;search='.$getstring.'" aria-label="forward"><span aria-hidden="true"><span class="fas fa-caret-square-right fa-fw" aria-hidden="true"></span></span></a></li></ul></div></nav>';
return $pagination;
}
@@ -280,7 +758,7 @@ function php_error_handling($err_code, $err_msg, $err_file, $err_line) {
default: $loglevel = 4;
}
if(substr($err_msg, 0, 15) != "password_hash()" && substr($err_msg, 0, 11) != "fsockopen()") {
enter_logfile($cfg,$loglevel,$err_code.": ".$err_msg." on line ".$err_line." in ".$err_file);
enter_logfile($loglevel,$err_code.": ".$err_msg." on line ".$err_line." in ".$err_file);
}
return true;
}
@@ -402,13 +880,13 @@ function select_channel($channellist, $cfg_cid, $multiple=NULL) {
}
function set_language($language) {
if(is_dir(substr(__DIR__,0,-5).'languages/')) {
foreach(scandir(substr(__DIR__,0,-5).'languages/') as $file) {
if(is_dir($GLOBALS['langpath'])) {
foreach(scandir($GLOBALS['langpath']) as $file) {
if ('.' === $file || '..' === $file || is_dir($file)) continue;
$sep_lang = preg_split("/[._]/", $file);
if(isset($sep_lang[0]) && $sep_lang[0] == 'core' && isset($sep_lang[1]) && strlen($sep_lang[1]) == 2 && isset($sep_lang[4]) && strtolower($sep_lang[4]) == 'php') {
if(strtolower($language) == strtolower($sep_lang[1])) {
include(substr(__DIR__,0,-5).'languages/core_'.$sep_lang[1].'_'.$sep_lang[2].'_'.$sep_lang[3].'.'.$sep_lang[4]);
include($GLOBALS['langpath'].DIRECTORY_SEPARATOR.'/core_'.$sep_lang[1].'_'.$sep_lang[2].'_'.$sep_lang[3].'.'.$sep_lang[4]);
$_SESSION[get_rspath().'language'] = $sep_lang[1];
$required_lang = 1;
break;
@@ -417,7 +895,7 @@ function set_language($language) {
}
}
if(!isset($required_lang)) {
include('../languages/core_en_english_gb.php');
include($GLOBALS['langpath'].DIRECTORY_SEPARATOR.'core_en_english_gb.php');
}
return $lang;
}
@@ -425,16 +903,18 @@ function set_language($language) {
function set_session_ts3($mysqlcon,$cfg,$lang,$dbname) {
$hpclientip = getclientip();
$rspathhex = get_rspath();
$allclients = $mysqlcon->query("SELECT `u`.`uuid`,`u`.`cldbid`,`u`.`name`,`u`.`firstcon`,`s`.`total_connections` FROM `$dbname`.`user` AS `u` LEFT JOIN `$dbname`.`stats_user` AS `s` ON `u`.`uuid`=`s`.`uuid` WHERE `online`='1'")->fetchAll();
$iptable = $mysqlcon->query("SELECT `uuid`,`iphash`,`ip` FROM `$dbname`.`user_iphash`")->fetchAll(PDO::FETCH_ASSOC|PDO::FETCH_UNIQUE);
if(!isset($_SESSION[$rspathhex.'connected']) && isset($cfg['stats_news_html'])) $_SESSION[$rspathhex.'stats_news_html'] = $cfg['stats_news_html'];
$_SESSION[$rspathhex.'connected'] = 0;
$_SESSION[$rspathhex.'tsname'] = $lang['stag0016'];
$_SESSION[$rspathhex.'serverport'] = $cfg['teamspeak_voice_port'];
$_SESSION[$rspathhex.'multiple'] = array();
if($cfg['rankup_hash_ip_addresses_mode'] == 2) {
$salt = md5(dechex(crc32(substr(__DIR__,0,-5))));
$salt = md5(dechex(crc32(dirname(__DIR__))));
$hashedip = crypt($hpclientip, '$2y$10$'.$salt.'$');
}
@@ -475,7 +955,7 @@ function set_session_ts3($mysqlcon,$cfg,$lang,$dbname) {
}
$_SESSION[$rspathhex.'tscldbid'] = $client['cldbid'];
if ($client['firstcon'] == 0) {
$_SESSION[$rspathhex.'tscreated'] = "unkown";
$_SESSION[$rspathhex.'tscreated'] = $lang['unknown'];
} else {
$_SESSION[$rspathhex.'tscreated'] = date('d-m-Y', $client['firstcon']);
}
@@ -498,6 +978,7 @@ function set_session_ts3($mysqlcon,$cfg,$lang,$dbname) {
}
$_SESSION[$rspathhex.'connected'] = 1;
$_SESSION[$rspathhex.'language'] = $cfg['default_language'];
$_SESSION[$rspathhex.'style'] = $cfg['default_style'];
}
}
}
@@ -510,55 +991,59 @@ function sendmessage($ts3, $cfg, $uuid, $msg, $targetmode, $targetid=NULL, $erro
usleep($cfg['teamspeak_query_command_delay']);
if ($targetmode==2 && $targetid!=NULL) {
$ts3->serverGetSelected()->channelGetById($targetid)->message("\n".$frag);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage fragment to channel (ID: $targetid): ".$frag);
if($nolog==NULL) enter_logfile(6,"sendmessage fragment to channel (ID: $targetid): ".$frag);
} elseif ($targetmode==3) {
$ts3->serverGetSelected()->message("\n".$frag);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage fragment to server: ".$frag);
if($nolog==NULL) enter_logfile(6,"sendmessage fragment to server: ".$frag);
} elseif ($targetmode==1 && $targetid!=NULL) {
$ts3->serverGetSelected()->clientGetById($targetid)->message("\n".$frag);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage fragment to connectionID $targetid (uuid $uuid): ".$frag);
if($nolog==NULL) enter_logfile(6,"sendmessage fragment to connectionID $targetid (uuid $uuid): ".$frag);
} else {
$ts3->serverGetSelected()->clientGetByUid($uuid)->message("\n".$frag);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage fragment to uuid $uuid (connectionID $targetid): ".$frag);
if($nolog==NULL) enter_logfile(6,"sendmessage fragment to uuid $uuid (connectionID $targetid): ".$frag);
}
}
} else {
usleep($cfg['teamspeak_query_command_delay']);
if ($targetmode==2 && $targetid!=NULL) {
$ts3->serverGetSelected()->channelGetById($targetid)->message($msg);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage to channel (ID: $targetid): ".$msg);
if($nolog==NULL) enter_logfile(6,"sendmessage to channel (ID: $targetid): ".$msg);
} elseif ($targetmode==3) {
$ts3->serverGetSelected()->message($msg);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage to server: ".$msg);
if($nolog==NULL) enter_logfile(6,"sendmessage to server: ".$msg);
} elseif ($targetmode==1 && $targetid!=NULL) {
$ts3->serverGetSelected()->clientGetById($targetid)->message($msg);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage to connectionID $targetid (uuid $uuid): ".$msg);
if($nolog==NULL) enter_logfile(6,"sendmessage to connectionID $targetid (uuid $uuid): ".$msg);
} else {
$ts3->serverGetSelected()->clientGetByUid($uuid)->message($msg);
if($nolog==NULL) enter_logfile($cfg,6,"sendmessage to uuid $uuid (connectionID $targetid): ".$msg);
if($nolog==NULL) enter_logfile(6,"sendmessage to uuid $uuid (connectionID $targetid): ".$msg);
}
}
if($successmsg!=NULL) {
enter_logfile($cfg,5,$successmsg);
enter_logfile(5,$successmsg);
}
} catch (Exception $e) {
if($loglevel!=NULL) {
enter_logfile($cfg,$loglevel,$erromsg." TS3: ".$e->getCode().': '.$e->getMessage());
enter_logfile($loglevel,$erromsg." TS3: ".$e->getCode().': '.$e->getMessage());
} else {
enter_logfile($cfg,3,"sendmessage: ".$e->getCode().': '.$e->getMessage().", targetmode: $targetmode, targetid: $targetid");
enter_logfile(3,"sendmessage: ".$e->getCode().': '.$e->getMessage().", targetmode: $targetmode, targetid: $targetid");
}
}
}
function shutdown($mysqlcon,$cfg,$loglevel,$reason,$nodestroypid = TRUE) {
function shutdown($mysqlcon,$loglevel,$reason,$nodestroypid = TRUE) {
if($nodestroypid === TRUE) {
if (file_exists($cfg['logs_path'].'pid')) {
unlink($cfg['logs_path'].'pid');
if (file_exists($GLOBALS['pidfile'])) {
unlink($GLOBALS['pidfile']);
}
}
enter_logfile($cfg,$loglevel,$reason." Shutting down!");
enter_logfile($cfg,9,"###################################################################");
if($nodestroypid === TRUE) {
enter_logfile($loglevel,$reason." Shutting down!");
enter_logfile(9,"###################################################################");
} else {
enter_logfile($loglevel,$reason." Ignore request!");
}
if(isset($mysqlcon)) {
$mysqlcon = null;
}
@@ -604,6 +1089,36 @@ function sort_channel_tree($channellist) {
return $sorted_channel;
}
function sort_options($lang) {
$arr_sort_options = array(
array('option' => 'rank', 'title' => $lang['listrank'], 'icon' => 'fas fa-hashtag', 'config' => 'stats_column_rank_switch'),
array('option' => 'name', 'title' => $lang['listnick'], 'icon' => 'fas fa-user', 'config' => 'stats_column_client_name_switch'),
array('option' => 'uuid', 'title' => $lang['listuid'], 'icon' => 'fas fa-id-card', 'config' => 'stats_column_unique_id_switch'),
array('option' => 'cldbid', 'title' => $lang['listcldbid'], 'icon' => 'fas fa-database', 'config' => 'stats_column_client_db_id_switch'),
array('option' => 'lastseen', 'title' => $lang['listseen'], 'icon' => 'fas fa-user-clock', 'config' => 'stats_column_last_seen_switch'),
array('option' => 'nation', 'title' => $lang['listnat'], 'icon' => 'fas fa-globe-europe', 'config' => 'stats_column_nation_switch'),
array('option' => 'version', 'title' => $lang['listver'], 'icon' => 'fas fa-tag', 'config' => 'stats_column_version_switch'),
array('option' => 'platform', 'title' => $lang['listpla'], 'icon' => 'fas fa-server', 'config' => 'stats_column_platform_switch'),
array('option' => 'count', 'title' => $lang['listsumo'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_time_switch'),
array('option' => 'idle', 'title' => $lang['listsumi'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_idle_time_switch'),
array('option' => 'active', 'title' => $lang['listsuma'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_active_time_switch'),
array('option' => 'count_day', 'title' => $lang['listsumo'].' '.$lang['stix0013'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_day_switch'),
array('option' => 'idle_day', 'title' => $lang['listsumi'].' '.$lang['stix0013'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_idle_day_switch'),
array('option' => 'active_day', 'title' => $lang['listsuma'].' '.$lang['stix0013'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_active_day_switch'),
array('option' => 'count_week', 'title' => $lang['listsumo'].' '.$lang['stix0014'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_week_switch'),
array('option' => 'idle_week', 'title' => $lang['listsumi'].' '.$lang['stix0014'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_idle_week_switch'),
array('option' => 'active_week', 'title' => $lang['listsuma'].' '.$lang['stix0014'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_active_week_switch'),
array('option' => 'count_month', 'title' => $lang['listsumo'].' '.$lang['stix0015'], 'icon' => 'fas fa-hourglass-start', 'config' => 'stats_column_online_month_switch'),
array('option' => 'idle_month', 'title' => $lang['listsumi'].' '.$lang['stix0015'], 'icon' => 'fas fa-hourglass-half', 'config' => 'stats_column_idle_month_switch'),
array('option' => 'active_month', 'title' => $lang['listsuma'].' '.$lang['stix0015'], 'icon' => 'fas fa-hourglass-end', 'config' => 'stats_column_active_month_switch'),
array('option' => 'grpid', 'title' => $lang['listacsg'], 'icon' => 'fas fa-clipboard-check', 'config' => 'stats_column_current_server_group_switch'),
array('option' => 'grpidsince', 'title' => $lang['listgrps'], 'icon' => 'fas fa-history', 'config' => 'stats_column_current_group_since_switch'),
array('option' => 'nextup', 'title' => $lang['listnxup'], 'icon' => 'fas fa-clock', 'config' => 'stats_column_next_rankup_switch'),
array('option' => 'active', 'title' => $lang['listnxsg'], 'icon' => 'fas fa-clipboard-list', 'config' => 'stats_column_next_server_group_switch')
);
return $arr_sort_options;
}
function start_session($cfg) {
ini_set('session.cookie_httponly', 1);
ini_set('session.use_strict_mode', 1);

View File

@@ -1,5 +1,5 @@
<?PHP
require_once('dbconfig.php');
require_once(__DIR__.DIRECTORY_SEPARATOR.'dbconfig.php');
$rspathhex = get_rspath();
@@ -16,11 +16,6 @@ $mysqlcon = db_connect($db['type'], $db['host'], $db['dbname'], $db['user'], $db
if (isset($mysqlcon) && ($newcfg = $mysqlcon->query("SELECT * FROM `$dbname`.`cfg_params`"))) {
if(isset($newcfg) && $newcfg != NULL) {
$cfg = $newcfg->fetchAll(PDO::FETCH_KEY_PAIR);
if (!isset($cfg['logs_timezone']) || $cfg['logs_timezone'] == NULL) {
$cfg['logs_timezone'] = "Europe/Berlin";
}
date_default_timezone_set($cfg['logs_timezone']);
if(empty($cfg['webinterface_admin_client_unique_id_list'])) {
$cfg['webinterface_admin_client_unique_id_list'] = NULL;
} else {
@@ -68,19 +63,48 @@ if (isset($mysqlcon) && ($newcfg = $mysqlcon->query("SELECT * FROM `$dbname`.`cf
$cfg['stats_api_keys'] = NULL;
} else {
foreach (explode(',', $cfg['stats_api_keys']) as $entry) {
list($key, $value) = explode('=>', $entry);
$addnewvalue3[$key] = $value;
list($key, $desc, $perm_bot) = array_pad(explode('=>', $entry), 3, null);
if(!$perm_bot) $perm_bot = 0;
$addnewvalue3[$key] = array("key"=>$key,"desc"=>$desc,"perm_bot"=>$perm_bot);
$cfg['stats_api_keys'] = $addnewvalue3;
}
}
unset($addnewvalue1, $addnewvalue2, $newcfg);
unset($addnewvalue1, $addnewvalue2, $addnewvalue3, $newcfg);
}
}
if(empty($cfg['logs_debug_level'])) {
$cfg['logs_debug_level'] = "5";
$GLOBALS['logs_debug_level'] = $cfg['logs_debug_level'] = "5";
} else {
$GLOBALS['logs_debug_level'] = $cfg['logs_debug_level'];
}
if(empty($cfg['logs_rotation_size'])) {
$cfg['logs_rotation_size'] = "5";
$GLOBALS['logs_rotation_size'] = $cfg['logs_rotation_size'] = "5";
} else {
$GLOBALS['logs_rotation_size'] = $cfg['logs_rotation_size'];
}
if(!isset($cfg['logs_path']) || $cfg['logs_path'] == NULL) { $cfg['logs_path'] = dirname(__DIR__).DIRECTORY_SEPARATOR."logs".DIRECTORY_SEPARATOR; }
if(!isset($cfg['logs_timezone'])) {
$GLOBALS['logs_timezone'] = "Europe/Berlin";
} else {
$GLOBALS['logs_timezone'] = $cfg['logs_timezone'];
}
date_default_timezone_set($GLOBALS['logs_timezone']);
$GLOBALS['logpath'] = $cfg['logs_path'];
$GLOBALS['logfile'] = $cfg['logs_path'].'ranksystem.log';
$GLOBALS['pidfile'] = $cfg['logs_path'].'pid';
$GLOBALS['autostart'] = $cfg['logs_path'].'autostart_deactivated';
$GLOBALS['langpath'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR;
if(!isset($cfg['default_language']) || $cfg['default_language'] == NULL) {
$GLOBALS['default_language'] = 'en';
} else {
$GLOBALS['default_language'] = $cfg['default_language'];
}
$GLOBALS['stylepath'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'styles'.DIRECTORY_SEPARATOR;
if(isset($cfg['default_style'])) $GLOBALS['style'] = get_style($cfg['default_style']);
$GLOBALS['avatarpath'] = dirname(__DIR__).DIRECTORY_SEPARATOR.'avatars'.DIRECTORY_SEPARATOR;
require_once(__DIR__.DIRECTORY_SEPARATOR.'phpcommand.php');
$GLOBALS['phpcommand'] = $phpcommand;
?>

View File

@@ -18,7 +18,7 @@ $phpcommand = 'php';
## WINDOWS
#$phpcommand = 'C:\PHP7\php.exe';
#$phpcommand = 'C:\wamp\bin\php\php.exe';
#$phpcommand = 'C:\xampp\php\php.exe';
#$phpcommand = 'C:\xampp\php80\php.exe';
# On blanks or special characters inside the path, you need to escape these with special marks --> \" <-- at the beginning and end of the path, see example below
#$phpcommand = '\"C:\Program Files (x86)\PHP\php.exe\"';
#$phpcommand = '\"C:\Program Files (x86)\Plesk\Additional\PHP73\php.exe\"';

View File

@@ -0,0 +1,10 @@
<?PHP
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'other/_functions.php');
require_once(dirname(__DIR__).DIRECTORY_SEPARATOR.'other/config.php');
$prot = start_session($cfg);
if(isset($_POST['stats_news_html'])) {
unset($_SESSION[$rspathhex.$_POST['stats_news_html']]);
}
?>