Hello,
I have made a little script that displays an icon with a dynamic link, in order to allow my users to join a teamspeak server with the same name they have on the forum.
I'm not a PHP guru, sorry if my code isn't perfect.
Any member that belongs to membergroup #9 can see this icon with that link:
teamspeak://ts.mysite.com:9022/loginname=UserName?password=bingo?nickname=UserName
Example : Peter belongs to membergroup #9 he can see this link:
teamspeak://ts.mysite.com:9022/loginname=Peter?password=bingo?nickname=Peter
//Logo TS
if (in_array(9, $GLOBALS['user_info']['groups']))
{
echo '<a href=teamspeak://ts.mysite.com:9022/loginname=';
echo $context['user']['name'];
echo '?password=bingo?nickname=';
echo $context['user']['name'];
echo '><img src=Themes/SullenMadness_RC2/images/ts_ico2.jpg border=0></a>';
}
//end logo
This is working fine...but my problem is when a member has a UserName composed of at least 2 words (for instance "John Wayne") my code returns this link:
teamspeak://ts.mysite.com:9022/loginname=John
...The link ends at the 1st space in the UserName...
Why I don't have this kind of link?
teamspeak://ts.mysite.com:9022/loginname=John Wayne?password=bingo?nickname=John Wayne
Is there anything I can adapt in my code?
Thank you for the help (as usual) :)
try
//Logo TS
if (in_array(9, $GLOBALS['user_info']['groups']))
{
echo '<a href=teamspeak://ts.mysite.com:9022/loginname=';
echo urlencode($context['user']['name']);
echo '?password=bingo?nickname=';
echo urlencode($context['user']['name']);
echo '><img src=Themes/SullenMadness_RC2/images/ts_ico2.jpg border=0></a>';
}
//end logo
Non-alphanumeric characters should be encoded in urls.
Hello and thank you for the answer :)
It doesn't not work (but it's a good start!) because it returns this:
teamspeak://ts.mysite.com:9022/loginname=John+Wayne?password=bingo?nickname=John+Wayne
Do you have an idea?
That's what it has to return. The space in urls should be +
You're right but now my user is logged on teamspeak with John+Wayne instead of John Wayne :(
Or is any way to convert any + into space? (just for this part of code...I don't want to break the whole forum :D)
Sorry.
Try
//Logo TS
if (in_array(9, $GLOBALS['user_info']['groups']))
{
echo '<a href=teamspeak://ts.mysite.com:9022/loginname=';
echo urlencode($context['user']['name']);
echo '?password=bingo?nickname=';
echo urlencode($context['user']['name']);
echo '><img src=Themes/SullenMadness_RC2/images/ts_ico2.jpg border=0></a>';
}
//end logo
This will replace spaces with %20 maybe teampseak will understand it that it's the space character.
I am sorry but I don't see the difference between your last answer an your previous code ::)
Because there wasn't any. :-[
Here's the one it was supposed to be.
//Logo TS
if (in_array(9, $GLOBALS['user_info']['groups']))
{
echo '<a href=teamspeak://ts.mysite.com:9022/loginname=';
echo rawurlencode($context['user']['name']);
echo '?password=bingo?nickname=';
echo rawurlencode($context['user']['name']);
echo '><img src=Themes/SullenMadness_RC2/images/ts_ico2.jpg border=0></a>';
}
//end logo
It works!
Thank you a lot :)