PDA

View Full Version : .pl file.... i need colour in it!



Chris2k2
May 17th, 2002, 18:33
Hey

I got this User online script and its split into frames... but one frame points to my index.php and one points to whos_online.pl file... but i want to add colour to the whos_online.pl but when i try to add html code to it, it stops the users online script working and says no output.

Anyone got any ideas?

Dusty
May 17th, 2002, 18:38
What are you changing in the script? Show the orginal line then show us how you edited it.

Chris2k2
May 17th, 2002, 18:40
Right... if you go to http://www.24hrsimshop.com/ and look at the frame at the bottom i want that the rest of the colour of my website.

But how can i do this in a pl script as its stopping my output when i try to enter a colour code!

Dusty
May 17th, 2002, 18:52
But how are you editing whos_online.pl itself? After you opened the file, what did you do?

I can't really tell you how to change the color without seeing the script.

Chris2k2
May 17th, 2002, 18:54
#!c:\perl\bin\perlis.dll -w
use strict;

############################################################ #########################
#
# Who's Online? v1.0 (15/01/2002)
#
# Copyright (C) 2002 Mike Mackay
#
# Author : Mike Mackay
# Website : http://www.ultrafusion.co.uk/
# E-mail : scripts@ultrafusion.co.uk
#
############################################################ #########################
#
# This program may be used and modified free of charge by anyone so long
# as this copyright notice and the comments above remain intact. If you
# modify this script for the better, then please send a copy of the
# updated code to the email address shown above. If it gets included in
# the next release you will be fully credited.
#
# By using this code you agree to indemnify Mike Mackay from any liability
# that might arise from it's use publicly, or privately.
#
# Selling this programs code without prior written consent is expressly
# forbidden.
#
# Obtain permission before redistributing this software over the Internet
# or in any other medium. In all cases the copyright and header must remain
# intact at all times.
#
############################################################ #########################
#
# THE VARIABLES SHOWN HERE MAY BE MODIFIED TO SUIT YOUR NEEDS.
# MODIFY ONLY THE VALUES SHOWN INSIDE THE QUOTES, AND NOT THE VARIABLE NAMES
# OR THE SCRIPT MAY FAIL TO RUN.
#
############################################################ #########################
#
my $data_file="cgi-bin/count-file.dat"; # The file that keeps a record of the visitors.
my $timeout="300"; # The value (seconds) in which time to count visitors
#
############################################################ #########################
# DO NOT EDIT/MODIFY ANYTHING BELOW THIS LINE
############################################################ #########################

my $time_now=time;
my $visitor_ip=$ENV{'REMOTE_ADDR'};
my $visitors="1";
my(@new);

open(DATA, "$data_file")|| file_error("Error reading <u>$data_file</u> : $!");
my @data=<DATA>;
close(DATA);

foreach my $data_value (@data){
my($logged_ip, $logged_time) = split(/\|/, $data_value);
my $time_diff=$time_now-$logged_time;
push(@new, $data_value) if ($time_diff <= $timeout);
}

open(UPDATED, ">$data_file")|| file_error("Error writing to <u>$data_file</u> : $!");
foreach my $record (@new) {
my($logged_ip, $logged_time) = split(/\|/, $record);
print UPDATED "$record" if ($visitor_ip ne $logged_ip);
$visitors++ if ($visitor_ip ne $logged_ip);
}
print UPDATED "$visitor_ip|$time_now\n";
close(UPDATED);

sub file_error {
print "Content-type: text/html\n\n";
print "<font face=Verdana size=2>@_</font>";
exit;
}

print "Content-type: text/html\n\n";
print "$visitors";

exit;


Thats the scripts code.

Any help on adding colour into that would be great!

Dusty
May 17th, 2002, 18:57
Change:


print "Content-type: text/html\n\n";
print "$visitors";

Into:


print "Content-type: text/html\n\n";
print "<html><head><title></title></head><body bgcolor=\"#XXXXXX\"><font face=\"XXXX\" color=\"#XXXXXX\">".$visitors."</font></body></html>";

Then make the X's the colors and font face you want.

Chris2k2
May 17th, 2002, 18:59
Ok thanks mate i'll try it!

Oh just one more thing. How could i add text to it? Just in front of the colour code?

Dusty
May 17th, 2002, 19:04
Just add it in like normal HTML, but be sure to escape any quotes you might use (add a \ before them). For example, to add a title, you would change "<title></title>" to "<title>This is my title</title>".

Chris2k2
May 17th, 2002, 19:05
ok thanks!

If you look now there is a still a white line.... very annoying!

Dusty
May 17th, 2002, 19:10
White line? I don't see a white line, what browser are you using? If it's small and thin, it's probably the border between the frames. Check your frameset to make sure it's turned off and set to zero spacing.

<frameset rows="..." border="0" frameborder="0" framespacing="0">

Chris2k2
May 17th, 2002, 19:11
Im using Internet Explorer 6 and they are set to off and 0!

Chris2k2
May 17th, 2002, 19:12
Doesn't matter might just be me who can see it. Doesn't look that bad anyway.

Thanks for the help! :)

Dusty
May 17th, 2002, 19:14
I edited my post while you replied. I'm using Mozilla 1.0RC2 and, like I said, I don't see a line, but I'm certain that's the problem-- you don't have a spacing set and IE probably wants one.

Chris2k2
May 17th, 2002, 19:15
Well thats Microsoft for ya!! He He!

Chris2k2
May 17th, 2002, 19:18
Thanks for that code.

You see the code for the frames you got with the visitor thing was different to the one you put in your post.

They put it like this: <FRAMESET ROWS="*,32" BORDER="NONE" FRAMEBORDER="0">

Thanks again! :) :)