Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

popup url-rotation (links in CLEAN textfile)

Hey experts

Is there an easy way to rotate a list of url's in popups (automatic), with the following 4 demands:
1) The script must read the Url-list from a seperate textfile

2) The Urls can be both locale and global ones

3) The popups should stop after running the last Url from the textfile

4) Url-textfile should be easy the config., and should ONLY CONSIST of the links like:  
http://www.link1.html
http://www.link1.html
http://www.link1.html
...

And therefore NOT like (ex. Array style):
Url[1]=4http://www.link1.html4
Url[2]=4http://www.link2.html4
Url[3]=4http://www.link3.html4
....

Can anyone please help!
Carl
0
cebh
Asked:
cebh
  • 2
1 Solution
 
DennisParaguayCommented:
************************************
#!/usr/bin/perl

$cnt = 0;
$localpath = 'http://www.mywebsite.com/myfolder/';

open(LINKS,"<name_of_the_textfile");
while ($link = <LINKS>)
{
      $links[$cnt++] = $link;
}
close(LINKS);

(@time) = gmtime(time);
$rnd = $time[0] / 60 * $cnt;
$url = "$links[$rnd];

$url = $localpath.$url if ($url !~ /\Ahttp\:\/\//i);

print "Location: $url";

die;
************************************

Should work.

I didnĀ“t get what "The popups should stop after running the last Url from the textfile" means, sorry.

-Dennis
0
 
DennisParaguayCommented:
Sorry for the typo.

Line 15 must be:

******************
$url = $links[$rnd];
******************

-Dennis
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now