release 1.1.0
This commit is contained in:
23
jobs/bot.php
23
jobs/bot.php
@@ -44,6 +44,11 @@ function enter_logfile($logpath,$timezone,$loglevel,$logtext) {
|
||||
|
||||
require_once(substr(__DIR__,0,-4).'other/config.php');
|
||||
|
||||
if(version_compare(phpversion(), '5.5.0', '<')) {
|
||||
enter_logfile($logpath,$timezone,1,"Your PHP version (".phpversion().") is below 5.5.0. Update of PHP needed! Shuttin down!\n\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
enter_logfile($logpath,$timezone,5,"Initialize Bot...");
|
||||
require_once(substr(__DIR__,0,-4).'ts3_lib/TeamSpeak3.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/calc_user.php');
|
||||
@@ -54,7 +59,7 @@ require_once(substr(__DIR__,0,-4).'jobs/calc_userstats.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/clean.php');
|
||||
require_once(substr(__DIR__,0,-4).'jobs/check_db.php');
|
||||
|
||||
function log_mysql($jobname,$mysqlcon,$timezone) {
|
||||
function log_mysql($jobname,$mysqlcon,$timezone,$dbname) {
|
||||
$timestamp = time();
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.job_log (timestamp,job_name,status) VALUES ('$timestamp','$jobname','9')") === false) {
|
||||
enter_logfile($logpath,$timezone,2,print_r($mysqlcon->errorInfo()));
|
||||
@@ -127,26 +132,24 @@ try {
|
||||
if($defchid != 0) {
|
||||
try { usleep($slowmode); $ts3->clientMove($whoami['client_id'],$defchid); } catch (Exception $e) {}
|
||||
}
|
||||
$jobid = log_mysql('calc_user',$mysqlcon,$timezone);
|
||||
calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$showgen,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath);
|
||||
$jobid = log_mysql('calc_user',$mysqlcon,$timezone,$dbname);
|
||||
calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$jobid = log_mysql('get_avatars',$mysqlcon,$timezone);
|
||||
$jobid = log_mysql('get_avatars',$mysqlcon,$timezone,$dbname);
|
||||
get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$logpath);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$jobid = log_mysql('update_groups',$mysqlcon,$timezone);
|
||||
$jobid = log_mysql('update_groups',$mysqlcon,$timezone,$dbname);
|
||||
update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$serverinfo,$logpath);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$jobid = log_mysql('calc_serverstats',$mysqlcon,$timezone);
|
||||
$jobid = log_mysql('calc_serverstats',$mysqlcon,$timezone,$dbname);
|
||||
calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$serverinfo,$substridle,$grouptime,$logpath);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$jobid = log_mysql('calc_userstats',$mysqlcon,$timezone);
|
||||
$jobid = log_mysql('calc_userstats',$mysqlcon,$timezone,$dbname);
|
||||
calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$logpath);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$jobid = log_mysql('clean',$mysqlcon,$timezone);
|
||||
$jobid = log_mysql('clean',$mysqlcon,$timezone,$dbname);
|
||||
clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$cleanclients,$cleanperiod,$logpath);
|
||||
//check auf fehler in job_log
|
||||
$looptime = microtime(true) - $starttime;
|
||||
//echo DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''))->setTimeZone(new DateTimeZone($timezone))->format("Y-m-d H:i:s.u "),"Loop: ",$looptime,"\n";
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
|
||||
@@ -212,14 +212,14 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezon
|
||||
$server_bytes_up = $serverinfo['connection_bytes_sent_total'];
|
||||
$server_uptime = $serverinfo['virtualserver_uptime'];
|
||||
$server_id = $serverinfo['virtualserver_id'];
|
||||
$server_name = str_replace('\\', '\\\\', htmlspecialchars($serverinfo['virtualserver_name'], ENT_QUOTES));
|
||||
$server_name = $mysqlcon->quote($serverinfo['virtualserver_name'], ENT_QUOTES);
|
||||
$server_pass = $serverinfo['virtualserver_flag_password'];
|
||||
$server_creation_date = $serverinfo['virtualserver_created'];
|
||||
$server_platform = $serverinfo['virtualserver_platform'];
|
||||
$server_weblist = $serverinfo['virtualserver_weblist_enabled'];
|
||||
$server_version = $serverinfo['virtualserver_version'];
|
||||
|
||||
if($mysqlcon->exec("UPDATE $dbname.stats_server SET total_user='$total_user', total_online_time='$total_online_time', total_online_month='$total_online_month', total_online_week='$total_online_week', total_active_time='$total_active_time', total_inactive_time='$total_inactive_time', country_nation_name_1='$country_nation_name_1', country_nation_name_2='$country_nation_name_2', country_nation_name_3='$country_nation_name_3', country_nation_name_4='$country_nation_name_4', country_nation_name_5='$country_nation_name_5', country_nation_1='$country_nation_1', country_nation_2='$country_nation_2', country_nation_3='$country_nation_3', country_nation_4='$country_nation_4', country_nation_5='$country_nation_5', country_nation_other='$country_nation_other', platform_1='$platform_1', platform_2='$platform_2', platform_3='$platform_3', platform_4='$platform_4', platform_5='$platform_5', platform_other='$platform_other', version_name_1='$version_name_1', version_name_2='$version_name_2', version_name_3='$version_name_3', version_name_4='$version_name_4', version_name_5='$version_name_5', version_1='$version_1', version_2='$version_2', version_3='$version_3', version_4='$version_4', version_5='$version_5', version_other='$version_other', version_name_1='$version_name_1', server_status='$server_status', server_free_slots='$server_free_slots', server_used_slots='$server_used_slots', server_channel_amount='$server_channel_amount', server_ping='$server_ping', server_packet_loss='$server_packet_loss', server_bytes_down='$server_bytes_down', server_bytes_up='$server_bytes_up', server_uptime='$server_uptime', server_id='$server_id', server_name='$server_name', server_pass='$server_pass', server_creation_date='$server_creation_date', server_platform='$server_platform', server_weblist='$server_weblist', server_version='$server_version'") === false) {
|
||||
if($mysqlcon->exec("UPDATE $dbname.stats_server SET total_user='$total_user', total_online_time='$total_online_time', total_online_month='$total_online_month', total_online_week='$total_online_week', total_active_time='$total_active_time', total_inactive_time='$total_inactive_time', country_nation_name_1='$country_nation_name_1', country_nation_name_2='$country_nation_name_2', country_nation_name_3='$country_nation_name_3', country_nation_name_4='$country_nation_name_4', country_nation_name_5='$country_nation_name_5', country_nation_1='$country_nation_1', country_nation_2='$country_nation_2', country_nation_3='$country_nation_3', country_nation_4='$country_nation_4', country_nation_5='$country_nation_5', country_nation_other='$country_nation_other', platform_1='$platform_1', platform_2='$platform_2', platform_3='$platform_3', platform_4='$platform_4', platform_5='$platform_5', platform_other='$platform_other', version_name_1='$version_name_1', version_name_2='$version_name_2', version_name_3='$version_name_3', version_name_4='$version_name_4', version_name_5='$version_name_5', version_1='$version_1', version_2='$version_2', version_3='$version_3', version_4='$version_4', version_5='$version_5', version_other='$version_other', version_name_1='$version_name_1', server_status='$server_status', server_free_slots='$server_free_slots', server_used_slots='$server_used_slots', server_channel_amount='$server_channel_amount', server_ping='$server_ping', server_packet_loss='$server_packet_loss', server_bytes_down='$server_bytes_down', server_bytes_up='$server_bytes_up', server_uptime='$server_uptime', server_id='$server_id', server_name=$server_name, server_pass='$server_pass', server_creation_date='$server_creation_date', server_platform='$server_platform', server_weblist='$server_weblist', server_version='$server_version'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_serverstats 8:".print_r($mysqlcon->errorInfo()));
|
||||
$sqlmsg .= print_r($mysqlcon->errorInfo());
|
||||
$sqlerr++;
|
||||
|
||||
@@ -1,32 +1,61 @@
|
||||
<?PHP
|
||||
function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$showgen,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath) {
|
||||
function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$update,$grouptime,$boostarr,$resetbydbchange,$msgtouser,$uniqueid,$updateinfotime,$currvers,$substridle,$exceptuuid,$exceptgroup,$allclients,$logpath,$rankupmsg,$ignoreidle,$exceptcid) {
|
||||
$starttime = microtime(true);
|
||||
$nowtime = time();
|
||||
$sqlmsg = '';
|
||||
$sqlerr = 0;
|
||||
|
||||
|
||||
if(($getversion = $mysqlcon->query("SELECT * FROM $dbname.job_check WHERE job_name='get_version'")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user -3:".print_r($mysqlcon->errorInfo()));
|
||||
$sqlmsg .= print_r($mysqlcon->errorInfo());
|
||||
$sqlerr++;
|
||||
} else {
|
||||
$getversion = $getversion->fetchAll();
|
||||
$updatetime = $nowtime - 43200;
|
||||
if ($getversion[0]['timestamp'] < $updatetime) {
|
||||
set_error_handler(function() { });
|
||||
$newversion = file_get_contents('http://ts-n.net/ranksystem/version');
|
||||
restore_error_handler();
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='get_version'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user -2:".print_r($mysqlcon->errorInfo()));
|
||||
$sqlmsg .= print_r($mysqlcon->errorInfo());
|
||||
$sqlerr++;
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE $dbname.config SET newversion='$newversion'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user -1:".print_r($mysqlcon->errorInfo()));
|
||||
$sqlmsg .= print_r($mysqlcon->errorInfo());
|
||||
$sqlerr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($update == 1) {
|
||||
$updatetime = $nowtime - $updateinfotime;
|
||||
if(($lastupdate = $mysqlcon->query("SELECT * FROM $dbname.job_check WHERE job_name='check_update'")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 1:".print_r($mysqlcon->errorInfo()));
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 0:".print_r($mysqlcon->errorInfo()));
|
||||
$sqlmsg .= print_r($mysqlcon->errorInfo());
|
||||
$sqlerr++;
|
||||
}
|
||||
$lastupdate = $lastupdate->fetchAll();
|
||||
if ($lastupdate[0]['timestamp'] < $updatetime) {
|
||||
set_error_handler(function() { });
|
||||
$newversion = file_get_contents('http://ts-n.net/ranksystem/version');
|
||||
restore_error_handler();
|
||||
if (substr($newversion, 0, 4) != substr($currvers, 0, 4) && $newversion != '') {
|
||||
if(($getversion = $mysqlcon->query("SELECT newversion FROM $dbname.config")) === false) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 1:".print_r($mysqlcon->errorInfo()));
|
||||
$sqlmsg .= print_r($mysqlcon->errorInfo());
|
||||
$sqlerr++;
|
||||
}
|
||||
$getversion = $getversion->fetchAll();
|
||||
$newversion = $getversion[0];
|
||||
if(version_compare(substr($newversion, 0, 5), substr($currvers, 0, 5), '>') && $newversion != '') {
|
||||
enter_logfile($logpath,$timezone,4,$lang['upinf']);
|
||||
foreach ($uniqueid as $clientid) {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
try {
|
||||
$ts3->clientGetByUid($clientid)->message(sprintf($lang['upmsg'], $currvers, $newversion));
|
||||
enter_logfile($logpath,$timezone,5," ".sprintf($lang['upusrinf'], $clientid));
|
||||
enter_logfile($logpath,$timezone,4," ".sprintf($lang['upusrinf'], $clientid));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2," ".sprintf($lang['upusrerr'], $clientid));
|
||||
enter_logfile($logpath,$timezone,4," ".sprintf($lang['upusrerr'], $clientid));
|
||||
$sqlmsg .= $e->getCode() . ': ' . $e->getMessage();
|
||||
$sqlerr++;
|
||||
}
|
||||
@@ -80,7 +109,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$show
|
||||
}
|
||||
unset($uuids);
|
||||
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$yetonline[] = '';
|
||||
$insertdata = '';
|
||||
if(empty($grouptime)) {
|
||||
@@ -103,8 +132,12 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$show
|
||||
$nation=$client['client_country'];
|
||||
$version=$client['client_version'];
|
||||
$firstconnect=$client['client_created'];
|
||||
$channel=$client['cid'];
|
||||
if (!in_array($uid, $yetonline) && $client['client_version'] != "ServerQuery") {
|
||||
$clientidle = floor($client['client_idle_time'] / 1000);
|
||||
if(isset($ignoreidle) && $clientidle < $ignoreidle) {
|
||||
$clientidle = 0;
|
||||
}
|
||||
$yetonline[] = $uid;
|
||||
if(in_array($uid, $exceptuuid) || array_intersect($sgroups, $exceptgroup)) {
|
||||
$except = 1;
|
||||
@@ -130,7 +163,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$show
|
||||
$boosttime = $nowtime;
|
||||
} else {
|
||||
if ($nowtime > $sqlhis[$uid]['boosttime'] + $boost['time']) {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($boost['group'], $cldbid);
|
||||
$boosttime = 0;
|
||||
@@ -173,10 +206,14 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$show
|
||||
$grpcount=0;
|
||||
foreach ($grouptime as $time => $groupid) {
|
||||
$grpcount++;
|
||||
if ($activetime > $time && !in_array($uid, $exceptuuid) && !array_intersect($sgroups, $exceptgroup)) {
|
||||
if(in_array($channel, $exceptcid)) {
|
||||
$count = $sqlhis[$uid]['count'];
|
||||
$idle = $sqlhis[$uid]['idle'];
|
||||
$except = 1;
|
||||
} elseif ($activetime > $time && !in_array($uid, $exceptuuid) && !array_intersect($sgroups, $exceptgroup)) {
|
||||
if ($sqlhis[$uid]['grpid'] != $groupid) {
|
||||
if ($sqlhis[$uid]['grpid'] != 0 && in_array($sqlhis[$uid]['grpid'], $sgroups)) {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientDel($sqlhis[$uid]['grpid'], $cldbid);
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrprm'], $sqlhis[$uid]['grpid'], $name, $uid, $cldbid));
|
||||
@@ -188,7 +225,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$show
|
||||
}
|
||||
}
|
||||
if (!in_array($groupid, $sgroups)) {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
try {
|
||||
$ts3->serverGroupClientAdd($groupid, $cldbid);
|
||||
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrpadd'], $groupid, $name, $uid, $cldbid));
|
||||
@@ -206,22 +243,12 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$show
|
||||
$hours = $dtF->diff($dtT)->format('%h');
|
||||
$mins = $dtF->diff($dtT)->format('%i');
|
||||
$secs = $dtF->diff($dtT)->format('%s');
|
||||
if ($substridle == 1) {
|
||||
try {
|
||||
$ts3->clientGetByUid($uid)->message(sprintf($lang['usermsgactive'], $days, $hours, $mins, $secs));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 11:".sprintf($lang['sgrprerr'], $name, $uid, $cldbid));
|
||||
$sqlmsg .= $e->getCode() . ': ' . $e->getMessage();
|
||||
$sqlerr++;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$ts3->clientGetByUid($uid)->message(sprintf($lang['usermsgonline'], $days, $hours, $mins, $secs));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 12:".sprintf($lang['sgrprerr'], $name, $uid, $cldbid));
|
||||
$sqlmsg .= $e->getCode() . ': ' . $e->getMessage();
|
||||
$sqlerr++;
|
||||
}
|
||||
try {
|
||||
$ts3->clientGetByUid($uid)->message(sprintf($rankupmsg, $days, $hours, $mins, $secs));
|
||||
} catch (Exception $e) {
|
||||
enter_logfile($logpath,$timezone,2,"calc_user 12:".sprintf($lang['sgrprerr'], $name, $uid, $cldbid));
|
||||
$sqlmsg .= $e->getCode() . ': ' . $e->getMessage();
|
||||
$sqlerr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,
|
||||
$count_month = 0;
|
||||
$idle_month = 0;
|
||||
}
|
||||
$clientdesc = str_replace('\\', '\\\\', htmlspecialchars($clientinfo['client_description'], ENT_QUOTES));
|
||||
$clientdesc = $mysqlcon->quote($clientinfo['client_description'], ENT_QUOTES);;
|
||||
if(isset($uidarrstats[$userstats['uuid']])) {
|
||||
$allupdateuuid = $allupdateuuid . "'" . $userstats['uuid'] . "',";
|
||||
$allupdaterank = $allupdaterank . "WHEN '" . $userstats['uuid'] . "' THEN '" . $userstats['rank'] . "' ";
|
||||
@@ -129,9 +129,9 @@ function calc_userstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,
|
||||
$allupdatebase64 = $allupdatebase64 . "WHEN '" . $userstats['uuid'] . "' THEN '" . $clientinfo['client_base64HashClientUID'] . "' ";
|
||||
$allupdatecldtup = $allupdatecldtup . "WHEN '" . $userstats['uuid'] . "' THEN '" . $clientinfo['client_total_bytes_uploaded'] . "' ";
|
||||
$allupdatecldtdo = $allupdatecldtdo . "WHEN '" . $userstats['uuid'] . "' THEN '" . $clientinfo['client_total_bytes_downloaded'] . "' ";
|
||||
$allupdateclddes = $allupdateclddes . "WHEN '" . $userstats['uuid'] . "' THEN '" . $clientdesc . "' ";
|
||||
$allupdateclddes = $allupdateclddes . "WHEN '" . $userstats['uuid'] . "' THEN " . $clientdesc . " ";
|
||||
} else {
|
||||
$allinsertuserstats = $allinsertuserstats . "('" . $userstats['uuid'] . "', '" .$userstats['rank'] . "', '" . $count_week . "', '" . $count_month . "', '" . $idle_week . "', '" . $idle_month . "', '" . $clientinfo['client_totalconnections'] . "', '" . $clientinfo['client_base64HashClientUID'] . "', '" . $clientinfo['client_total_bytes_uploaded'] . "', '" . $clientinfo['client_total_bytes_downloaded'] . "', '" . $clientdesc . "'),";
|
||||
$allinsertuserstats = $allinsertuserstats . "('" . $userstats['uuid'] . "', '" .$userstats['rank'] . "', '" . $count_week . "', '" . $count_month . "', '" . $idle_week . "', '" . $idle_month . "', '" . $clientinfo['client_totalconnections'] . "', '" . $clientinfo['client_base64HashClientUID'] . "', '" . $clientinfo['client_total_bytes_uploaded'] . "', '" . $clientinfo['client_total_bytes_downloaded'] . "', " . $clientdesc . "),";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
//error would be, when client is missing in ts db
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
$newversion = '1.0.2-dev';
|
||||
$newversion = '1.1.0';
|
||||
enter_logfile($logpath,$timezone,5,"Check Ranksystem database for updates.");
|
||||
|
||||
function set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath) {
|
||||
@@ -10,20 +10,20 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
exit;
|
||||
} else {
|
||||
$currvers = $newversion;
|
||||
enter_logfile($logpath,$timezone,5," Database successfully updated!");
|
||||
enter_logfile($logpath,$timezone,4," Database successfully updated!");
|
||||
return $currvers;
|
||||
}
|
||||
}
|
||||
|
||||
function check_chmod($timezone) {
|
||||
if (substr(sprintf('%o', fileperms(substr(__DIR__,0,-4).'icons/')), -4)!='0777') {
|
||||
enter_logfile($logpath,$timezone,2,"Write Permissions failed on folder \"icons\". Please give them a chmod 777 and try to start the Ranksystem again.");
|
||||
enter_logfile($logpath,$timezone,2,sprintf($lang['isntwichm'],'icons'));
|
||||
}
|
||||
if (substr(sprintf('%o', fileperms(substr(__DIR__,0,-4).'logs/')), -4)!='0777') {
|
||||
enter_logfile($logpath,$timezone,2,"Write Permissions failed on folder \"logs\". Please give them a chmod 777 and try to start the Ranksystem again.");
|
||||
enter_logfile($logpath,$timezone,2,sprintf($lang['isntwichm'],'logs'));
|
||||
}
|
||||
if (substr(sprintf('%o', fileperms(substr(__DIR__,0,-4).'avatars/')), -4)!='0777') {
|
||||
enter_logfile($logpath,$timezone,2,"Write Permissions failed on folder \"avatars\". Please give them a chmod 777 and try to start the Ranksystem again.");
|
||||
enter_logfile($logpath,$timezone,2,sprintf($lang['isntwichm'],'avatars'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,31 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: jquerylib/thickbox-compressed.js");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'other/webinterface_list.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'other/webinterface_list.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: other/webinterface_list.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'other/webinterface_login.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'other/webinterface_login.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: other/webinterface_login.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'webinterface.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'webinterface.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: webinterface.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'other/style.css.php')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'other/style.css.php')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: other/style.css.php");
|
||||
}
|
||||
}
|
||||
if(is_file(substr(__DIR__,0,-4).'bootstrap/js/_bootstrap.js')) {
|
||||
if(!unlink(substr(__DIR__,0,-4).'bootstrap/js/_bootstrap.js')) {
|
||||
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: bootstrap/js/_bootstrap.js");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($currvers==$newversion) {
|
||||
@@ -95,7 +120,7 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
old_files($timezone);
|
||||
check_chmod($timezone);
|
||||
} elseif($currvers=="0.13-beta") {
|
||||
enter_logfile($logpath,$timezone,5," Update the Ranksystem Database to version 1.01.");
|
||||
enter_logfile($logpath,$timezone,4," Update the Ranksystem Database to version 1.0.1");
|
||||
|
||||
$errcount=1;
|
||||
|
||||
@@ -230,6 +255,26 @@ function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
|
||||
}
|
||||
} else {
|
||||
if($mysqlcon->exec("CREATE INDEX serverusage_timestamp ON $dbname.server_usage (timestamp)") === false) { }
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (advancemode int(1) NOT NULL default '0', count_access int(2) NOT NULL default '0', last_access bigint(11) NOT NULL default '0', ignoreidle bigint(11) NOT NULL default '0', exceptcid text CHARACTER SET utf8 COLLATE utf8_unicode_ci, rankupmsg text CHARACTER SET utf8 COLLATE utf8_unicode_ci, boost_mode int(1) NOT NULL default '0', newversion varchar(25) CHARACTER SET utf8 COLLATE utf8_unicode_ci)") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," Adjusted table config successfully.");
|
||||
}
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set ignoreidle='600', rankupmsg='\\nHey, you got a rank up, cause you reached an activity of %s days, %s hours, %s minutes and %s seconds.', newversion='1.1.0'") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," Set default values to new fields in table config.");
|
||||
}
|
||||
if($mysqlcon->exec("INSERT INTO $dbname.job_check (job_name) VALUES ('get_version')") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," Set new values to table job_check.");
|
||||
}
|
||||
if(($password = $mysqlcon->query("SELECT webpass FROM $dbname.config")) === false) { }
|
||||
$password = $password->fetchAll();
|
||||
if(strlen($password[0]['webpass']) != 60) {
|
||||
$newwebpass = password_hash($password[0]['webpass'], PASSWORD_DEFAULT);
|
||||
if($mysqlcon->exec("UPDATE $dbname.config set webpass='$newwebpass'") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," Encrypted password for the webinterface and wrote hash to database.");
|
||||
}
|
||||
}
|
||||
if($mysqlcon->exec("ALTER TABLE $dbname.config DROP COLUMN showexgrp, DROP COLUMN showgen, DROP COLUMN bgcolor, DROP COLUMN hdcolor, DROP COLUMN txcolor, DROP COLUMN hvcolor, DROP COLUMN ifcolor, DROP COLUMN wncolor, DROP COLUMN sccolor") === false) { } else {
|
||||
enter_logfile($logpath,$timezone,4," Delete old configs, which are no more needed.");
|
||||
}
|
||||
$currvers = set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath);
|
||||
old_files($timezone);
|
||||
check_chmod($timezone);
|
||||
|
||||
@@ -37,7 +37,7 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$cleancli
|
||||
$countrs = $dbuserdata->rowCount();
|
||||
$uuids = $dbuserdata->fetchAll();
|
||||
if ($lastclean[0]['timestamp'] < $cleantime) {
|
||||
enter_logfile($logpath,$timezone,5,$lang['clean']);
|
||||
enter_logfile($logpath,$timezone,4,$lang['clean']);
|
||||
$start=0;
|
||||
$break=200;
|
||||
$clientdblist=array();
|
||||
@@ -50,7 +50,7 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$cleancli
|
||||
if ($start == 100000 || $count_tsuser['count'] <= $start) {
|
||||
break;
|
||||
}
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
}
|
||||
foreach($clientdblist as $uuidts) {
|
||||
$single_uuid = $uuidts['client_unique_identifier']->toString();
|
||||
@@ -68,8 +68,8 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$cleancli
|
||||
}
|
||||
|
||||
unset($uidarrts);
|
||||
enter_logfile($logpath,$timezone,5," ".sprintf($lang['cleants'], $countts, $count_tsuser['count']));
|
||||
enter_logfile($logpath,$timezone,5," ".sprintf($lang['cleanrs'], $countrs));
|
||||
enter_logfile($logpath,$timezone,4," ".sprintf($lang['cleants'], $countts, $count_tsuser['count']));
|
||||
enter_logfile($logpath,$timezone,4," ".sprintf($lang['cleanrs'], $countrs));
|
||||
|
||||
if(isset($deleteuuids)) {
|
||||
$alldeldata = '';
|
||||
@@ -84,7 +84,7 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$cleancli
|
||||
$sqlmsg .= print_r($mysqlcon->errorInfo());
|
||||
$sqlerr++;
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,5," ".sprintf($lang['cleandel'], $countdel));
|
||||
enter_logfile($logpath,$timezone,4," ".sprintf($lang['cleandel'], $countdel));
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='check_clean'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"clean 6:".print_r($mysqlcon->errorInfo()));
|
||||
$sqlmsg .= print_r($mysqlcon->errorInfo());
|
||||
@@ -93,7 +93,7 @@ function clean($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$cleancli
|
||||
}
|
||||
}
|
||||
} else {
|
||||
enter_logfile($logpath,$timezone,2," ".$lang['cleanno']);
|
||||
enter_logfile($logpath,$timezone,4," ".$lang['cleanno']);
|
||||
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='$nowtime' WHERE job_name='check_clean'") === false) {
|
||||
enter_logfile($logpath,$timezone,2,"clean 7:".print_r($mysqlcon->errorInfo()));
|
||||
$sqlmsg .= print_r($mysqlcon->errorInfo());
|
||||
|
||||
@@ -6,7 +6,7 @@ function get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$lo
|
||||
$count = 0;
|
||||
|
||||
try {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$tsfilelist = $ts3->channelFileList($cid="0", $cpw="", $path="/");
|
||||
} catch (Exception $e) {
|
||||
if ($e->getCode() != 1281) {
|
||||
@@ -29,7 +29,7 @@ function get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$lo
|
||||
if (!isset($fsfilelistarray[$uuidasbase16.'.png']) || $tsfile['datetime']>$fsfilelistarray[$uuidasbase16.'.png']) {
|
||||
if (substr($tsfile['name'],0,7) == 'avatar_') {
|
||||
try {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$avatar = $ts3->transferInitDownload($clientftfid="5",$cid="0",$name=$fullfilename,$cpw="", $seekpos=0);
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . $avatar["host"] . ":" . $avatar["port"]);
|
||||
$tsfile = $transfer->download($avatar["ftkey"], $avatar["size"]);
|
||||
|
||||
@@ -5,7 +5,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$
|
||||
$sqlerr = 0;
|
||||
|
||||
try {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$iconlist = $ts3->channelFileList($cid="0", $cpw="", $path="/icons/");
|
||||
} catch (Exception $e) {
|
||||
if ($e->getCode() != 1281) {
|
||||
@@ -21,7 +21,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$
|
||||
}
|
||||
|
||||
try {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
$ts3->serverGroupListReset();
|
||||
$ts3groups = $ts3->serverGroupList();
|
||||
} catch (Exception $e) {
|
||||
@@ -56,7 +56,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$
|
||||
if (!isset($sqlhisgroup['0']) || $sqlhisgroup['0']['iconid'] != $sIconId || $iconarr["i".$sIconId] > $sqlhisgroup['0']['icondate']) {
|
||||
if($sIconId > 600) {
|
||||
try {
|
||||
check_shutdown($timezone); usleep($slowmode);
|
||||
check_shutdown($timezone,$logpath); usleep($slowmode);
|
||||
enter_logfile($logpath,$timezone,5,"Download new ServerIcon");
|
||||
$sIconFile = $ts3->iconDownload();
|
||||
if(file_put_contents(substr(dirname(__FILE__),0,-4) . "icons/servericon.png", $sIconFile) === false) {
|
||||
@@ -71,7 +71,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$
|
||||
if (!isset($sqlhisgroup['0'])) {
|
||||
$insertgroups[] = array(
|
||||
"sgid" => "0",
|
||||
"sgidname" => "ServerIcon",
|
||||
"sgidname" => $mysqlcon->quote("ServerIcon", ENT_QUOTES),
|
||||
"iconid" => $sIconId,
|
||||
"icon" => $sIconFile,
|
||||
"icondate" => $iconarr["i".$sIconId]
|
||||
@@ -79,7 +79,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$
|
||||
} else {
|
||||
$updategroups[] = array(
|
||||
"sgid" => "0",
|
||||
"sgidname" => "ServerIcon",
|
||||
"sgidname" => $mysqlcon->quote("ServerIcon", ENT_QUOTES),
|
||||
"iconid" => $sIconId,
|
||||
"icon" => $sIconFile,
|
||||
"icondate" => $iconarr["i".$sIconId]
|
||||
@@ -91,7 +91,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$
|
||||
foreach ($ts3groups as $servergroup) {
|
||||
$tsgroupids[] = $servergroup['sgid'];
|
||||
$sgid = $servergroup['sgid'];
|
||||
$sgname = str_replace('\\', '\\\\', htmlspecialchars($servergroup['name'], ENT_QUOTES));
|
||||
$sgname = $mysqlcon->quote($servergroup['name'], ENT_QUOTES);
|
||||
$gefunden = 2;
|
||||
$iconid = $servergroup['iconid'];
|
||||
$iconid = ($iconid < 0) ? (pow(2, 32)) - ($iconid * -1) : $iconid;
|
||||
@@ -148,7 +148,11 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$
|
||||
if (isset($insertgroups)) {
|
||||
$allinsertdata = '';
|
||||
foreach ($insertgroups as $insertarr) {
|
||||
$allinsertdata = $allinsertdata . "('" . $insertarr['sgid'] . "', '" . $insertarr['sgidname'] . "', '" . $insertarr['iconid'] . "', '" . $insertarr['icondate'] . "'),";
|
||||
if( $insertarr['iconid'] == 0) {
|
||||
//enter_logfile($logpath,$timezone,6,"IconID is 0 for (servergroup) ".$insertarr['sgidname']." (".$insertarr['sgid'].")");
|
||||
continue;
|
||||
}
|
||||
$allinsertdata = $allinsertdata . "('" . $insertarr['sgid'] . "', " . $insertarr['sgidname'] . ", '" . $insertarr['iconid'] . "', '" . $insertarr['icondate'] . "'),";
|
||||
}
|
||||
$allinsertdata = substr($allinsertdata, 0, -1);
|
||||
if ($allinsertdata != '') {
|
||||
@@ -167,7 +171,7 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$jobid,$timezone,$
|
||||
$allupdatedate = '';
|
||||
foreach ($updategroups as $updatedata) {
|
||||
$allsgids = $allsgids . "'" . $updatedata['sgid'] . "',";
|
||||
$allupdatesgid = $allupdatesgid . "WHEN '" . $updatedata['sgid'] . "' THEN '" . $updatedata['sgidname'] . "' ";
|
||||
$allupdatesgid = $allupdatesgid . "WHEN '" . $updatedata['sgid'] . "' THEN " . $updatedata['sgidname'] . " ";
|
||||
$allupdateiconid = $allupdateiconid . "WHEN '" . $updatedata['sgid'] . "' THEN '" . $updatedata['iconid'] . "' ";
|
||||
$allupdatedate = $allupdatedate . "WHEN '" . $updatedata['sgid'] . "' THEN '" . $updatedata['icondate'] . "' ";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user