function process($file)
 {
     // include needed functions
     include 'includes/classes/' . FILENAME_IMAGEMANIPULATOR;
     @vam_set_time_limit(0);
     // action
     // get images in original_images folder
     $files = array();
     // BOF Subdirectory support
     require_once DIR_WS_FUNCTIONS . 'trumbnails_add_funcs.php';
     $files = vam_get_files_in_dir(DIR_FS_CATALOG_ORIGINAL_IMAGES);
     //			echo '<pre>';var_dump($files);echo '</pre>';
     /*
     			if ($dir= opendir(DIR_FS_CATALOG_ORIGINAL_IMAGES)){
     				while  ($file = readdir($dir)) {
     					if (is_file(DIR_FS_CATALOG_ORIGINAL_IMAGES.$file) and ($file !="index.html") and (strtolower($file) != "thumbs.db")){
     						$files[]=array(
     													 'id' => $file,
     													 'text' =>$file);
     					}
     				}
     				closedir($dir);
     			}
     */
     // EOF Subdirectory support
     for ($i = 0; $n = sizeof($files), $i < $n; $i++) {
         $products_image_name = $files[$i]['text'];
         if ($files[$i]['text'] != 'Thumbs.db' && $files[$i]['text'] != 'Index.html') {
             require DIR_WS_INCLUDES . 'product_thumbnail_images.php';
             require DIR_WS_INCLUDES . 'product_info_images.php';
             require DIR_WS_INCLUDES . 'product_popup_images.php';
         }
     }
 }
function vam_get_files_in_dir($startdir, $ext = array('.jpg', '.jpeg', '.png', '.gif', '.JPG', '.bmp'), $dir_only = false, $subdir = '')
{
    //		echo 'Directory: ' . $startdir . '  Subirectory: ' . $subdir . '<br />';
    if (!is_array($ext)) {
        $ext = array();
    }
    $dirname = $startdir . $subdir;
    if ($dir = opendir($dirname)) {
        while (false !== ($file = readdir($dir))) {
            if (substr($file, 0, 1) != '.') {
                if (is_file($dirname . $file) && !$dir_only) {
                    if (in_array(substr($file, strrpos($file, '.')), $ext)) {
                        //							echo '&nbsp;&nbsp;File: ' . $subdir.$file . '<br />';
                        $files[] = array('id' => $subdir . $file, 'text' => $subdir . $file);
                        array_multisort($files, SORT_ASC);
                    }
                } elseif (is_dir($dirname . $file)) {
                    if ($dir_only) {
                        $files[] = array('id' => $subdir . $file . '/', 'text' => $subdir . $file . '/');
                        array_multisort($files, SORT_ASC);
                    }
                    $files = vam_array_merge($files, vam_get_files_in_dir($startdir, $ext, $dir_only, $subdir . $file . '/'));
                }
            }
        }
        closedir($dir);
    }
    return $files;
}
   --------------------------------------------------------------
   based on:
   (c) 2004	 xt:Commerce (products_images.php,v 1.2 2003/08/23); www.nextcommerce.org

   Released under the GNU General Public License
   --------------------------------------------------------------*/
defined('_VALID_VAM') or die('Direct Access to this location is not allowed.');
//include needed functions
require_once DIR_FS_INC . 'vam_get_products_mo_images.inc.php';
// BOF Add existing image
require_once DIR_WS_FUNCTIONS . 'trumbnails_add_funcs.php';
// EOF Add existing image
// show images
if ($_GET['action'] == 'new_product') {
    // BOF Add existing image
    $dir_list = vam_array_merge(array('0' => array('id' => '', 'text' => TEXT_SELECT_DIRECTORY)), vam_get_files_in_dir(DIR_FS_CATALOG_ORIGINAL_IMAGES, '', true));
    //$file_list = vam_array_merge(array('0' => array('id' => '', 'text' => TEXT_SELECT_IMAGE)),vam_get_files_in_dir(DIR_FS_CATALOG_ORIGINAL_IMAGES));
    // EOF Add existing image
    // display images fields:
    echo '<tr><td colspan="4">' . vam_draw_separator('pixel_trans.gif', '1', '10') . '</td></tr>';
    if ($pInfo->products_image) {
        echo '<tr><td colspan="4"><table><tr><td align="center" class="main" width="' . (PRODUCT_IMAGE_THUMBNAIL_WIDTH + 15) . '">' . vam_image(DIR_WS_CATALOG_THUMBNAIL_IMAGES . $pInfo->products_image, TEXT_STANDART_IMAGE) . '</td>';
    }
    echo '<td class="main">' . TEXT_PRODUCTS_IMAGE . '<br />' . vam_draw_file_field('products_image') . '<br />' . vam_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . $pInfo->products_image . vam_draw_hidden_field('products_previous_image_0', $pInfo->products_image);
    // BOF Add existing image
    echo '<br />' . TEXT_PRODUCTS_IMAGE_UPLOAD_DIRECTORY . '<br />' . vam_draw_pull_down_menu('upload_dir_image_0', $dir_list, dirname($pInfo->products_image) . '/');
    //	echo '<br /><br />' . TEXT_PRODUCTS_IMAGE_GET_FILE . '<br />' . vam_draw_pull_down_menu('get_file_image_0',$file_list,$pInfo->products_image);
    // EOF Add existing image
    if ($pInfo->products_image != '') {
        echo '</tr><tr><td align="center" class="main" valign="middle">' . vam_draw_selection_field('del_pic', 'checkbox', $pInfo->products_image) . ' ' . TEXT_DELETE . '</td></tr></table>';
    } else {