hooly_kooly_alli_n
02-14-2006, 09:08 PM
I wanna have a thing where it sais like *webmistress* is currently online/offline. like so they know if they can im me or not? does n e one know how to do that with html?
|
View Full Version : c if im online (with html) hooly_kooly_alli_n 02-14-2006, 09:08 PM I wanna have a thing where it sais like *webmistress* is currently online/offline. like so they know if they can im me or not? does n e one know how to do that with html? Annlander 02-14-2006, 09:48 PM One solution if you have Yahoo Messenger is to use Yahoo Presence (http://messenger.yahoo.com/messenger/help/online.html):cheese: Combat Babe 02-14-2006, 10:00 PM There is a way to do this yourself, but I don't think it is possible with plain html. However, I did a short google of "online status" and I found a service that looks quite promising: http://www.onlinestatus.org/ According to it, it will show them if you are on the messenger and comes with default icons, or you can make your own icon to match your site. war59312 02-15-2006, 06:25 AM Hey, So you want to show users if you are online or offline on your web site? And online or offline of what, your site or AIM, MSN, etc. or something else? Anyways, yes you can show your users if your online or not, that is if your currently on your web site or not. This can be done using php. Basicly what you need is a simple if else script. All the script does is check if a certian ip address, (in this case your ip) is at your web site atm. So something like this (replace yourIP with your ip address - dont know your ip address well then see my example below, it will tell you): <?php $online = $_SERVER["REMOTE_ADDR"]; if ( $online == "yourIP" ) { echo "webmistress is currently on-line" . "<br />"; } else { echo "webmistress is currently off-line" . "<br />"; } echo "Your IP Address Is: " . $online ?> Example: http://www.war59312.com/ip.php Now this is just an example. Its not really worth using because it would only show me online at the excat moment I made a request on war59312.com . Its just a demo. So basicly to make it worth something you would want to look up requests made in say the past 15mins and if your included then you would save your online. Plus you should cache the result for say 5mins that way you not hammering your server every time someone requests the page, only every five mins. Well good luck, Will hooly_kooly_alli_n 02-15-2006, 07:14 PM Thanx for all the help. Um... the code u gave me wasnt working. it didnt not work exactly, just nothing was showing up. and i checked out the website and for somereason it wont let me get one. anyways, i got some ideas from your ideas and now i got it. thanx. iTux 02-15-2006, 07:51 PM Just a modification to war59312s code, if you use a wireless card or have multiple computers that you use this is what you should use <?php $online = $_SERVER["REMOTE_ADDR"]; if ( $online == "yourIP" || $online == "yourIP2" || $online == "yourIP3") { echo "webmistress is currently on-line" . "<br />"; } else { echo "webmistress is currently off-line" . "<br />"; } echo "Your IP Address Is: " . $online ?> And if you want to add more IP addresses this is the code you use || $online == "anotherIP" Put that next to where it says || $online == "yourIP3" when you want to include it somewhere, make it a seperate file and use this code in any page you want it to show it in <? include("online.php"); Also if you need to change the extenstion of the file from .html or .htm to .php to make it work. war59312 02-16-2006, 02:28 PM Thanx for all the help. Um... the code u gave me wasnt working. it didnt not work exactly, just nothing was showing up. and i checked out the website and for somereason it wont let me get one. anyways, i got some ideas from your ideas and now i got it. thanx. Um OK I'm bored. ;) Read the comments! OH and yeah its not secure at all. Anyone can read the ip.txt file and its in clear text. Though if you notice for my demo i don't allow access to ip.txt via httacess so thats a simple way to prevent someone from accessing the log file other than the script. But still since it includes ip address which can identify people it should be private so the data should be encrypted. BTW again its just a demo and uses a flat text file. The best way would be to store to a database instead like mysql in which the data is encrypted via md5. So again don't use in real environment. Enjoy, Will Demo: http://www.war59312.com/testing/online.php <?php $rip = $_SERVER['REMOTE_ADDR']; //Get User's IP Address $sd = time(); //Record Time Of Hit $count = 1; //Counter Must Start At 1 $file1 = "ip.txt"; //Reading The Log File $lines = file($file1); $line2 = ""; foreach ($lines as $line_num => $line) { //Read Data From File $fp = strpos($line,'****'); $nam = substr($line,0,$fp); $sp = strpos($line,'++++'); $val = substr($line,$fp+4,$sp-($fp+4)); $diff = $sd-$val; if($diff < 300 && $nam != $rip) //Cache Record For 300 Secs Or Five Mins { $count = $count+1; $line2 = $line2.$line; } } $my = $rip."****".$sd."++++\n"; //Write data to file $open1 = fopen($file1, "w"); fwrite($open1,"$line2"); fwrite($open1,"$my"); fclose($open1); $filename = "ip.txt"; //File which holds all data - make sure its chmod 777 or you wont be able to read the file if (!$file_handle = fopen($filename,"r")) { echo "ip.txt appears to not exist - make a new ip.txt file and upload it to same location as this script."; exit; //ip.txt does not appear to exist } if (!$file_contents = fread($file_handle, filesize($filename))) { echo "Cannot retrieve file contents of ip.txt - make sure ip.txt has been chmod 777."; exit; //you must chmod ip.txt 777 for this to work } else { $arrFp = file( $filename ); //Make array of file content lines $numAdds = count( $arrFp ); //Count no. of elements in the array, count email addresses } fclose($file_handle); //Done reading the log file so close it for($i=0; $i<$numAdds; $i++) { $emailAddress = trim( $arrFp[$i] ); //Trim email addresses before sending mails $emailAddress = substr($emailAddress, 0, 14); //Change to size of your ip address - its the ammount of chars including periods if ( $emailAddress == "yourIP" ) //Checks to see if your online so change to your ip address { echo "I am now online! Come say hi please." . "<br />"; //User Is Online so display that user is online and end script - no point reading log futher exit; } else { continue; //Seems user is offline so make sure .. continue to check log until log is done being read } } echo "I'm NOT online so leave me alone would you!" //I am sure that the user is 100% offline now ?> war59312 02-17-2006, 07:34 AM I meant chmod 666 btw. Not 777. Slip of the keyboard. ;) |