<?php
include "../data/config.php";
$stunde = date("H");
$banners = array();
$sql = "SELECT
id,
pfad,
link,
anzahl,
angezeigt
FROM
banner
WHERE
datum_start <= NOW() && zeit_start <= $stunde && zeit_ende > $stunde
";
$return = mysql_query($sql) OR die(mysql_error());
while($data = mysql_fetch_assoc($return))
{
for($x = 0; $x < $data['anzahl']; $x++)
{
$next = count($banners);
$banners[$next]['id'] = $data['id'];
$banners[$next]['pfad'] = $data['pfad'];
$banners[$next]['link'] = $data['link'];
$banners[$next]['angezeigt'] = $data['angezeigt'];
}
}
#echo "<pre>";print_r($banners);echo "</pre>";
$summe = count($banners) -1;
mt_srand((double)microtime()*1000000);
$random = mt_rand(0, $summe);
if(preg_match("/^google$/i",$banners[$random]['pfad']))
{
?>
<script type="text/javascript">
<!--
google_ad_client = "pub-0495625609562971";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_channel = "";
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<?php
}
else
{
?>
<a href="../data/impressum_jump.php?banner=<?php echo $banners[$random]['id']; ?>" target="_blank" title="<?php echo $banners[$random]['link']; ?>">
<img src="<?php echo $banners[$random]['pfad']; ?>" alt="<?php echo $banners[$random]['link']; ?>" width="468" height="60" border="0" style="display:block;border:none;">
</a>
<?php
}
$sql = "UPDATE
banner
SET
angezeigt = '".++$banners[$random]['angezeigt']."'
WHERE
id = '".$banners[$random]['id']."'
";
$return = mysql_query($sql) OR die(mysql_error());
?>