[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 image_handler.php

Zen Cart 源代码 image_handler.php




下载文件

文件名: image_handler.php
文件类型: PHP文件
文件大小: 53.98 KiB
MD5: b30b82d59aa01c052fc252f8014885c9

image_handler.php - 关闭高亮
  1. <?php
  2. /**
  3.  * image_handler.php
  4.  * IH2 admin interface
  5.  *
  6.  * @author  Tim Kroeger (original author)
  7.  * @copyright Copyright 2005-2006
  8.  * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License V2.0
  9.  * @version $Id: image_handler.php,v 2.0 Rev 8 2010-05-31 23:46:5 DerManoMann Exp $
  10.  * Last modified by DerManoMann 2010-05-31 23:46:50
  11.  # And again by Nigelt74 2012- 02-18
  12.  */
  13.  
  14.   require('includes/application_top.php');
  15.   require(DIR_WS_CLASSES . 'currencies.php');
  16.   require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'bmz_image_handler.class.php');
  17.  
  18.   define('HEADING_TITLE', IH_HEADING_TITLE);
  19.   define('HEADING_TITLE_PRODUCT_SELECT', IH_HEADING_TITLE_PRODUCT_SELECT);
  20.  
  21.   global $messageStack;
  22.   $page = isset($_GET['page']) ? $_GET['page'] : ((!defined('IH_VERSION') || (IH_VERSION == 'REMOVED')) ? 'admin' : 'manager');
  23.   //$action = (isset($_GET['action']) ? $_GET['action'] : '');
  24.   //------- Nigel
  25.   if (isset($_POST['action'])) { $action = $_POST['action'];
  26.     } elseif (isset($_GET['action'])) {
  27.     $action = $_GET['action'];
  28.     }
  29. //-------End Nigel
  30. //  $action = (isset($_GET['action']) ? $_GET['action'] : '');
  31.   $products_filter = (isset($_GET['products_filter']) ? $_GET['products_filter'] : '');
  32.   $current_category_id = (isset($_GET['current_category_id']) ? $_GET['current_category_id'] : $current_category_id);
  33.   $currencies = new currencies();
  34.   $import_info = null;
  35.  
  36.   function get_image_details_string( $filename ) {
  37.  
  38.     if (!file_exists( $filename )) {
  39.       return "no info";
  40.     }
  41.     $str = "";
  42.     // find out some details about the file
  43.     $image_size = @getimagesize($filename);
  44.     $image_fs_size = filesize($filename);
  45.  
  46.     $str .= $image_size[0]."x".$image_size[1];
  47.     $str .= "<br /><strong>". round($image_fs_size/1024, 2) . "Kb</strong>";
  48.    
  49.     return $str;
  50.   }
  51.  
  52.   //
  53.   // Search the base directory and find additional images
  54.   //
  55.   function find_additional_images(&$array, $directory, $extension, $base ) {
  56.  
  57.     $image = $base . $extension;
  58.  
  59.     // Check for additional matching images
  60.     if ($dir = @dir($directory)) {
  61.       while ($file = $dir->read()) {
  62.         if (!is_dir($directory . $file)) {
  63.           if(preg_match("/^" . $base . "/i", $file) == '1') {
  64.             // echo "BASE: ".$base.' FILE: '.$file.'<br />';
  65.             if (substr($file, 0, strrpos($file, '.')) != substr($image, 0, strrpos($image, '.'))) {
  66.               if ($base . preg_replace("/^$base/", '', $file) == $file) {
  67.                 $array[] = $file;
  68.                 // echo 'I AM A MATCH ' . $products_image_directory . '/'.$file . $products_image_extension .'<br />';
  69.               } else {
  70.                 // echo 'I AM NOT A MATCH ' . $file . '<br />';
  71.               }
  72.             }
  73.           }
  74.         }
  75.       }
  76.      
  77.       if (sizeof($array) > 1) {
  78.         sort($array);
  79.       }
  80.      
  81.       $dir->close();
  82.      
  83.       return 1;
  84.     }
  85.    
  86.     return 0;
  87.   }
  88.  
  89.   function find_original_image($src) {
  90.     global $ihConf;
  91.     // try to find file by using different file extensions if initial
  92.     // source doesn't succeed
  93.     $imageroot = $ihConf['dir']['docroot'] . $ihConf['dir']['images'] . 'original/';
  94.     if (is_file($imageroot . $src)) {
  95.       return 'original/' . $src;
  96.     } else {
  97.       // do a quick search for files with common extensions
  98.       $extensions = array('.png', '.PNG', '.jpg', '.JPG', '.jpeg', '.JPEG', '.gif', '.GIF');
  99.       $base = substr($src, 0, strrpos($src, '.'));
  100.       for ($i=0; $i<count($extensions); $i++) {
  101.         if (is_file($imageroot . $base . $extensions[$i])) {
  102.           return 'original/' . $base . $extensions[$i];
  103.         }
  104.       }
  105.       // not found? maybe mixed case file extension?
  106.       if ($ihConf['allow_mixed_case_ext']) {
  107.         // this can cost some time for every displayed image so default is
  108.         // to not do this search
  109.         $directory = dirname($imageroot . $src);
  110.         $dir = @dir($directory);
  111.         while ($file = $dir->read()) {
  112.           if (!is_dir($directory . $file)) {
  113.             if(preg_match("/^" . $imageroot . $base . "/i", $file) == '1') {
  114.               $file_ext = substr($file, strrpos($file, '.'));
  115.               if (is_file($imageroot . $base . $file_ext)) {
  116.                 return 'original/' . $base . $file_ext;
  117.               }
  118.             }
  119.           }
  120.         }
  121.       }
  122.     }
  123.     // still here? no file found...
  124.     return false;
  125.   }
  126.  
  127.   function get_import_info() {
  128.     global $db;
  129.     $products = $db->Execute("select products_id, products_image from " . TABLE_PRODUCTS . " where products_image != '' order by products_image asc");
  130.     $previous_image = '';
  131.     $info = array();
  132.     $index = 0;
  133.     $previous_image = '';
  134.     while (!$products->EOF){
  135.       $image = $products->fields['products_image'];
  136.       if ($image != $previous_image) {
  137.         $previous_image = $image;
  138.         $original_image = find_original_image($image);
  139.         if ($original_image) {
  140.           $info[$index]['source'] = $image;
  141.           $info[$index]['original'] = $original_image;
  142.           $info[$index]['target'] = preg_replace('/^original\//', '', $original_image);
  143.           $index++;  
  144.         }
  145.       }
  146.       $products->MoveNext();
  147.     }
  148.     return $info;
  149.   }
  150.  
  151.  
  152.   if ($action == 'set_products_filter') {  
  153.     $_GET['products_filter'] = $_POST['products_filter'];
  154.     zen_redirect(zen_href_link(FILENAME_IMAGE_HANDLER, 'page=manager&products_filter=' . $_GET['products_filter']));
  155.   }
  156.  
  157.   if ($page == 'manager') {
  158.     // manager actions are handled in a seperate file
  159.     require('includes/ih_manager.php');
  160.   }
  161.  
  162.  
  163.  
  164.  
  165.    if ($action == 'ih_remove') {
  166.     $uninstall = 'uninstall';
  167.     $message_type = 'session';
  168.     require_once('includes/init_includes/init_image_handler.php');
  169.         zen_redirect(zen_href_link(FILENAME_CONFIGURATION, 'gID=4'));
  170.    }
  171.  
  172.  
  173.   if ($action == 'ih_import_images') {
  174.     $files = get_import_info();
  175.     $previous_image = '';
  176.     $imageroot = $ihConf['dir']['docroot'] . $ihConf['dir']['images'];
  177.     if (count($files) > 0) {
  178.       for ($i = 0; $i < count($files); $i++) {
  179.         // Remove destination file if it's there
  180.         @unlink($imageroot . $files[$i]['target']);
  181.         if (rename($imageroot . $files[$i]['original'], $imageroot . $files[$i]['target'])) {
  182.           // Update database
  183.           if ($files[$i]['target'] != $files[$i]['source']) {
  184.             $db->Execute("update " . TABLE_PRODUCTS . " set products_image='" . $files[$i]['target'] . "' where products_image='" . $files[$i]['source'] . "'");
  185.           }
  186.           @unlink($imageroot . $files[$i]['source']);
  187.           $messageStack->add(TEXT_MSG_IMPORT_SUCCESS . $files[$i]['original'] . ' => ' . $files[$i]['target'], 'success');
  188.         } else {
  189.           $messageStack->add(TEXT_MSG_IMPORT_FAILURE . $files[$i]['original'] . ' => ' . $files[$i]['target'], 'error');
  190.         }
  191.       }
  192.       $messageStack->add(IH_IMAGES_IMPORTED, 'success');
  193.     }
  194.   }
  195.  
  196.   if ($action == 'ih_scan_originals') {
  197.     $import_info = get_import_info();
  198.     if (count($import_info) <= 0) {
  199.       $messageStack->add(IH_NO_ORIGINALS, 'caution');
  200.     }
  201.   }  
  202.  
  203.   if ($action == 'ih_clear_cache') {
  204.     $error = bmz_clear_cache();
  205.     if (!$error) {
  206.       $messageStack->add(IH_CACHE_CLEARED, 'success');
  207.     }
  208.   }
  209.  
  210.  
  211.  
  212. ?>
  213. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  214. <html <?php echo HTML_PARAMS; ?>>
  215. <head>
  216. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  217. <title><?php echo TITLE; ?></title>
  218. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  219. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  220. <script language="javascript" src="includes/menu.js"></script>
  221. <script language="javascript" src="includes/general.js"></script>
  222. <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
  223. <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
  224.  
  225. <script type="text/javascript">
  226.   <!--
  227.   function init()
  228.   {
  229.     cssjsmenu('navbar');
  230.     if (document.getElementById)
  231.     {
  232.       var kill = document.getElementById('hoverJS');
  233.       kill.disabled = true;
  234.     }
  235.   }
  236.  
  237.    function popupWindow(url) {
  238.         window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=600,height=460,screenX=150,screenY=150,top=150,left=150')
  239.     }
  240.  
  241.   // -->
  242. </script>
  243. <style type="text/css">
  244.   /* general headline setup */
  245.   h1, h2, h3, h4, h5 {
  246.      color: #000000;
  247.      /*font-family: Georgia,"Times New Roman",serif;*/
  248.      font-weight: bold;
  249.      letter-spacing: 0.1em;
  250.      word-spacing: 0.2em;
  251.      margin: 0 0 0 0;
  252.      padding: 0 0 0 0;
  253.      clear: left
  254.   }
  255.  
  256.   .logo h1 {margin: 0; padding: 11px 0 0 0; font-size: 30px; color:#CCCCCC}
  257.   h1 {font-size: 180%}
  258.   h2 {font-size: 160%}
  259.   h3 {font-size: 140%}
  260.   h4 {font-size: 120%}
  261.   h5 {font-size: 100%}
  262.  
  263.   h1 a, h2 a, h3 a, h4 a, h5 a {
  264.      /*font-family: Georgia,"Times New Roman",serif;*/
  265.      font-weight: bold;
  266.      letter-spacing: 0.1em;
  267.      word-spacing: 0.2em;
  268.   }
  269.  
  270.   input[type="text"], input[type="submit"], input[type="file"], select {
  271.     border: 1px solid #CCCCCC;
  272.     background-color: #FFFFFF;
  273.   }
  274.  
  275.   div.adminbox {
  276.     padding: 10px;
  277.   }
  278.  
  279.   div.aboutbox {
  280.     /*margin: 0 auto;*/
  281.     width: 65%;
  282.     /*text-align:center;*/
  283.   }
  284.  
  285.   .aboutbox p {
  286.     text-align: justify;
  287.   }
  288.  
  289.  
  290. fieldset {
  291.     background: #f6f6f8;
  292.     padding: 0.5em 0.5em 0.5em 0.5em;
  293.     margin: 0 0 1em 0;
  294.     border: 1px solid #ccc;
  295. }
  296.  
  297. legend {
  298.     /*font-family : arial, helvetica, sans-serif;*/
  299.     font-weight: bold;
  300.     font-size: 1.4em;
  301.     color: #1240b0;
  302. }
  303.  
  304.  
  305.   div.managerbox {
  306.     clear: both;
  307.   }
  308.  
  309.   div.donationbox {
  310.     display: none;
  311.   }
  312.  
  313.   .donationbox label {
  314.     display: none;
  315.   }
  316.  
  317.   .donationbox input[type=text], .donationbox input[type=submit], .donationbox select {
  318.     display: none;
  319.   }
  320.  
  321.   .donationbox input[type=submit] {margin-bottom: 5px; cursor: pointer}
  322.  
  323.   .donationbox h2 {
  324.     font-size: 100%;
  325.   }
  326.  
  327.   a.wikilink1:link    { color:#009900; text-decoration:none }
  328.   a.wikilink1:visited { color:#009900; text-decoration:none }
  329.   a.wikilink1:hover   { color:#009900; text-decoration:underline }
  330.  
  331.  
  332.  
  333. </style>
  334.  
  335.  
  336. </head>
  337. <body onLoad="init()">
  338. <div id="spiffycalendar" class="text"></div>
  339. <!-- header //-->
  340. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  341. <!-- header_eof //-->
  342.  
  343. <!-- body //-->
  344.  
  345. <div>
  346.  
  347. <div style="float:left; padding: 8px 5px;">
  348. <h1><?php echo HEADING_TITLE; ?></h1>
  349. <?php
  350. if (defined('IH_VERSION')) {
  351.     echo IH_VERSION_VERSION . ':&nbsp;' . IH_VERSION . '<br />';
  352. } else {
  353.     echo IH_VERSION_NOT_FOUND . '<br />';
  354. }
  355. ?>
  356. </div>
  357.  
  358. <?php
  359. if ($page == 'manager') {
  360. // SEARCH DIALOG BOX
  361.   echo '<div style="float:right; padding: 5px;">';
  362.   echo zen_draw_form('search', FILENAME_CATEGORIES, '', 'get');
  363. // show reset search
  364.   if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  365.     echo '<a href="' . zen_href_link(FILENAME_CATEGORIES) . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>&nbsp;&nbsp;';
  366.   }
  367.   echo HEADING_TITLE_SEARCH_DETAIL . ' ' . zen_draw_input_field('search');
  368.   if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  369.     $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
  370.     echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . $keywords;
  371.   }
  372.   echo '</form>';
  373.   echo '</div>';
  374. }
  375. ?>
  376. </div>
  377.  
  378. <div style="clear:both">
  379.  
  380. <ul style="background-color:#F5F5F5; border: solid #CCCCCC; border-width: 1px 0px;">
  381.   <li style="display:inline; padding:2px 5px; <?php echo ($page == 'manager') ? 'background:#CCCCCC;' : ''; ?>">
  382.     <a href="<?php echo zen_href_link(FILENAME_IMAGE_HANDLER, 'page=manager') ?>"><?php echo IH_MENU_MANAGER; ?></a>
  383.   </li>
  384.   <li style="display:inline; padding:2px 5px; <?php echo ($page == 'admin') ? 'background:#CCCCCC;' : ''; ?>">
  385.      <a href="<?php echo zen_href_link(FILENAME_IMAGE_HANDLER, 'page=admin') ?>"><?php echo IH_MENU_ADMIN; ?></a>
  386.   </li>
  387.   <li style="display:inline; padding:2px 5px; <?php echo ($page == 'preview') ? 'background:#CCCCCC;' : ''; ?>">
  388.     <a href="<?php echo zen_href_link(FILENAME_IMAGE_HANDLER, 'page=preview') ?>"><?php echo IH_MENU_PREVIEW; ?></a>
  389.   </li>
  390.   <li style="display:inline; padding:2px 5px; <?php echo ($page == 'about') ? 'background:#CCCCCC;' : ''; ?>">
  391.     <a href="<?php echo zen_href_link(FILENAME_IMAGE_HANDLER, 'page=about') ?>"><?php echo IH_MENU_ABOUT; ?></a>
  392.   </li>
  393. </ul>
  394.  
  395. <div class="adminbox">
  396. <?php
  397.  
  398.  
  399.  
  400. /**
  401.  * ADMIN TABPAGE INITIALIZATION
  402.  */
  403. $ih_admin_actions = array();
  404. $page = isset($_GET['page']) ? $_GET['page'] : ((!defined('IH_VERSION') || (IH_VERSION == 'REMOVED')) ? 'admin' : 'manager');
  405. if ($page == 'admin') {
  406.     $ih_admin_actions['ih_confirm_remove'] = IH_REMOVE;
  407.     $ih_admin_actions['ih_clear_cache'] = IH_CLEAR_CACHE;
  408.     $ih_admin_actions['ih_scan_originals'] = IH_SCAN_FOR_ORIGINALS;
  409. }
  410.  
  411.  
  412.  
  413.  
  414. /**
  415.  * image handler uninstall confirmation
  416.  */
  417.  
  418. if ($action == 'ih_confirm_remove') {
  419.   echo zen_draw_form('remove_form', FILENAME_IMAGE_HANDLER, '', 'get');
  420.   echo zen_draw_hidden_field('action', 'ih_remove');
  421.   echo IH_CONFIRM_REMOVE . '&nbsp;';
  422.   echo zen_image_submit('button_delete.gif', IMAGE_DELETE);
  423.   echo '</form>';
  424. }
  425.  
  426. if ($action == 'ih_scan_originals') {
  427.   if (count($import_info) > 0) {
  428.     echo zen_draw_form('import_form', FILENAME_IMAGE_HANDLER, '', 'get');
  429.     echo zen_draw_hidden_field('action', 'ih_import_images');
  430.     echo IH_CONFIRM_IMPORT . '<br />';
  431.     echo zen_image_submit('button_confirm.gif', IMAGE_CONFIRM) . '<br /><br />';
  432.     for ($i = 0; $i < count($import_info); $i++) {
  433.       echo "#$i: " . $import_info[$i]['original'] . ' => ' . $import_info[$i]['target'] . '<br /><br />';
  434.     }
  435.     echo '<br /><br />' . IH_CONFIRM_IMPORT . '<br />';
  436.     echo zen_image_submit('button_confirm.gif', IMAGE_CONFIRM) . '<br />';
  437.     echo '</form>';
  438.   }
  439. }
  440.  
  441. if (count($ih_admin_actions) > 0) {
  442.     echo '<ul>';
  443.     foreach ($ih_admin_actions as $action_name => $link_name) {
  444.         echo '<li><a href="' . zen_href_link(FILENAME_IMAGE_HANDLER, 'page=admin&action=' . $action_name) . '">' . $link_name . '</a></li>';
  445.     }
  446.     echo '</ul>';
  447. }
  448.  
  449.  
  450.  
  451.  
  452. /**
  453.  * MANAGER TABPAGE
  454.  */
  455.  
  456. if ($page == 'manager') {
  457.   $curr_page = FILENAME_IMAGE_HANDLER;
  458.     require(DIR_WS_MODULES . FILENAME_PREV_NEXT_DISPLAY);
  459. ?>
  460.  
  461.          
  462.          <?php echo zen_draw_form('set_products_filter_id', FILENAME_IMAGE_HANDLER, 'action=set_products_filter', 'post'); ?>
  463. <!--    
  464.       <?php echo zen_draw_hidden_field('products_filter', $_GET['products_filter']); ?>
  465.  -->
  466.       <?php echo zen_draw_hidden_field('products_filter', $_GET['products_filter']); ?>
  467.       <?php //echo zen_draw_hidden_field('action', 'set_products_filter'); // superflous hack - ?>
  468.  
  469.          
  470.         <table border="0" cellspacing="0" cellpadding="2">
  471.           <tr>
  472.             <td class="main" width="200" align="left" valign="top">&nbsp;</td>
  473.             <td colspan="2" class="main"><?php echo TEXT_PRODUCT_TO_VIEW; ?></td>
  474.           </tr>
  475.           <tr>
  476.             <td class="main" width="200" align="center" valign="top">
  477.  
  478. <?php  
  479.     //----- Nigel - Another ugly hack - probably need to clean up the attributes section - not really sure why the attributes section matters to IH - ask Diva
  480.   if (isset($_POST['products_filter'])) { $_GET['products_filter'] = $_POST['products_filter'];
  481.     }
  482.     //------  Nigel --End ugly hack
  483. // FIX HERE
  484. if ($_GET['products_filter'] != '') {
  485.   $display_priced_by_attributes = zen_get_products_price_is_priced_by_attributes($_GET['products_filter']);
  486.   echo ($display_priced_by_attributes ? '<span class="alert">' . TEXT_PRICED_BY_ATTRIBUTES . '</span>' . '<br />' : '');
  487.   echo zen_get_products_display_price($_GET['products_filter']) . '<br /><br />';
  488.   echo zen_get_products_quantity_min_units_display($_GET['products_filter'], $include_break = true);
  489.   $not_for_cart = $db->Execute("select p.products_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCT_TYPES . " pt on p.products_type= pt.type_id where pt.allow_add_to_cart = 'N'");
  490. } else {
  491.   echo '';
  492.   $not_for_cart = new stdClass();
  493.   $not_for_cart->fields = array();
  494. }
  495. ?>
  496.             </td>
  497.             <td class="attributes-even" align="center"><?php echo zen_draw_products_pull_down('products_filter', 'size="5"', $not_for_cart->fields, true, $_GET['products_filter'], true, true); ?></td>
  498.             <td class="main" align="center" valign="top">
  499.               <?php
  500.                 echo zen_image_submit('button_display.gif', IMAGE_DISPLAY);
  501.               ?>
  502.             </td>
  503.           </tr>
  504.  
  505.         <tr>
  506.           <td colspan="3">
  507.             <table>
  508.  
  509. <?php
  510. // show when product is linked
  511. if (zen_get_product_is_linked($products_filter) == 'true') {
  512. ?>
  513.               <tr>
  514.                 <td class="main" align="center" valign="bottom">
  515.                   <?php echo zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', IMAGE_ICON_LINKED) . '&nbsp;&nbsp;' . TEXT_LEGEND_LINKED . ' ' . zen_get_product_is_linked($products_filter, 'true'); ?>
  516.                 </td>
  517.               </tr>
  518. <?php } ?>
  519.               <tr>
  520.                 <td class="main" align="center" valign="bottom">
  521. <?php
  522.   if ($_GET['products_filter'] != '') {
  523.     echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'action=new_product' . '&cPath=' . $current_category_id . '&pID=' . $products_filter . '&product_type=' . zen_get_products_type($products_filter)) . '">' . zen_image_button('button_edit_product.gif', IMAGE_EDIT_PRODUCT) . '<br />' . TEXT_PRODUCT_EDIT . '</a>';
  524.     echo '</td><td class="main" align="center" valign="bottom">';
  525.     echo '<a href="' . zen_href_link(FILENAME_ATTRIBUTES_CONTROLLER, 'products_filter=' . $products_filter . '&current_category_id=' . $current_category_id, 'NONSSL') . '">' . zen_image_button('button_edit_attribs.gif', IMAGE_EDIT_ATTRIBUTES) . '<br />' . TEXT_ATTRIBUTE_EDIT . '</a>' . '&nbsp;&nbsp;&nbsp;';
  526.   }
  527. ?>
  528.                 </td>
  529.               </tr>
  530.             </table>
  531.           </td>
  532.         </tr>
  533.  
  534.         </table>
  535.       </form>
  536.  
  537.  
  538. <div class="managerbox">
  539. <!-- Start Photo Display -->
  540.  
  541. <?php
  542. // start of attributes display
  543. if ($products_filter == '') {
  544. ?>
  545.     <h2><?php echo HEADING_TITLE_PRODUCT_SELECT; ?></h2>
  546. <?php
  547. } else {
  548.   // Get the details for the product
  549.   $product = $db->Execute("select p.products_id, p.products_model,
  550.                                      p.products_image,
  551.                                      p.product_is_free, p.product_is_call, p.products_quantity_mixed, p.products_priced_by_attribute, p.products_status,
  552.                                      p.products_discount_type, p.products_discount_type_from, p.products_price_sorter,
  553.                                      pd.products_name,
  554.                                      p.master_categories_id
  555.                               from " . TABLE_PRODUCTS . " p, " .
  556.                                         TABLE_PRODUCTS_DESCRIPTION . " pd
  557.                               where p.products_id = '" . $_GET['products_filter'] . "'
  558.                               and p.products_id = pd.products_id
  559.                               and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
  560.  
  561.  
  562.     if ($product->RecordCount() > 0) {
  563.         $pInfo = new objectInfo($product->fields);
  564.     }
  565.  
  566.   // Determine if there are any images and work out the file names
  567.   // (based on code from modules/pages/product_info/main_template_vars_images(& _additional) (copying is evil!))
  568.   if ($pInfo->products_image != '') {
  569.    
  570.     $products_image = $pInfo->products_image;
  571.     $products_image_match_array = array();
  572.  
  573.     // get file extension and base
  574.     $products_image_extension = substr($products_image, strrpos($products_image, '.'));
  575.     $products_image_base = preg_replace("/".$products_image_extension."$/", '', $products_image);
  576.        
  577.     // if in a subdirectory
  578.     if (strrpos($products_image_base, '/')) {
  579.       $products_image_base = substr($products_image_base, strrpos($products_image_base, '/')+1);
  580.     }
  581.    
  582.    
  583.     // sort out directory
  584.     $products_image_directory =  substr($products_image, 0, strrpos($products_image, '/'));
  585.       // add slash to base dir
  586.       if (($products_image_directory != '') && (!preg_match("|\/$|", $products_image_directory))) {
  587.         $products_image_directory .= '/';
  588.       }
  589.     $products_image_directory_full = DIR_FS_CATALOG . DIR_WS_IMAGES . $products_image_directory;
  590.    
  591.     // Check that the image exists! (out of date Database)
  592.     if (file_exists( $products_image_directory_full . $products_image_base . $products_image_extension )) {
  593.  
  594.       // Add base image to array
  595.       $products_image_match_array[] = $products_image_base . $products_image_extension;
  596.       // $products_image_base .= "_";
  597.      
  598.       // Check for additional matching images
  599.       find_additional_images($products_image_match_array, $products_image_directory_full,
  600.         $products_image_extension, $products_image_base );
  601.     }
  602.    
  603.   } // if products_image
  604.  
  605. ?>
  606.  
  607. <?php
  608.   if ($pInfo->products_id != '') {
  609. ?>
  610.     <h2>
  611.       <?php echo TEXT_PRODUCT_INFO . ': #' . $pInfo->products_id . '&nbsp;&nbsp;' . $pInfo->products_name; ?>&nbsp;&nbsp;&nbsp;
  612.       <?php
  613.         if ($pInfo->products_model != '') {
  614.           echo TEXT_PRODUCTS_MODEL . ': ' . $pInfo->products_model;
  615.         }
  616.       ?>
  617.       &nbsp;&nbsp;&nbsp;
  618.       <?php
  619.         if ($pInfo->products_image != '') {
  620.           if (preg_match("/^([^\/]+)\//", $pInfo->products_image, $matches)) {
  621.             echo TEXT_IMAGE_BASE_DIR .': ';
  622.             echo $matches[1];
  623.           }
  624.         }
  625.       ?>
  626.     </h2>
  627.     <table border="0" width="100%" cellspacing="0" cellpadding="2"><tr><td valign="top">
  628.     <table border="0" width="100%" cellspacing="0" cellpadding="2">
  629.     <tr class="dataTableHeadingRow">
  630.       <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PHOTO_NAME; ?></td>
  631.       <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_FILETYPE; ?></td><?php //added nigel ?>
  632.       <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DEFAULT_SIZE; ?></td>
  633.       <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_MEDIUM_SIZE; ?></td>
  634.       <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_LARGE_SIZE; ?></td>
  635.       <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  636.     </tr>
  637. <?php
  638.   $selected_image_suffix = '';
  639.   // no images
  640.   $no_images = (0 == $count = sizeof($products_image_match_array));
  641.   if ($no_images) {
  642. ?>
  643.       <tr>
  644.         <td colspan="6" class="dataTableContent" align="center"><?php echo TEXT_NO_PRODUCT_IMAGES; ?></td>
  645.       </tr>
  646. <?php
  647.   }
  648. ?>
  649.  
  650. <?php
  651.     $default_extension = 'bob';
  652.   $first = 1;
  653.   for ($i=0; $i < $count; $i++) {
  654.     // there are some pictures, show them!
  655.     $splitpos = strrpos($products_image_match_array[$i], '.');
  656.     $tmp_image_name = substr($products_image_match_array[$i], 0, $splitpos);
  657.     $products_image_extension = substr($products_image_match_array[$i], $splitpos);
  658.     if ($default_extension == 'bob') {$default_extension = $products_image_extension;}//added nigel
  659.     $image_file = DIR_WS_IMAGES . $products_image_directory . $tmp_image_name . $products_image_extension;
  660.     $image_file_medium = DIR_WS_IMAGES . 'medium/' . $products_image_directory . $tmp_image_name . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
  661.     $image_file_large  = DIR_WS_IMAGES . 'large/' . $products_image_directory . $tmp_image_name . IMAGE_SUFFIX_LARGE .  $products_image_extension;
  662.  
  663.     $image_file_full = DIR_FS_CATALOG . $image_file;
  664.     $image_file_medium_full = DIR_FS_CATALOG . $image_file_medium;
  665.     $image_file_large_full = DIR_FS_CATALOG . $image_file_large;
  666.  
  667.     $tmp_image = new ih_image($image_file, $ihConf['small']['width'], $ihConf['small']['height']);
  668.     $tmp_image_file = $tmp_image->get_local();
  669.     $tmp_image_file_full = DIR_FS_CATALOG . $tmp_image_file;
  670.     $tmp_image_preview = new ih_image($tmp_image_file, IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT);
  671.  
  672.     $tmp_image_medium = new ih_image($image_file_medium, $ihConf['medium']['width'], $ihConf['medium']['height']);
  673.     $tmp_image_file_medium = $tmp_image_medium->get_local();
  674.     $tmp_image_file_medium_full = DIR_FS_CATALOG . $tmp_image_file_medium;
  675.     $tmp_image_medium_preview = new ih_image($tmp_image_file_medium, IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT);
  676.    
  677.     $tmp_image_large = new ih_image($image_file_large, $ihConf['large']['width'], $ihConf['large']['height']);
  678.     $tmp_image_file_large = $tmp_image_large->get_local();
  679.     $tmp_image_file_large_full = DIR_FS_CATALOG . $tmp_image_file_large;
  680.     $tmp_image_large_preview = new ih_image($tmp_image_file_large, IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT);
  681.  
  682.  
  683.     // Get file details
  684.     $text_default_size = get_image_details_string( $tmp_image_file_full );
  685.     $text_medium_size = get_image_details_string( $tmp_image_file_medium_full );
  686.     $text_large_size = get_image_details_string( $tmp_image_file_large_full );
  687.  
  688.     if ($first == 1) {
  689.       $tmp_image_link = zen_catalog_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $pInfo->products_id);
  690.       $first = 0;
  691.     } else {
  692.       $tmp_image_link = zen_catalog_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL,
  693.         'pID=' . $pInfo->products_id . '&pic='.($i).'&products_image_large_additional='.$tmp_image_file_large);
  694.     }
  695.  
  696.    
  697.     if ( isset($_GET['imgName']) && $_GET['imgName'] == $tmp_image_name ) {
  698.       // an image is selected, highlight it
  699.       echo '<tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\''
  700.        . zen_href_link(FILENAME_IMAGE_HANDLER, 'products_filter=' . $_GET['products_filter']
  701.        . '&imgName=' .$tmp_image_name . '&action=layout_edit') . '\'">' . "\n";
  702.         // set some details for later usage
  703.       $selected_image_file = DIR_WS_CATALOG . $tmp_image_file_medium;
  704.       $selected_image_file_large = DIR_WS_CATALOG . $tmp_image_file_large;
  705.         $selected_image_link = $tmp_image_link;
  706.         $selected_image_name = $tmp_image_name;
  707.         $selected_image_suffix = preg_replace("/^".$products_image_base."/", '', $tmp_image_name);
  708.         $selected_image_extension = $products_image_extension;
  709.     } else {
  710.       echo '<tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\''
  711.         . zen_href_link(FILENAME_IMAGE_HANDLER, 'products_filter=' . $_GET['products_filter']
  712.         . '&imgName=' . $tmp_image_name . '&action=layout_info') . '\'">' . "\n";
  713.     }
  714. ?>
  715.    
  716.       <td class="dataTableContent"><?php echo $tmp_image_name; ?></td>
  717.       <td class="dataTableContent"<?php if ($products_image_extension != $default_extension){echo 'style="color:red;"';} ?>><?php echo $products_image_extension; ?></td>
  718.       <td class="dataTableContent" align="center" valign="top">
  719.         <?php
  720.           $preview_image = $tmp_image_preview->get_resized_image(IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT, 'generic');
  721.           list($width, $height) = @getimagesize(DIR_FS_CATALOG . $preview_image);
  722.           $width = min($width, intval(IMAGE_SHOPPING_CART_WIDTH));
  723.           $height = min ($height, intval(IMAGE_SHOPPING_CART_HEIGHT));
  724.           echo zen_image(DIR_WS_CATALOG . $preview_image, addslashes($pInfo->products_name), $width, $height) . '<br />';
  725.         ?>
  726.         <?php echo $text_default_size; ?>
  727.       </td>
  728.       <td class="dataTableContent" align="center" valign="top">
  729.         <?php
  730.           $preview_image = $tmp_image_medium_preview->get_resized_image(IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT, 'generic');
  731.           list($width, $height) = @getimagesize(DIR_FS_CATALOG . $preview_image);
  732.           $width = min($width, intval(IMAGE_SHOPPING_CART_WIDTH));
  733.           $height = min ($height, intval(IMAGE_SHOPPING_CART_HEIGHT));
  734.           echo zen_image(DIR_WS_CATALOG . $preview_image, addslashes($pInfo->products_name), $width, $height) . '<br />';
  735.           echo $text_medium_size . '<br />';
  736.           if (is_file($image_file_medium_full)) {
  737.             echo ' <a href="' . zen_href_link(FILENAME_IMAGE_HANDLER, 'imgName='
  738.               . $image_file_medium . '&products_filter=' . $_GET['products_filter'] . '&action=quick_delete') . '">'
  739.               . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>';
  740.           }
  741.         ?>
  742.       </td>
  743.       <td class="dataTableContent" align="center" valign="top">
  744.         <?php
  745.           $preview_image = $tmp_image_large_preview->get_resized_image(IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT, 'generic');
  746.           list($width, $height) = @getimagesize(DIR_FS_CATALOG . $preview_image);
  747.           $width = min($width, intval(IMAGE_SHOPPING_CART_WIDTH));
  748.           $height = min ($height, intval(IMAGE_SHOPPING_CART_HEIGHT));
  749.           echo zen_image(DIR_WS_CATALOG . $preview_image, addslashes($pInfo->products_name), $width, $height) . '<br />';
  750.           echo $text_large_size . '<br />';
  751.           if (is_file($image_file_large_full)) {
  752.             echo ' <a href="' . zen_href_link(FILENAME_IMAGE_HANDLER, 'imgName='
  753.               . $image_file_large . '&products_filter=' . $_GET['products_filter'] . '&action=quick_delete') . '">'
  754.               . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>';
  755.           }
  756.         ?>
  757.       </td>
  758.       <td class="dataTableContent" align="right"><?php
  759.         if ( isset($_GET['imgName']) && $_GET['imgName'] == $tmp_image_name ) {
  760.           echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', '');
  761.         } else {
  762.           echo '<a href="' . zen_href_link(FILENAME_IMAGE_HANDLER, 'products_filter=' . $_GET['products_filter']
  763.             . '&imgName=' . $tmp_image_name . '&action=layout_info')
  764.             . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>';
  765.         }
  766.       ?>&nbsp;</td>
  767.     </tr>
  768. <?php  
  769.    
  770.   } // for each photo loop
  771. ?>
  772.   </table></td><!-- END Photo list table -->
  773.   <!-- Start Data Edit Pane -->
  774. <?php
  775.   $heading = array();
  776.   $contents = array();
  777.  
  778.   $imgNameStr = '';
  779.   switch ($action) {
  780.     case 'layout_info':
  781.       // edit
  782.       list($width, $height) = @getimagesize(DIR_FS_CATALOG . $selected_image_file);
  783. //      $width = min($width, intval(MEDIUM_IMAGE_WIDTH));
  784. //      $height = min($height, intval(MEDIUM_IMAGE_HEIGHT));
  785.       $heading[] = array('text' => '<strong>' . TEXT_INFO_IMAGE_INFO . '</strong>');
  786.       $contents = array('align' => 'center', 'form' => zen_draw_form('image_define', FILENAME_IMAGE_HANDLER,
  787.         'page=' . $_GET['page'] . '&products_filter=' . $_GET['products_filter'] . '&action=save', 'post', 'enctype="multipart/form-data"'));
  788.           $contents[] = array('text' => '<strong>'.TEXT_INFO_NAME.': </strong>' . $selected_image_name .'<br />');
  789.           $contents[] = array('text' => '<strong>'.TEXT_INFO_FILE_TYPE.': </strong>' . $selected_image_extension .'<br />');
  790.           $contents[] = array('text' =>
  791.               '<script language="javascript" type="text/javascript"><!--
  792.              document.write(\'<a href="javascript:popupWindow(\\\'' . $selected_image_link . '\\\')">'
  793.              . zen_image($selected_image_file, addslashes($pInfo->products_name), $width, $height)
  794.              . '<br />' . TEXT_CLICK_TO_ENLARGE . '</a>\');'
  795.               .'//-->'
  796.         .'</script>
  797.        <noscript>'
  798.         .'<a href="' . zen_href_link($selected_image_file_large) . '" target="_blank">'
  799.             . zen_image($selected_image_file, $pInfo->products_name, $width, $height)
  800.             . TEXT_CLICK_TO_ENLARGE . '</a>'
  801.         .'</noscript>' );
  802.       // show new, delete, and edit buttons
  803.       $contents[] = array('align' => 'center', 'text' => '<br />' .
  804.         ' <a href="' . zen_href_link(FILENAME_IMAGE_HANDLER, 'imgName='
  805.         . $_GET['imgName'] . '&products_filter=' . $_GET['products_filter'] . '&action=layout_edit') . '">'
  806.         . zen_image_button('button_edit.gif', IH_IMAGE_EDIT) . '</a> &nbsp; '
  807.         .' <a href="' . zen_href_link(FILENAME_IMAGE_HANDLER, 'imgName='
  808.         . $_GET['imgName'] . '&products_filter=' . $_GET['products_filter'] . '&action=layout_delete') . '">'
  809.         . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a> &nbsp;'
  810.         .' <a href="' . zen_href_link(FILENAME_IMAGE_HANDLER,
  811.         '&products_filter=' . $_GET['products_filter'] . '&action=layout_new') . '">'
  812.         . zen_image_button('button_new_file.gif', IH_IMAGE_NEW_FILE) . '</a>');
  813.      
  814.       break;
  815.     case 'layout_edit':
  816.       // Edit specific details
  817.       $imgNameStr = '&imgEdit=1' .'&imgBase=' . $products_image_base
  818.           . "&imgSuffix=" . $selected_image_suffix
  819.           . "&imgBaseDir=" . $products_image_directory
  820.           . "&imgExtension=" . $selected_image_extension;
  821.       $heading[] = array('text' => '<strong>' . TEXT_INFO_EDIT_PHOTO . '</strong>');
  822.  
  823.     case 'layout_new':  
  824.      
  825. /*      if ( $action != 'layout_edit' ) {
  826.         $imgNameStr .= ( $no_images ) ? "&newImg=1" : '&imgBase='.$products_image_base
  827.           . "&imgBaseDir=" . $products_image_directory
  828.           . "&imgExtension=" . $products_image_extension;
  829.         $heading[] = array('text' => '<strong>' . TEXT_INFO_NEW_PHOTO . '</strong>');
  830.       }
  831.  */    
  832.       if ( $action != 'layout_edit' ) {
  833.         $imgNameStr .= ( $no_images ) ? "&newImg=1" : '&imgBase='.$products_image_base
  834.           . "&imgBaseDir=" . $products_image_directory
  835.           . "&imgExtension=" . $default_extension;
  836.         $heading[] = array('text' => '<strong>' . TEXT_INFO_NEW_PHOTO . '</strong>');
  837.       }
  838.      
  839.      
  840.       $contents = array('form' => zen_draw_form('image_define', FILENAME_IMAGE_HANDLER,
  841.         '&products_filter=' . $_GET['products_filter'] . $imgNameStr
  842.         .'&action=save', 'post', 'enctype="multipart/form-data"'));
  843.  
  844.       // check if this is a master image or if no images exist
  845.       if ($no_images) {
  846.         $contents[] = array('text' => '<strong>'.TEXT_INFO_IMAGE_BASE_NAME.'</strong><br />' );
  847.         $contents[] = array('text' => zen_draw_input_field('imgBase', '', 30));
  848.              
  849.         $dir = @dir(DIR_FS_CATALOG_IMAGES);
  850.             $dir_info[] = array('id' => '', 'text' => TEXT_INFO_MAIN_DIR);
  851.             while ($file = $dir->read()) {
  852.               if (is_dir(DIR_FS_CATALOG_IMAGES . $file)
  853.                   && strtoupper($file) != 'CVS'
  854.                   && $file != "."
  855.                   && $file != ".."
  856.                   && $file != 'original'
  857.                   && $file != 'medium'
  858.                   && $file != 'large') {
  859.                   $dir_info[] = array('id' => $file . '/', 'text' => $file);
  860.               }
  861.             }
  862.             $contents[] = array('text' => '<br /><strong>'.TEXT_INFO_BASE_DIR.'</strong><br />'.TEXT_INFO_NEW_DIR);
  863.             $contents[] = array('text' => TEXT_INFO_IMAGE_DIR . zen_draw_pull_down_menu('imgBaseDir', $dir_info, ""));
  864.             $contents[] = array('text' => TEXT_INFO_OR.' ' . zen_draw_input_field('imgNewBaseDir', '', 20) );
  865.  
  866.       } else if ($action != 'layout_edit') {
  867.             $contents[] = array('text' => '<strong>'.TEXT_INFO_IMAGE_SUFFIX.'</strong><br />'.TEXT_INFO_USE_AUTO_SUFFIX.'<br />' );
  868.             $contents[] = array('text' => zen_draw_input_field('imgSuffix', $selected_image_suffix, 10) );
  869.       }
  870.  
  871.       // Image fields
  872.         // Nigels ugly hack to display warning on edit screen that the default file must be filled in
  873.         if ( $action == 'layout_new' ) {// -this section is the hack
  874.         //-------------------------
  875.       $contents[] = array('text' => '<br /><strong>' . TEXT_INFO_DEFAULT_IMAGE . '</strong>&nbsp;&nbsp;<strong class="errorText">(required)</strong><br />'
  876.           . TEXT_INFO_DEFAULT_IMAGE_HELP . '<br />'
  877.           . zen_draw_input_field('default_image', '', ' size="20" ', false, 'file') . '<br />' . $pInfo->products_image);
  878.         } else { // this section is the original code
  879.       $contents[] = array('text' => '<br /><strong>' . TEXT_INFO_DEFAULT_IMAGE . '</strong><br />'
  880.           . TEXT_INFO_DEFAULT_IMAGE_HELP . '<br />'
  881.           . zen_draw_input_field('default_image', '', ' size="20" ', false, 'file') . '<br />' . $pInfo->products_image);
  882.            
  883.         }
  884.  
  885.       if ( $action == 'layout_edit' ) {
  886.         if ( $selected_image_name == $products_image_match_array[0]) {
  887.           $contents[] = array('text' => zen_draw_radio_field('imgNaming', 'new_discard', true)
  888.                 . IH_NEW_NAME_DISCARD_IMAGES . '<br />'
  889. //  new_copy functionality scheduled for future release                
  890. //            . zen_draw_radio_field('imgNaming', 'new_copy', false)
  891. //                . IH_NEW_NAME_COPY_IMAGES . '<br />'
  892.             . zen_draw_radio_field('imgNaming', 'keep_name', false)
  893.                 . IH_KEEP_NAME);
  894.         }
  895.       }
  896.  
  897.        $contents[] = array('text' => '<br /><strong>' . TEXT_MEDIUM_FILE_IMAGE . '</strong><br />' .
  898.           zen_draw_input_field('medium_image', '', ' size="20" ', false, 'file') . '<br />');
  899.       $contents[] = array('text' => '<br /><strong>' . TEXT_LARGE_FILE_IMAGE . '</strong><br />' .
  900.           zen_draw_input_field('large_image', '', ' size="20" ', false, 'file') . '<br />');
  901.       $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_save.gif', IMAGE_SAVE) );
  902.       break;
  903.     case 'layout_delete':
  904.  
  905.       $imgStr = "&imgBase=" . $products_image_base
  906.           . "&imgSuffix=" . $selected_image_suffix
  907.           . "&imgBaseDir=" . $products_image_directory
  908.           . "&imgExtension=" . $selected_image_extension;
  909.          
  910.       // show new button      
  911.       $heading[] = array('text' => '<strong>' . TEXT_INFO_CONFIRM_DELETE . '</strong>');
  912.      
  913.       $contents[] = array('text' => '<br />' . $products_image_directory.$products_image_base.$selected_image_suffix.$selected_image_extension);
  914.       $contents[] = array('text' => '<br />' . TEXT_INFO_CONFIRM_DELETE_SURE);
  915.       if ($selected_image_suffix == '') {
  916.         $contents[] = array('text' => zen_draw_checkbox_field('delete_from_database_only', 'Y', false) . IH_DELETE_FROM_DB_ONLY);
  917.       }
  918.  
  919.       $contents[] = array('align' => 'center', 'text' => '<br />'
  920.         .' <a href="' . zen_href_link(FILENAME_IMAGE_HANDLER,
  921.         '&products_filter=' . $_GET['products_filter'] . '&action=delete'
  922.         . $imgStr ) . '">'
  923.         . zen_image_button( 'button_delete.gif', IMAGE_DELETE ) . '</a>');
  924.       break;
  925.     default:
  926.       // show new button      
  927.       $heading[] = array('text' => '<strong>' . TEXT_INFO_SELECT_ACTION . '</strong>');
  928.       $contents = array('form' => zen_draw_form('image_define', FILENAME_PRODUCT_TYPES, 'page=' . $_GET['page'] . '&action=new', 'post', 'enctype="multipart/form-data"'));
  929.       $contents[] = array('text' => '<br />' . TEXT_INFO_CLICK_TO_ADD);
  930.       $contents[] = array('align' => 'center', 'text' => '<br />'
  931.         .' <a href="' . zen_href_link(FILENAME_IMAGE_HANDLER,
  932.         '&products_filter=' . $_GET['products_filter'] . '&action=layout_new') . '">'
  933.         . zen_image_button('button_new_file.gif', IH_IMAGE_NEW_FILE) . '</a>');
  934.       break;
  935.   }
  936.  
  937.   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
  938.     echo '            <td width="25%" valign="top">' . "\n";
  939.  
  940.     $box = new box;
  941.     echo $box->infoBox($heading, $contents);
  942.  
  943.     echo '            </td>' . "\n";
  944.   }
  945. ?>  
  946.   </tr></table>
  947. <?php
  948.  
  949.   } // if products_id
  950.  
  951. } // if products_filter
  952. ?>
  953. </div>
  954. <?php
  955. } // if $page == 'manager'
  956.  
  957.  
  958. /**
  959.  * PREVIEW TABPAGE
  960.  */
  961.  
  962. if ($page == 'preview') {
  963.   $images = array();
  964.   $pngimage = new ih_image(basename($ihConf['dir']['admin']) . "/" . 'images/ih-test.png', intval($ihConf['small']['width']), intval($ihConf['small']['height']));
  965.   $images['pngsource'] = $pngimage->get_resized_image(intval($ihConf['small']['width']), intval($ihConf['small']['height']), 'orig');
  966.   $images['pngsmall'] = $pngimage->get_resized_image($ihConf['small']['width'], $ihConf['small']['height'], 'small');
  967.   $images['pngmedium'] = $pngimage->get_resized_image($ihConf['medium']['width'], $ihConf['medium']['height'], 'medium');
  968.   $images['pnglarge'] = $pngimage->get_resized_image($ihConf['large']['width'], $ihConf['large']['height'], 'large');
  969.  
  970.   $jpgimage = new ih_image(basename($ihConf['dir']['admin']) . "/" . 'images/ih-test.jpg', intval($ihConf['small']['width']), intval($ihConf['small']['height']));
  971.   $images['jpgsource'] = $jpgimage->get_resized_image(intval($ihConf['small']['width']), intval($ihConf['small']['height']), 'orig');
  972.   $images['jpgsmall'] = $jpgimage->get_resized_image($ihConf['small']['width'], $ihConf['small']['height'], 'small');
  973.   $images['jpgmedium'] = $jpgimage->get_resized_image($ihConf['medium']['width'], $ihConf['medium']['height'], 'medium');
  974.   $images['jpglarge'] = $jpgimage->get_resized_image($ihConf['large']['width'], $ihConf['large']['height'], 'large');
  975.  
  976.   $gifimage = new ih_image(basename($ihConf['dir']['admin']) . "/" . 'images/ih-test.gif', intval($ihConf['small']['width']), intval($ihConf['small']['height']));
  977.   $images['gifsource'] = $gifimage->get_resized_image(intval($ihConf['small']['width']), intval($ihConf['small']['height']), 'orig');
  978.   $images['gifsmall'] = $gifimage->get_resized_image($ihConf['small']['width'], $ihConf['small']['height'], 'small');
  979.   $images['gifmedium'] = $gifimage->get_resized_image($ihConf['medium']['width'], $ihConf['medium']['height'], 'medium');
  980.   $images['giflarge'] = $gifimage->get_resized_image($ihConf['large']['width'], $ihConf['large']['height'], 'large');
  981.  
  982. ?>
  983.   <table style="background-color:#F5F5F5" cellspacing="0" cellpadding="5px" border="0">
  984.     <tr>
  985.         <th style="border-bottom: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC"><?php echo IH_SOURCE_TYPE; ?></th>
  986.         <th style="border-bottom: 1px solid #CCCCCC"><?php echo IH_SOURCE_IMAGE; ?></th>
  987.         <th style="border-bottom: 1px solid #CCCCCC"><?php echo IH_SMALL_IMAGE; ?></th>
  988.         <th style="border-bottom: 1px solid #CCCCCC"><?php echo IH_MEDIUM_IMAGE; ?></th>
  989.     </tr>
  990.     <!-- source png row -->
  991.     <tr>
  992.         <td style="border-right: 1px solid #CCCCCC"><strong>png</strong></td>
  993.         <td><img style="border: 1px solid #000000; background:url(images/checkpattern.gif)" src="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $images['pngsource']?>" /></td>
  994.         <td><img style="border: 1px solid #000000; background:url(images/checkpattern.gif)" src="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $images['pngsmall']?>" /></td>
  995.         <td><img style="border: 1px solid #000000; background:url(images/checkpattern.gif)" src="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $images['pngmedium']?>" /></td>
  996.     </tr>
  997.     <!-- source jpg row -->
  998.     <tr>
  999.         <td style="border-right: 1px solid #CCCCCC"><strong>jpg</strong></td>
  1000.         <td><img style="border: 1px solid #000000; background:url(images/checkpattern.gif)" src="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $images['jpgsource']?>" /></td>
  1001.         <td><img style="border: 1px solid #000000; background:url(images/checkpattern.gif)" src="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $images['jpgsmall']?>" /></td>
  1002.         <td><img style="border: 1px solid #000000; background:url(images/checkpattern.gif)" src="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $images['jpgmedium']?>" /></td>
  1003.     </tr>
  1004.     <!-- source gif row -->
  1005.     <tr style="border-right: 1px solid #CCCCCC">
  1006.         <td style="border-right: 1px solid #CCCCCC"><strong>gif</strong></td>
  1007.         <td><img style="border: 1px solid #000000; background:url(images/checkpattern.gif)" src="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $images['gifsource']?>" /></td>
  1008.         <td><img style="border: 1px solid #000000; background:url(images/checkpattern.gif)" src="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $images['gifsmall']?>" /></td>
  1009.         <td><img style="border: 1px solid #000000; background:url(images/checkpattern.gif)" src="<?php echo HTTP_SERVER . DIR_WS_CATALOG . $images['gifmedium']?>" /></td>
  1010.     </tr>
  1011.   </table>
  1012. <?php
  1013. }
  1014.  
  1015.  
  1016.  
  1017. /**
  1018.  * ABOUT TABPAGE
  1019.  */
  1020.  
  1021. if ($page == 'about') {
  1022. ?>
  1023. <div class="aboutbox">
  1024. <h2>Image Handler<sup>4</sup> v4.0 for v1.5.x</h2>
  1025.  
  1026. <p>
  1027. Image Handler<sup>4</sup> v4.0 for v1.5.x is based on an original contribution by Tim Kr&#246;ger.<br /></p>
  1028. <fieldset>
  1029. <legend>Purpose &amp; Aim</legend>
  1030. <p>Image Handler<sup>4</sup> at the heart of it's code is really meant to ease the management of product images (particularly the management of additional product images), and to help improve page performance by
  1031.   optimizing the product images.</p>
  1032. <p>Image Handler<sup>4</sup> generates product images (based on your image settings) in the Image Handler<sup>4</sup> bmz_cache folder. It <strong>DOES NOT</strong> replace or modify the original images. So it's PERFECTLY safe to use on an existing store.</p>
  1033. <p> Image Handler<sup>4</sup> enables you to use GD libraries or ImageMagick (if   installed on your server) to generate and resize small, medium and large   images on the fly on page request. You can simply upload just one image   or you can have different sources for medium and large images. Image Handler<sup>4</sup> further enables you to watermark your images (overlay a second   specific translucent image) and have medium or large images pop up when you move   your mouse over a small image (fancy hover).</p>
  1034. <p> This contribution includes a powerful admin interface to browse your   products just like you would with the Attribute Manager and upload /   delete / add additional images without having to do this manually via <acronym title="File Transfer Protocol">FTP</acronym>. Image Handler<sup>4</sup> works fine with mass update utilities like EzPopulate. </p>
  1035. </fieldset>
  1036. <hr>
  1037. <fieldset>
  1038. <legend>Features</legend>
  1039. <ul>
  1040.   <li>Improve site performance (faster loading, faster display)</li>
  1041.   <li>Professional looking images (no stair-effects, smooth edges)</li>
  1042.   <li>Choose preferred image-types for each image size</li>
  1043.   <li>Uploading one image automatically creates small, medium and large images on page request</li>
  1044.   <li>Drops in and out seamlessly. No need to redo your images. All images are kept.</li>
  1045.   <li>Easy install. One-click-database-upgrade.</li>
  1046.   <li>Works with mass-update/-upload tools like EzPopulate.</li>
  1047.   <li>Watermark images to prevent competitors from stealing them.</li>
  1048.   <li>Fancy image hover functionality lets a larger image pop up whenever you move your mouse above a small image (switchable).</li>
  1049.   <li>Choose an image background color matching to match you site's color or select a transparent background for your images.</li>
  1050.   <li>Manage your multiple images for products easily from one page just like you do with attributes in the Products Attribute Manager.</li>
  1051. </ul>
  1052. <p>Image Handler<sup>4</sup> is meant to ease the work required to setup images for your store.   It works WITH default Zen Cart functionality, it does not replace it. </p>
  1053. <p>It is very strongly recommend you read through the ENTIRE "<strong>Configuration</strong>" &amp; "<strong>Usage</strong>" sections of the Image Handler<sup>4</sup> readme file. There you will find out exactly what <strong>Image Handler<sup>4</sup></strong> can do.</p>
  1054. </fieldset>
  1055.  
  1056. <hr>
  1057.  
  1058. <fieldset>
  1059. <legend>Troubleshooting Basics</legend>
  1060. <p>Make sure your custom template is active. (Admin &gt; Tools &gt; Template Selection)</p>
  1061. <p>Make sure Image Handler<sup>4</sup> is installed. <strong>Admin
  1062. &gt; Tools &gt; Image Handler<sup>4</sup> &gt; Admin</strong>.
  1063. Set permissions in both your <strong>images</strong> and <strong>bmz_cache</strong> folders to 755 (eg: <strong>both </strong>of these folders need
  1064. to have  the same permissions. For some webhosts you may have to set these permissions
  1065. to 777).</p>
  1066. <p>If Image Handler<sup>4</sup> does not work or gives you errors:</p>
  1067. <ul>
  1068.   <li>Make sure all files are in correct location</li>
  1069.   <li>Make sure you uploaded ALL the Image Handler<sup>4</sup> files
  1070.   </li>
  1071.   <li>Make sure the files are not corrupt from bad FTP transfers</li>
  1072.   <li>Make sure your file merge edits are correct</li>
  1073.   <li>MAKE SURE YOU RE-READ THE CONFIGURATION AND USAGE SECTIONS!!!</li>
  1074.   <li>Make sure that there are no javascript conflicts (this last point has been largely addressed since Rev 7)</li>
  1075.   <li>Make sure that your main product image files names DO NOT contain any special characters (<font>non-alphanumeric characters such as / \ :
  1076. ! @ # $ % ^ &lt; &gt; , [ ] { } &amp; * ( ) + = </font>). Always use
  1077. proper filenaming practices when naming your images - See this document as a reference: <small><a href="http://www.records.ncdcr.gov/erecords/filenaming_20080508_final.pdf" target="_blank">http://www.records.ncdcr.gov/erecords/filenaming_20080508_final.pdf\</a></small></li>
  1078. </ul>
  1079. </fieldset>
  1080.  
  1081. <hr>
  1082.  
  1083. <fieldset>
  1084. <legend>Zen Cart and Image Management</legend>
  1085. <p>Image Handler<sup>4</sup> is meant to ease the work required to setup images for your store..   It works WITH default Zen Cart functionality, it does not replace it..   Here's some additional FAQs which discuss how product images work in Zen   Cart.</p>
  1086. <ul>
  1087.   <li><a href="http://tutorials.zen-cart.com/index.php?article=224" target="_blank">Image Preparation - How-to</a></li>
  1088.   <li><a href="http://tutorials.zen-cart.com/index.php?article=30" target="_blank">My images are distorted/fuzzy/squished, help?</a><br>
  1089.   </li>
  1090. </ul>
  1091. <p>Information on how Zen Cart   identifies/manages additional product images can be found on these Zen Cart FAQs:</p>
  1092. <ul>
  1093.   <li><a href="http://tutorials.zen-cart.com/index.php?article=315" target="_blank">Why am I seeing images for other products on my product pages?</a></li>
  1094.   <li><a href="http://tutorials.zen-cart.com/index.php?article=58" target="_blank">How do I add multiple images to a product?</a></li>
  1095.   <li><a href="http://tutorials.zen-cart.com/index.php?article=202" target="_blank">How   do I add more than one image of a product?  I want to have a main image   and also one or two other images that show more parts of a particular   product. How/where do I add additional images to a product page?    Thanks!</a></li>
  1096. </ul>
  1097. <p>Check out these FAQs and see if they help clarify how Zen Cart works with product images.</p>
  1098. </fieldset>
  1099.  
  1100. <hr>
  1101.  
  1102. <fieldset>
  1103. <legend> Prepare Your Site for Growth</legend>
  1104. <p>Not many users are aware that Image Handler<sup>4</sup> can manage the needs of a very large site as easily as it does a small one. When first building a site, the owner of a small site needs only to load images to the images folder. But when the site gets bigger and images multiply like rabbits, this can cause file naming confusions for Zen Cart and slow down the site. Preparing for your business to grow from the beginning will save you hours of work later on!</p>
  1105. <p>Without Image Handler<sup>4</sup> installed, Zen Cart requires you to create, optimize, and upload three different size images for each image you want to use. You must name these images using naming suffixes, and place them in corresponding folders inside your main image folder. For example: A product called &quot;Widget&quot; requires images/widget.jpg (small image) images/medium/widget_MED.jpg (medium image) and images/large/widget_LRG.jpg. This is such a hassle, especially if many of your products have multiple images. And as your site grows, it becomes an impossible task!</p>
  1106. <p>With Image Handler<sup>4</sup>, you no longer have to make three sizes of the same images and place them in different folders (unless you want to)! Instead, you need upload only one image in one folder and Image Handler<sup>4</sup> will do the rest! Simply upload your largest highest quality image and Image Handler<sup>4</sup> will resize and optimize your image as needed, and serve up small, medium, or large image sizes appropriate to the page loaded - all automatically and all without actually modifying your original image file in any way! Check out the Configuration Tab of this ReadMe for more info about this awesome functionality!</p>
  1107. <p>Prepare your site for growth by simply creating sub-folders in your main images folder. For example, you may want to put all your &quot;widget&quot; images in a folder called &quot;widgets&quot; and all your doodad images in a folder called &quot;doodads&quot; , like this:<br>
  1108. </p>
  1109. <p>Product: Blue Widget with 3 images<br>
  1110.   ---------------------------------- <br>
  1111.   /images/widgets/blue_widget1.jpg (main product image for a blue widget, i.e. front view)<br>
  1112.   /images/widgets/blue_widget2.jpg (additional product image for a blue widget, i.e. side view)<br>
  1113.   /images/widgets/blue_widget3.jpg (additional product image for a blue widdget, i.e. rear view)</p>
  1114. <p>&nbsp;</p>
  1115. <p>Product: Red Widget with 1 image<br>
  1116.   --------------------------------<br>
  1117.   /images/widgets/red_widget.jpg (main product image for a red widget)</p>
  1118. <p>&nbsp;</p>
  1119. <p>Product: Gold Doodad with 2 images<br>
  1120.   ----------------------------------<br>
  1121.   /images/doodads/gold_doodad1.jpg (main product image for a gold doodad, i.e. view from above)<br>
  1122.   /images/doodads/gold_doodad2.jpg (additional product image for a gold doodad, i.e. view from side)</p>
  1123. <p>&nbsp;</p>
  1124. <p>Product: Silver Doodad with 3 images<br>
  1125.   ------------------------------------<br>
  1126.   /images/doodads/silver_doodad1.jpg (main product image for a silver doodad, i.e. product)<br>
  1127.   /images/doodads/silver_doodad2.jpg (additional product image for a silver doodad, i.e. product detail)<br>
  1128.   /images/doodads/silver_doodad3.jpg (additional product image for a silver doodad, i.e. product's silver stamp)<br>
  1129. </p>
  1130. <p>Using Image Handler<sup>4</sup>, you can easily sort and manage thousands of images without confusion or hassle! When selecting the main image for a product in the Image Handler<sup>4</sup> interface, Image Handler<sup>4</sup> lets you pick the location for this image. This prompt disappears afterwards because Image Handler<sup>4</sup> knows that additional images need to be in the same folder as their main product image and handles that automatically!</p>
  1131. </fieldset>
  1132.  
  1133. </div>
  1134. </div>
  1135. <?php
  1136. }
  1137. ?>
  1138. <!-- body_eof //-->
  1139. <!-- footer //-->
  1140. <?php
  1141.     require(DIR_WS_INCLUDES . 'footer.php');
  1142. ?>
  1143. <!-- footer_eof //-->
  1144. </body>
  1145. </html>
  1146. <?php
  1147.     require(DIR_WS_INCLUDES . 'application_bottom.php');
  1148.  


cron