Gepostet am:17.02.2003 18:45
#4
Hack: Banner-Reload
17.02.2003 18:45 Hi
Ich habe mit Unterstützung eine schöne Lösung für einen Banner-Reload. Also daß ein Werbebanner nach x Sekunden neu geladen wird.
Anleitung
eine banner.php erstellen mit folgendem Inhalt:
<?php
include("mainfile.php");
$lvc_include_dir = XOOPS_ROOT_PATH."/modules/visitors2/include/";
if ( file_exists($lvc_include_dir."new-visitor.inc.php") ) {
$stat_mod = XoopsModule::getByDirname("visitors2");
if ( $stat_mod && $stat_mod->isActivated() ) {
$ignore_messages = true;
include($lvc_include_dir."config.php");
include($lvc_include_dir."new-visitor.inc.php");
}
}
//check if start page is defined
loadbanner();
?>
Dann die includes/functions.php so verändern:
function showbanner durch das ersetzen:
/* ****************************************
* Function to display banners in all pages
***************************************** */
function loadbanner() {
global $xoopsDB, $xoopsConfig, $REMOTE_ADDR;
$bresult = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("banner")."");
list ($numrows) = $xoopsDB->fetchRow($bresult);
if ( $numrows > 1 ) {
$numrows = $numrows-1;
mt_srand((double)microtime()*1000000);
$bannum = mt_rand(0, $numrows);
} else {
$bannum = 0;
}
if ( $numrows > 0 ) {
$bresult = $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("banner")."",1,$bannum);
list ($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date) = $xoopsDB->fetchRow($bresult);
if ( $xoopsConfig['my_ip']==$REMOTE_ADDR ) {
// EMPTY
} else {
$xoopsDB->queryF("UPDATE ".$xoopsDB->prefix("banner")." SET impmade=impmade+1 WHERE bid=$bid");
}
/* Check if this impression is the last one and print the banner */
if ( $imptotal == $impmade ) {
$newid = $xoopsDB->genId($xoopsDB->prefix("bannerfinish")."_bid_seq");
$xoopsDB->queryF("INSERT INTO ".$xoopsDB->prefix("bannerfinish")." (bid, cid, impressions, clicks, datestart, dateend) VALUES ($newid, $cid, $impmade, $clicks, $date, ".time().")");
$xoopsDB->queryF("DELETE FROM ".$xoopsDB->prefix("banner")." WHERE bid=".$bid."");
}
echo "<html><head><meta http-equiv='refresh' content='120; URL='http://www.enzephalon.de/new/banner.php'></head>";
echo "<BODY leftmargin='0' topmargin='0' marginwith='0' marginhight='0'>";
echo "<div><img src='".XOOPS_URL."/images/werbung.gif'><a href='".XOOPS_URL."/banners.php?op=click&bid=$bid' target='_blank'><img src='$imageurl' alt='' /></a></div>";
echo "</body></html>";
}
}
und das noch in die includes/functions.php einfügen:
function showbanner() {
echo "<iframe src='http://www.enzephalon.de/new/banner.php' framespacing='0' frameborder='no' scrolling='no' width='482' height='60'></iframe>";
}
Viel Spaß!
EnzephaloN