}
    // if
    if ($parent_check == 'yes') {
        $parent_id = $parent_id;
    } else {
        $parent_id = '0';
    }
    // if
    if ($error == false) {
        // file upload
        if ($select_file != 'default') {
            $content_file_name = $select_file;
        }
        $accepted_file_upload_files_extensions = array("xls", "xla", "hlp", "chm", "ppt", "ppz", "pps", "pot", "doc", "dot", "pdf", "rtf", "swf", "cab", "tar", "zip", "au", "snd", "mp2", "rpm", "stream", "wav", "gif", "jpeg", "jpg", "jpe", "png", "tiff", "tif", "bmp", "csv", "txt", "rtf", "tsv", "mpeg", "mpg", "mpe", "qt", "mov", "avi", "movie", "rar", "7z");
        $accepted_file_upload_files_mime_types = array("application/msexcel", "application/mshelp", "application/mspowerpoint", "application/msword", "application/pdf", "application/rtf", "application/x-shockwave-flash", "application/x-tar", "application/zip", "audio/basic", "audio/x-mpeg", "audio/x-pn-realaudio-plugin", "audio/x-qt-stream", "audio/x-wav", "image/gif", "image/jpeg", "image/png", "image/tiff", "image/bmp", "text/comma-separated-values", "text/plain", "text/rtf", "text/tab-separated-values", "video/mpeg", "video/quicktime", "video/x-msvideo", "video/x-sgi-movie", "application/x-rar-compressed", "application/x-7z-compressed");
        if ($content_file = xtc_try_upload('file_upload', DIR_FS_CATALOG . 'media/content/', '644', $accepted_file_upload_files_extensions, $accepted_file_upload_files_mime_types)) {
            $content_file_name = $content_file->filename;
        }
        // update data in table
        $sql_data_array = array('languages_id' => $content_language, 'content_title' => $content_title, 'content_heading' => $content_header, 'content_text' => $content_text, 'content_file' => $content_file_name, 'content_status' => $content_status, 'parent_id' => $parent_id, 'group_ids' => $group_ids, 'content_group' => $group_id, 'sort_order' => $sort_order, 'file_flag' => $file_flag, 'content_meta_title' => $content_meta_title, 'content_meta_description' => $content_meta_description, 'content_meta_keywords' => $content_meta_keywords, 'content_meta_index' => $content_meta_index, 'change_date' => $time);
        if ($id == 'update') {
            xtc_db_perform(TABLE_CONTENT_MANAGER, $sql_data_array, 'update', "content_id = '" . $coID . "'");
        } else {
            xtc_db_perform(TABLE_CONTENT_MANAGER, $sql_data_array);
        }
        // if get id
        xtc_redirect(xtc_href_link(FILENAME_CONTENT_MANAGER));
    }
    // if error
}
// if
 $banners_image_local = xtc_db_prepare_input($_POST['banners_image_local']);
 $banners_image_target = xtc_db_prepare_input($_POST['banners_image_target']);
 $db_image_location = '';
 $banner_error = false;
 if (empty($banners_title)) {
     $messageStack->add(ERROR_BANNER_TITLE_REQUIRED, 'error');
     $banner_error = true;
 }
 if (empty($banners_group)) {
     $messageStack->add(ERROR_BANNER_GROUP_REQUIRED, 'error');
     $banner_error = true;
 }
 if (empty($banners_image_local)) {
     $accepted_banners_image_files_extensions = array("jpg", "jpeg", "jpe", "gif", "png", "bmp", "tiff", "tif", "bmp", "swf", "cab");
     $accepted_banners_image_files_mime_types = array("image/jpeg", "image/gif", "image/png", "image/bmp", "application/x-shockwave-flash");
     if (!($banners_image = xtc_try_upload('banners_image', DIR_FS_CATALOG_IMAGES . 'banner/' . $banners_image_target, '644', $accepted_banners_image_files_extensions, $accepted_banners_image_files_mime_types))) {
         $messageStack->add(ERROR_BANNER_IMAGE_REQUIRED, 'error');
         $banner_error = true;
     }
 }
 if ($banner_error == false) {
     $db_image_location = xtc_not_null($banners_image_local) ? $banners_image_local : $banners_image_target . $banners_image->filename;
     $sql_data_array = array('banners_title' => $banners_title, 'banners_url' => $banners_url, 'banners_image' => $db_image_location, 'banners_group' => $banners_group, 'banners_html_text' => $html_text);
     if ($action == 'insert') {
         $insert_sql_data = array('date_added' => 'now()', 'status' => '1');
         $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
         xtc_db_perform(TABLE_BANNERS, $sql_data_array);
         $banners_id = xtc_db_insert_id();
         $messageStack->add_session(SUCCESS_BANNER_INSERTED, 'success');
     } elseif ($action == 'update') {
         xtc_db_perform(TABLE_BANNERS, $sql_data_array, 'update', 'banners_id = \'' . (int) $banners_id . '\'');
function ProductsImageUpload()
{
    global $_GET, $_POST;
    if ($products_image =& xtc_try_upload('products_image', DIR_FS_CATALOG . DIR_WS_ORIGINAL_IMAGES, '777', '', true)) {
        $products_image_name = $products_image->filename;
        // rewrite values to use resample classes
        define('DIR_FS_CATALOG_ORIGINAL_IMAGES', DIR_FS_CATALOG . DIR_WS_ORIGINAL_IMAGES);
        define('DIR_FS_CATALOG_INFO_IMAGES', DIR_FS_CATALOG . DIR_WS_INFO_IMAGES);
        define('DIR_FS_CATALOG_POPUP_IMAGES', DIR_FS_CATALOG . DIR_WS_POPUP_IMAGES);
        define('DIR_FS_CATALOG_THUMBNAIL_IMAGES', DIR_FS_CATALOG . DIR_WS_THUMBNAIL_IMAGES);
        define('DIR_FS_CATALOG_IMAGES', DIR_FS_CATALOG . DIR_WS_IMAGES);
        // generate resampled images
        require DIR_FS_DOCUMENT_ROOT . 'admin/includes/product_thumbnail_images.php';
        require DIR_FS_DOCUMENT_ROOT . 'admin/includes/product_info_images.php';
        require DIR_FS_DOCUMENT_ROOT . 'admin/includes/product_popup_images.php';
        $code = 0;
        $message = 'OK';
    } else {
        $code = -1;
        $message = 'UPLOAD FAILED';
    }
    print_xml_status($code, $_POST['action'], $message, '', 'FILE_NAME', $products_image->filename);
}
 function insert_product($products_data, $dest_category_id, $link, $action = 'insert')
 {
     $products_id = xtc_db_prepare_input($products_data['products_id']);
     $products_date_available = xtc_db_prepare_input($products_data['products_date_available']);
     $products_date_available = date('Y-m-d') < $products_date_available ? $products_date_available : 'null';
     $products_status = xtc_db_prepare_input($products_data['products_status']);
     if ($products_data['products_startpage'] == 1) {
         $this->link_product($products_data['products_id'], 0);
         //$products_status = 1;    //web28 2012-10-30 - don't set status active
     } else {
         $this->set_product_remove_startpage_sql($products_data['products_id'], 0);
         //Dokuman - 2009-11-12 - BUGFIX #0000351: When products disable display on startpage, should update table products_to_categories
     }
     if (PRICE_IS_BRUTTO == 'true' && $products_data['products_price']) {
         $products_data['products_price'] = round($products_data['products_price'] / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100, PRICE_PRECISION);
     }
     $customers_statuses_array = xtc_get_customers_statuses();
     $permission = array();
     for ($i = 0, $n = sizeof($customers_statuses_array); $i < $n; $i++) {
         if (isset($customers_statuses_array[$i]['id'])) {
             $permission[$customers_statuses_array[$i]['id']] = 0;
         }
     }
     if (isset($products_data['groups'])) {
         foreach ($products_data['groups'] as $dummy => $b) {
             $permission[$b] = 1;
         }
     }
     // build array
     if ($permission['all'] == 1) {
         $permission = array();
         end($customers_statuses_array);
         for ($i = 0, $n = key($customers_statuses_array); $i < $n + 1; $i++) {
             if (isset($customers_statuses_array[$i]['id'])) {
                 $permission[$customers_statuses_array[$i]['id']] = 1;
             }
         }
     }
     $permission_array = array();
     // set pointer to last key
     end($customers_statuses_array);
     for ($i = 0, $n = key($customers_statuses_array); $i < $n + 1; $i++) {
         if (isset($customers_statuses_array[$i]['id'])) {
             $permission_array = array_merge($permission_array, array('group_permission_' . $customers_statuses_array[$i]['id'] => $permission[$customers_statuses_array[$i]['id']]));
         }
     }
     $sql_data_array = array('products_quantity' => xtc_db_prepare_input($products_data['products_quantity']), 'products_model' => xtc_db_prepare_input($products_data['products_model']), 'products_ean' => xtc_db_prepare_input($products_data['products_ean']), 'products_price' => xtc_db_prepare_input($products_data['products_price']), 'products_sort' => xtc_db_prepare_input($products_data['products_sort']), 'products_shippingtime' => xtc_db_prepare_input($products_data['shipping_status']), 'products_discount_allowed' => xtc_db_prepare_input($products_data['products_discount_allowed']), 'products_date_available' => $products_date_available, 'products_weight' => xtc_db_prepare_input($products_data['products_weight']), 'products_status' => $products_status, 'products_startpage' => xtc_db_prepare_input($products_data['products_startpage']), 'products_startpage_sort' => xtc_db_prepare_input($products_data['products_startpage_sort']), 'products_tax_class_id' => xtc_db_prepare_input($products_data['products_tax_class_id']), 'product_template' => xtc_db_prepare_input($products_data['info_template']), 'options_template' => xtc_db_prepare_input($products_data['options_template']), 'manufacturers_id' => xtc_db_prepare_input($products_data['manufacturers_id']), 'products_fsk18' => xtc_db_prepare_input($products_data['fsk18']), 'products_vpe_value' => xtc_db_prepare_input($products_data['products_vpe_value']), 'products_vpe_status' => xtc_db_prepare_input($products_data['products_vpe_status']), 'products_vpe' => xtc_db_prepare_input($products_data['products_vpe']), 'wholesaler_id' => xtc_db_prepare_input($products_data['wholesaler_id']), 'wholesaler_reorder' => xtc_db_prepare_input($products_data['wholesaler_reorder']));
     if (trim(ADD_PRODUCTS_FIELDS) != '') {
         $sql_data_array = array_merge($sql_data_array, $this->add_data_fields(ADD_PRODUCTS_FIELDS, $products_data));
     }
     //echo print_r($sql_data_array); EXIT;
     $sql_data_array = array_merge($sql_data_array, $permission_array);
     //get the next ai-value from table products if no products_id is set
     if (!$products_id || $products_id == '') {
         $new_pid_query = xtc_db_query("SHOW TABLE STATUS LIKE '" . TABLE_PRODUCTS . "'");
         $new_pid_query_values = xtc_db_fetch_array($new_pid_query);
         $products_id = $new_pid_query_values['Auto_increment'];
     }
     //prepare products_image filename
     $accepted_products_image_files_extensions = array("jpg", "jpeg", "jpe", "gif", "png", "bmp", "tiff", "tif", "bmp");
     $accepted_products_image_files_mime_types = array("image/jpeg", "image/gif", "image/png", "image/bmp");
     if ($products_image = xtc_try_upload('products_image', DIR_FS_CATALOG_ORIGINAL_IMAGES, '777', $accepted_products_image_files_extensions, $accepted_products_image_files_mime_types)) {
         $pname_arr = explode('.', $products_image->filename);
         $nsuffix = array_pop($pname_arr);
         $products_image_name = $products_id . '_0.' . $nsuffix;
         $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                FROM " . TABLE_PRODUCTS . "\n                                               WHERE products_image = '" . $products_data['products_previous_image_0'] . "'");
         $dup_check = xtc_db_fetch_array($dup_check_query);
         if ($dup_check['total'] < 2) {
             @xtc_del_image_file($products_data['products_previous_image_0']);
         }
         //workaround if there are v2 images mixed with v3
         $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                FROM " . TABLE_PRODUCTS . "\n                                               WHERE products_image = '" . $products_image->filename . "'");
         $dup_check = xtc_db_fetch_array($dup_check_query);
         if ($dup_check['total'] == 0) {
             rename(DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image->filename, DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image_name);
         } else {
             copy(DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image->filename, DIR_FS_CATALOG_ORIGINAL_IMAGES . $products_image_name);
         }
         $sql_data_array['products_image'] = xtc_db_prepare_input($products_image_name);
         require DIR_WS_INCLUDES . 'product_thumbnail_images.php';
         require DIR_WS_INCLUDES . 'product_info_images.php';
         require DIR_WS_INCLUDES . 'product_popup_images.php';
         // set file rights
         $this->set_products_images_file_rights($products_image_name);
     } else {
         // save, when wo no upload an image
         $mo_img = array('image_title' => xtc_db_prepare_input($products_data['image_title'][$img + 1]), 'image_alt' => xtc_db_prepare_input($products_data['image_alt'][$img + 1]));
         if ($action == 'update' && $products_data['products_previous_image_' . ($img + 1)]) {
             if ($products_data['del_mo_pic']) {
                 foreach ($products_data['del_mo_pic'] as $dummy => $val) {
                     if ($val == $products_data['products_previous_image_' . ($img + 1)]) {
                         xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
                     }
                     break;
                 }
             }
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_name = \'' . xtc_db_input($products_data['products_previous_image_' . ($img + 1)]) . '\'');
         } elseif (!$products_data['products_previous_image_' . ($img + 1)]) {
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
         }
         $products_image_name = $products_data['products_previous_image_0'];
     }
     //are we asked to delete some pics?
     if ($products_data['del_pic'] != '') {
         $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                FROM " . TABLE_PRODUCTS . "\n                                               WHERE products_image = '" . $products_data['del_pic'] . "'");
         $dup_check = xtc_db_fetch_array($dup_check_query);
         if ($dup_check['total'] < 2) {
             @xtc_del_image_file($products_data['del_pic']);
         }
         xtc_db_query("UPDATE " . TABLE_PRODUCTS . "\n                         SET products_image = NULL\n                       WHERE products_id    = '" . xtc_db_input($products_id) . "'");
     }
     if ($products_data['del_mo_pic'] != '') {
         foreach ($products_data['del_mo_pic'] as $dummy => $val) {
             $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                      FROM " . TABLE_PRODUCTS_IMAGES . "\n                                                     WHERE image_name = '" . $val . "'");
             $dup_check = xtc_db_fetch_array($dup_check_query);
             if ($dup_check['total'] < 2) {
                 @xtc_del_image_file($val);
             }
             xtc_db_query("DELETE FROM " . TABLE_PRODUCTS_IMAGES . "\n                                     WHERE products_id = '" . xtc_db_input($products_id) . "'\n                                       AND image_name  = '" . $val . "'");
         }
     }
     //MO_PICS
     $accepted_mo_pics_image_files_extensions = array("jpg", "jpeg", "jpe", "gif", "png", "bmp", "tiff", "tif", "bmp");
     $accepted_mo_pics_image_files_mime_types = array("image/jpeg", "image/gif", "image/png", "image/bmp");
     for ($img = 0; $img < MO_PICS; $img++) {
         if ($pIMG = xtc_try_upload('mo_pics_' . $img, DIR_FS_CATALOG_ORIGINAL_IMAGES, '777', $accepted_mo_pics_image_files_extensions, $accepted_mo_pics_image_files_mime_types)) {
             $pname_arr = explode('.', $pIMG->filename);
             $nsuffix = array_pop($pname_arr);
             $products_image_name = $products_id . '_' . ($img + 1) . '.' . $nsuffix;
             $dup_check_query = xtc_db_query("SELECT COUNT(*) AS total\n                                                      FROM " . TABLE_PRODUCTS_IMAGES . "\n                                                     WHERE image_name = '" . $products_data['products_previous_image_' . ($img + 1)] . "'");
             $dup_check = xtc_db_fetch_array($dup_check_query);
             if ($dup_check['total'] < 2) {
                 @xtc_del_image_file($products_data['products_previous_image_' . ($img + 1)]);
             }
             @xtc_del_image_file($products_image_name);
             rename(DIR_FS_CATALOG_ORIGINAL_IMAGES . '/' . $pIMG->filename, DIR_FS_CATALOG_ORIGINAL_IMAGES . '/' . $products_image_name);
             //get data & write to table
             // $mo_img = array ('products_id' => xtc_db_prepare_input($products_id), 'image_nr' => xtc_db_prepare_input($img +1), 'image_name' => xtc_db_prepare_input($products_image_name));
             $mo_img = array('products_id' => xtc_db_prepare_input($products_id), 'image_nr' => xtc_db_prepare_input($img + 1), 'image_name' => xtc_db_prepare_input($products_image_name), 'image_title' => xtc_db_prepare_input($products_data['image_title'][$img + 1]), 'image_alt' => xtc_db_prepare_input($products_data['image_alt'][$img + 1]));
             if ($action == 'insert') {
                 xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
             } elseif ($action == 'update' && $products_data['products_previous_image_' . ($img + 1)]) {
                 if ($products_data['del_mo_pic']) {
                     foreach ($products_data['del_mo_pic'] as $dummy => $val) {
                         if ($val == $products_data['products_previous_image_' . ($img + 1)]) {
                             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
                         }
                         break;
                     }
                 }
                 xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_name = \'' . xtc_db_input($products_data['products_previous_image_' . ($img + 1)]) . '\'');
             } elseif (!$products_data['products_previous_image_' . ($img + 1)]) {
                 xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img);
             }
             //image processing
             require DIR_WS_INCLUDES . 'product_thumbnail_images.php';
             require DIR_WS_INCLUDES . 'product_info_images.php';
             require DIR_WS_INCLUDES . 'product_popup_images.php';
             //set file rights
             $this->set_products_images_file_rights($products_image_name);
         }
     }
     if (is_array($products_data['image_title'])) {
         foreach ($products_data['image_title'] as $it_image_nr => $it_image_title) {
             $mo_img = array('image_title' => xtc_db_prepare_input($it_image_title));
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_nr = \'' . xtc_db_prepare_input($it_image_nr + 1) . '\' AND products_id = \'' . xtc_db_prepare_input($products_id) . '\'');
         }
     }
     if (is_array($products_data['image_alt'])) {
         foreach ($products_data['image_alt'] as $ia_image_nr => $ia_image_title) {
             $mo_img = array('image_alt' => xtc_db_prepare_input($ia_image_title));
             xtc_db_perform(TABLE_PRODUCTS_IMAGES, $mo_img, 'update', 'image_nr = \'' . xtc_db_prepare_input($ia_image_nr + 1) . '\' AND products_id = \'' . xtc_db_prepare_input($products_id) . '\'');
         }
     }
     if (isset($products_data['products_image']) && xtc_not_null($products_data['products_image']) && $products_data['products_image'] != 'none') {
         $sql_data_array['products_image'] = xtc_db_prepare_input($products_data['products_image']);
     }
     if ($action == 'insert') {
         $insert_sql_data = array('products_date_added' => 'now()');
         $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
         xtc_db_perform(TABLE_PRODUCTS, $sql_data_array);
         $products_id = xtc_db_insert_id();
         xtc_db_query("INSERT INTO " . TABLE_PRODUCTS_TO_CATEGORIES . "\n                              SET products_id   = '" . $products_id . "',\n                              categories_id = '" . $dest_category_id . "'");
         // web28 - 2012-03-11 - link product to startpage
         /* not longer needed
            if ($products_data['products_startpage'] == 1 ) {
              xtc_db_query("INSERT INTO ".TABLE_PRODUCTS_TO_CATEGORIES."
                                    SET products_id   = '".$products_id."',
                                        categories_id = '0'");
            }
            */
     } elseif ($action == 'update') {
         $update_sql_data = array('products_last_modified' => 'now()');
         $sql_data_array = xtc_array_merge($sql_data_array, $update_sql_data);
         xtc_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', 'products_id = \'' . xtc_db_input($products_id) . '\'');
     }
     //Included specials
     if (file_exists("includes/modules/categories_specials.php")) {
         require_once "includes/modules/categories_specials.php";
         saveSpecialsData($products_id);
     }
     $languages = xtc_get_languages();
     // Here we go, lets write Group prices into db
     // start
     $i = 0;
     $group_query = xtc_db_query("SELECT customers_status_id\n                                         FROM " . TABLE_CUSTOMERS_STATUS . "\n                                        WHERE language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                          AND customers_status_id != '0'");
     while ($group_values = xtc_db_fetch_array($group_query)) {
         // load data into array
         $i++;
         $group_data[$i] = array('STATUS_ID' => $group_values['customers_status_id']);
     }
     for ($col = 0, $n = sizeof($group_data); $col < $n + 1; $col++) {
         if ($group_data[$col]['STATUS_ID'] != '') {
             $personal_price = xtc_db_prepare_input($products_data['products_price_' . $group_data[$col]['STATUS_ID']]);
             if ($personal_price == '' || $personal_price == '0.0000') {
                 $personal_price = '0.00';
             } else {
                 if (PRICE_IS_BRUTTO == 'true') {
                     $personal_price = $personal_price / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100;
                 }
                 $personal_price = xtc_round($personal_price, PRICE_PRECISION);
             }
             if ($action == 'insert') {
                 xtc_db_query("DELETE FROM personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                              WHERE products_id = '" . $products_id . "'\n                                AND quantity    = '1'");
                 $insert_array = array();
                 $insert_array = array('personal_offer' => $personal_price, 'quantity' => '1', 'products_id' => $products_id);
                 xtc_db_perform("personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'], $insert_array);
             } else {
                 xtc_db_query("UPDATE personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                         SET personal_offer = '" . $personal_price . "'\n                                       WHERE products_id = '" . $products_id . "'\n                                         AND quantity    = '1'");
             }
         }
     }
     // end
     // ok, lets check write new staffelpreis into db (if there is one)
     $i = 0;
     $group_query = xtc_db_query("SELECT customers_status_id\n                                         FROM " . TABLE_CUSTOMERS_STATUS . "\n                                        WHERE language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                          AND customers_status_id != '0'");
     while ($group_values = xtc_db_fetch_array($group_query)) {
         // load data into array
         $i++;
         $group_data[$i] = array('STATUS_ID' => $group_values['customers_status_id']);
     }
     for ($col = 0, $n = sizeof($group_data); $col < $n + 1; $col++) {
         if ($group_data[$col]['STATUS_ID'] != '') {
             $quantity = xtc_db_prepare_input($products_data['products_quantity_staffel_' . $group_data[$col]['STATUS_ID']]);
             $staffelpreis = xtc_db_prepare_input($products_data['products_price_staffel_' . $group_data[$col]['STATUS_ID']]);
             if (PRICE_IS_BRUTTO == 'true') {
                 $staffelpreis = $staffelpreis / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100;
             }
             $staffelpreis = xtc_round($staffelpreis, PRICE_PRECISION);
             if ($staffelpreis != '' && $quantity != '') {
                 // ok, lets check entered data to get rid of user faults
                 if ($quantity <= 1) {
                     $quantity = 2;
                 }
                 $check_query = xtc_db_query("SELECT quantity\n                                                           FROM personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                                          WHERE products_id = '" . $products_id . "'\n                                                            AND quantity    = '" . $quantity . "'");
                 // dont insert if same qty!
                 if (xtc_db_num_rows($check_query) < 1) {
                     xtc_db_query("INSERT INTO personal_offers_by_customers_status_" . $group_data[$col]['STATUS_ID'] . "\n                                                   SET price_id       = '',\n                                                       products_id    = '" . $products_id . "',\n                                                       quantity       = '" . $quantity . "',\n                                                       personal_offer = '" . $staffelpreis . "'");
                 }
             }
         }
     }
     foreach ($languages as $lang) {
         $language_id = $lang['id'];
         $sql_data_array = array('products_name' => xtc_db_prepare_input($products_data['products_name'][$language_id]), 'products_description' => xtc_db_prepare_input($products_data['products_description_' . $language_id]), 'products_short_description' => xtc_db_prepare_input($products_data['products_short_description_' . $language_id]), 'products_keywords' => xtc_db_prepare_input($products_data['products_keywords'][$language_id]), 'products_url' => xtc_db_prepare_input($products_data['products_url'][$language_id]), 'products_meta_title' => xtc_db_prepare_input($products_data['products_meta_title'][$language_id]), 'products_meta_description' => xtc_db_prepare_input($products_data['products_meta_description'][$language_id]), 'products_meta_keywords' => xtc_db_prepare_input($products_data['products_meta_keywords'][$language_id]));
         if (trim(ADD_PRODUCTS_DESCRIPTION_FIELDS)) {
             $sql_data_array = array_merge($sql_data_array, $this->add_data_fields(ADD_PRODUCTS_DESCRIPTION_FIELDS, $products_data, $language_id));
         }
         if ($action == 'insert') {
             $insert_sql_data = array('products_id' => $products_id, 'language_id' => $language_id);
             $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
             xtc_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
         } elseif ($action == 'update') {
             //BOF - web28 - 2010-07-11 - BUGFIX no entry stored for previous deactivated languages
             $product_query = xtc_db_query("SELECT * FROM " . TABLE_PRODUCTS_DESCRIPTION . "\n                                               WHERE language_id = '" . $lang['id'] . "'\n                                                 AND products_id = '" . $products_id . "'");
             if (xtc_db_num_rows($product_query) == 0) {
                 xtc_db_perform(TABLE_PRODUCTS_DESCRIPTION, array('products_id' => $products_id, 'language_id' => $lang['id']));
             }
             //EOF - web28 - 2010-07-11 - BUGFIX no entry stored for previous deactivated languages
             xtc_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', 'products_id = \'' . xtc_db_input($products_id) . '\' and language_id = \'' . $language_id . '\'');
         }
     }
     //redirect by update button
     if (isset($products_data['prod_update'])) {
         xtc_redirect(xtc_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&action=new_product&pID=' . $products_id . $this->page_parameter));
     }
     xtc_redirect(xtc_href_link(FILENAME_CATEGORIES, xtc_get_path($dest_categories_id) . '&pID=' . $products_id . $this->page_parameter));
     //web28 2012-04-14 new redirect
 }
            } else {
                $messageStack->add(ERROR_DOWNLOAD_LINK_NOT_ACCEPTABLE, 'error');
            }
            break;
        case 'deleteconfirm':
            if (strstr($_GET['file'], '..')) {
                xtc_redirect(xtc_href_link(FILENAME_BACKUP));
            }
            xtc_remove(DIR_FS_BACKUP . '/' . $_GET['file']);
            if (!$xtc_remove_error) {
                $messageStack->add_session(SUCCESS_BACKUP_DELETED, 'success');
                xtc_redirect(xtc_href_link(FILENAME_BACKUP));
            }
            break;
        case 'restorelocalnow':
            $file = xtc_try_upload('sql_file', DIR_FS_BACKUP, '777', array('sql', 'gz'));
            xtc_redirect(xtc_href_link(FILENAME_BACKUP));
            break;
    }
}
// check if the backup directory exists
$dir_ok = false;
if (is_dir(DIR_FS_BACKUP)) {
    $dir_ok = true;
    if (!is_writeable(DIR_FS_BACKUP)) {
        $messageStack->add(ERROR_BACKUP_DIRECTORY_NOT_WRITEABLE, 'error');
    }
} else {
    $messageStack->add(ERROR_BACKUP_DIRECTORY_DOES_NOT_EXIST, 'error');
}
require DIR_WS_INCLUDES . 'head.php';
                for ($i = 0; $i < sizeof($languages); $i++) {
                    $customers_status_name_array = $_POST['customers_status_name'];
                    $language_id = $languages[$i]['id'];
                    $customers_status_query = xtc_db_query("SELECT * FROM " . TABLE_CUSTOMERS_STATUS . " WHERE language_id = '" . $language_id . "' AND customers_status_id = '" . xtc_db_input($customers_status_id) . "'");
                    if (xtc_db_num_rows($customers_status_query) == 0) {
                        xtc_db_perform(TABLE_CUSTOMERS_STATUS, array('customers_status_id' => xtc_db_input($customers_status_id), 'customers_status_name' => xtc_db_prepare_input($customers_status_name_array[$language_id]), 'language_id' => $language_id));
                    } else {
                        $update_sql_data = array('customers_status_name' => xtc_db_prepare_input($customers_status_name_array[$language_id]));
                        xtc_db_perform(TABLE_CUSTOMERS_STATUS, $update_sql_data, 'update', "customers_status_id = '" . xtc_db_input($customers_status_id) . "' AND language_id = '" . $language_id . "'");
                    }
                }
                xtc_db_perform(TABLE_CUSTOMERS_STATUS, $sql_data_array, 'update', "customers_status_id = '" . xtc_db_input($customers_status_id) . "'");
            }
            $accepted_customers_status_image_files_extensions = array("jpg", "jpeg", "jpe", "gif", "png", "bmp", "tiff", "tif", "bmp");
            $accepted_customers_status_image_files_mime_types = array("image/jpeg", "image/gif", "image/png", "image/bmp");
            if ($customers_status_image = xtc_try_upload('customers_status_image', DIR_WS_ICONS, '', $accepted_customers_status_image_files_extensions, $accepted_customers_status_image_files_mime_types)) {
                xtc_db_query("UPDATE " . TABLE_CUSTOMERS_STATUS . " SET customers_status_image = '" . $customers_status_image->filename . "' WHERE customers_status_id = '" . xtc_db_input($customers_status_id) . "'");
            }
            if ($_POST['default'] == 'on') {
                xtc_db_query("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '" . xtc_db_input($customers_status_id) . "' WHERE configuration_key = 'DEFAULT_CUSTOMERS_STATUS_ID'");
            }
            xtc_redirect(xtc_href_link(FILENAME_CUSTOMERS_STATUS, 'page=' . $_GET['page'] . '&cID=' . $customers_status_id));
            break;
    }
}
require DIR_WS_INCLUDES . 'head.php';
?>
  
</head>
<body onLoad="SetFocus();">
    <!-- header //-->
                        $shipping_status_id = $next_id['shipping_status_id'] + 1;
                    }
                    $insert_sql_data = array('shipping_status_id' => $shipping_status_id, 'language_id' => $language_id);
                    $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
                    xtc_db_perform(TABLE_SHIPPING_STATUS, $sql_data_array);
                } elseif ($_GET['action'] == 'save') {
                    //BOF - web28 - 2010-07-11 - BUGFIX no entry stored for previous deactivated languages
                    $shipping_status_query = xtc_db_query("select * from " . TABLE_SHIPPING_STATUS . " where language_id = '" . $language_id . "' and shipping_status_id = '" . xtc_db_input($shipping_status_id) . "'");
                    if (xtc_db_num_rows($shipping_status_query) == 0) {
                        xtc_db_perform(TABLE_SHIPPING_STATUS, array('shipping_status_id' => xtc_db_input($shipping_status_id), 'language_id' => $language_id));
                    }
                    //EOF - web28 - 2010-07-11 - BUGFIX no entry stored for previous deactivated languages
                    xtc_db_perform(TABLE_SHIPPING_STATUS, $sql_data_array, 'update', "shipping_status_id = '" . xtc_db_input($shipping_status_id) . "' and language_id = '" . $language_id . "'");
                }
            }
            if ($shipping_status_image = xtc_try_upload('shipping_status_image', DIR_WS_ICONS)) {
                xtc_db_query("update " . TABLE_SHIPPING_STATUS . " set shipping_status_image = '" . $shipping_status_image->filename . "' where shipping_status_id = '" . xtc_db_input($shipping_status_id) . "'");
            }
            if ($_POST['default'] == 'on') {
                xtc_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . xtc_db_input($shipping_status_id) . "' where configuration_key = 'DEFAULT_SHIPPING_STATUS_ID'");
            }
            xtc_redirect(xtc_href_link(FILENAME_SHIPPING_STATUS, 'page=' . $_GET['page'] . '&oID=' . $shipping_status_id));
        } else {
            $_SESSION['repopulate_form'] = $_REQUEST;
            $_SESSION['errors'] = $error;
            xtc_redirect(xtc_href_link(FILENAME_SHIPPING_STATUS, 'page=' . $_GET['page'] . '&action=' . $url_action . '&errors=1&oID=' . $shipping_status_id));
        }
        break;
}
require DIR_WS_INCLUDES . 'head.php';
?>
   Copyright (c) 2003 XT-Commerce
   --------------------------------------------------------------
   based on:
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
   (c) 2002-2003 osCommercecoding standards (a typical file) www.oscommerce.com

   Released under the GNU General Public License
   --------------------------------------------------------------*/
require 'includes/application_top.php';
require DIR_WS_CLASSES . 'import.php';
require_once DIR_FS_INC . 'xtc_format_filesize.inc.php';
define('FILENAME_CSV_BACKEND', 'csv_backend.php');
switch ($_GET['action']) {
    case 'upload':
        $upload_file = xtc_db_prepare_input($_POST['file_upload']);
        if ($upload_file =& xtc_try_upload('file_upload', DIR_FS_CATALOG . 'import/')) {
            ${$upload_file_name} = $upload_file->filename;
        }
        break;
    case 'import':
        $handler = new xtcImport($_POST['select_file']);
        $mapping = $handler->map_file($handler->generate_map());
        $import = $handler->import($mapping);
        break;
    case 'export':
        $handler = new xtcExport('export.csv');
        $import = $handler->exportProdFile();
        break;
    case 'save':
        $configuration_query = xtc_db_query("select configuration_key,configuration_id, configuration_value, use_function,set_function from " . TABLE_CONFIGURATION . " where configuration_group_id = '20' order by sort_order");
        while ($configuration = xtc_db_fetch_array($configuration_query)) {
         $insert_sql_data = array('date_added' => 'now()');
         $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
         xtc_db_perform(TABLE_MANUFACTURERS, $sql_data_array);
         $manufacturers_id = xtc_db_insert_id();
     } elseif ($_GET['action'] == 'save') {
         $update_sql_data = array('last_modified' => 'now()');
         $sql_data_array = xtc_array_merge($sql_data_array, $update_sql_data);
         xtc_db_perform(TABLE_MANUFACTURERS, $sql_data_array, 'update', "manufacturers_id = '" . xtc_db_input($manufacturers_id) . "'");
     }
 } else {
     $_SESSION['repopulate_form'] = $_REQUEST;
     $_SESSION['errors'] = $error;
     xtc_redirect(xtc_href_link(FILENAME_MANUFACTURERS, 'page=' . $_GET['page'] . '&action=' . $url_action . '&errors=1&mID=' . $manufacturers_id));
 }
 $dir_manufacturers = DIR_FS_CATALOG_IMAGES . "/manufacturers";
 if ($manufacturers_image = xtc_try_upload('manufacturers_image', $dir_manufacturers)) {
     xtc_db_query("update " . TABLE_MANUFACTURERS . " set\n                                 manufacturers_image ='manufacturers/" . $manufacturers_image->filename . "'\n                                 where manufacturers_id = '" . xtc_db_input($manufacturers_id) . "'");
 }
 $languages = xtc_get_languages();
 for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
     $manufacturers_url_array = $_POST['manufacturers_url'];
     $manufacturers_meta_title_array = $_POST['manufacturers_meta_title'];
     $manufacturers_meta_description_array = $_POST['manufacturers_meta_description'];
     $manufacturers_description_array = $_POST['manufacturers_description'];
     $manufacturers_description_array_more = $_POST['manufacturers_description_more'];
     $manufacturers_short_description_array = $_POST['manufacturers_short_description'];
     $language_id = $languages[$i]['id'];
     $sql_data_array = array('manufacturers_url' => xtc_db_prepare_input($manufacturers_url_array[$language_id]), 'manufacturers_meta_title' => xtc_db_prepare_input($manufacturers_meta_title_array[$language_id]), 'manufacturers_meta_description' => xtc_db_prepare_input($manufacturers_meta_description_array[$language_id]), 'manufacturers_description' => xtc_db_prepare_input($manufacturers_description_array[$language_id]), 'manufacturers_description_more' => xtc_db_prepare_input($manufacturers_description_array_more[$language_id]), 'manufacturers_short_description' => xtc_db_prepare_input($manufacturers_short_description_array[$language_id]));
     if ($_GET['action'] == 'insert') {
         $insert_sql_data = array('manufacturers_id' => $manufacturers_id, 'languages_id' => $language_id);
         $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
     $insert_sql_data = array('date_added' => 'now()');
     $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
     xtc_db_perform(TABLE_IMAGESLIDERS, $sql_data_array);
     $imagesliders_id = xtc_db_insert_id();
 } elseif ($_GET['action'] == 'save') {
     $update_sql_data = array('last_modified' => 'now()');
     $sql_data_array = xtc_array_merge($sql_data_array, $update_sql_data);
     xtc_db_perform(TABLE_IMAGESLIDERS, $sql_data_array, 'update', "imagesliders_id = '" . xtc_db_input($imagesliders_id) . "'");
 }
 $languages = xtc_get_languages();
 for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
     if ($_POST['imagesliders_image_delete' . $i] == true) {
         @unlink(DIR_FS_CATALOG_IMAGES . xtc_get_imageslider_image($imagesliders_id, $languages[$i]['id']));
         $imagepfad = '';
     }
     if ($image =& xtc_try_upload('imagesliders_image' . $i, DIR_FS_CATALOG_IMAGES . 'imagesliders/' . $languages[$i]['directory'] . '/')) {
         $imagepfad = 'imagesliders/' . $languages[$i]['directory'] . '/' . $image->filename;
     } else {
         if ($_POST['imagesliders_image_delete' . $i] == false) {
             $imagepfad = xtc_get_imageslider_image($imagesliders_id, $languages[$i]['id']);
         }
     }
     $imagesliders_url_array = $_POST['imagesliders_url'];
     $imagesliders_url_target_array = $_POST['imagesliders_url_target'];
     $imagesliders_url_typ_array = $_POST['imagesliders_url_typ'];
     $imagesliders_title_array = $_POST['imagesliders_title'];
     $imagesliders_description_array = $_POST['imagesliders_description'];
     $language_id = $languages[$i]['id'];
     $sql_data_array = array('imagesliders_url' => xtc_db_prepare_input($imagesliders_url_array[$language_id]), 'imagesliders_url_target' => xtc_db_prepare_input($imagesliders_url_target_array[$language_id]), 'imagesliders_url_typ' => xtc_db_prepare_input($imagesliders_url_typ_array[$language_id]), 'imagesliders_image' => $imagepfad, 'imagesliders_title' => xtc_db_prepare_input($imagesliders_title_array[$language_id]), 'imagesliders_alt' => xtc_db_prepare_input($imagesliders_alt_array[$language_id]), 'imagesliders_description' => xtc_db_prepare_input($imagesliders_description_array[$language_id]));
     if ($_GET['action'] == 'insert') {
         $insert_sql_data = array('imagesliders_id' => $imagesliders_id, 'languages_id' => $language_id);