Fork me on GitHub Fork me on GitHub
Banner w bloku - Artykuły
Banner w bloku
  Posted on Thu 20 Jul 2006 by red_Slider (4422 reads)
q. Tworzymy własny blok (blok użytkownika) i wklejamy do niego nastepujacy kod:
Quote:
include_once XOOPS_ROOT_PATH.'/include/functions.php';
global $xoopsConfig;
$db =& Database::getInstance();
$bannerobject = '';
$bresult = $db->query("SELECT COUNT(*) FROM ".$db->prefix("banner"));
list ($numrows) = $db->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 = $db->query("SELECT * FROM ".$db->prefix("banner"), 1, $bannum);
list ($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult);
if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) {
// EMPTY
} else {
$db->queryF(sprintf("UPDATE %s SET impmade = impmade+1 WHERE bid = %u", $db->prefix("banner"), $bid));
}
/* Check if this impression is the last one and print the banner */
if ( $imptotal == $impmade ) {
$newid = $db->genId($db->prefix("bannerfinish")."_bid_seq");
$sql = sprintf("INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)", $db->prefix("bannerfinish"), $newid, $cid, $impmade, $clicks, $date, time());
$db->queryF($sql);
$db->queryF(sprintf("DELETE FROM %s WHERE bid = %u", $db->prefix("banner"), $bid));
}
if ($htmlbanner){
$bannerobject = $htmlcode;
}else{
$bannerobject = '<center><a href="'.XOOPS_URL.'/banners.php?op=click&bid='.$bid.'" target="_blank">';
if (stristr($imageurl, '.swf')) {
$bannerobject = $bannerobject
.'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://dąownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="468" height="60">'
.'<param name=movie value="'.$imageurl.'">'
.'<param name=quality value=high>'
.'<embed src="'.$imageurl.'" quality=high pluginspage="http://www.macromedia.com/shockwave/d ... ion=ShockwaveFlash"; type="application/x-shockwave-flash" width="468" height="60">'
.'</embed>'
.'</object>';
} else {
$bannerobject = $bannerobject.'<img src="'.$imageurl.'" alt="" />';
}

$bannerobject = $bannerobject.'</a></center>';
}
echo $bannerobject;
}


po nadaniou wszystkich niezbednych informacji (nazwa bloku, kolumna wyświetlenia itd) zapisz go jako php.

Pamiętaj by bannery, jakie masz w systemie nie były większe niż bloki, których używasz.

PS zwróć uwagę na wyróznioną linie, w której określasz wielkość banneru!
Index :: Print :: E-mail
The comments are owned by the author. We aren't responsible for their content.