MyXoops Forum

Hack: Banner-Reload [Script-Workshop] - myXOOPS German Support

enzephalon

"myXOOPs"-Neuling
Gepostet am:17.02.2003 18:45
enzephalon
enzephalon Offline (Show more)
"myXOOPs"-Neuling
Posts: 43
Since: 04.02.2003
#1

Hack: Banner-Reload

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 ) {
     
$numrows $numrows-1;
      
mt_srand((double)microtime()*1000000);
      
$bannum mt_rand(0$numrows);
       } else {
      
$bannum 0;
        }
       if ( 
$numrows ) {
     
$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
MOMENT OF TERROR IS THE BEGINNING OF LIFE
EnzephaloN ist Moderator bei WinHelpline.info
Diesen Thread durchsuchen:  1 Anonyme Benutzer

Aktuell aus dem Forum

Forum Thema Antworten Views Letzter Beitrag