[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: affiliate_show_banner.php 14 2006-07-28 17:42:07Z user $ 4 5 OSC-Affiliate 6 7 Contribution based on: 8 9 osCMax Power E-Commerce 10 http://oscdox.com 11 12 Copyright 2006 osCMax 13 14 Released under the GNU General Public License 15 */ 16 17 // Most of this file is changed or moved to BTS - Basic Template System - format. 18 // For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change). 19 // catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change). 20 // (Sub 'fallback' with your current template to see if there is a template specific file.) 21 22 23 // CHECKIT 24 // -> optimize code -> double parts 25 26 // require of application_top not possible 27 // cause then whois online registers it also as visitor 28 // 29 30 define('TABLE_AFFILIATE_BANNERS_HISTORY', 'affiliate_banners_history'); 31 define('TABLE_AFFILIATE_BANNERS', 'affiliate_banners'); 32 define('TABLE_PRODUCTS', 'products'); 33 34 // Set the local configuration parameters - mainly for developers 35 if (file_exists('includes/local/configure.php')) include('includes/local/configure.php'); 36 require ('includes/configure.php'); 37 if (file_exists('includes/local/affiliate_configure.php')) include('includes/local/affiliate_configure.php'); 38 require ('includes/affiliate_configure.php'); 39 40 // include the database functions 41 require (DIR_WS_FUNCTIONS . 'database.php'); 42 // make a connection to the database... now 43 tep_db_connect() or die('Unable to connect to database server!'); 44 45 function affiliate_show_banner($pic) { 46 //Read Pic and send it to browser 47 $fp = fopen($pic, "rb"); 48 if (!$fp) exit(); 49 // Get Image type 50 $img_type = substr($pic, strrpos($pic, ".") + 1); 51 // Get Imagename 52 $pos = strrpos($pic, "/"); 53 if ($pos) { 54 $img_name = substr($pic, strrpos($pic, "/" ) + 1); 55 } else { 56 $img_name=$pic; 57 } 58 header ("Content-type: image/$img_type"); 59 header ("Content-Disposition: inline; filename=$img_name"); 60 fpassthru($fp); 61 // The file is closed when fpassthru() is done reading it (leaving handle useless). 62 // fclose ($fp); 63 exit(); 64 } 65 66 function affiliate_debug($banner,$sql) { 67 ?> 68 <table border=1 cellpadding=2 cellspacing=2> 69 <tr><td colspan=2>Check the pathes! (catalog/includes/configure.php)</td></tr> 70 <tr><td>absolute path to picture:</td><td><?php echo DIR_FS_CATALOG . DIR_WS_IMAGES . $banner; ?></td></tr> 71 <tr><td>build with:</td><td>DIR_FS_CATALOG . DIR_WS_IMAGES . $banner</td></tr> 72 <tr><td>DIR_FS_CATALOG</td><td><?php echo DIR_FS_CATALOG; ?></td></tr> 73 <tr><td>DIR_WS_CATALOG</td><td><?php echo DIR_WS_CATALOG ; ?></td></tr> 74 <tr><td>DIR_WS_IMAGES</td><td><?php echo DIR_WS_IMAGES; ?></td></tr> 75 <tr><td>$banner</td><td><?php echo $banner; ?></td></tr> 76 <tr><td>SQL-Query used:</td><td><?php echo $sql; ?></td></tr> 77 <tr><th>Try to find error:</td><td> </th></tr> 78 <tr><td>SQL-Query:</td><td><?php if ($banner) echo "Got Result"; else echo "No result"; ?></td></tr> 79 <tr><td>Locating Pic</td><td> 80 <?php 81 $pic = DIR_FS_CATALOG . DIR_WS_IMAGES . $banner; 82 echo $pic . "<br>"; 83 if (!is_file($pic)) { 84 echo "failed<br>"; 85 } else { 86 echo "success<br>"; 87 } 88 ?> 89 </td></tr> 90 </table> 91 <?php 92 exit(); 93 } 94 95 // Register needed Post / Get Variables 96 if ($HTTP_GET_VARS['ref']) $affiliate_id=$HTTP_GET_VARS['ref']; 97 if ($HTTP_POST_VARS['ref']) $affiliate_id=$HTTP_POST_VARS['ref']; 98 99 if ($HTTP_GET_VARS['affiliate_banner_id']) $banner_id = $HTTP_GET_VARS['affiliate_banner_id']; 100 if ($HTTP_POST_VARS['affiliate_banner_id']) $banner_id = $HTTP_POST_VARS['affiliate_banner_id']; 101 if ($HTTP_GET_VARS['affiliate_pbanner_id']) $prod_banner_id = $HTTP_GET_VARS['affiliate_pbanner_id']; 102 if ($HTTP_POST_VARS['affiliate_pbanner_id']) $prod_banner_id = $HTTP_POST_VARS['affiliate_pbanner_id']; 103 104 $banner = ''; 105 $products_id = ''; 106 107 if ($banner_id) { 108 $sql = "select affiliate_banners_image, affiliate_products_id from " . TABLE_AFFILIATE_BANNERS . " where affiliate_banners_id = '" . $banner_id . "' and affiliate_status = 1"; 109 $banner_values = tep_db_query($sql); 110 if ($banner_array = tep_db_fetch_array($banner_values)) { 111 $banner = $banner_array['affiliate_banners_image']; 112 $products_id = $banner_array['affiliate_products_id']; 113 } 114 } 115 116 if ($prod_banner_id) { 117 $banner_id = 1; // Banner ID for these Banners is one 118 $sql = "select products_image from " . TABLE_PRODUCTS . " where products_id = '" . $prod_banner_id . "' and products_status = 1"; 119 $banner_values = tep_db_query($sql); 120 if ($banner_array = tep_db_fetch_array($banner_values)) { 121 $banner = $banner_array['products_image']; 122 $products_id = $prod_banner_id; 123 } 124 } 125 126 // DebugModus 127 if (AFFILIATE_SHOW_BANNERS_DEBUG == 'true') affiliate_debug($banner,$sql); 128 129 if ($banner) { 130 $pic = DIR_FS_CATALOG . DIR_WS_IMAGES . $banner; 131 132 // Show Banner only if it exists: 133 if (is_file($pic)) { 134 $today = date('Y-m-d'); 135 // Update stats: 136 if ($affiliate_id) { 137 $banner_stats_query = tep_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 . "'"); 138 // Banner has been shown today 139 if ($banner_stats_array = tep_db_fetch_array($banner_stats_query)) { 140 tep_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 . "'"); 141 } else { // First view of Banner today 142 tep_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 . "')"); 143 } 144 } 145 // Show Banner 146 affiliate_show_banner($pic); 147 } 148 } 149 150 // Show default Banner if none is found 151 if (is_file(AFFILIATE_SHOW_BANNERS_DEFAULT_PIC)) { 152 affiliate_show_banner(AFFILIATE_SHOW_BANNERS_DEFAULT_PIC); 153 } else { 154 echo "<br>"; // Output something to prevent endless loading 155 } 156 exit(); 157 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |