That's easy to do, I can show you if you want. It's around 5 lines of code to tweak. I created this code to my needs (I'm using cloudflare as you can see), if you are not using it it would be $_SERVER['REMOTE_ADDR'] just like below...The Script is also nice, but the Script from the german dev is much better. You dont need to enter a username.
foreach ($ts3->clientList() as $cl) {
if ($cl->client_type) continue;
//if ($cl->getProperty('connection_client_ip') == $_SERVER['HTTP_CF_CONNECTING_IP']) {
if ($cl->getProperty('connection_client_ip') == $_SERVER['REMOTE_ADDR']) {
$clientuid = $ts3->clientGetByName("$cl->client_nickname")->client_unique_identifier;
echo $clientuid; //Here I just print to the screen the client UID for fun
$FLAG = true;
break;
}
else {
$FLAG = false;
}
}
if (!$FLAG){
unset($_SESSION);
$error[] = array('type' => 'danger', 'msg' => 'You are not connected on the server!');
}
Oh sorry, I actually went into all this trouble for nothing. I tought it was your way of asking for it lol -_-.Yeah, I know it's easy. I had done it too.
That's easy to do, I can show you if you want. It's around 5 lines of code to tweak. I created this code to my needs (I'm using cloudflare as you can see), if you are not using it it would be $_SERVER['REMOTE_ADDR'] just like below...
PHP:foreach ($ts3->clientList() as $cl) { if ($cl->client_type) continue; //if ($cl->getProperty('connection_client_ip') == $_SERVER['HTTP_CF_CONNECTING_IP']) { if ($cl->getProperty('connection_client_ip') == $_SERVER['REMOTE_ADDR']) { $clientuid = $ts3->clientGetByName("$cl->client_nickname")->client_unique_identifier; echo $clientuid; //Here I just print to the screen the client UID for fun $FLAG = true; break; } else { $FLAG = false; } } if (!$FLAG){ unset($_SESSION); $error[] = array('type' => 'danger', 'msg' => 'You are not connected on the server!'); }
function getClientIp() {
if (!empty($_SERVER['HTTP_CLIENT_IP']))
return $_SERVER['HTTP_CLIENT_IP'];
else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
return $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(!empty($_SERVER['HTTP_X_FORWARDED']))
return $_SERVER['HTTP_X_FORWARDED'];
else if(!empty($_SERVER['HTTP_FORWARDED_FOR']))
return $_SERVER['HTTP_FORWARDED_FOR'];
else if(!empty($_SERVER['HTTP_FORWARDED']))
return $_SERVER['HTTP_FORWARDED'];
else if(!empty($_SERVER['REMOTE_ADDR']))
return $_SERVER['REMOTE_ADDR'];
else
return false;
}
$FLAG = false;
foreach ($ts3->clientList(array('client_type' => '0', 'connection_client_ip' => getClientIp())) as $client) {
$clientuid = $client->client_unique_identifier;
$FLAG = true;
break;
}
if (!$FLAG){
session_unset();
$error[] = array('type' => 'danger', 'msg' => 'You are not connected on the server!');
}
I modified your Code a little to look Cleaner:
clientList() has a integrated filtering possibility already built in
and I use this getClientIp as default Function for my Projects (< found somewhere on stackoverflow)
this may be a bit cleaner Code
PHP:function getClientIp() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) return $_SERVER['HTTP_CLIENT_IP']; else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) return $_SERVER['HTTP_X_FORWARDED_FOR']; else if(!empty($_SERVER['HTTP_X_FORWARDED'])) return $_SERVER['HTTP_X_FORWARDED']; else if(!empty($_SERVER['HTTP_FORWARDED_FOR'])) return $_SERVER['HTTP_FORWARDED_FOR']; else if(!empty($_SERVER['HTTP_FORWARDED'])) return $_SERVER['HTTP_FORWARDED']; else if(!empty($_SERVER['REMOTE_ADDR'])) return $_SERVER['REMOTE_ADDR']; else return false; } $FLAG = false; foreach ($ts3->clientList(array('client_type' => '0', 'connection_client_ip' => getClientIp())) as $client) { $clientuid = $client->client_unique_identifier; $FLAG = true; break; } if (!$FLAG){ session_unset(); $error[] = array('type' => 'danger', 'msg' => 'You are not connected on the server!'); }
Modified a little again....
I used unset($_SESSION); aswell but this wont work and will not reset your Session Variable...
use session_unset() instead
On php.net there are these info/warning
Note:
If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use unset() to unregister a session variable, i.e. unset ($_SESSION['varname']);.
Caution
Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of session variables through the$_SESSION superglobal.
The Scripts i have released on my multivitamin.wtf page...
The First idea of my Group Assigner i had by myself,
i designed my assigner independently from the others but it has some similar looks^^
i like this script but one think dont work for me the icons dont show when i am using the script.Nice nice nice.
if you do not mind I will use this for my script.
Since it was something other projects but never added it ...
https://github.com/Doc94/TS3IconManager/tree/dev
What?the DGEcan be foundpokebotbuyoutpocketwhen connectingto the server
What?