View Full Version : a little help with redirect

04-25-2008, 01:25 AM
i am very unfamiliar with web page design. i need a script that will do the following.
*redirect to a different page every X seconds
*redirects in a targeted frame and repeats redirecting to a different url every X seconds
*never repeats a url
*reads the target url's from a text file
**EXAMPLE: redirects to "http://webaddress/folder/?id="+"000000" with "000000" being the data from the text file
***end address being "http://webaddress/folder/?id=000000"
*has a selection box to pick how many seconds before redirect

Any body know of something like this or could write a quick script? if you could i'd appreciate it and if not thats cool too.

04-25-2008, 01:45 AM
you'll be best off with a server-side language to do the text reading but this will work too.

var urls;
var redirectInterval = 5;
var targetFrameIndex = 0;
var cur_url = 0;
var sourceFileUrl = "config/urllist.txt";

function doRedirect(){
window.frames[targetFrameIndex].document.location = urls[cur_url];
cur_url = (cur_url + 1) % urls.length;

function processTextFile(){
if(this.readyState == 4 && this.status == 200){
urls = split(this.responseText, "\n");
setInterval("doRedirect()", redirectInterval*1000);

function setup(){
var xhr = new (window.XMLHttpRequest?XMLHttpRequest():ActiveXObject("MSXML.XMLHTTP"));
xhr.open("get", sourceFileUrl, true);
xhr.onreadystatechange = processTextFile;

window.onload = setup;

most everything should be on target, the setting of the url for the frame though i'm not 100% on (usually don't work with frames). just make sure you don't end up making your frame go outside of your domain, if you do, you won't be able to access the document property of the frame, giving an error & terminating the script.

file format would be like:

just seperate them by pressing the enter key

04-25-2008, 02:36 AM
thanks for the help. maybe you can help me with the whole project. i'm using a text file as a database to log profile url's such as myspace and i want it to automatically go through a list of url's randomly and not repeat any.the text file database is updated with html and php and i got most of that working except i dont know how i can prevent duplicate entries. its all source code for different projects that i've stripped of features and modified. here's what i got do far

if (isset($_POST['submitBtn'])){
// Get user input
$username = isset($_POST['username']) ? $_POST['username'] : '';

// Try to register the user
$error = registerUser($username);

<SCRIPT language=Javascript>
function isNumberKey(evt)
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

return true;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<title>Simple Id</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<div id="main">
<?php if ((!isset($_POST['submitBtn'])) || ($error != '')) {?>
<div class="caption">Register Id</div>
<div id="icon">&nbsp;</div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="registerform">
<table width="100%">
<tr><td>Id:</td><td> <input class="text" name="username" type="text" onkeypress="return isNumberKey(event)" /></td></tr>
<tr><td colspan="2" align="center"><input class="text" type="submit" name="submitBtn" value="Register" /></td></tr>

if (isset($_POST['submitBtn'])){

<div class="caption">Result:</div>
<div id="icon2">&nbsp;</div>
<div id="result">
<table width="100%"><tr><td><br/>
if ($error == '') {
echo " User id was registered successfully!<br/><br/>";
echo ' <a href="index.php">You can submit another id here.</a>';

else echo $error;



function registerUser($user){
$errorText = '';
if (strlen($user) < 6) $errorText = "Id must be six digits long.";

// Check user existance
$pfile = fopen("id.txt","a+");

while (!feof($pfile)) {
$line = fgets($pfile);
$tmp = explode(" ", $line);
if ($tmp[0] == $user) {
$errorText = "That user id is already registered!";

// If everything is OK -> store user data
if ($errorText == ''){

fwrite($pfile, "\r\n$user");


return $errorText;

which outputs the the text file id.txt which could look something like this
thanks ahead of time
(this script is to boost profile views, to use if you would register your id and open the refreshing script in a new window and let it run. you would be boosting other people's page views as they boost yours)

04-25-2008, 02:51 AM
hrm, this looks interesting... um, maybe just attach the files, there's a lot a lot of information in that post, could wrap the different regions inside code blocks too, it's just not readable (sorry :s)

04-25-2008, 03:06 AM
here's the entire script, just unzip it wherever php is installed. if this doesn't help i've added you to msn if that would be easier 6294