Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-21-2004, 01:55 PM Help - Php Script
Junior Talker

Posts: 1
Location: Scotland
Trades: 0
Hi Guys,

I need some help with this script... i run a wallpaper site and i found this script for rotating ads... i was looking for the same idea but with a wallpaper of the week that automatically goes to a different wallpaper every 7 days...

I have tried messing about with this one but could not quite get it to work, can anyone help modify this or create one for me...


Thanks guys

Jonny....

<?PHP
// Functions:

// Gives today's date with no time
function todaysDate()
{
list($dd,$mm,$yyyy) = split("-",date("d-m-Y",time()));
return makeDateValue($dd,$mm,$yyyy);
}

function makeDateValue($dd,$mm,$yyyy)
{
return mktime(0, 0, 0, $mm, $dd, $yyyy);
}


?>
<SCRIPT LANGUAGE="JavaScript">
// Setup
var curAd;
var ads = new Array();
var delays = new Array();
var linx = new Array();
var external = new Array();
function displayAd()
{
var adLink = document.getElementById("ADLINK");
var ad = document.getElementById("AD");
if (ads.length)
{
ad.src = "./"+ads[curAd];
adLink.href=linx[curAd];
if (external[curAd])
{
adLink.target="_blank";
}
else
{
// It's one of our own!
adLink.target="_blank";
}
if (ads.length > 1)
// Skip refresh if we only have 1 ad!
setTimeout("displayAd()",delays[curAd]*1000);
// Move on
curAd = (++curAd) % ads.length;
}
}
</SCRIPT>

<DIV align=center>
<A id=ADLINK href="#">
<IMG id=AD border=0 src="#">
</A>

<SCRIPT LANGUAGE="JavaScript">
// Setup
var i = 0;

// PHP generated JavaScript array:
<?php
$fd = fopen ("./Ads/ads.csv", "r");
if ($fd)
{
$adsUsed = 0;
$today = todaysDate();
$line = null;
while (!feof ($fd))
{
if (!$line)
{
// Skip header
$line = fgets($fd, 4096);
}
else
{
$line = fgets($fd, 4096);
if (strlen($line) > 10)
{
list($startDate,$durationMonths,$adDurationSecs,$p ipeSeparatedImages,$URL) = split (",", $line, 5);
list($dd,$mm,$yyyy)= split ("\/", $startDate, 3);
$startDateTime = mktime(0, 0, 0, $mm, $dd, $yyyy);
$endDateTime = mktime(0, 0, 0, $mm + $durationMonths, $dd, $yyyy);
if ($durationMonths < 0 || ($durationMonths > 0 && ($startDateTime <= $today ) && ($today <= $endDateTime)))
{
// We've got a contender
++$adsUsed;
$image = split("\|",$pipeSeparatedImages);
foreach($image as $anImage)
{
if (strtolower(substr($URL,0,7))=="http://")
{
echo "external[i]=true;\n";
}
echo "ads[i] = \"$anImage\";\n";
echo "linx[i] = \"".rtrim($URL)."\";\n";
echo "delays[i++] = $adDurationSecs;\n";
}
}
}
}
}
fclose($fd);
}
?>
// Prevent same start ad being shown on every new page.. add random element
curAd = <?php echo rand(0,$adsUsed - 1); ?>;
displayAd();
</SCRIPT>
</DIV>
J-Rock is offline
Reply With Quote
View Public Profile Visit J-Rock's homepage!
 
 
Register now for full access!
Reply     « Reply to Help - Php Script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08770 seconds with 12 queries