Server LFS Join Link defined by a Username?
I like it!

And I think this can be done on the server side too ...
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.
Basically it's a friends gadget, its a fair way off from being finished...
A picture speaks a thousand words


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.

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 image) - possibly double-click so that you can't click it accidently

Hope you like my concept so far, btw

Quote from Victor :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...
that would be better, actually
#6 - Krane
Quote from Victor :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.");?
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
Quote from Flame CZE :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

Even better (reads only 29 bytes):

<?php 

function isOnline($uname)
{
    if(
$fp fopen("http://www.lfsworld.net/isonline.{$uname}"'r'))
    {
        if(
$data fread($fp29))
        {
            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;
}
?>

Nice, thanks, I will use that, too
Quote from morpha :Even better (reads only 29 bytes):

<?php 

function isOnline($uname)
{
    if(
$fp fopen("http://www.lfsworld.net/isonline.{$uname}"'r'))
    {
        if(
$data fread($fp29))
        {
            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
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

Quote from Victor :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="-----"></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... :\
Quote from Jamesisinthehouse12 :Hey, could I possibly have the coding for your "{$uname}" function? I'm very new to javascript
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 and retruns the number.
Quote from Jamesisinthehouse12 :
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*</a> ?

This can be done with PHP, too. You can use the file_get_contents() function to get the file contents to a string.

<?php 
$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...
Quote from Flame CZE :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
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... maybe hovering over the shows the current server they are at...
Quote from Flame CZE :(...) it opens the first 29 bytes of the image and then something I don't understand (...)

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.
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'." :\
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.
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 .html

in a file named .htaccess in the same location the .html is in.
Quote from morpha :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 .html

in 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.
Quote from bunder9999 :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.

Yes it would, but Jamesisinthehouse12 specifically asked (and later removed the question from his post) whether it's possible to parse .html files.
Quote from morpha :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

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...?

Quote from Victor :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. [url]lfs://follow=Dygear[/url]. 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.


<?php 
[url=lfs://follow=Dygear][img]http://www.lfsworld.net/isonline.USERNAME[/img][/url]
?>

Quote from Victor :Give this a try : [url]http://www.lfsworld.net/athost.USERNAME[/url]

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.

Quote from Flame CZE :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 and retruns the number.



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.

Quote from morpha :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.

Quote from Jamesisinthehouse12 :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 <? ?>.
Quote from Jamesisinthehouse12 :Which one of these options should I choose if I want it to run on whatever machine I'm using...?

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.
how exactly do I add the php file to the html file?... cause Windows Gadgets use html...?
Quote from Jamesisinthehouse12 :how exactly do I add the php file to the html file?... cause Windows Gadgets use html...?

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?
Quote from Victor :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
working again. Sorry about that.

FGED GREDG RDFGDR GSFDG