Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - PHP Online Indicator? | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 92/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 04-22-04 10:50 AM Link | Quote
Anyone know if there's some kinda php script you can use to geneatre an image showing your online status?

I'm thinking something that acts similar to the ICQ online indicator. Or is this not possible?
Vystrix Nexoth

Level: 30

Posts: 110/348
EXP: 158678
For next: 7191

Since: 03-15-04
From: somewhere between anima and animus

Since last post: 3 days
Last activity: 2 days
Posted on 04-22-04 09:52 PM Link | Quote
I'll assume that:
  • you already have a way to figure out whether a user is online or not; and
  • you already have prefabricated images available for each status; and
  • the images are named "online.png" and "offline.png"


<?php
include "figure_out_whether_user_is_online_or_not.php";

if (user_is_online())
{ $filename = 'online.png';
}
else
{ $filename = 'offline.png';
}

header ('Content-Type: image/png');
header ('Content-Length: '.filesize($filename));
readfile ($filename);

?>


the Content-Length line is not necessary; it's just a nicety. the Content-Type line, however, is required.

anyhow, all it does is figures out whether the user is online, and outputs either 'online.png' or 'offline.png' (as the document content) accordingly.

if you want to use .jpg images instead of .png, just change the Content-Type line to image/jpeg instead of image/png

HTH
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 93/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 04-23-04 01:37 AM Link | Quote
Originally posted by Vystrix Nexoth
I'll assume that:
  • you already have a way to figure out whether a user is online or not; and
I don't have anything for this.

I was really hoping it'd be a simple script, and then I could just whip up a couple of images, upload everything, and be good to go.

I knew it wouldn't be that easy, but I could hope hope, right?

Also, since I know that you're knowledgable about .png images, is there any way to have a .png with a fully transparent background, and NOT have to reduce it to 256 colors? Paint Shop Pro forces you to reduce an image to 256 colors before you can add a transparency, regardless of the image you're working with.
Darth Coby

Vire
Dacht je nou echt dat het over was?
Dacht je nou echt dat ik gebroken was? Nee toch?
Nou kijk eens goed op uit je ogen gast.
zonder clic heb je geen kloten tjap... bitch
Level: 55

Posts: 513/1371
EXP: 1240774
For next: 73415

Since: 03-15-04
From: Belgium

Since last post: 2 days
Last activity: 9 hours
Posted on 04-23-04 02:32 AM Link | Quote
You'll need to write a program that keeps telling the script that your online, a simple VB program that sets a variable each minute'll do.
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 97/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 04-23-04 09:19 AM Link | Quote
Oh, OK. No problem. Except that I don't know VB. Sucks to be me, eh?

I'm pretty much outta luck, since I don't have the knowledge needed to make something like this, but that's OK. This was more of an idle curiosity than an, "OMFG! I GOTA HAEB IT NOW!!11" thing.

Thanks for the info, though.
Vystrix Nexoth

Level: 30

Posts: 111/348
EXP: 158678
For next: 7191

Since: 03-15-04
From: somewhere between anima and animus

Since last post: 3 days
Last activity: 2 days
Posted on 04-25-04 10:55 PM Link | Quote
using VB? for one, I assume elric's server does not support ASP, and even if it did, that's way too complicated a solution. the board automatically records the last time you were online (meaning, you viewed a page while signed in).
the board uses Unix-style timestamps (which is the number of seconds since 01/01/1970 00:00 UTC), so:

if ($TimeUserWasLastOnline > time() - 3600)
{ user is online
}
else
{ user is not online
}


where 3600 = how long you want a user to be considered "online", in seconds (which in this case means one hour).

as for PNGs, that's a problem with the program you're using, not the PNG format itself. I can think of two ways to add binary (either 100% opaque or 100% transparent) transparency to an RGB image:
  • use an alpha channel
  • use a single color for the parts you want transparent (some color not used throughout the rest of the image, such as bright pink or such), and add a chunk in the PNG making that particular color transparent.


I found this program a while back, and have found it to be helpful. to do the second method (assigning one color as transparent), do this:
  1. save a regular 24-bit RGB image as a PNG file, without transparency, using pink (or some other color) in the parts you want transparent.
  2. open it in TweakPNG
  3. Insert -> tRNS (it's at the bottom)
  4. Double-click on the tRNS chunk that was inserted.
  5. type in the RGB value for the color to be transparent.
  6. Save, and rejoice.


...now, whether that will work in Internet Explorer or not, I don't know; I doubt that it will. alternately, you can try this, using the same program:
  1. save it as an 8-bit PNG, again, without actual transparency, but with one palette entry set aside for it.
  2. open it in tweakpng, and add a tRNS chunk as described above.
  3. double-click on it. In the "alpha values" box, type in the same number of colors are there are in the palette (so if there are 256 colors in the palette, type 256 in the "alpha values" box)
  4. find the color that you want to be transparent, and click on it. Type "0" in the box that pops up.
  5. Save.
  6. Buy war bonds!


again, hope this helps.


(edited by Vystrix Nexoth on 04-25-04 01:59 PM)
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 99/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 04-26-04 09:48 AM Link | Quote
Well, it's not for my board, actually. I'm registered at Gaia Online, a phpBB. Currently, the Online/Offline status is disabled, and the list of online users is hidden unless you click a link, since there are generally over 3,000 users on at any given time (there are 5,866 online right now). I just wanted to add a link to a php file as an image (i.e. <img src=http://www.blah.com/online.php>), so that anyone who wants to talk to me, or trade with me, will know if I'm online or not.

Of course, the more I think about it right now, I realize that even with a script, I'd probably have to edit my profile to make it show the right image. And I wanted a script so that I wouldn't have to do that, since I'd probably forget to edit me to offline before I signed off the net.

Ah well.

For the .PNG files, I do include one color for the transparency that isn't used for anything else. However, as soon as I click the button to set the transpareny, it pops up a window, telling me that the image HAS to be reduced to 256 colors. I even tried PhotoShop once, and the same thing happend. Same thing happened with the few different image editors my wife has on her laptop.

The ONLY place I see ANYTHING that mentions Alpha channel is things involving something called "masks". I have NO idea what that is...
Vystrix Nexoth

Level: 30

Posts: 115/348
EXP: 158678
For next: 7191

Since: 03-15-04
From: somewhere between anima and animus

Since last post: 3 days
Last activity: 2 days
Posted on 04-28-04 04:31 AM Link | Quote
mask == alpha channel

anyhow, what you do is allocate a transparent color, but without actually making it transparent in photoshop. just have it be a plain old 256-color image, no transparency or anything. save it. then, open it in TweakPNG and define that color as being transparent, yourself, as described in my previous post.

and I assumed you were making this for an AcmlmBoard; I don't know what format phpBB uses to record a user's online status, so I can't help you there (although if it uses unix timestamps like AB does, then the basic method is the same).
kiwibonga

Double metal axe
Level: 27

Posts: 92/266
EXP: 106040
For next: 10119

Since: 03-15-04
From: Montreal, QC, Canada

Since last post: 126 days
Last activity: 3 days
Posted on 04-28-04 04:56 PM Link | Quote
You know, you can simply use a header() redirect for this

<?php

if(user is online)
{
$file="online.png";
}
else
{
$file="offline.png";
}

header("Location: http://www.whatever.com/$file");

?>

As for something that lets people know whether you're online... I have 3 ideas:

1. Make a desktop background item which is actually a php page that updates the last online time and keeps opening the page every 20 minutes or so

2. If you're using AIM, find a way to change the url where AIM fetches the ads and make that your online status refresh script

3. If you use IRC, make a simple script that opens the page with a timer, it would update your status whenever the IRC client is open.

It would prevent you from writing a program
Vystrix Nexoth

Level: 30

Posts: 116/348
EXP: 158678
For next: 7191

Since: 03-15-04
From: somewhere between anima and animus

Since last post: 3 days
Last activity: 2 days
Posted on 04-29-04 10:33 AM Link | Quote
4. have the system (message board, etc) keep track of the last time you were online (which, for example, AB already does). when you go to check if a user is online, compare that time to the current time.
much simpler, less klugy, is accurate to within one second, unlike the other methods which are accurate only to within 20 minutes (or however frequently the scripts are run), and
  • does not require you to change your desktop (not to mention using the buggy "active desktop")
  • works whether or not you use AIM, ICQ, or any IM program


as for the header() suggestion, it did occur to me, however, having different results returned in the same file creates a canonical name for online status. but using such a method by no means means that you do not "have to program"!
  • a program is a program, whether it's a simple "pick one or the other" script or a full-blown forum engine.
  • you still have to determine whether the user is online or not.
in this sense, it's the same amount of programming (in one method, you pick which file to pass through; in the other, you pick which file to redirect to).

I'd rather use the pass-through method myself, but the redirection method would be:

<php
if ($user_is_online)
header ('Location: online.png');
else
header ('Location: offline.png');
?>

by no means perfect code (technically, it is in violation of HTTP spec by giving relative URIs in the Location: fields) but it should work in most cases.
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 103/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 04-30-04 08:15 AM Link | Quote
This is not a board I run, just one I visit, so I can't have it do anything. Sorry.
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - PHP Online Indicator? | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.016 seconds.