Current location: Hot Scripts Forums » Programming Languages » Perl » refresh script?


refresh script?

Reply
  #1 (permalink)  
Old 10-09-05, 01:33 PM
mikeyfaces mikeyfaces is offline
New Member
 
Join Date: Oct 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
refresh script?

okay, so i got this piece of script from a friend years ago, it simply put makes a random image appear from a list of url's.

now, what i would like to do is make this script automatically refresh at a given interval.

i don't want to have to make the entire page refresh to get the script going again, i just want the script to re-run itself at a specified interval.

i am completely lost as to how to do this! :-/
mike

======================================
#Variables:
$RandomTextFile = "../mainimages/Random-IMG.txt";
$BaseImgURL = "http://www.url.com/mainimages/";
#Options:
$UseLog = 0; # Use Log File ? 1 = YES; 0 = NO
$LogFile = "../mainimages/Random-Text-Log.txt";

srand(time);
open(LINKS,"$RandomTextFile") || &Error("Cannot Open Links File : $RandomTextFile, Error $!\n");
$NbLines = @IMGFile = <LINKS>;
close(LINKS);

$Url = $IMGFile[int rand $NbLines];

if ($UseLog) {
@date = localtime(time); $date[4]++; $date[5] += 1900;
$Time = "$date[4]/$date[3]/$date[5]";
open(LOG,">>$LogFile") || &Error("Cannot Write Log File : $LogFile, Error $!\n");
print LOG "[$Time] - $ENV{'REMOTE_HOST'} -> $Url\n";
close(LOG);
}

if ($Url =~ /^http:\/\//) {
print "Location: $Url\n\n";
} else {
print "Location: $BaseImgURL$Url\n\n";
}

sub Error {
my($ErrorText) = @_;
exit;
}
==================================
Reply With Quote
  #2 (permalink)  
Old 10-10-05, 08:49 AM
ser ser is offline
Newbie Coder
 
Join Date: Jun 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Try to modify HTTP header as shown below, add httpd header named "Refresh".
PHP Code:

if ($Url =~ /^http:\/\//) {

# Add this line
  
print "Refresh: $refresh_time;$url_of_this_script\n";
#------------
  
print "Location: $Url\n\n";
} else {
# Add this line
  
print "Refresh: $refresh_time;$url_of_this_script\n";
#------------
  
print "Location: $BaseImgURL$Url\n\n";

P.S.: Don't forget to define $refresh_time and $url_of_this_script, of replace them with appropriate values.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Your Own Profitable and VERY unique eBusiness Voltaire General Advertisements 3 03-30-10 06:36 AM
Raffle/Lottery Script (Very profitable!), Coded it myself. Voltaire General Advertisements 6 03-16-09 07:15 AM
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
Using crond to run a php script with redirect and refresh php_newbie PHP 2 02-09-04 12:03 PM


All times are GMT -5. The time now is 04:07 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.