Jump to content

Function Show Banner


balkan7

Recommended Posts

soryy my previous topic are solved and i start new topic whit good example to create 2 function for show banners, here is detail inforamtion for that...

 

banner_plans - i got 5 : 1. header, 2. sub-header, 3.right, 4.right2 and 5. footer.

banner_type - 0 is image, 1 is flash.

banner_state - 0 is inactive, 1 is active

 

plans 1,2,5 have same width and height, i wanna create one function for this.

plan 3 have difrent width and height, maybe need new function for this

and plan 4 have difrent W and H. same like plan 3.

 

code for Prepare Banners for display, functions are:

 

<?php function ss($text){
return stripslashes($text);
}

function setBannerView($banData){
global $db_prefix;
$currentData = explode(".", $banData['banner_clicks']);
$newViews = $currentData[1] + 1;
$lastData = implode(".", array($currentData[0], $newViews)); 
$updateViews = dbquery("UPDATE ".$db_prefix."btr_banners SET banner_clicks = '$lastData' WHERE banner_id = ".$banData['banner_id']."");
}

//Show Banner function
function showBanner($banData, $type="int"){
global $db_prefix;
setBannerView($banData);

if ($banData['banner_type'] == "0" AND $banData['banner_plans'] == "1"){
	$type = (strpos($banData['banner_img'], "http://") !== false) ? "ext" : "int";
	return "<a href='".INFUSIONS."marketing_panel/banner_click.php?banner_id=".ss($banData['banner_id'])."' target='_blank' title='".ss($banData['banner_name'])."'>
		<img alt='".ss($banData['banner_name'])."' src='".($type=="int" ? ss($banData['banner_img']) : ss($banData['banner_img']))."' border='0' width='468' height='60' />
		</a>";
} else {
	if ($banData['banner_type'] == "1" AND $banData['banner_plans'] == "1"){
		return "<embed width='468' height='60' src='".ss($banData['banner_url'])."' />";
 } 
}
}
//Prepare Banners for display
function displayBanners(){
global $db_prefix, $locale;
$bannersDb = dbquery("SELECT * FROM ".$db_prefix."btr_banners WHERE banner_state = '1'");
if (dbrows($bannersDb)){
	while ($tbData = dbarray($bannersDb)) $possRand[] = $tbData['banner_id'];
	$prCount = count($possRand)-1;
	$rand = mt_rand(0, $prCount);
	$banData = dbarray(dbquery("SELECT * FROM ".$db_prefix."btr_banners WHERE banner_state = '1' AND banner_id = ".$possRand[$rand]));
	return showBanner($banData);
} else {
	return $locale['BB_001']; 
}
}

 

Link to comment
https://forums.phpfreaks.com/topic/84633-function-show-banner/
Share on other sites

i have tried whit function but whiout result :(

 

<?php //Show Banner function
function showBanner($banData, $type="int"){
global $db_prefix;
setBannerView($banData);
if ($banData['banner_plans'] == "1"){
if ($banData['banner_type'] == "0"){
	$type = (strpos($banData['banner_img'], "http://") !== false) ? "ext" : "int";
	return "<a href='".INFUSIONS."marketing_panel/banner_click.php?banner_id=".ss($banData['banner_id'])."' target='_blank' title='".ss($banData['banner_name'])."'>
		<img alt='".ss($banData['banner_name'])."' src='".($type=="int" ? ss($banData['banner_img']) : ss($banData['banner_img']))."' border='0' width='468' height='60' />
		</a>";
} else {
	if ($banData['banner_type'] == "1"){
		return "<embed width='468' height='60' src='".ss($banData['banner_url'])."' />";
 } 
}
}
}?>

Link to comment
https://forums.phpfreaks.com/topic/84633-function-show-banner/#findComment-431440
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.