Hacks

Revolution Xoops Banner System!

slyss  11-Nov-2009 08:11 12702 Reads   15 Comment(s) 
Please, go to your root_directory/include/ and open the file functions.php
Go to the end of the file functions.php and before the tag ?> insert this code:

function getbanner_from_id_banner($banner_id)
{
###### Hack by www.stefanosilvestrini.com ######
global $xoopsConfig;
$db =& Database::getInstance();
$bresult $db->query("SELECT COUNT(*) FROM ".$db->prefix("banner")." WHERE bid = "$banner_id);
list (
$numrows) = $db->fetchRow($bresult);
if ( 
$numrows ) {
$numrows $numrows-1;
mt_srand((double)microtime()*1000000);
$bannum mt_rand(0$numrows);
} else {
$bannum 0;
}
if ( 
$numrows ) {
$bresult $db->query("SELECT * FROM ".$db->prefix("banner")." WHERE bid = "$banner_id1$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$datetime());
$db->queryF($sql);
$db->queryF(sprintf("DELETE FROM %s WHERE bid = %u"$db->prefix("banner"), $bid));
}
if (
$htmlbanner){
$bannerobject $htmlcode;
}else{
$bannerobject '.XOOPS_URL.'/banners.php?op=click&bid='.$bid.'" rel="nofollow">';
if (
stristr($imageurl'.swf')) {
$bannerobject $bannerobject
.''
.'.$imageurl.'">'
.''
.'.$imageurl.'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">'
.''
.'';
} else {
$bannerobject $bannerobject.'.$imageurl.'" alt="" />';
}

$bannerobject $bannerobject.'
';
}
return 
$bannerobject;
}
}

function 
getbanner_from_id_client($client_id)
{
###### Hack by www.stefanosilvestrini.com ######
global $xoopsConfig;
$db =& Database::getInstance();
$bresult $db->query("SELECT COUNT(*) FROM ".$db->prefix("banner")." WHERE cid = "$client_id);
list (
$numrows) = $db->fetchRow($bresult);
if ( 
$numrows ) {
$numrows $numrows-1;
mt_srand((double)microtime()*1000000);
$bannum mt_rand(0$numrows);
} else {
$bannum 0;
}
if ( 
$numrows ) {
$bresult $db->query("SELECT * FROM ".$db->prefix("banner")." WHERE cid = "$client_id ." ORDER BY rand()"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$datetime());
$db->queryF($sql);
$db->queryF(sprintf("DELETE FROM %s WHERE bid = %u"$db->prefix("banner"), $bid));
}
if (
$htmlbanner){
$bannerobject $htmlcode;
}else{
$bannerobject '.XOOPS_URL.'/banners.php?op=click&bid='.$bid.'" rel="nofollow">';
if (
stristr($imageurl'.swf')) {
$bannerobject $bannerobject
.''
.'.$imageurl.'">'
.''
.'.$imageurl.'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">'
.''
.'';
} else {
$bannerobject $bannerobject.'.$imageurl.'" alt="" />';
}

$bannerobject $bannerobject.'
';
}
return 
$bannerobject;
}
}


then SAVE and CLOSE.

Now there are 3 simple ways to create your BANNERS BLOCKS:

CASE 1:

Place your BANNERS in your blocks (no limit for number of blocks) anywhere you want! BANNERS will be shown randomly!

Add a new custom Xoops block PHP and insert this code:

echo xoops_getbanner();


CASE 2:

Place your BANNERS in your blocks (no limit for number of blocks) anywhere you want! BANNERS will be shown by ID_BANNER and so, e.g., you can select a specific BANNER in a specific block!

Add a new custom Xoops block PHP and insert this code:

echo getbanner_from_id_banner(ID_BANNER);


where ID_BANNER = ID of BANNER to SHOW (you can see this ID on your BANNERS admin page --> Banner ID on Current Active Banners)

CASE 3:

Place your BANNERS in your blocks (no limit for number of blocks) anywhere you want! BANNERS will be shown by ID_CLIENT and so, e.g., if a client has 10 banners, your BANNERS will be view random only from this 10 BANNERS!

Add a new custom Xoops block PHP and insert this code:

echo getbanner_from_id_client(ID_CLIENT);


where ID_CLIENT = ID of CLIENT of BANNERS to SHOW (you can see this ID on your BANNERS admin page --> Banner ID on Advertising Clients)

THAT'S ALL!
Rating 0/5
Rating: 0/5 (0 votes)
Voting is disabled!


Login

Who's Online

314 user(s) are online (90 user(s) are browsing Publisher)


Members: 0


Guests: 314


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits

Categories