Registration page

Flynns82

Member
Jun 23, 2016
16
0
36
Hi,
I found a script similar to the IconManager that automatically detects the user's uid on the site, I wanted to try to create a registration page based on that script and I did it:
now I wanted to add two checks, which unfortunately I can not make it work:
1. Verify if the user already has one of the two registered servergroupgroups.
2. Verify if your nickname (which automatically detects it) and the other data you write on the registration page are already present in mysql.
for now I tried only with the first, but without results, I created this script and put it in after the captcha check:
but the script starts and assigns the servergroup and adds the data to mysql anyway, although I'm already registered, can anyone help me? I would like to finish it also to post it in this forum if ever someone serves.
Thank you all
 

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
Keep in mind that with your current get user IP function, people will be able to fake their IP and mess with other users.

To get a clients server groups and check them, do this:
(I'm not sure if it's gonna work because I didn't test it)
PHP:
$client_groups = explode(",", $ts3_Client['client_servergroups']);
foreach($client_groups as $client_group){
    if($group == $client_group){
        echo "Has group from config: " . $client_group;
}
}

For number 2, just do a sql select with where username is $ts3_Client['client_nickname']
 

Flynns82

Member
Jun 23, 2016
16
0
36
i know for the ip.. but, exist an another method that can read automatically what is my uid?
anyway i try but its the same of mine
 
Last edited:

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
Only use REMOTE_ADDR (HTTP_CF_CONNECTING_IP but only if you're using cloudflare) and tell people to disable the proxy. That's my way of doing it.

Your if (in_array(18 ,$sgcid) or in_array(7 ,$sgcid)) doesn't echo anything. Could that be the problem?

The way I solved it is this:
PHP:
    $client = $ts3->clientGetByName($clientName);
    $groupsArr = $client->memberOf();
    $UID = $client['client_unique_identifier'];
    if($client['connection_client_ip'] <> $ip) {
        echo 'Nickname not found';
    }
    else{
    foreach ($groupsArr as $group){
        $groupsString = $groupsString . $group;
    }
    if (strstr($groupsString, 'United Member') || strstr($groupsString, 'Moderator') || strstr($groupsString, 'Premiumuser')){
        echo 'User has group';
    }
I'm not sure why I didn't use the group ID's but I'm too lazy to change it now because it works.
 
Last edited:

Flynns82

Member
Jun 23, 2016
16
0
36
please, can you explain me all this? o.o sorry i dont understand some thing
 

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
please, can you explain me all this? o.o sorry i dont understand some thing
I edited my post. I hope it's clear now.
strstr($groupsString, 'Moderator') Checks if the user is in a group called "Moderator"
 

Flynns82

Member
Jun 23, 2016
16
0
36
yes, thanks so much, now its simply, but i have only one question, with this, i dont understando how to autodetect the client
 

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
If that is your real password in your first post please change it on your server right now
yes, thanks so much, now its simply, but i have only one question, with this, i dont understando how to autodetect the client
Do you mean detect if they are in the database or what do you mean?
If in database try this
PHP:
$conn = new mysqli($host_db, $Login_db, $pwd_db, $bdd_name);

    $sql = "SELECT nickname FROM regTS3 WHERE UID='" . $uid. "'" ;
    $results = mysqli_query($conn, $sql);
    if ($results == false) {
        die(__FILE__ . ' Error: ' . $sql . '<br>' . mysqli_error($conn);
    }
    $profileExists = 0;
    $rows = mysqli_fetch_row($results);
    if (count($rows) == 1) {
         echo "User is in database";
    }
   else{
       echo "User is not in database";
}
 

Flynns82

Member
Jun 23, 2016
16
0
36
nono, i mean autodetect the uid or the client of the user that want to register
 

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
nono, i mean autodetect the uid or the client of the user that want to register
Ah okay. I would do it with REMOTE_ADDR only because that can't be modified by a client.
What I do to detect the UID is this:
PHP:
    $ip = $_SERVER['REMOTE_ADDR']; // Use HTTP_CF_CONNECTING_IP if you have cloudflare
    $ts3 = TeamSpeak3::factory("serverquery://" . $config["Username"] . ":" . $config["Password"] . "@" . $config["IP"] . ":" . $config["qPort"] . "/?server_port=" . $config["Port"] . "&nickname=" . $config["Nickname"] . "");

    $arr_ClientList = $ts3->clientList();
    $ts3->clientListReset();
    $comboboxValues = '';
    foreach ($arr_ClientList as $client){
        if($client["client_type"] == 1) continue;
            if($client["connection_client_ip"] <> $ip) continue;
            $comboboxValues = $comboboxValues . '<option value="' . $client['client_nickname'] . '">' . $client['client_nickname'] . '</option>';
       
    }
Put this at the top of your website and then put
PHP:
<?php echo '<select required id="absender" size="1" class="form-control" name="name">' . $comboboxValues . '</select>'; ?>
this where you want them to select their name. It will look like this https://drgn.li/img/ypmfY.png
 

Flynns82

Member
Jun 23, 2016
16
0
36
im trying, thanks so much for all! I'll let you know if it works shortly, only one thing, what is <> on the if? i never see it and i didnt find anything on google o.o
sorry but i know php a little
 

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
im trying, thanks so much for all! I'll let you know if it works shortly, only one thing, what is <> on the if? i never see it and i didnt find anything on google o.o
sorry but i know php a little
It's like ==. I don't think there is any difference

Edit: It's !=. Was a little distracted when I posted that
 
Last edited:

DifferentUser

Member
Feb 19, 2016
53
23
58
why just dont use the built in filter function of the Framework?

PHP:
$ts3 = TeamSpeak3::factory("serverquery://".$config["Username"].":".$config["Password"]."@".$config["IP"].":".$config["qPort"]."/?server_port=".$config["Port"]."&nickname=".$config["Nickname"]);

    $values = '';
    $clients = $ts3->clientList(array(
        "connection_client_ip" => $_SERVER['REMOTE_ADDR'],
        "client_type" => 0
    ));
    foreach ($clients as $client){
        $values .= '<option value="' . $client['client_nickname'] . '">' . $client['client_nickname'] . '</option>';
    }
   echo '<select required id="sender" size="1" class="form-control" name="name">' . $values . '</select>';

way more readable
 

Flynns82

Member
Jun 23, 2016
16
0
36
It's like ==. I don't think there is any difference

Edit: It's !=. Was a little distracted when I posted that
I think you wanted to write != not == :D (guessing - https://www.w3schools.com/php/php_operators.asp)
ah okk, perfect thanks!
why just dont use the built in filter function of the Framework?

PHP:
$ts3 = TeamSpeak3::factory("serverquery://".$config["Username"].":".$config["Password"]."@".$config["IP"].":".$config["qPort"]."/?server_port=".$config["Port"]."&nickname=".$config["Nickname"]);

    $values = '';
    $clients = $ts3->clientList(array(
        "connection_client_ip" => $_SERVER['REMOTE_ADDR'],
        "client_type" => 0
    ));
    foreach ($clients as $client){
        $values .= '<option value="' . $client['client_nickname'] . '">' . $client['client_nickname'] . '</option>';
    }
   echo '<select required id="sender" size="1" class="form-control" name="name">' . $values . '</select>';

way more readable
thanks so much but for me its more easy the code of Kieran, that "clientlist(...) its hard for me haha
anyway im trying now, soon I will let you know
 

Flynns82

Member
Jun 23, 2016
16
0
36
EDIT2:
PHP:
        $ip = $_SERVER['HTTP_CF_CONNECTING_IP']; // Use HTTP_CF_CONNECTING_IP if you have cloudflare
        $ts3 = TeamSpeak3::factory('serverquery://'.rawurlencode($config['loginname']).':'.rawurlencode($config['qpassword']).'@'.rawurlencode($config['ip']).':'.rawurlencode($config['queryport']).'?server_port='.rawurlencode($config['serverport']).'&nickname='.rawurlencode($config['displayname']));
        $arr_ClientList = $ts3->clientList();
        $ts3->clientListReset();
        foreach ($arr_ClientList as $client){
            $groupsArr = $client->memberOf();
            if($client["client_type"] == 1) continue;
                if($client['connection_client_ip'] <> $ip) continue;
                    
                foreach ($groupsArr as $group)
                {
                    $groupsString = $groupsString . $group;
                }
                if (strstr($groupsString, 'Otaku Member') || strstr($groupsString, 'Apprendista Otaku'))
                {
                    $errormsg = "Sei Gia registrato!";
                    $error=true;
                }
        }
is it correct?
 
Last edited:

Flynns82

Member
Jun 23, 2016
16
0
36
PHP:
if(!$error)
{
        $ip = $_SERVER['HTTP_CF_CONNECTING_IP']; // Use HTTP_CF_CONNECTING_IP if you have cloudflare
        $ts3 = TeamSpeak3::factory('serverquery://'.rawurlencode($config['loginname']).':'.rawurlencode($config['qpassword']).'@'.rawurlencode($config['ip']).':'.rawurlencode($config['queryport']).'?server_port='.rawurlencode($config['serverport']).'&nickname='.rawurlencode($config['displayname']));
        $arr_ClientList = $ts3->clientList();
        $ts3->clientListReset();
        foreach ($arr_ClientList as $client){
            $groupsArr = $client->memberOf();
            if($client["client_type"] == 1) continue;
                if($client['connection_client_ip'] <> $ip) continue;
                  
                foreach ($groupsArr as $group)
                {
                    $groupsString = $groupsString . $group;
                }
                if (strstr($groupsString, 'Otaku Member') || strstr($groupsString, 'Apprendista Otaku'))
                {
                    $errormsg = "Sei Gia registrato!";
                    $error=true;
                }
        }
}
//start registration
    if (!$error)
    {
            try
            {
                $nickname= $client["client_nickname"];
                $uid=$client["client_unique_identifier"];
                $ts3->serverGroupClientAdd(132, $client->client_database_id);
            } catch (Exception $e) {}
  
            $nome=$_POST['name'];
            $anni=$_POST['anni'];
            $conn=mysqli_connect($host_db,$Login_db,$pwd_db);
            mysqli_select_db($conn,$bdd_name);
            $request="INSERT INTO `regTS3`.`regTS3` (`Nome`, `Nickname`, `Anni`,`UniqueID`)
                                           VALUES ('$nome', '$nickname', '$anni','$uid' );";
            if(mysqli_query($conn,$request))
            {
                        
                    $successmsg = "Registrato con successo!";
            }else
            {
                    $errormsg = "Errore durante la registrazione...Riprovare piu tardi!";
            }
    }
if i have the registered servergroup it say that im already registered, but if i take out the servergroup, it register me only on mysql and here appear, like nickname, the name of the bot and like uid appear "serveradmin" o.o but im logged into ts only with a normal user

EDIT: i think there is a problem with the client that the script read on the first "if" with the variables on the second "if", the problem is that i dont understand how to work the ts3 framework :c and i hate copy the code that i find online without understand all:
the variable $ts3 set the connection with the server, what i dont understand is the variable $client, what is in this variable? after "if($client['connection_client_ip'] <> $ip) continue;" where the code identify your client, after this, what are inside this variable? is correct how i have used this in the second IF?
 
Last edited:

Kieran

Tag me
Contributor
Jan 1, 2016
459
286
122
Idk you kind of mixed my html form element and php together.

Put this
PHP:
<?php
    $ip = $_SERVER['HTTP_CF_CONNECTING_IP']; // Use HTTP_CF_CONNECTING_IP if you have cloudflare
    $ts3 = TeamSpeak3::factory("serverquery://" . $config["Username"] . ":" . $config["Password"] . "@" . $config["IP"] . ":" . $config["qPort"] . "/?server_port=" . $config["Port"] . "&nickname=" . $config["Nickname"] . "");

    $arr_ClientList = $ts3->clientList();
    $ts3->clientListReset();
    $comboboxValues = '';
    foreach ($arr_ClientList as $client){
        if($client["client_type"] == 1) continue;
            if($client["connection_client_ip"] <> $ip) continue;
            $comboboxValues = $comboboxValues . '<option value="' . $client['client_nickname'] . '">' . $client['client_nickname'] . '</option>';
    
    }
?>
In the html file with the form.
Then put this
PHP:
<?php echo '<select required id="absender" size="1" class="form-control" name="client_name">' . $comboboxValues . '</select>'; ?>
Somewhere inside the html form element.


Then you can use
PHP:
$client = $ts3->clientGetByName($_POST['client_nickname']);
to get the details of the client. After that, add all the group stuff
PHP:
          if($_SERVER['HTTP_CF_CONNECTING_IP'] == $client['connection_client_ip']){
               $groupsArr = $client->memberOf();
                foreach ($groupsArr as $group)
                {
                    $groupsString = $groupsString . $group;
                }
                if (strstr($groupsString, 'Otaku Member') || strstr($groupsString, 'Apprendista Otaku'))
                {
                    $errormsg = "Sei Gia registrato!";
                    $error=true;
                }
        }
 if (!$error)
    {
            try
            {
                $nickname= $client["client_nickname"];
                $uid=$client["client_unique_identifier"];
                $ts3->serverGroupClientAdd(132, $client->client_database_id);
            } catch (Exception $e) {}
  
            $nome=$_POST['name'];
            $anni=$_POST['anni'];
            $conn=mysqli_connect($host_db,$Login_db,$pwd_db);
            mysqli_select_db($conn,$bdd_name);
            $request="INSERT INTO `regTS3`.`regTS3` (`Nome`, `Nickname`, `Anni`,`UniqueID`)
                                           VALUES ('$nome', '$nickname', '$anni','$uid' );";
            if(mysqli_query($conn,$request))
            {
                        
                    $successmsg = "Registrato con successo!";
            }else
            {
                    $errormsg = "Errore durante la registrazione...Riprovare piu tardi!";
            }
    }
 
Top