Skip to content

Commit

Permalink
release 1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Newcomer1989 committed Dec 24, 2017
1 parent 4522009 commit c7fb367
Show file tree
Hide file tree
Showing 39 changed files with 1,653 additions and 655 deletions.
83 changes: 53 additions & 30 deletions install.php

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions jobs/calc_serverstats.php
Expand Up @@ -111,10 +111,12 @@ function calc_serverstats($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serv
arsort($country_array);
$country_counter = 0;
$country_nation_other = 0;
$country_nation_name_1 = 0;
$country_nation_name_2 = 0;
$country_nation_name_3 = 0;
$country_nation_name_4 = 0;
$country_nation_name_5 = 0;
$country_nation_1 = 0;
$country_nation_2 = 0;
$country_nation_3 = 0;
$country_nation_4 = 0;
Expand Down
20 changes: 15 additions & 5 deletions jobs/calc_user.php
Expand Up @@ -8,7 +8,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
$getversion = $getversion->fetchAll();
$updatetime = $nowtime - 43200;
if ($getversion[0]['timestamp'] < $updatetime) {
$newversion=get_data('http://ts-n.net/ranksystem/'.$upchannel,$currvers,$ts);
$newversion=get_data('https://ts-n.net/ranksystem/'.$upchannel,$currvers,$ts);
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(), true));
}
Expand Down Expand Up @@ -101,6 +101,16 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
krsort($grouptime);
$sumentries = 0;
$nextupforinsert = key($grouptime) - 1;

if(!isset($dbgroups)) {
if(($dbgroups = $mysqlcon->query("SELECT sgid,sgidname FROM $dbname.groups")) === false) {
enter_logfile($logpath,$timezone,2,"calc_user 8.1:".print_r($mysqlcon->errorInfo(), true));
} else {
$dbgroups = $dbgroups->fetchAll(PDO::FETCH_ASSOC);
}
}

print_r($dbgroups);

foreach ($allclients as $client) {
$sumentries++;
Expand Down Expand Up @@ -164,7 +174,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
try {
$ts3->serverGroupClientDel($boost['group'], $cldbid);
$boosttime = 0;
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrprm'], $sqlhis[$uid]['grpid'], $name, $uid, $cldbid));
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrprm'], $dbgroups[$sqlhis[$uid]['grpid']]['sgidname'], $sqlhis[$uid]['grpid'], $name, $uid, $cldbid));
}
catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"calc_user 8:".sprintf($lang['sgrprerr'], $name, $uid, $cldbid));
Expand Down Expand Up @@ -213,7 +223,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
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));
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrprm'], $dbgroups[$sqlhis[$uid]['grpid']]['sgidname'], $sqlhis[$uid]['grpid'], $name, $uid, $cldbid));
}
catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"calc_user 9:".sprintf($lang['sgrprerr'], $name, $uid, $cldbid));
Expand All @@ -224,7 +234,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
try {
$ts3->serverGroupClientAdd($groupid, $cldbid);
$grpsince = $nowtime;
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrpadd'], $groupid, $name, $uid, $cldbid));
enter_logfile($logpath,$timezone,5,sprintf($lang['sgrpadd'], $dbgroups[$groupid]['sgidname'], $groupid, $name, $uid, $cldbid));
}
catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"calc_user 10:".sprintf($lang['sgrprerr'], $name, $uid, $cldbid));
Expand All @@ -238,7 +248,7 @@ function calc_user($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$update,$gro
$mins = $dtF->diff($dtT)->format('%i');
$secs = $dtF->diff($dtT)->format('%s');
try {
$ts3->clientGetByUid($uid)->message(sprintf($rankupmsg, $days, $hours, $mins, $secs));
$ts3->clientGetByUid($uid)->message(sprintf($rankupmsg, $days, $hours, $mins, $secs, $dbgroups[$groupid]['sgidname'], $client['client_nickname']));
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"calc_user 12:".sprintf($lang['sgrprerr'], $name, $uid, $cldbid));
}
Expand Down
38 changes: 34 additions & 4 deletions jobs/check_db.php
@@ -1,6 +1,6 @@
<?PHP
function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
$newversion = '1.2.2';
$newversion = '1.2.3';
enter_logfile($logpath,$timezone,5,"Check Ranksystem database for updates.");

function set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath) {
Expand All @@ -16,8 +16,8 @@ function set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath) {
}

function check_chmod($timezone,$logpath,$lang) {
if(substr(sprintf('%o', fileperms(substr(__DIR__,0,-4).'icons/')), -3, 1)!='7') {
enter_logfile($logpath,$timezone,2,sprintf($lang['isntwichm'],'icons'));
if(substr(sprintf('%o', fileperms(substr(__DIR__,0,-4).'tsicons/')), -3, 1)!='7') {
enter_logfile($logpath,$timezone,2,sprintf($lang['isntwichm'],'tsicons'));
}
if(substr(sprintf('%o', fileperms($logpath)), -3, 1)!='7') {
enter_logfile($logpath,$timezone,2,sprintf($lang['isntwichm'],'logs'));
Expand Down Expand Up @@ -98,7 +98,7 @@ function old_files($timezone,$logpath) {
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: other/style.css.php");
}
}
if(is_file(substr(__DIR__,0,-4).'other/search.php')) {
if(is_file(substr(__DIR__,0,-4).'other/search.php')) {
if(!unlink(substr(__DIR__,0,-4).'other/search.php')) {
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: other/search.php");
}
Expand All @@ -108,6 +108,21 @@ function old_files($timezone,$logpath) {
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: server-news");
}
}
if(is_dir(substr(__DIR__,0,-4).'icons/')) {
if(!rmdir(substr(__DIR__,0,-4).'icons/')) {
enter_logfile($logpath,$timezone,4,"Unnecessary folder, please delete it from your webserver: icons/");
}
}
if(is_file(substr(__DIR__,0,-4).'libs/combined_stats.css')) {
if(!unlink(substr(__DIR__,0,-4).'libs/combined_stats.css')) {
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: libs/combined_stats.css");
}
}
if(is_file(substr(__DIR__,0,-4).'libs/combined_stats.js')) {
if(!unlink(substr(__DIR__,0,-4).'libs/combined_stats.js')) {
enter_logfile($logpath,$timezone,4,"Unnecessary file, please delete it from your webserver: libs/combined_stats.js");
}
}
}

function check_writable($timezone,$logpath) {
Expand Down Expand Up @@ -421,6 +436,21 @@ function check_writable($timezone,$logpath) {
enter_logfile($logpath,$timezone,4," [1.2.2] Created table addon_assign_groups successfully.");
}
}
if(version_compare($currvers, '1.2.2', '<=')) {
if($mysqlcon->exec("DELETE FROM $dbname.groups") === false) { } else {
enter_logfile($logpath,$timezone,4," [1.2.3] Cleaned table groups successfully. (cause new icon folder tsicons - redownload)");
}
if($mysqlcon->exec("ALTER TABLE $dbname.config MODIFY COLUMN tsvoice smallint(5) UNSIGNED NOT NULL default '0'") === false) { } else {
enter_logfile($logpath,$timezone,4," [1.2.3] Adjusted table config successfully.");
}
if($mysqlcon->exec("CREATE INDEX snapshot_timestamp ON $dbname.user_snapshot (timestamp)") === false) { } else {
enter_logfile($logpath,$timezone,4," [1.2.3] Recreated index on table user_snapshot successfully.");
}

if($mysqlcon->exec("CREATE INDEX serverusage_timestamp ON $dbname.server_usage (timestamp)") === false) { } else {
enter_logfile($logpath,$timezone,4," [1.2.3] Recreated index on table server_usage successfully.");
}
}
$currvers = set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath);
old_files($timezone,$logpath);
check_chmod($timezone,$logpath,$lang);
Expand Down
3 changes: 0 additions & 3 deletions jobs/get_avatars.php
@@ -1,7 +1,5 @@
<?PHP
function get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath,$avatar_delay) {
$count = 0;

try {
check_shutdown($timezone,$logpath); usleep($slowmode);
$tsfilelist = $ts3->channelFileList($cid="0", $cpw="", $path="/");
Expand Down Expand Up @@ -33,7 +31,6 @@ function get_avatars($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$logpath,$
if(file_put_contents($avatarfilepath, $tsfile) === false) {
enter_logfile($logpath,$timezone,2,"Error while writing out the avatar. Please check the permission for the folder 'avatars'");
}
$count++;
}
catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"get_avatars 2:".$e->getCode().': '."Error while downloading avatar: ".$e->getMessage());
Expand Down
39 changes: 28 additions & 11 deletions jobs/handle_messages.php
Expand Up @@ -5,9 +5,9 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
$uuid = $event["invokeruid"];


if(strstr($event["msg"], 'nextup') && $nextupinfo != 0) {
if((strstr($event["msg"], '!nextup') || strstr($event["msg"], '!next')) && $nextupinfo != 0) {
//enter_logfile($logpath,$timezone,6,"Client ".$event["invokername"]." (".$event["invokeruid"].") sent textmessage: ".$event["msg"]);
if(($dbuserdata = $mysqlcon->query("SELECT count,nextup,idle,except FROM $dbname.user WHERE uuid='$uuid'")) === false) {
if(($dbuserdata = $mysqlcon->query("SELECT count,nextup,idle,except,name FROM $dbname.user WHERE uuid='$uuid'")) === false) {
enter_logfile($logpath,$timezone,2,"handle_messages 1:".print_r($mysqlcon->errorInfo(), true));
}
$user = $dbuserdata->fetchAll(PDO::FETCH_ASSOC);
Expand Down Expand Up @@ -35,24 +35,25 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
$hours = $dtF->diff($dtT)->format('%h');
$mins = $dtF->diff($dtT)->format('%i');
$secs = $dtF->diff($dtT)->format('%s');
$name = $user[0]['name'];
$grpcount++;
if ($nextup > 0 && $nextup < $time || $grpcount == $countgrp && $nextup <= 0) {
check_shutdown($timezone,$logpath); usleep($slowmode);
if ($grpcount == $countgrp && $nextup <= 0) {
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg2, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid]));
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg2, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid], $name));
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"handle_messages 3:".$e->getCode().': '.$e->getMessage());
}
} elseif ($user[0]['except'] == 2 || $user[0]['except'] == 3) {
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg3, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid]));
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg3, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid], $name));
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"handle_messages 4:".$e->getCode().': '.$e->getMessage());
}
} else {
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg1, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid]));
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg1, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid], $name));
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"handle_messages 5:".$e->getCode().': '.$e->getMessage());
}
Expand All @@ -64,7 +65,7 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
}
}

if(strstr($event["msg"], 'version')) {
if(strstr($event["msg"], '!version')) {
if(version_compare(substr($newversion, 0, 5), substr($currvers, 0, 5), '>') && $newversion != '') {
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($lang['upmsg'], $currvers, $newversion));
Expand All @@ -80,15 +81,15 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
}
}

if(strstr($event["msg"], 'help') || strstr($event["msg"], 'info') || strstr($event["msg"], 'commands')) {
if(strstr($event["msg"], '!help') || strstr($event["msg"], '!info') || strstr($event["msg"], '!commands')) {
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0002']);
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"handle_messages 8:".$e->getCode().': '.$e->getMessage());
}
}

if((strstr($event["msg"], 'shutdown') || strstr($event["msg"], 'quit') || strstr($event["msg"], 'stop')) && $event["invokeruid"] == $adminuuid) {
if((strstr($event["msg"], '!shutdown') || strstr($event["msg"], '!quit') || strstr($event["msg"], '!stop')) && $event["invokeruid"] == $adminuuid) {
enter_logfile($logpath,$timezone,5,sprintf($lang['msg0004'], $event["invokername"], $event["invokeruid"]));
$path = substr(__DIR__, 0, -4);
try {
Expand All @@ -97,15 +98,15 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
enter_logfile($logpath,$timezone,2,"handle_messages 9:".$e->getCode().': '.$e->getMessage());
}
exec($phpcommand." ".$path."worker.php stop");
} elseif (strstr($event["msg"], 'shutdown') || strstr($event["msg"], 'exit')) {
} elseif (strstr($event["msg"], '!shutdown') || strstr($event["msg"], '!quit') || strstr($event["msg"], '!stop')) {
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0003']);
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"handle_messages 10:".$e->getCode().': '.$e->getMessage());
}
}

if((strstr($event["msg"], 'restart') || strstr($event["msg"], 'reboot')) && $event["invokeruid"] == $adminuuid) {
if((strstr($event["msg"], '!restart') || strstr($event["msg"], '!reboot')) && $event["invokeruid"] == $adminuuid) {
enter_logfile($logpath,$timezone,5,sprintf($lang['msg0007'], $event["invokername"], $event["invokeruid"]));
$path = substr(__DIR__, 0, -4);
try {
Expand All @@ -118,14 +119,30 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
} else {
exec($phpcommand." ".$path."worker.php restart > /dev/null 2>/dev/null &");
}
} elseif (strstr($event["msg"], 'shutdown') || strstr($event["msg"], 'exit')) {
} elseif (strstr($event["msg"], '!restart') || strstr($event["msg"], '!reboot')) {
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0003']);
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"handle_messages 12:".$e->getCode().': '.$e->getMessage());
}
}

if((strstr($event["msg"], '!checkupdate') || strstr($event["msg"], '!update')) && $event["invokeruid"] == $adminuuid) {
if($mysqlcon->exec("UPDATE $dbname.job_check SET timestamp='0' WHERE job_name IN ('check_update','get_version')") === false) {
enter_logfile($logpath,$timezone,4,"handle_messages 13:".print_r($mysqlcon->errorInfo(), true));
}
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0008']);
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"handle_messages 14:".$e->getCode().': '.$e->getMessage());
}
} elseif (strstr($event["msg"], '!checkupdate') || strstr($event["msg"], '!update')) {
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message($lang['msg0003']);
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"handle_messages 15:".$e->getCode().': '.$e->getMessage());
}
}
}
}
?>
8 changes: 4 additions & 4 deletions jobs/update_groups.php
Expand Up @@ -50,8 +50,8 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serveri
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) {
enter_logfile($logpath,$timezone,2,"Error while writing out the servericon. Please check the permission for the folder 'icons'");
if(file_put_contents(substr(dirname(__FILE__),0,-4) . "tsicons/servericon.png", $sIconFile) === false) {
enter_logfile($logpath,$timezone,2,"Error while writing out the servericon. Please check the permission for the folder 'tsicons'");
}
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"update_groups 4:".$e->getCode().': '."Error while downloading servericon: ".$e->getMessage());
Expand Down Expand Up @@ -95,8 +95,8 @@ function update_groups($ts3,$mysqlcon,$lang,$dbname,$slowmode,$timezone,$serveri
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"update_groups 5:".$e->getCode().': '."Error while downloading servergroupicon: ".$e->getMessage());
}
if(file_put_contents(substr(dirname(__FILE__),0,-4) . "icons/" . $sgid . ".png", $iconfile) === false) {
enter_logfile($logpath,$timezone,2,"Error while writing out the servergroup icon. Please check the permission for the folder 'icons'");
if(file_put_contents(substr(dirname(__FILE__),0,-4) . "tsicons/" . $sgid . ".png", $iconfile) === false) {
enter_logfile($logpath,$timezone,2,"Error while writing out the servergroup icon. Please check the permission for the folder 'tsicons'");
}
} catch (Exception $e) {
enter_logfile($logpath,$timezone,2,"update_groups 6:".$e->getCode().': '."Error while downloading servergroup icon: ".$e->getMessage());
Expand Down
10 changes: 2 additions & 8 deletions jobs/update_rs.php
Expand Up @@ -117,16 +117,10 @@ function update_rs($mysqlcon,$lang,$dbname,$logpath,$timezone,$newversion,$phpco

if (substr(php_uname(), 0, 7) == "Windows") {
exec("start ".$phpcommand." ".$path."worker.php restart");
exit;
} else {
exec($phpcommand." ".$path."worker.php restart > /dev/null 2>/dev/null &");
}

if (substr(php_uname(), 0, 7) == "Windows") {
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("cmd /C php ".substr(__DIR__,0,-4)."\worker.php stop", 0, false);
} else {
exec("php ".substr(__DIR__,0,-5)."/worker.php stop");
check_shutdown($timezone,$logpath);
exit;
}
} else {
enter_logfile($logpath,$timezone,1," Files updated with at least one error. Please check the log!\n",$norotate);
Expand Down
2 changes: 1 addition & 1 deletion languages/add_new_language.php
@@ -1,5 +1,5 @@
<?PHP
echo 'Take the actual languale file like "core_en"<br>';
echo 'Take the actual language file like "core_en"<br>';
echo 'Translate the textes to the wished language<br>';
echo 'Send the translated file to admin@ts-n.net<br>';
echo 'We will implement it with the next release<br>';
Expand Down

1 comment on commit c7fb367

@rlnt
Copy link

@rlnt rlnt commented on c7fb367 Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to see that you are back Newcomer. <3

Please sign in to comment.