Enterprise3.01 > Affiliate Show Banner.php

Questions? Need Help? Want to share? » PHP Forum
Script Name:
Enterprise3.01

Download:
enterprise3.01.zip

Category:
E Commerce

Archive Content:

Content:

Admin

Admin > Htmlarea

Admin > Htmlarea > Images

Admin > Htmlarea > Popups

Admin > Htmlarea > Popups > File

Admin > Htmlarea > Popups > File > Icons

Admin > Htmlarea > Popups > File > Images

Admin > Images

Admin > Images > Categories

Admin > Images > Graphs

Admin > Images > Icons

Admin > Includes

Admin > Includes > Boxes

Admin > Includes > Classes

Admin > Includes > Functions

Admin > Includes > Graphs

Admin > Includes > Javascript

Admin > Includes > Javascript > SpiffyCal

Admin > Includes > Javascript > SpiffyCal > Images

Admin > Includes > Languages

Admin > Includes > Languages > English

Admin > Includes > Languages > English > CVS

Admin > Includes > Languages > English > Images > Buttons

Admin > Includes > Languages > English > Images > Buttons > CVS

Admin > Includes > Languages > English > Images > Copy Of Buttons

Admin > Includes > Languages > English > Images > Copy Of Buttons > CVS

Admin > Includes > Languages > English > Images > CVS

Admin > Includes > Languages > English > Modules > Newsletters

Admin > Includes > Languages > Espanol

Admin > Includes > Languages > Espanol > CVS

Admin > Includes > Languages > Espanol > Images > Buttons

Admin > Includes > Languages > Espanol > Images > Buttons > CVS

Admin > Includes > Languages > Espanol > Images > CVS

Admin > Includes > Languages > Espanol > Modules > Newsletters

Admin > Includes > Languages > German

Admin > Includes > Languages > German > CVS

Admin > Includes > Languages > German > Images > Buttons

Admin > Includes > Languages > German > Images > Buttons > CVS

Admin > Includes > Languages > German > Images > CVS

Admin > Includes > Languages > German > Modules > Newsletters

Admin > Includes > Local

Admin > Includes > Modules > Newsletters

Admin > Live Support

Admin > Live Support > Blue

Admin > Live Support > Green

Admin > Live Support > Red

Admin > Live Support > White

Admin > Live Support > Yellow

Download

Images

Images > Banners

Images > Default

Images > Icons

Images > Infobox

Images > Mail

Includes

Includes > Boxes

Includes > Classes

Includes > Color Schemes > 1

Includes > Color Schemes > 10

Includes > Color Schemes > 11

Includes > Color Schemes > 12

Includes > Color Schemes > 2

Includes > Color Schemes > 3

Includes > Color Schemes > 4

Includes > Color Schemes > 5

Includes > Color Schemes > 6

Includes > Color Schemes > 7

Includes > Color Schemes > 8

Includes > Color Schemes > 9

Includes > Functions

Includes > Javascript

Includes > Languages

Includes > Languages > English

Includes > Languages > English > CVS

Includes > Languages > English > Images

Includes > Languages > English > Images > Buttons

Includes > Languages > English > Images > Buttons > CVS

Includes > Languages > English > Images > CVS

Includes > Languages > English > Modules > Order Total

Includes > Languages > English > Modules > Payment

Includes > Languages > English > Modules > Shipping

Includes > Languages > Espanol

Includes > Languages > Espanol > CVS

Includes > Languages > Espanol > Images

Includes > Languages > Espanol > Images > Buttons

Includes > Languages > Espanol > Images > Buttons > CVS

Includes > Languages > Espanol > Images > CVS

Includes > Languages > Espanol > Modules > Order Total

Includes > Languages > Espanol > Modules > Payment

Includes > Languages > Espanol > Modules > Shipping

Includes > Languages > French

Includes > Languages > French > Images > Buttons

Includes > Languages > French > Modules > Payment

Includes > Languages > German

Includes > Languages > German > CVS

Includes > Languages > German > Images

Includes > Languages > German > Images > Buttons

Includes > Languages > German > Images > Buttons > CVS

Includes > Languages > German > Images > CVS

Includes > Languages > German > Modules > Order Total

Includes > Languages > German > Modules > Payment

Includes > Languages > German > Modules > Shipping

Includes > Local

Includes > Modules

Includes > Modules > Order Total

Includes > Modules > Payment

Includes > Modules > Shipping

Install

Install > Images

Install > Images > Layout

Install > Includes

Install > Includes > Functions

Install > Templates

Install > Templates > Main Page

Install > Templates > Pages

Live Support

Live Support > Blue

Live Support > Green

Live Support > Red

Live Support > White

Live Support > Yellow

Members

Members > Cashhub

Members > Cashhub > Images

Members > User

Members > User > Test Dir

Templates

Templates > Content

Affiliate Show Banner.php:


<?php

/*

  $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


  OSC-Affiliate



  Contribution based on:



  Enterprise Shopping Cart

  http://www.enterprisecart.com



  Copyright (c) 2004 Enterprise Shopping Cart Software.  Portions Copyright (c) 2001-2004 osCommerce: http://www.oscommerce.com



  Released under the GNU General Public License

*/



// CHECKIT

// -> optimize code -> double parts



// require of application_top not possible

// cause then whois online registers it also as visitor

//



  
define('TABLE_AFFILIATE_BANNERS_HISTORY',  'affiliate_banners_history');

  
define('TABLE_AFFILIATE_BANNERS',  'affiliate_banners');

  
define('TABLE_PRODUCTS',  'products');



// Set the local configuration parameters - mainly for developers

  
if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

  require(
'includes/configure.php');

  if (
file_exists('includes/local/affiliate_configure.php')) include('includes/local/affiliate_configure.php');

  require(
'includes/affiliate_configure.php');



// include the database functions

  
require(DIR_WS_FUNCTIONS 'database.php');

// make a connection to the database... now

  
escs_db_connect() or die('Unable to connect to database server!');



  function 
affiliate_show_banner($pic) {

//Read Pic and send it to browser

    
$fp fopen($pic,  "rb");

    if (!
$fp) exit();

// Get Image type

    
$img_type substr($pic,  strrpos($pic,  ".") + 1);

// Get Imagename

    
$pos strrpos($pic,  "/");

    if (
$pos) {

      
$img_name substr($pic,  strrpos($pic,  "/" ) + 1);

    } else {

      
$img_name=$pic;

    }

    
header ("Content-type: image/$img_type");

    
header ("Content-Disposition: inline; filename=$img_name");

    
fpassthru($fp);

    
// The file is closed when fpassthru() is done reading it (leaving handle useless).

    // fclose ($fp);

    
exit();

  }



  function 
affiliate_debug($banner, $sql) {

?>

    <table border=1 cellpadding=2 cellspacing=2>

      <tr><td colspan=2>Check the pathes! (catalog/includes/configure.php)</td></tr>

      <tr><td>absolute path to picture:</td><td><?php echo DIR_FS_DOCUMENT_ROOT DIR_WS_CATALOGDIR_WS_IMAGES $banner?></td></tr>

      <tr><td>build with:</td><td>DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG . DIR_WS_IMAGES . $banner</td></tr>

      <tr><td>DIR_FS_DOCUMENT_ROOT</td><td><?php echo DIR_FS_DOCUMENT_ROOT?></td></tr>

      <tr><td>DIR_WS_CATALOG</td><td><?php echo DIR_WS_CATALOG ?></td></tr>

      <tr><td>DIR_WS_IMAGES</td><td><?php echo DIR_WS_IMAGES?></td></tr>

      <tr><td>$banner</td><td><?php echo $banner?></td></tr>

      <tr><td>SQL-Query used:</td><td><?php echo $sql?></td></tr>

      <tr><th>Try to find error:</td><td>&nbsp;</th></tr>

      <tr><td>SQL-Query:</td><td><?php if ($banner) echo "Got Result"; else echo "No result"?></td></tr>

      <tr><td>Locating Pic</td><td>

<?php

    $pic 
DIR_FS_CATALOG DIR_WS_IMAGES $banner;

    echo 
$pic "<br>";

    if (!
is_file($pic)) {

      echo 
"failed<br>";

    } else {

      echo 
"success<br>";

    }

?>

      </td></tr>

    </table>

<?php

    
exit();

  }



// Register needed Post / Get Variables

  
if ($HTTP_GET_VARS['ref']) $affiliate_id=$HTTP_GET_VARS['ref'];

  if (
$HTTP_POST_VARS['ref']) $affiliate_id=$HTTP_POST_VARS['ref'];



  if (
$HTTP_GET_VARS['affiliate_banner_id']) $banner_id $HTTP_GET_VARS['affiliate_banner_id'];

  if (
$HTTP_POST_VARS['affiliate_banner_id']) $banner_id $HTTP_POST_VARS['affiliate_banner_id'];

  if (
$HTTP_GET_VARS['affiliate_pbanner_id']) $prod_banner_id $HTTP_GET_VARS['affiliate_pbanner_id'];

  if (
$HTTP_POST_VARS['affiliate_pbanner_id']) $prod_banner_id $HTTP_POST_VARS['affiliate_pbanner_id'];



  
$banner '';

  
$products_id '';



  if (
$banner_id) {

    
$sql "select affiliate_banners_image,  affiliate_products_id from " TABLE_AFFILIATE_BANNERS " where affiliate_banners_id = '" $banner_id  "' and affiliate_status = 1";

    
$banner_values escs_db_query($sql);

    if (
$banner_array escs_db_fetch_array($banner_values)) {

      
$banner $banner_array['affiliate_banners_image'];

      
$products_id $banner_array['affiliate_products_id'];

    }

  }



  if (
$prod_banner_id) {

    
$banner_id 1// Banner ID for these Banners is one

    
$sql "select products_image from " TABLE_PRODUCTS " where products_id = '" $prod_banner_id  "' and products_status = 1";

    
$banner_values escs_db_query($sql);

    if (
$banner_array escs_db_fetch_array($banner_values)) {

      
$banner $banner_array['products_image'];

      
$products_id $prod_banner_id;

    }

  }



// DebugModus

  
if (AFFILIATE_SHOW_BANNERS_DEBUG == 'true'affiliate_debug($banner, $sql);



  if (
$banner) {

    
$pic DIR_FS_CATALOG DIR_WS_IMAGES $banner;



    
// Show Banner only if it exists:

    
if (is_file($pic)) {

      
$today date('Y-m-d');

    
// Update stats:

      
if ($affiliate_id) {

        
$banner_stats_query escs_db_query("select * from " TABLE_AFFILIATE_BANNERS_HISTORY " where affiliate_banners_id = '" $banner_id  "' and affiliate_banners_products_id = '" $products_id ."' and affiliate_banners_affiliate_id = '" $affiliate_id"' and affiliate_banners_history_date = '" $today "'");

    
// Banner has been shown today

        
if ($banner_stats_array escs_db_fetch_array($banner_stats_query)) {

          
escs_db_query("update " TABLE_AFFILIATE_BANNERS_HISTORY " set affiliate_banners_shown = affiliate_banners_shown + 1 where affiliate_banners_id = '" $banner_id  "' and affiliate_banners_affiliate_id = '" $affiliate_id"' and affiliate_banners_products_id = '" $products_id ."' and affiliate_banners_history_date = '" $today "'");

        } else { 
// First view of Banner today

          
escs_db_query("insert into " TABLE_AFFILIATE_BANNERS_HISTORY " (affiliate_banners_id,  affiliate_banners_products_id,  affiliate_banners_affiliate_id,  affiliate_banners_shown,  affiliate_banners_history_date) VALUES ('" $banner_id  "',  '" .  $products_id ."',  '" $affiliate_id"',  '1',  '" $today "')");

        }

      }

    
// Show Banner

      
affiliate_show_banner($pic);

    }

  }



// Show default Banner if none is found

  
if (is_file(AFFILIATE_SHOW_BANNERS_DEFAULT_PIC)) {

    
affiliate_show_banner(AFFILIATE_SHOW_BANNERS_DEFAULT_PIC);

  } else {

    echo 
"<br>"// Output something to prevent endless loading

  
}

  exit();

?>


Other E Commerce Scripts:

WebMaster Resources Home

©RingsWorld.com