hi i have a free rotator script, but it is picking urls randomly is there any way i can get it to pick the first one then pick each one down the list. any help would be great.
<?php /* Free URL Rotator Script Version: 1.2 © iTechDev and LJScripts.com */ /* Your configuration file location */ $inc_file = "configuration.php"; /* DO NOT EDIT BELOW THIS LINE */ if (phpversion() <= '4.0.6') {$_SERVER=$HTTP_SERVER_VARS;$_POST=$HTTP_POST_VARS;$_GET=$HTTP_GET_VARS;$_ENV=$HTTP_ENV_VARS;$_COOKIE=$HTTP_COOKIE_VARS;} require($inc_file); if (empty($_SERVER['QUERY_STRING'])) { $urls = file($url_file); $url = ''; $cnt = 0; while (empty($url) and $cnt < 5) { $url = trim($urls[mt_rand(0, sizeof($urls) - 1)]); $cnt++; if ($cnt == 3) optimizeURLS(); } if (empty($url)) { echo("Could not find a URL to display. Please add one first."); exit; } header("Location: $url"); exit; } if (!empty($_SERVER['QUERY_STRING']) or strcmp($_POST['admin'], 'edurls') == 0 or strcmp($_POST['page'], 'edadmin') == 0 or strcmp($_GET['admin'], 'edurls') == 0 or strcmp($_GET['admin'], 'edadmin') == 0) { @session_start(); checkInvasion(); chkConfig($url_file, true); if (strcmp($_SERVER['QUERY_STRING'], 'LOGOUT') == 0) { $_SESSION = array(); @session_destroy(); header("Location: index.php?admin=edurls"); exit; } if (!empty($_POST['usern']) and !empty($_POST['passwd'])) { $_SESSION['admin_user'] = trim($_POST['usern']); $_SESSION['admin_pass'] = md5(trim($_POST['passwd'])); header("Location: ".$_SERVER['PHP_SELF'] . "?".$_SERVER['QUERY_STRING']); exit; } if (!isset($_SESSION['admin_user']) or !isset($_SESSION['admin_pass'])) { $_SESSION = array(); @session_destroy(); loginScreen(); exit; } else { if (strcmp($_SESSION['admin_user'], $login_username) != 0 or strcmp($_SESSION['admin_pass'], md5($login_password)) != 0) { $_SESSION = array(); @session_destroy(); loginScreen(); echo(""); exit; } } } ?> LJScripts Free Rotator Admin
Admin details were changed successfully!"; $_SESSION['admin_pass'] = md5($newpass); } else { ?>
<?php } } elseif (strcmp($_GET['admin'], 'edurls') == 0 or strcmp($_POST['admin'], 'edurls') == 0) { if (!empty($_POST['addnewurl'])) { $newurl = trim($_POST['addnewurl']); $newURLs = getURLs($newurl); if (count($newURLs) > 0) { $fp = fopen($url_file, "a"); for ($i = 0; $i < count($newURLs); $i++) @fwrite($fp, "$newURLs[$i]\n"); @fclose($fp); echo " ".count($newURLs)." New URL(s) successfully added."; } echo ""; } else if (count($_POST['del_url']) > 0) { $results = ""; $fp = @fopen($url_file, "r"); $read = @fread($fp, filesize($url_file)); @fclose($fp); $read = str_replace("\r", "", $read); $up_tot = 0; for ($i = 0; $i < count($_POST['del_url']); $i++) { $cur_url = trim($_POST['del_url'][$i]); if (!empty($cur_url)) { $read = str_replace("$cur_url\n", "", $read); $results .= "The URL \"$cur_url\" has been deleted"; $up_tot++; } }
} |
|||||||||||||
Add/Remove URL’s
|
/*
Functions
*/
function file_writer($fileurl,$contents)
{
$file=@fopen($fileurl,‘w’) or die("$fileurl File Doesn’t Exist");
if($contents)
{
if(@fwrite($file,$contents))
{
@fclose($file);
return true;
}
}
}
function chkConfig($url_file, $isURL = true)
{
if (!file_exists($url_file))
{
echo “Error! The rotator is not correctly configured - The “$url_file” file is not found!”;
exit;
}
if ($isURL and filesize($url_file) < 1)
{
echo “Error! Your rotator has no sites saved, there must be at least 2 (two) sites entered.”;
exit;
}
if (!is_readable($url_file) or !is_writable($url_file))
{
echo “Error! The rotator is not correctly set - The $url_file file is not readable or writable (CHMOD to 777)!”;
exit;
}
}
function loginScreen()
{
?>
Rotator Administration Login
Username : | |
Password : | |
function getURLs($url_str)
{
$ret_urls = array();
$url_str = str_replace("\r", ‘’, $url_str);
$tmp_u = explode("\n", $url_str);
for ($i = 0; $i < count($tmp_u); $i++)
{
$uval = trim($tmp_u[$i]);
if (empty($uval)) continue;
if (!empty($uval) and (preg_match(’/http:///i’, $uval) or preg_match(’/https:///i’, $uval)) and preg_match(’/./’, $uval)) $ret_urls[] = $uval;
else echo("
$uval was not a valid URL!");
}
return $ret_urls;
}
function checkInvasion()
{
if (isset($_REQUEST[’_SESSION’]) or isset($_POST[’_SESSION’]) or isset($_GET[’_SESSION’]) or isset($_COOKIE[’_SESSION’]))
{
header(“Location: index.php”);
@session_destroy();
exit;
}
}
function optimizeURLS()
{
global $url_file;
$new_str = “”;
$urls = @file($url_file);
for ($i = 0; $i < @sizeof($urls); $i++)
{
$ourl = trim($urls[$i]);
if (!empty($ourl)) $new_str .= $ourl."\n";
}
$fp = @fopen($url_file, “w”);
@fwrite($fp, $new_str);
@fclose($fp);
}
?>