Resource icon

Teamspeak 3 Rank System 2017-08-26

No permission to download
Status
Not open for further replies.

kaidinak

Active Member
Oct 11, 2015
51
11
98
I have already done some tries, but it didn't work at least on the tests i did. I keep trying but i don't know. If it works i will post it for sure! :)
Thanks! You can always contact with Stefan1200, he is good guy and will help you if you need some help. :)
 

ronny l

Member
Nov 15, 2015
0
0
36
Hi Alligatoras,
first off thanks for showing this nice script !
but it gives me error:
Code:
##
Warning: feof() expects parameter 1 to be resource, boolean given in /home/rank.php on line 107
PHP Warning:  fgets() expects parameter 1 to be resource, boolean given in /home/rank.php on line 109

Warning: fgets() expects parameter 1 to be resource, boolean given in /home/rank.php on line 109
PHP Warning:  feof() expects parameter 1 to be resource, boolean given in /home/rank.php on line 107
##
when i try to run this
##
PHP:
<?php
//-----------------------------------------------------------------------------------------------------------------
// TEAMSPEAK SETTINGS
$botname = "RANGBOT"; //Bot Name
$TSaddress = "127.0.0.1"; // TS server Adrress
$TSqueryport = "10011"; //Ts server query port
$TSport = "9992"; //TS Port
$TSadminNickname = "admin"; //TS Admin Nickname
$TSpassword = "HAHA"; // Ts Admin Pass
//-----------------------------------------------------------------------------------------------------------------
// RANK SETTINGS
$Rank1 = "344";  //Rank SG ID
$timetoget1 = "172800"; //2 days Time to get
$name1 = "Stammgast"; //Rank Name

//------------------------------------------------------------------------------------------------------------------
function time_elapsed($time)
{
    $bit = array(
        'y' => $time / 31556926 % 12,
        'w' => $time / 604800 % 52,
        'd' => $time / 86400 % 7,
        'h' => $time / 3600 % 24,
        'm' => $time / 60 % 60,
        's' => $time % 60);
    foreach ($bit as $k => $v)
        if ($v > 0)
            $ret[] = $v . $k;
    return join(' ', $ret);
}
// ERROR REPORT
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$filename = "OnlineStatus.txt";
$totaltime = "TotalTime.txt";
set_time_limit(0);
date_default_timezone_set('Europe/Warsaw');
require_once dirname(__file__) .
    "/libraries/TeamSpeak3/TeamSpeak3.php";
try
{
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://$TSadminNickname:$TSpassword@$TSaddress:$TSqueryport/?server_port=$TSport&nickname=$botname");
}
catch (TeamSpeak3_Exception $e)
{
    // print the error message returned by the server
    echo "Error " . $e->getCode() . ": " . $e->getMessage();
}
$arr_ClientList = $ts3_VirtualServer->clientList();
$TSuserdata = array();
foreach ($arr_ClientList as $TSClid => $TSArray)
{
    if ($TSArray->client_unique_identifier->toString() == "serveradmin")
    {
    } elseif ($TSArray->client_unique_identifier->toString() == "ServerQuery")
    {
    } else
    {
        array_push($TSuserdata, array(
            "TsNICK" => $TSArray->client_nickname->toString(),
            "TsDBID" => $TSArray->client_database_id,
            "TsUID" => $TSArray->client_unique_identifier->toString(),
            "TsSERVGIDs" => $TSArray->client_servergroups,
            "TsCHANGIDs" => $TSArray->client_channel_group_id,
            "TsCLIENTID" => $TSArray->clid,
            "TsCONTIME" => $TSArray->client_lastconnected,
            "TsIDLTIME" => $TSArray->client_idle_time,
            "TsCLIENTCHANID" => $TSArray->cid));
    }
}
foreach ($TSuserdata as $timeonline)
{
    $searchfor = "" . $timeonline["TsUID"] . "";
    $file = file_get_contents($filename);
    if (strpos($file, $searchfor) == false)
    {
        $timecon = $timeonline["TsCONTIME"];
        $data = "" . $timeonline["TsUID"] . ",$timecon\n";
        file_put_contents($filename, $data, FILE_APPEND | LOCK_EX);
    }
}
$fh = fopen($filename, 'r');
$members = array();
$onlinedata = array();
$i = 0;
while (!feof($fh))
{
    $huj = fgets($fh);
    $huj = trim($huj);
    $members[] = $huj;
}
fclose($fh);
foreach ($members as $Mem)
{
    $MemS = explode(",", $Mem);
    if (!empty($MemS[0]))
    {
        $a = ($MemS[0]);
        $b = ($MemS[1]);
        array_push($onlinedata, array("TsUID" => $a, "TsCONTIME" => $b));
    }
}
$tt = fopen($totaltime, 'r');
$members2 = array();
$totalonlinedata = array();
$i = 0;
while (!feof($tt))
{
    $chuj = fgets($tt);
    $chuj = trim($chuj);
    $members2[] = $chuj;
}
fclose($tt);
foreach ($members2 as $Mem2)
{
    $MemS2 = explode(",", $Mem2);
    if (!empty($MemS2[0]))
    {
        $a = ($MemS2[0]);
        $b = ($MemS2[1]);
        $time = $b;
        $c = time_elapsed($time);
        array_push($totalonlinedata, array(
            "TsUID" => $a,
            "TsTOTALONLINE" => $b,
            "TsTotalTime" => $c));
    }
}
$uilist = "";
foreach ($TSuserdata as $tsuid)
{
    $ui = $tsuid["TsUID"];
    $uilist = $uilist . $ui . ",";
}
foreach ($onlinedata as $ondat)
{
    if (!in_array($ondat["TsUID"], explode(',', $uilist)))
    {
        $file2 = file_get_contents($totaltime);
        $searchfor2 = $ondat["TsUID"];
        if (strpos($file2, $searchfor2) == false)
        {
            $sesiontime = time() - $ondat["TsCONTIME"];
            if ($sesiontime > 0)
            {
                $data = "" . $ondat["TsUID"] . ",$sesiontime\n";
                file_put_contents($totaltime, $data, FILE_APPEND | LOCK_EX);
            }
            $deleteEntry = "" . $ondat["TsUID"] . "," . $ondat["TsCONTIME"] . "";
            $file = file_get_contents($filename);
            $file = rtrim(str_replace("$deleteEntry", '', $file));
            $file = file_put_contents($filename, $file);
            file_put_contents($filename, "\n", FILE_APPEND | LOCK_EX);
        } elseif (strpos($file2, $searchfor2) !== false)
        {
            foreach ($totalonlinedata as $tsdat)
            {
                if ($ondat["TsUID"] == $tsdat["TsUID"])
                {
                    $sesiontime = time() - $ondat["TsCONTIME"];
                    $totalTime = $sesiontime + $tsdat["TsTOTALONLINE"];
                    if ($totalTime > 0)
                    {
                        $delEntry = "" . $tsdat["TsUID"] . "," . $tsdat["TsTOTALONLINE"] . "";
                        $dataentry = "" . $ondat["TsUID"] . ",$totalTime";
                        $file2 = file_get_contents($totaltime);
                        $file2 = rtrim(str_replace("$delEntry", "$dataentry", $file2));
                        $file2 = file_put_contents($totaltime, $file2);
                        file_put_contents($totaltime, "\n", FILE_APPEND | LOCK_EX);
                    }
                    $deleteEntry = "" . $ondat["TsUID"] . "," . $ondat["TsCONTIME"] . "";
                    $file = file_get_contents($filename);
                    $file = rtrim(str_replace("$deleteEntry", '', $file));
                    $file = file_put_contents($filename, $file);
                    file_put_contents($filename, "\n", FILE_APPEND | LOCK_EX);
                }
            }
        }
    }
}
foreach ($TSuserdata as $key => $s1)
{
    foreach ($totalonlinedata as $tr)
    {
        if ($s1["TsUID"] == $tr["TsUID"])
        {
            foreach ($tr as $k => $c)
            {
                $TSuserdata[$key][$k] = $c;
            }
            $find = 1;
            break;
        }
    }
}
foreach ($TSuserdata as $torank)
{
    if (array_key_exists("TsTOTALONLINE", $torank))
    {
        if ($torank["TsTOTALONLINE"] >= $timetoget1)
        {
            if (!in_array($Rank1, explode(',', $torank["TsSERVGIDs"])))
            {
                $ts3_VirtualServer->serverGroupClientAdd($Rank1, ($torank["TsDBID"]));
            }
        }
    }
}
?>
##
i only want 1 rank "stammgast" to be given after 48 h., a message to the user is not needed so i removed it (corretly?)

would really appreciate ure help : )

- TheGunter24
 

Alligatoras

Administrator
Mar 31, 2016
2,570
12
2,857
381
hello, if me right php rank.php is give me error in line 80 How fix ?
i would like you to send the code you have, in case you have deleted something important!

Hi Alligatoras,
first off thanks for showing this nice script !
but it gives me error:
Code:
##
Warning: feof() expects parameter 1 to be resource, boolean given in /home/rank.php on line 107
PHP Warning:  fgets() expects parameter 1 to be resource, boolean given in /home/rank.php on line 109

Warning: fgets() expects parameter 1 to be resource, boolean given in /home/rank.php on line 109
PHP Warning:  feof() expects parameter 1 to be resource, boolean given in /home/rank.php on line 107
##
when i try to run this
##
PHP:
<?php
//-----------------------------------------------------------------------------------------------------------------
// TEAMSPEAK SETTINGS
$botname = "RANGBOT"; //Bot Name
$TSaddress = "127.0.0.1"; // TS server Adrress
$TSqueryport = "10011"; //Ts server query port
$TSport = "9992"; //TS Port
$TSadminNickname = "admin"; //TS Admin Nickname
$TSpassword = "HAHA"; // Ts Admin Pass
//-----------------------------------------------------------------------------------------------------------------
// RANK SETTINGS
$Rank1 = "344";  //Rank SG ID
$timetoget1 = "172800"; //2 days Time to get
$name1 = "Stammgast"; //Rank Name

//------------------------------------------------------------------------------------------------------------------
function time_elapsed($time)
{
    $bit = array(
        'y' => $time / 31556926 % 12,
        'w' => $time / 604800 % 52,
        'd' => $time / 86400 % 7,
        'h' => $time / 3600 % 24,
        'm' => $time / 60 % 60,
        's' => $time % 60);
    foreach ($bit as $k => $v)
        if ($v > 0)
            $ret[] = $v . $k;
    return join(' ', $ret);
}
// ERROR REPORT
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$filename = "OnlineStatus.txt";
$totaltime = "TotalTime.txt";
set_time_limit(0);
date_default_timezone_set('Europe/Warsaw');
require_once dirname(__file__) .
    "/libraries/TeamSpeak3/TeamSpeak3.php";
try
{
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://$TSadminNickname:$TSpassword@$TSaddress:$TSqueryport/?server_port=$TSport&nickname=$botname");
}
catch (TeamSpeak3_Exception $e)
{
    // print the error message returned by the server
    echo "Error " . $e->getCode() . ": " . $e->getMessage();
}
$arr_ClientList = $ts3_VirtualServer->clientList();
$TSuserdata = array();
foreach ($arr_ClientList as $TSClid => $TSArray)
{
    if ($TSArray->client_unique_identifier->toString() == "serveradmin")
    {
    } elseif ($TSArray->client_unique_identifier->toString() == "ServerQuery")
    {
    } else
    {
        array_push($TSuserdata, array(
            "TsNICK" => $TSArray->client_nickname->toString(),
            "TsDBID" => $TSArray->client_database_id,
            "TsUID" => $TSArray->client_unique_identifier->toString(),
            "TsSERVGIDs" => $TSArray->client_servergroups,
            "TsCHANGIDs" => $TSArray->client_channel_group_id,
            "TsCLIENTID" => $TSArray->clid,
            "TsCONTIME" => $TSArray->client_lastconnected,
            "TsIDLTIME" => $TSArray->client_idle_time,
            "TsCLIENTCHANID" => $TSArray->cid));
    }
}
foreach ($TSuserdata as $timeonline)
{
    $searchfor = "" . $timeonline["TsUID"] . "";
    $file = file_get_contents($filename);
    if (strpos($file, $searchfor) == false)
    {
        $timecon = $timeonline["TsCONTIME"];
        $data = "" . $timeonline["TsUID"] . ",$timecon\n";
        file_put_contents($filename, $data, FILE_APPEND | LOCK_EX);
    }
}
$fh = fopen($filename, 'r');
$members = array();
$onlinedata = array();
$i = 0;
while (!feof($fh))
{
    $huj = fgets($fh);
    $huj = trim($huj);
    $members[] = $huj;
}
fclose($fh);
foreach ($members as $Mem)
{
    $MemS = explode(",", $Mem);
    if (!empty($MemS[0]))
    {
        $a = ($MemS[0]);
        $b = ($MemS[1]);
        array_push($onlinedata, array("TsUID" => $a, "TsCONTIME" => $b));
    }
}
$tt = fopen($totaltime, 'r');
$members2 = array();
$totalonlinedata = array();
$i = 0;
while (!feof($tt))
{
    $chuj = fgets($tt);
    $chuj = trim($chuj);
    $members2[] = $chuj;
}
fclose($tt);
foreach ($members2 as $Mem2)
{
    $MemS2 = explode(",", $Mem2);
    if (!empty($MemS2[0]))
    {
        $a = ($MemS2[0]);
        $b = ($MemS2[1]);
        $time = $b;
        $c = time_elapsed($time);
        array_push($totalonlinedata, array(
            "TsUID" => $a,
            "TsTOTALONLINE" => $b,
            "TsTotalTime" => $c));
    }
}
$uilist = "";
foreach ($TSuserdata as $tsuid)
{
    $ui = $tsuid["TsUID"];
    $uilist = $uilist . $ui . ",";
}
foreach ($onlinedata as $ondat)
{
    if (!in_array($ondat["TsUID"], explode(',', $uilist)))
    {
        $file2 = file_get_contents($totaltime);
        $searchfor2 = $ondat["TsUID"];
        if (strpos($file2, $searchfor2) == false)
        {
            $sesiontime = time() - $ondat["TsCONTIME"];
            if ($sesiontime > 0)
            {
                $data = "" . $ondat["TsUID"] . ",$sesiontime\n";
                file_put_contents($totaltime, $data, FILE_APPEND | LOCK_EX);
            }
            $deleteEntry = "" . $ondat["TsUID"] . "," . $ondat["TsCONTIME"] . "";
            $file = file_get_contents($filename);
            $file = rtrim(str_replace("$deleteEntry", '', $file));
            $file = file_put_contents($filename, $file);
            file_put_contents($filename, "\n", FILE_APPEND | LOCK_EX);
        } elseif (strpos($file2, $searchfor2) !== false)
        {
            foreach ($totalonlinedata as $tsdat)
            {
                if ($ondat["TsUID"] == $tsdat["TsUID"])
                {
                    $sesiontime = time() - $ondat["TsCONTIME"];
                    $totalTime = $sesiontime + $tsdat["TsTOTALONLINE"];
                    if ($totalTime > 0)
                    {
                        $delEntry = "" . $tsdat["TsUID"] . "," . $tsdat["TsTOTALONLINE"] . "";
                        $dataentry = "" . $ondat["TsUID"] . ",$totalTime";
                        $file2 = file_get_contents($totaltime);
                        $file2 = rtrim(str_replace("$delEntry", "$dataentry", $file2));
                        $file2 = file_put_contents($totaltime, $file2);
                        file_put_contents($totaltime, "\n", FILE_APPEND | LOCK_EX);
                    }
                    $deleteEntry = "" . $ondat["TsUID"] . "," . $ondat["TsCONTIME"] . "";
                    $file = file_get_contents($filename);
                    $file = rtrim(str_replace("$deleteEntry", '', $file));
                    $file = file_put_contents($filename, $file);
                    file_put_contents($filename, "\n", FILE_APPEND | LOCK_EX);
                }
            }
        }
    }
}
foreach ($TSuserdata as $key => $s1)
{
    foreach ($totalonlinedata as $tr)
    {
        if ($s1["TsUID"] == $tr["TsUID"])
        {
            foreach ($tr as $k => $c)
            {
                $TSuserdata[$key][$k] = $c;
            }
            $find = 1;
            break;
        }
    }
}
foreach ($TSuserdata as $torank)
{
    if (array_key_exists("TsTOTALONLINE", $torank))
    {
        if ($torank["TsTOTALONLINE"] >= $timetoget1)
        {
            if (!in_array($Rank1, explode(',', $torank["TsSERVGIDs"])))
            {
                $ts3_VirtualServer->serverGroupClientAdd($Rank1, ($torank["TsDBID"]));
            }
        }
    }
}
?>
##
i only want 1 rank "stammgast" to be given after 48 h., a message to the user is not needed so i removed it (corretly?)

would really appreciate ure help : )

- TheGunter24
As i am from my phone right now, i can't find the error! When i come back, i will check the code i have maybe you have mistaken deleted something important!
 

Ahmad

Member
Jun 4, 2015
17
0
33
i would like you to send the code you have, in case you have deleted something important!


As i am from my phone right now, i can't find the error! When i come back, i will check the code i have maybe you have mistaken deleted something important!
what delete ?
 

karamx

Member
Apr 15, 2016
12
0
33
when i go to www..........com/ranksystem its says
Not Found
The requested URL /ranksystem was not found on this server.

Apache/2.4.18 (Ubuntu) Server at xxx Port 80


Mod edit:
Do not post your domain/ server/ own IP publicly.
 
Last edited by a moderator:

Alligatoras

Administrator
Mar 31, 2016
2,570
12
2,857
381
This thread is no longer supported untill i fix all the bugs that have issued!

/Closed
 
Status
Not open for further replies.
Top