View Full Version : Server LFS Join Link defined by a Username?
Jamesisinthehouse12
15th December 2009, 12:40
Since the introduction of the LFS Join Links (http://www.lfsforum.net/showthread.php?t=63744) ("lfs://join=hostname"), do you think it would be possible to make a url like this except for retrieving another url? http://www.lfsworld.net/isonline.USERNAME
e.g. "http://www.lfsworld.net/serverlink.USERNAME (http://www.lfsworld.net/serverlink.USERNAME)"
Possibly provides a LFS Join Link to the server that the username is currently on? Like "lfs://join=hostname"?
What do you think? Just an idea... :shrug:
Dygear
15th December 2009, 13:06
I like it!
And I think this can be done on the server side too ...
Victor
16th December 2009, 16:51
mmmmmokey, i can do that fairly easily. I'm just wondering what it should return. Just the lfs://join=blahhere link as plain text?
What if someone is not online? Should it just return 'not online' or nothing at all?
In what context will that be used? I guess knowing that it'll make more sense to me, but atm i can't think of a useful scenario for this, so please enlighten me :)
PS, why not have it output just the hostname so you can create the link yourself? I mean, then it might be used in other scenarios as well, other than only providing an lfs: link.
Jamesisinthehouse12
16th December 2009, 17:03
A picture speaks a thousand words ;)
http://img43.imageshack.us/img43/7004/friendsgadget.jpg
Basically it's a friends gadget, its a fair way off from being finished... but this is the basic working concept which is a Windows Desktop Gadget. :thumb:
I was thinking of somehow returning that url with either a link or no link, that way... if someone was online there would be a link over the Online/Spectating or In The Pits status, and when they are offline it just wouldn't work at all... :) (over the http://www.lfsworld.net/isonline.USERNAME image) - possibly double-click so that you can't click it accidently :razz:
Hope you like my concept so far, btw :shy:
PS, why not have it output just the hostname so you can create the link yourself? I mean, then it might be used in other scenarios as well, other than only providing an lfs: link.
thats... a good idea :XD: don't know why I didn't think of that, although... you are Victor... :D
that would be better, actually :)
Victor
16th December 2009, 17:28
Give this a try : http://www.lfsworld.net/athost.USERNAME
If the user is offline or on a hidden host, nothing is returned (and so you shouldn't create the lfs: link)
Krane
16th December 2009, 17:35
What if someone is not online? Should it just return 'not online' or nothing at all?javascript:alert("User Nönnönnöö is not online.");?
Flame CZE
16th December 2009, 17:43
Well, nice feature Victor, thanks :)
I have dealed with it in another way, though. It very depends on the isonline image. When the image has got 1392 bytes, it means it's offline image. However, I don't know what would happen if you changed the images :D
morpha
16th December 2009, 17:59
Well, nice feature Victor, thanks :)
I have dealed with it in another way, though. It very depends on the isonline image. When the image has got 1392 bytes, it means it's offline image. However, I don't know what would happen if you changed the images :D
Even better (reads only 29 bytes):
<?
function isOnline($uname)
{
if($fp = fopen("http://www.lfsworld.net/isonline.{$uname}", 'r'))
{
if($data = fread($fp, 29))
{
switch(ord($data[28]))
{
case 199: // Racing
return 3;
case 255: // In the pits
return 2;
case 227: // Spectating
return 1;
case 236: // Offline
return 0;
default:
return false; // Images changed?
}
}
fclose($fp);
return false;
}
return false;
}
?>
Flame CZE
16th December 2009, 18:29
Nice, thanks, I will use that, too :thumbsup:
Jamesisinthehouse12
17th December 2009, 03:03
Even better (reads only 29 bytes):
<?
function isOnline($uname)
{
if($fp = fopen("http://www.lfsworld.net/isonline.{$uname}", 'r'))
{
if($data = fread($fp, 29))
{
switch(ord($data[28]))
{
case 199: // Racing
return 3;
case 255: // In the pits
return 2;
case 227: // Spectating
return 1;
case 236: // Offline
return 0;
default:
return false; // Images changed?
}
}
fclose($fp);
return false;
}
return false;
}
?>
Hey, could I possibly have the coding for your "{$uname}" function? I'm very new to javascript :shy:
also, how did you send the "http://www.lfsworld.net/isonline.{$uname}" out to an image file? (that coding would be cool too... :shy:)
P.S. Thanks Victor, this opens up a whole range of things for lfs... can't think of any right now xD, but this ability should bring out some cool stuff :thumb:
why not have it output just the hostname so you can create the link yourself?
I can understand javascript and how it works, I just can't put it together... if you know what I mean... how would I input the http://www.lfsworld.net/athost.USERNAME add the "lfs://join=" and "hostname" together (= "lfs://join=hostname") then send it to a <a href="-----">http://www.lfsworld.net/isonline.USERNAME</a> ?
function unameimg(k) {
if (document.images)
eval('document.img'+k+'.src=uname_img'+k+'.src');
}
function unameurl(k) {
if (document.URL)
eval('document.URL'+k+'.src=uname_url'+k+'.src');
}
if (document.images) {
uname_img1.src ='http://www.lfsworld.net/isonline.' + uname1;
uname_img2.src ='http://www.lfsworld.net/isonline.' + uname2;
uname_img3.src ='http://www.lfsworld.net/isonline.' + uname3;
uname_img4.src ='http://www.lfsworld.net/isonline.' + uname4;
uname_img5.src ='http://www.lfsworld.net/isonline.' + uname5;
uname_img6.src ='http://www.lfsworld.net/isonline.' + uname6;
uname_img7.src ='http://www.lfsworld.net/isonline.' + uname7;
uname_img8.src ='http://www.lfsworld.net/isonline.' + uname8;
uname_img9.src ='http://www.lfsworld.net/isonline.' + uname9;
uname_img10.src ='http://www.lfsworld.net/isonline.' + uname10;
uname_url1.src ='http://www.lfsworld.net/athost.' + uname1;
uname_url2.src ='http://www.lfsworld.net/athost.' + uname2;
uname_url3.src ='http://www.lfsworld.net/athost.' + uname3;
uname_url4.src ='http://www.lfsworld.net/athost.' + uname4;
uname_url5.src ='http://www.lfsworld.net/athost.' + uname5;
uname_url6.src ='http://www.lfsworld.net/athost.' + uname6;
uname_url7.src ='http://www.lfsworld.net/athost.' + uname7;
uname_url8.src ='http://www.lfsworld.net/athost.' + uname8;
uname_url9.src ='http://www.lfsworld.net/athost.' + uname9;
uname_url10.src ='http://www.lfsworld.net/athost.' + uname10;
}
something like this? :\ I know the url/athost needs more coding to retrieve the text from the link created... but I'm not sure how to do that... :\
Flame CZE
17th December 2009, 06:22
Hey, could I possibly have the coding for your "{$uname}" function? I'm very new to javascript :shy:
also, how did you send the "http://www.lfsworld.net/isonline.{$uname}" out to an image file? (that coding would be cool too... :shy:)
That's not JavaScript but PHP... He just coded a function, so when you write isOnline('Flame CZE');, it opens the first 29 bytes of the image and then something I don't understand :D and retruns the number.
I can understand javascript and how it works, I just can't put it together... if you know what I mean... how would I input the http://www.lfsworld.net/athost.USERNAME and then send it to a <a href="-----">* wrapped around this image*http://www.lfsworld.net/isonline.USERNAME</a> ?
This can be done with PHP, too. You can use the file_get_contents() function to get the file contents to a string.
$username = urlencode('Flame CZE');
$server = file_get_contents('http://www.lfsworld.net/athost.'.$username);
// if it outputs more than 1 character (is online)
if(strlen($server) > 0) {
echo '<a href="lfs://join='.$server.'">
<img src="http://www.lfsworld.net/isonline.'.$username'.">
</a>';
} else {
echo '<img src="http://www.lfsworld.net/isonline.'.$username'.">';
}
There should also be an encoding host name function, which Victor also posted in this forum somewhere.
I don't know how to make it in JavaScript, though...
Jamesisinthehouse12
17th December 2009, 06:30
There should also be an encoding host name function, which Victor also posted in this forum somewhere.
I don't know how to make it in JavaScript, though...
Awesome! Thanks man :thumb:
I don't need the name of the server they are at :)... although, not that I think about it... it would be handy to have... :D maybe hovering over the http://www.lfsworld.net/isonline.USERNAME shows the current server they are at... :shrug:
morpha
17th December 2009, 06:40
(...) it opens the first 29 bytes of the image and then something I don't understand :D (...)
The first 28 bytes are the GIF header, which is identical for all 4 images, but luckily the first byte of the actual image data is different. What it does is convert the literal to its numeric value and switch that to the appropriate status code.
Jamesisinthehouse12
17th December 2009, 07:01
I've stuck it in a html file with the <?php </?> around it... but the image just src's to "http://www.lfsworld.net/isonline.'.$username'." :\
Flame CZE
17th December 2009, 13:46
Can you please attach the entire code? Use <?php ?> or <? ?> for the php code. And I don't know if .html files can handle PHP or not.
morpha
17th December 2009, 14:05
Everything can be parsed through PHP, the file extension doesn't matter. What does matter is whether your server software supports it and if you have the necessary permissions to adjust the corresponding settings.
Where are you hosting the page? If you don't host it on your own machine, ask the company that hosts it. Depending on whether PHP is installed as CGI bin or apache module, a simple .htaccess could do the job.
Try AddType application/x-httpd-php .htmlin a file named .htaccess in the same location the .html is in.
bunder9999
17th December 2009, 15:31
Everything can be parsed through PHP, the file extension doesn't matter. What does matter is whether your server software supports it and if you have the necessary permissions to adjust the corresponding settings.
Where are you hosting the page? If you don't host it on your own machine, ask the company that hosts it. Depending on whether PHP is installed as CGI bin or apache module, a simple .htaccess could do the job.
Try AddType application/x-httpd-php .htmlin a file named .htaccess in the same location the .html is in.
wouldn't it be better to just rename the file to .php instead? it would put less overhead on the web server if it doesn't have to check each .html file for php code. :shrug:
morpha
17th December 2009, 16:06
wouldn't it be better to just rename the file to .php instead? it would put less overhead on the web server if it doesn't have to check each .html file for php code. :shrug:
Yes it would, but Jamesisinthehouse12 specifically asked (and later removed the question from his post) whether it's possible to parse .html files.
Jamesisinthehouse12
18th December 2009, 01:53
Yes it would, but Jamesisinthehouse12 specifically asked (and later removed the question from his post) whether it's possible to parse .html files.
yeh I did... sorry about that :shy:
Morpha, the htaccess didn't work btw... :shrugs:
Okay, I've made it a php file now... just cause its easier :P
Which one of these options should I choose if I want it to run on whatever machine I'm using...? :shrug:
http://img32.imageshack.us/img32/6213/testingserverwhichonexd.jpg
Dygear
18th December 2009, 02:35
mmmmmokey, i can do that fairly easily. I'm just wondering what it should return. Just the lfs://join=blahhere link as plain text?
What if someone is not online? Should it just return 'not online' or nothing at all?
In what context will that be used? I guess knowing that it'll make more sense to me, but atm i can't think of a useful scenario for this, so please enlighten me :)
PS, why not have it output just the hostname so you can create the link yourself? I mean, then it might be used in other scenarios as well, other than only providing an lfs: link.
What I was thinking was in fact more on Scawen's turf. Within LFS, it would accept the command follow with the value of Username. So for example the lfs join link would look like this. lfs://follow=Dygear. Then once the game is loaded LFS would check to see if the user is still connected to the server and if they are not tell them that the user is no longer online and weather or no they would still like to join the server they where last in, and it also allows you to build a link like this.
http://www.lfsworld.net/isonline.USERNAME (lfs://follow=Dygear)
Give this a try : http://www.lfsworld.net/athost.USERNAME
If the user is offline or on a hidden host, nothing is returned (and so you shouldn't create the lfs: link)
As a PHP programmer I like this also.
He just coded a function, so when you write isOnline('Flame CZE'); It opens the first 29 bytes of the image and then something I don't understand :D and retruns the number.
http://thinkreason.net/wp-content/uploads/2009/07/then-a-miracle-occurs-cartoon.png
I'm pretty sure it uses the ord function to return the value (in an integer form) of the first unique value (past the header of the image) for each of the images.
The first 28 bytes are the GIF header, which is identical for all 4 images, but luckily the first byte of the actual image data is different. What it does is convert the literal to its numeric value and switch that to the appropriate status code.
Beat me to it. :)
I've stuck it in a html file with the <?php </?> around it... but the image just src's to "http://www.lfsworld.net/isonline.'.$username'." :\
<?php </?>. <-- That's your problem. It should be <?php ?> or <? ?>.
boothy
18th December 2009, 03:09
Which one of these options should I choose if I want it to run on whatever machine I'm using...? :shrug:
Choose the one which suits the machine you're running it on? You're asking us for X when we don't even know Y. Although, if you have to ask whether you have PHP running on your machine then you probably don't.
If you're running on Windows don't get involved in the Dreamweaver pish, just open up the php files in your localhost or on a web server.
Jamesisinthehouse12
19th December 2009, 08:30
how exactly do I add the php file to the html file?... cause Windows Gadgets use html...? :shrug:
Dygear
19th December 2009, 10:38
how exactly do I add the php file to the html file?... cause Windows Gadgets use html...? :shrug:
Well, that really depends. Can Windows Gadgets run PHP? Can you setup a local apache / php / mysql install and use the apache parser inplace of the windows gadget function?
avetere
30th August 2010, 12:31
Give this a try : http://www.lfsworld.net/athost.USERNAME
If the user is offline or on a hidden host, nothing is returned (and so you shouldn't create the lfs: link)
I just recognized, that this service is down at the moment.
Have you suspended it, Victor, or will it be on again?
Thanks,
AV
Victor
30th August 2010, 12:44
working again. Sorry about that.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.