Advertisement Rotation on Refresh

//open dier
$dir=opendir("Demo/ads/");
//get each file and exclude some stuffs
while($file=readdir($dir))
{
if($file!="."&&$file!="..")
{
$stringarray = $stringarray.$file. " ";
}//end of if
}//end of while($file=readdir($dir))
//convert string "array" into "real array"
$filearray = explode(" ",$stringarray);
$count = count($filearray)-2;
//create random number
$rand=rand(0,$count);
//show an add
echo "
<a href='adgo.php?ad=$filearray[$rand]'><img src='Demo/ads/$filearray[$rand]' border=0></a>
";
//Html Code Start Here
<p>Please Wait... <!--<meta http-equiv='refresh' content='3'> -->
<a href="">Click Here To Refresh Page</a>
Index.php
$ad=$_GET['ad'];
switch($ad)
{
case "ad1.gif";
header ("Location: http://www.google.co.in");
break;
case "ad2.gif";
header ("Location: http://www.yahoo.com");
break;
}//end of switch

Please Wait... Click Here To Refresh Page
//open dier
$dir=opendir("Demo/ads/");
//get each file and exclude some stuffs
while($file=readdir($dir))
{
if($file!="."&&$file!="..")
{
$stringarray = $stringarray.$file. " ";
}//end of if
}//end of while($file=readdir($dir))
//convert string "array" into "real array"
$filearray = explode(" ",$stringarray);
$count = count($filearray)-2;
//create random number
$rand=rand(0,$count);
//show an add
echo "
<a href='adgo.php?ad=$filearray[$rand]'><img src='Demo/ads/$filearray[$rand]' border=0></a>
";
//Html Code Start Here
<p>Please Wait... <!--<meta http-equiv='refresh' content='3'> -->
<a href="">Click Here To Refresh Page</a>
Index.php
$ad=$_GET['ad'];
switch($ad)
{
case "ad1.gif";
header ("Location: http://www.google.co.in");
break;
case "ad2.gif";
header ("Location: http://www.yahoo.com");
break;
}//end of switch
No comments:
Post a Comment