";} // Connexion a la base de données @$mysql_link = mysql_connect("$serveur","$user","$password"); @mysql_select_db("$base",$mysql_link); $sql = "select IdBan, UrlBan, GfxBan, RawCode, AltBan, Target from $table "; $sql .= "where ( ( ( (AffBan < AffMaxBan) AND (ClickBan < ClickMaxBan) "; $sql .= "AND (DateDebut <= CurDate()) AND (DateFin > CurDate()) ) or (Permanent='oui') )"; $sql .= "AND (Active='oui')"; // pour trouver une campagne ciblée if (isset($IdCat)) $sql .= " AND ( IdCategorie = $IdCat ) "; $sql .= " )"; @$res = mysql_query($sql,$mysql_link); @$NbBan=mysql_num_rows($res); if ($NbBan == 0 AND $Priorite == 3) { // Si pas de campagne ciblées permanente en cours on cherche campagne permananente $sql = "select IdBan, UrlBan, GfxBan, RawCode, AltBan, Target from $table "; $sql .= "where (Permanent='oui' AND Active='oui' )"; @$res = mysql_query($sql,$mysql_link); @$NbBan=mysql_num_rows($res); } if ($NbBan == 0 AND $Priorite == 3) { // Si pas de campagne permanent en cours on cherche une autre banniere $sql = "select IdBan, UrlBan, GfxBan, RawCode, AltBan, Target from $table "; $sql .= "where ( (AffBan < AffMaxBan) AND (ClickBan < ClickMaxBan) "; $sql .= "AND (DateDebut <= CurDate()) AND (DateFin > CurDate()) AND Active='oui' )"; @$res = mysql_query($sql,$mysql_link); @$NbBan=mysql_num_rows($res); } if ($NbBan) { // Si campagnes en cours // recherche aléatoire //echo $NbBan."
"; $BanIndex=rand(0,@$NbBan-1); $succ=mysql_data_seek($res,$BanIndex); $row=mysql_fetch_row($res); //echo $BanIndex."
"; // On affiche la bannière if ($row[3]<>"") echo $row[3]; else { echo ""; echo "$row[4]"; } // On ajoute un affichage de plus $sql="UPDATE $table SET AffBan = AffBan + 1 where IdBan = $row[0]"; mysql_query($sql,$mysql_link); // On ajoute un affichage de plus pour les stats $mois=date("m"); $annee=date("Y"); $IdPub=$row[0]; $sql="SELECT * FROM $table_stat WHERE ( (Id_Pub = $IdPub) AND (Mois_Stat = $mois) AND (Annee_Stat = $annee) )"; $query=mysql_query($sql,$mysql_link); $res=mysql_num_rows($query); if ($res > 0) { $sql="UPDATE $table_stat SET Aff_Stat = Aff_Stat + 1 WHERE ( (Id_Pub = $IdPub) AND (Mois_Stat = $mois) AND (Annee_Stat = $annee) )"; mysql_query($sql,$mysql_link); } else { $sql="INSERT INTO $table_stat VALUES ('$IdPub', '$mois', '$annee', '0', '1')"; mysql_query($sql,$mysql_link); } } else { if ($Priorite == 2 OR $Priorite == 3) { if (!$image_defaut) {$image_defaut = "admin/images/utilise_phpmypub_468x60.gif";} if (!$lien_defaut) {$lien_defaut = "http://www.phpmypub.net";} if (!$alt_defaut) {$alt_defaut = "PHP my Pub, gestionnaire de publicité";} // C'est la banniere à afficher si toutes les campagnes // sont épuisées echo ""; echo "$alt_defaut"; } } // initialisation des variables clefs $NbBan = ''; $IdPub = ''; @mysql_close(); ?>