Skip to content

Commit

Permalink
release 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 2, 2016
1 parent 5620db4 commit 114633a
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 82 deletions.
17 changes: 10 additions & 7 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
$nextupinfomsg3 = $mysqlcon->quote("You are excepted from the Ranksystem. If you wish to rank contact an admin on the TS3 server.");
$servernews = $mysqlcon->quote("<strong>Message</strong><br>This is an example Message.<br>Change this Message inside the webinterface.");
$rankupmsg = $mysqlcon->quote('Hey, you reached a higher rank, since you already connected for %1$s days, %2$s hours and %3$s minutes to our TS3 server.[B]Keep it up![/B] ;-) ');
if($mysqlcon->exec("INSERT INTO $dbname.config (webuser,webpass,tshost,tsquery,tsvoice,tsuser,language,queryname,queryname2,grouptime,resetbydbchange,msgtouser,upcheck,uniqueid,updateinfotime,currvers,exceptuuid,exceptgroup,dateformat,showexcld,showcolcld,showcoluuid,showcoldbid,showcolot,showcolit,showcolat,showcolnx,showcolsg,showcolrg,showcolls,slowmode,cleanclients,cleanperiod,showhighest,showcolas,defchid,timezone,logpath,ignoreidle,rankupmsg,newversion,servernews,nextupinfo,nextupinfomsg1,nextupinfomsg2,nextupinfomsg3,shownav,showgrpsince) VALUES ('$user','$pass','localhost','10011','9987','serveradmin','en','Ranksystem','RankSystem','31536000=>47,31536060=>50','1','1','1','xrTKhT/HDl4ea0WoFDQH2zOpmKg=,9odBYAU7z2E2feUz965sL0/Myom=','7200','1.1.2','xrTKhT/HDl4ea0WoFDQH2zOpmKg=','2,6','%a days, %h hours, %i mins, %s secs','1','1','1','1','1','1','1','1','1','1','1','0','1','86400','1','1','0','Europe/Berlin','$logpath','600',$rankupmsg,'1.1.2',$servernews,'1',$nextupinfomsg1,$nextupinfomsg2,$nextupinfomsg3,'1','1')") === false) {
if($mysqlcon->exec("INSERT INTO $dbname.config (webuser,webpass,tshost,tsquery,tsvoice,tsuser,language,queryname,queryname2,grouptime,resetbydbchange,msgtouser,upcheck,uniqueid,updateinfotime,currvers,exceptuuid,exceptgroup,dateformat,showexcld,showcolcld,showcoluuid,showcoldbid,showcolot,showcolit,showcolat,showcolnx,showcolsg,showcolrg,showcolls,slowmode,cleanclients,cleanperiod,showhighest,showcolas,defchid,timezone,logpath,ignoreidle,rankupmsg,newversion,servernews,nextupinfo,nextupinfomsg1,nextupinfomsg2,nextupinfomsg3,shownav,showgrpsince) VALUES ('$user','$pass','localhost','10011','9987','serveradmin','en','Ranksystem','RankSystem','31536000=>47,31536060=>50','1','1','1','xrTKhT/HDl4ea0WoFDQH2zOpmKg=,9odBYAU7z2E2feUz965sL0/Myom=','7200','1.1.3','xrTKhT/HDl4ea0WoFDQH2zOpmKg=','2,6','%a days, %h hours, %i mins, %s secs','1','1','1','1','1','1','1','1','1','1','1','0','1','86400','1','1','0','Europe/Berlin','$logpath','600',$rankupmsg,'1.1.3',$servernews,'1',$nextupinfomsg1,$nextupinfomsg2,$nextupinfomsg3,'1','1')") === false) {
$err_msg = $lang['isntwidbmsg'].$mysqlcon->errorCode()." ".print_r($mysqlcon->errorInfo(), true); $err_lvl = 2;
} else {
$err_msg = $lang['isntwiusr'].'<br><br>';
Expand All @@ -278,27 +278,30 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
if(!is_writeable('./other/dbconfig.php')) {
$err_msg .= "<br>".$lang['isntwicfg']; $err_lvl = 3;
}
if (substr(sprintf('%o', fileperms('./avatars/')), -4)!='0777') {
if(substr(sprintf('%o', fileperms('./avatars/')), -4)!='0777') {
$err_msg .= "<br>".sprintf($lang['isntwichm'],"avatars"); $err_lvl = 3;
}
if (substr(sprintf('%o', fileperms('./icons/')), -4)!='0777') {
if(substr(sprintf('%o', fileperms('./icons/')), -4)!='0777') {
$err_msg .= "<br>".sprintf($lang['isntwichm'],"icons"); $err_lvl = 3;
}
if (substr(sprintf('%o', fileperms('./logs/')), -4)!='0777') {
if(substr(sprintf('%o', fileperms('./logs/')), -4)!='0777') {
$err_msg .= "<br>".sprintf($lang['isntwichm'],"logs"); $err_lvl = 3;
}
if (!class_exists('PDO')) {
if(!class_exists('PDO')) {
$err_msg .= "<br>".$lang['insterr2']; $err_lvl = 3;
}
if (!function_exists('exec')) {
if(!function_exists('exec')) {
$err_msg .= "<br>".$lang['insterr3']; $err_lvl = 3;
}
if(version_compare(phpversion(), '5.5.0', '<')) {
$err_msg .= "<br>".sprintf($lang['insterr4'],phpversion()); $err_lvl = 3;
}
if (!function_exists('simplexml_load_file')) {
if(!function_exists('simplexml_load_file')) {
$err_msg .= "<br>".$lang['insterr5']; $err_lvl = 3;
}
if(!in_array('curl', get_loaded_extensions())) {
$err_msg .= "<br>".$lang['insterr6']; $err_lvl = 3;
}
if(!isset($err_lvl)) {
unset($err_msg);
}
Expand Down
8 changes: 8 additions & 0 deletions jobs/bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ function enter_logfile($logpath,$timezone,$loglevel,$logtext) {
enter_logfile($logpath,$timezone,1,"Your PHP version (".phpversion().") is below 5.5.0. Update of PHP needed! Shuttin down!\n\n");
exit;
}
if(!function_exists('simplexml_load_file')) {
enter_logfile($logpath,$timezone,1,"SimpleXML is missed. Installation of SimpleXML is needed! Shuttin down!\n\n");
exit;
}
if(!in_array('curl', get_loaded_extensions())) {
enter_logfile($logpath,$timezone,1,"PHP cURL is missed. Installation of PHP cURL is needed! Shuttin down!\n\n");
exit;
}

enter_logfile($logpath,$timezone,5,"Initialize Bot...");
require_once(substr(__DIR__,0,-4).'ts3_lib/TeamSpeak3.php');
Expand Down
21 changes: 11 additions & 10 deletions jobs/check_db.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?PHP
function check_db($mysqlcon,$lang,$dbname,$timezone,$currvers,$logpath) {
$newversion = '1.1.2';
$newversion = '1.1.3';
enter_logfile($logpath,$timezone,5,"Check Ranksystem database for updates.");

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

function check_chmod($timezone) {
if (substr(sprintf('%o', fileperms(substr(__DIR__,0,-4).'icons/')), -4)!='0777') {
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).'logs/')), -4)!='0777') {
if(substr(sprintf('%o', fileperms($logpath)), -3, 1)!='7') {
enter_logfile($logpath,$timezone,2,sprintf($lang['isntwichm'],'logs'));
}
if (substr(sprintf('%o', fileperms(substr(__DIR__,0,-4).'avatars/')), -4)!='0777') {
if(substr(sprintf('%o', fileperms(substr(__DIR__,0,-4).'avatars/')), -3, 1)!='7') {
enter_logfile($logpath,$timezone,2,sprintf($lang['isntwichm'],'avatars'));
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ function old_files($timezone,$logpath) {
if($currvers==$newversion) {
enter_logfile($logpath,$timezone,5," No newer version detected; Database check finished.");
old_files($timezone,$logpath);
check_chmod($timezone);
check_chmod($timezone,$logpath,$lang);
check_config($mysqlcon,$dbname);
} elseif($currvers=="0.13-beta") {
enter_logfile($logpath,$timezone,4," Update the Ranksystem Database to version 1.0.1");
Expand Down Expand Up @@ -260,7 +260,7 @@ function old_files($timezone,$logpath) {

if ($errcount == 1) {
$currvers = set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath);
old_files($timezone,$logpath);
check_chmod($timezone,$logpath,$lang);
check_chmod($timezone);
} else {
enter_logfile($logpath,$timezone,1,"An error happens due updating the Ranksystem Database!");
Expand Down Expand Up @@ -335,8 +335,6 @@ function old_files($timezone,$logpath) {
enter_logfile($logpath,$timezone,4," [1.1.2] Adjusted table config (part1) successfully.");
}
}
}
if(version_compare($currvers, '1.1.1', '<=')) {
if($mysqlcon->exec("ALTER TABLE $dbname.config ADD (shownav int(1) NOT NULL default '0', showgrpsince int(1) NOT NULL default '0')") === false) { } else {
if($mysqlcon->exec("UPDATE $dbname.config set shownav='1', showgrpsince='1'") === false) { } else {
enter_logfile($logpath,$timezone,4," [1.1.2] Adjusted table config (part2) successfully.");
Expand All @@ -346,9 +344,12 @@ function old_files($timezone,$logpath) {
enter_logfile($logpath,$timezone,4," [1.1.2] Adjusted table user successfully.");
}
}
if(version_compare($currvers, '1.1.2', '<=')) {
enter_logfile($logpath,$timezone,4," [1.1.3] No database changes needed.");
}
$currvers = set_new_version($mysqlcon,$dbname,$timezone,$newversion,$logpath);
old_files($timezone,$logpath);
check_chmod($timezone);
check_chmod($timezone,$logpath,$lang);
check_config($mysqlcon,$dbname);
}
return $currvers;
Expand Down
28 changes: 15 additions & 13 deletions jobs/handle_messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
$uuid = $event["invokeruid"];


if(strstr($event["msg"], 'nextup') && $nextupinfo == 1) {
if(strstr($event["msg"], 'nextup') && $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) {
enter_logfile($logpath,$timezone,2,"handle_messages 1:".print_r($mysqlcon->errorInfo(), true));
}
$user = $dbuserdata->fetchAll(PDO::FETCH_ASSOC);
$nextup = $user[0]['nextup'];
$dtF = new DateTime("@0");
$dtT = new DateTime("@$nextup");
$days = $dtF->diff($dtT)->format('%a');
$hours = $dtF->diff($dtT)->format('%h');
$mins = $dtF->diff($dtT)->format('%i');
$secs = $dtF->diff($dtT)->format('%s');

if(($dbgroups = $mysqlcon->query("SELECT * FROM $dbname.groups")) === false) {
enter_logfile($logpath,$timezone,2,"handle_messages 2:".print_r($mysqlcon->errorInfo(), true));
Expand All @@ -31,15 +24,21 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
$countgrp = count($grouptime);
$grpcount=0;
foreach ($grouptime as $time => $groupid) {
$grpcount++;
if ($substridle == 1) {
$activetime = $user[0]['count'] - $user[0]['idle'];
$nextup = $time - $user[0]['count'] - $user[0]['idle'];
} else {
$activetime = $user[0]['count'];
$nextup = $time - $user[0]['count'];
}
if ($activetime < $time || $grpcount == $countgrp && $nextup <= 0) {
$dtF = new DateTime("@0");
$dtT = new DateTime("@$nextup");
$days = $dtF->diff($dtT)->format('%a');
$hours = $dtF->diff($dtT)->format('%h');
$mins = $dtF->diff($dtT)->format('%i');
$secs = $dtF->diff($dtT)->format('%s');
$grpcount++;
if ($nextup > 0 && $nextup < $time || $grpcount == $countgrp && $nextup <= 0) {
check_shutdown($timezone,$logpath); usleep($slowmode);
if ($grpcount == $countgrp && $nextup == 0) {
if ($grpcount == $countgrp && $nextup <= 0) {
try {
$host->serverGetSelected()->clientGetByUid($event["invokeruid"])->message(sprintf($nextupinfomsg2, $days, $hours, $mins, $secs, $sqlhisgroup[$groupid]));
} catch (Exception $e) {
Expand All @@ -58,6 +57,9 @@ function handle_messages(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3
enter_logfile($logpath,$timezone,2,"handle_messages 5:".$e->getCode().': '.$e->getMessage());
}
}
if($nextupinfo == 1) {
break;
}
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions languages/core_ar.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
$lang['insterr3'] = "PHP exec function need to be enabled but seems to be disabled. Please enable the PHP <a href=\http://php.net/manual/de/function.exec.php\" target=\"_blank\">exec</a> function and try it again!";
$lang['insterr4'] = "Your PHP version (%s) is below 5.5.0. Update your PHP and try it again!";
$lang['insterr5'] = "SimpleXML is needed but seems not available. Install <a href=\"http://php.net/manual/en/simplexml.installation.php\" target=\"_blank\">simpleXML</a> and try it again!";
$lang['insterr6'] = "PHP cURL is needed but seems not available. Install <a href=\"//php.net/manual/en/book.curl.php\" target=\"_blank\">PHP cURL</a> and try it again!";
$lang['isntwicfg'] = "Can't save the database configuration! Please edit the 'other/dbconfig.php' with a chmod 0777 (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 777 (on windows 'full access') and try to start the Ranksystem again.";
Expand Down Expand Up @@ -335,13 +336,16 @@
$lang['winav10'] = "Please use the webinterface only via %s HTTPS%s An encryption is critical to ensure your privacy and security.%sTo be able to use HTTPS your webserver needs to support an SSL connection.";
$lang['winav11'] = "Please enter the unique Client-ID of the admin of the Ranksystem (Other -> admin ID). This is very important in case you lost your login details for the webinterface (to reset these).";
$lang['winxinfo'] = "Command \"nextup\"";
$lang['winxinfodesc'] = "Allows the user on the TS3 server to write the command \"nextup\" to the Ranksystem (query) bot as private textmessage.<br><br>As answer the user will get a defined text message with the needed time for the next rankup.";
$lang['winxinfodesc'] = "Allows the user on the TS3 server to write the command \"nextup\" to the Ranksystem (query) bot as private textmessage.<br><br>As answer the user will get a defined text message with the needed time for the next rankup.<br><br><b>deactivated</b> - The function is deactivated. The command 'nextup' will be ignored.<br><b>allowed - only next rank</b> - Gives back the needed time for the next group.<br><b>allowed - all next ranks</b> - Gives back the needed time for all higher ranks.";
$lang['winxmode1'] = "deactivated";
$lang['winxmode2'] = "allowed - only next rank";
$lang['winxmode3'] = "allowed - all next ranks";
$lang['winxmsg1'] = "Message";
$lang['winxmsgdesc1'] = "Define a message, which the user will get as answer at the command \"nextup\".<br><br>Arguments:<br>%1\$s - days to next rankup<br>%2\$s - hours to next rankup<br>%3\$s - minutes to next rankup<br>%4\$s - seconds to next rankup<br>%5\$s - name of the next servergroup<br><br>Example:<br>Your next rank up will be in %1\$s days, %2\$s hours and %3\$s minutes and %4\$s seconds. The next servergroup you will reach is [B]%5\$s[/B].";
$lang['winxmsgdesc1'] = "Define a message, which the user will get as answer at the command \"nextup\".<br><br>Arguments:<br>%1&#36;s - days to next rankup<br>%2&#36;s - hours to next rankup<br>%3&#36;s - minutes to next rankup<br>%4&#36;s - seconds to next rankup<br>%5&#36;s - name of the next servergroup<br><br>Example:<br>Your next rank up will be in %1&#36;s days, %2&#36;s hours and %3&#36;s minutes and %4&#36;s seconds. The next servergroup you will reach is [B]%5&#36;s[/B].";
$lang['winxmsg2'] = "Message (highest)";
$lang['winxmsgdesc2'] = "Define a message, which the user will get as answer at the command \"nextup\", when the user already reached the highest rank.<br><br>Arguments:<br>%1\$s - days to next rankup<br>%2\$s - hours to next rankup<br>%3\$s - minutes to next rankup<br>%4\$s - seconds to next rankup<br>%5\$s - name of the next servergroup<br><br>Example:<br>You have already reached the highest rank.";
$lang['winxmsgdesc2'] = "Define a message, which the user will get as answer at the command \"nextup\", when the user already reached the highest rank.<br><br>Arguments:<br>%1&#36;s - days to next rankup<br>%2&#36;s - hours to next rankup<br>%3&#36;s - minutes to next rankup<br>%4&#36;s - seconds to next rankup<br>%5&#36;s - name of the next servergroup<br><br>Example:<br>You have been reached the highest rank for %1&#36;s days, %2&#36;s hours and %3&#36;s minutes and %4&#36;s seconds.";
$lang['winxmsg3'] = "Message (excepted)";
$lang['winxmsgdesc3'] = "Define a message, which the user will get as answer at the command \"nextup\", when the user is excepted from the Ranksystem.<br><br>Arguments:<br>%1\$s - days to next rankup<br>%2\$s - hours to next rankup<br>%3\$s - minutes to next rankup<br>%4\$s - seconds to next rankup<br>%5\$s - name of the next servergroup<br><br>Example:<br>You are excepted from the Ranksystem. If you wish to rank contact an admin on the TS3 server.";
$lang['winxmsgdesc3'] = "Define a message, which the user will get as answer at the command \"nextup\", when the user is excepted from the Ranksystem.<br><br>Arguments:<br>%1&#36;s - days to next rankup<br>%2&#36;s - hours to next rankup<br>%3&#36;s - minutes to next rankup<br>%4&#36;s - seconds to next rankup<br>%5&#36;s - name of the next servergroup<br><br>Example:<br>You are excepted from the Ranksystem. If you wish to rank contact an admin on the TS3 server.";
$lang['wirtpw1'] = "Sorry Bro, you have forgotten to enter your admin ID inside the webinterface before. There is no way to reset the password!";
$lang['wirtpw2'] = "Admin ID not found on TS3 server. You need to be online with the unique Client ID, which is saved as admin ID.";
$lang['wirtpw3'] = "Your IP address do not match with the IP address of the admin on the TS3 server. Be sure you are with the same IP address online on the TS3 server and also on this page (same protocol IPv4 / IPv6 is also needed).";
Expand Down
Loading

0 comments on commit 114633a

Please sign in to comment.