kdb Posted November 25, 2008 Share Posted November 25, 2008 Can anyone tell me how to get the banner images to show up in OSC Affiliate. I am using OSC 2.2rc2a/PHP 5 and have done all the messy fixes. I have changed the reference to DIR_WS_CATALOG to DIR_WS_HTTP_CATALOG as I found a fix for that If I set debug to true it doesn't give me the debug information If I try http://localhost/affiliate_show_banner.php...nner_id=4" in another browser window I get: PHP Notice: Undefined index: ref in C:\Inetpub\wwwroot\affiliate_show_banner.php on line 96 PHP Notice: Undefined index: affiliate_banner_id in C:\Inetpub\wwwroot\affiliate_show_banner.php on line 98 PHP Notice: Undefined index: affiliate_pbanner_id in C:\Inetpub\wwwroot\affiliate_show_banner.php on line 99 PHP Notice: Undefined index: affiliate_pbanner_id in C:\Inetpub\wwwroot\affiliate_show_banner.php on line 100 PHP Notice: Undefined variable: prod_banner_id in C:\Inetpub\wwwroot\affiliate_show_banner.php on line 114 If I just change if ($HTTP_GET_VARS['affiliate_banner_id']) $banner_id = $HTTP_GET_VARS['affiliate_banner_id']; to if (isset($HTTP_GET_VARS['affiliate_banner_id'])) $banner_id = $HTTP_GET_VARS['affiliate_banner_id']; I get the same as above but if I change only if ($HTTP_POST_VARS['affiliate_banner_id']) $banner_id = $HTTP_POST_VARS['affiliate_banner_id']; to if (isset($HTTP_POST_VARS['affiliate_banner_id'])) $banner_id = $HTTP_POST_VARS['affiliate_banner_id']; I get an HTTP 500 error Can someone tell me what the right code should be - it seems from trawling all the forums that lots of people had these sort of problems a while ago - but no real solutions seem to be offered, or at least that I can make work. Please help - this is urgent My affiliate_show_banner.php code is below Kdb <?php /* $Id: affiliate_show_banner.php,v 2.00 2003/10/12 OSC-Affiliate Contribution based on: osCommerce, Open Source E-Commerce Solutions [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url] Copyright © 2002 - 2003 osCommerce 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 tep_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_CATALOG . DIR_WS_IMAGES . $banner; ?></td></tr> <tr><td>build with:</td><td>DIR_FS_CATALOG . DIR_WS_IMAGES . $banner</td></tr> <tr><td>DIR_FS_CATALOG</td><td><?php echo DIR_FS_CATALOG; ?></td></tr> <tr><td>DIR_WS_HTTP_CATALOG</td><td><?php echo DIR_WS_HTTP_CATALOG; ?></td></tr> <tr><td>DIR_WS_IMAGES</td><td><?php echo DIR_WS_IMAGES; ?></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> </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 (isset($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 = tep_db_query($sql); if ($banner_array = tep_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 = tep_db_query($sql); if ($banner_array = tep_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 = 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 . "'"); // Banner has been shown today if ($banner_stats_array = tep_db_fetch_array($banner_stats_query)) { 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 . "'"); } else { // First view of Banner today 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 . "')"); } } // 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(); ?> Quote Link to comment Share on other sites More sharing options...
kdb Posted November 27, 2008 Author Share Posted November 27, 2008 Well... I have finally managed to fix it myself and am posting my solution after much deconstructing and trawling around in case anyone else is having the problem catalog/affiliate_show_banner.php First the Post and Get variables need to have (isset.... ) added thus: // Register needed Post / Get Variables if (isset($HTTP_GET_VARS['ref'])) $affiliate_id=$HTTP_GET_VARS['ref']; if (isset($HTTP_POST_VARS['ref'])) $affiliate_id=$HTTP_POST_VARS['ref']; if (isset($HTTP_GET_VARS['affiliate_banner_id'])) $banner_id = $HTTP_GET_VARS['affiliate_banner_id']; if (isset($HTTP_POST_VARS['affiliate_banner_id'])) $banner_id = $HTTP_POST_VARS['affiliate_banner_id']; if (isset($HTTP_GET_VARS['affiliate_pbanner_id'])) $prod_banner_id = $HTTP_GET_VARS['affiliate_pbanner_id']; if (isset($HTTP_POST_VARS['affiliate_pbanner_id'])) $prod_banner_id = $HTTP_POST_VARS['affiliate_pbanner_id']; Second: $banner_id and $prod_banner_id need to be defined for some reason so put these lines just before the code above so it looks like this: $banner_id = ''; $prod_banner_id = ''; // Register needed Post / Get Variables if (isset($HTTP_GET_VARS['ref'])) $affiliate_id=$HTTP_GET_VARS['ref']; if (isset($HTTP_POST_VARS['ref'])) $affiliate_id=$HTTP_POST_VARS['ref']; if (isset($HTTP_GET_VARS['affiliate_banner_id'])) $banner_id = $HTTP_GET_VARS['affiliate_banner_id']; if (isset($HTTP_POST_VARS['affiliate_banner_id'])) $banner_id = $HTTP_POST_VARS['affiliate_banner_id']; if (isset($HTTP_GET_VARS['affiliate_pbanner_id'])) $prod_banner_id = $HTTP_GET_VARS['affiliate_pbanner_id']; if (isset($HTTP_POST_VARS['affiliate_pbanner_id'])) $prod_banner_id = $HTTP_POST_VARS['affiliate_pbanner_id']; Third. In the function affiliate_show_banner nearer the top of the file you need to send an additional content header so I got the length of the file and sent the header with the length just before the content-disposition header. The function now looks like this: 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; } $len = filesize($pic); header ("Content-type: image/$img_type"); header ("Content-Length: $len"); 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(); } and the images all show up!!!! Quote Link to comment Share on other sites More sharing options...
thor1964 Posted June 5, 2009 Share Posted June 5, 2009 Had the same affiliate image display issue.. and lots of people seem too have encountered it.. This specific solution didn't fix it for me probably due to a different environment.. but in searching I found that someone found via debug and noted that the original script was calling the /catalog/image directory as /catalogimage, effectively a concantanation of two directory names caused by a missing "/". When I used the provided work-around of creating a directory called /catalogimages along side /catalog, and I put the affiliate banner/product images I created into the /catalogimages directory - they showed up like they're suppose too!! I'm absolutely sure this isn't a complete fix and other issues will continue to exist, but it difinitively shows us what caused the display issue and thus, what the original script error actually is. Hopefully, this will enable someone more familar with the code \:-) to inform us where to fix the original script error by adding the missing "/". If you figure it out, please reply. Thanks to all, - T Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.