function affiliate_insert($sql_data_array, $affiliate_parent = 0)
{
    // LOCK TABLES
    smn_db_query("LOCK TABLES " . TABLE_AFFILIATE . " WRITE");
    if ($affiliate_parent > 0) {
        $affiliate_root_query = smn_db_query("select affiliate_root, affiliate_rgt, affiliate_lft�from  " . TABLE_AFFILIATE . " where affiliate_id = '" . $affiliate_parent . "' ");
        // Check if we have a parent affiliate
        if ($affiliate_root_array = smn_db_fetch_array($affiliate_root_query)) {
            smn_db_query("update " . TABLE_AFFILIATE . " SET affiliate_lft = affiliate_lft + 2 WHERE affiliate_root  =  '" . $affiliate_root_array['affiliate_root'] . "' and  affiliate_lft > " . $affiliate_root_array['affiliate_rgt'] . "  AND affiliate_rgt >= " . $affiliate_root_array['affiliate_rgt'] . " ");
            smn_db_query("update " . TABLE_AFFILIATE . " SET affiliate_rgt = affiliate_rgt + 2 WHERE affiliate_root  =  '" . $affiliate_root_array['affiliate_root'] . "' and  affiliate_rgt >= " . $affiliate_root_array['affiliate_rgt'] . "  ");
            $sql_data_array['affiliate_root'] = $affiliate_root_array['affiliate_root'];
            $sql_data_array['affiliate_lft'] = $affiliate_root_array['affiliate_rgt'];
            $sql_data_array['affiliate_rgt'] = $affiliate_root_array['affiliate_rgt'] + 1;
            smn_db_perform(TABLE_AFFILIATE, $sql_data_array);
            $affiliate_id = smn_db_insert_id();
        }
        // no parent -> new root
    } else {
        $sql_data_array['affiliate_lft'] = '1';
        $sql_data_array['affiliate_rgt'] = '2';
        smn_db_perform(TABLE_AFFILIATE, $sql_data_array);
        $affiliate_id = smn_db_insert_id();
        smn_db_query("update " . TABLE_AFFILIATE . " set affiliate_root = '" . $affiliate_id . "' where affiliate_id = '" . $affiliate_id . "' ");
    }
    // UNLOCK TABLES
    smn_db_query("UNLOCK TABLES");
    return $affiliate_id;
}
 function create($customers_id = 0)
 {
     //if customer is 0, then is a new account...(needs to be added in for editing)
     //add data for table customers which hold most of the primary customers info
     $sql_data_array = array('customers_firstname' => $this->firstname, 'customers_lastname' => $this->lastname, 'customers_email_address' => $this->email_address, 'customers_telephone' => $this->telephone, 'customers_fax' => $this->fax, 'customers_newsletter' => $this->newsletter, 'customers_gender' => $this->gender, 'customers_dob' => $this->dob);
     if ($customers_id == 0) {
         $sql_data_array['customers_password'] = $this->password;
         smn_db_perform(TABLE_CUSTOMERS, $sql_data_array);
         $this->customer_id = smn_db_insert_id();
         //primary KEY for customer
     } else {
         smn_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', 'customers_id=' . (int) $customers_id);
         $this->customer_id = (int) $customers_id;
     }
     //start building array for adress book entries using the default address given on sign up
     $sql_data_array = array('customers_id' => $this->customer_id, 'entry_firstname' => $this->firstname, 'entry_lastname' => $this->lastname, 'entry_company' => $this->company, 'entry_street_address' => $this->street_address, 'entry_postcode' => $this->postcode, 'entry_city' => $this->city, 'entry_country_id' => $this->country_id, 'entry_gender' => $this->gender, 'entry_zone_id' => $this->zone_id, 'entry_state' => $this->state);
     if ($customers_id == 0) {
         smn_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
         $this->address_id = smn_db_insert_id();
         smn_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int) $this->address_id . "' where customers_id = '" . (int) $this->customer_id . "'");
         smn_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values ('" . (int) $this->customer_id . "', '0', now())");
     } else {
         smn_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', 'customers_id=' . (int) $customers_id);
         smn_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int) $customer_id . "'");
     }
     if (SESSION_RECREATE == 'True') {
         smn_session_recreate();
     }
     return $this->customer_id;
 }
function store_category($action)
{
    if (isset($_POST['store_categories_id'])) {
        $store_categories_id = smn_db_prepare_input($_POST['store_categories_id']);
    }
    $sort_order = smn_db_prepare_input($_POST['sort_order']);
    $sql_data_array = array('sort_order' => $sort_order);
    if ($action == 'insert_store_category') {
        $insert_sql_data = array('store_parent_id' => (int) $current_store_category_id, 'date_added' => 'now()');
        $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
        smn_db_perform(TABLE_STORE_CATEGORIES, $sql_data_array);
        $store_categories_id = smn_db_insert_id();
    } elseif ($action == 'update_store_category') {
        $update_sql_data = array('last_modified' => 'now()');
        $sql_data_array = array_merge($sql_data_array, $update_sql_data);
        smn_db_perform(TABLE_STORE_CATEGORIES, $sql_data_array, 'update', "store_categories_id = '" . (int) $store_categories_id . "'");
    }
    $languages = smn_get_languages();
    $sizeof_languages = sizeof($languages);
    $store_categories_name_array = $_POST['store_categories_name'];
    $store_categories_description_array = $_POST['store_categories_description'];
    for ($i = 0, $n = $sizeof_languages; $i < $n; $i++) {
        $language_id = $languages[$i]['id'];
        $sql_data_array = array('store_categories_description' => smn_db_prepare_input($store_categories_description_array[$language_id]), 'store_categories_name' => smn_db_prepare_input($store_categories_name_array[$language_id]));
        if ($action == 'insert_store_category') {
            $insert_sql_data = array('store_categories_id' => (int) $store_categories_id, 'language_id' => $languages[$i]['id']);
            $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
            smn_db_perform(TABLE_STORE_CATEGORIES_DESCRIPTION, $sql_data_array);
        } elseif ($action == 'update_store_category') {
            smn_db_perform(TABLE_STORE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "store_categories_id = '" . (int) $store_categories_id . "' and language_id = '" . (int) $languages[$i]['id'] . "'");
        }
    }
    if (isset($_FILES['store_categories_image']) && is_array($_FILES['store_categories_image']) && $_FILES['store_categories_image']['size'] > 0) {
        if ($store_categories_image = new upload('store_categories_image', DIR_FS_CATALOG_IMAGES)) {
            smn_db_query("update " . TABLE_STORE_CATEGORIES . " set store_categories_image = '" . smn_db_input($store_categories_image->filename) . "' where store_categories_id = '" . (int) $store_categories_id . "'");
        }
    }
    if (USE_CACHE == 'true') {
        smn_reset_cache_block('store_categories');
        smn_reset_cache_block('also_purchased');
    }
    smn_redirect(smn_href_link(FILENAME_MANAGEMENT, 'sPath=' . $sPath . '&cID=' . $store_categories_id));
}
             $entry_state = '';
         }
         $sql_data_array = array('entry_firstname' => $customers_firstname, 'entry_lastname' => $customers_lastname, 'entry_street_address' => $entry_street_address, 'entry_postcode' => $entry_postcode, 'entry_city' => $entry_city, 'entry_country_id' => $entry_country_id);
         if (ACCOUNT_COMPANY == 'true') {
             $sql_data_array['entry_company'] = $entry_company;
         }
         if (ACCOUNT_STATE == 'true') {
             if ($entry_zone_id > 0) {
                 $sql_data_array['entry_zone_id'] = $entry_zone_id;
                 $sql_data_array['entry_state'] = '';
             } else {
                 $sql_data_array['entry_zone_id'] = '0';
                 $sql_data_array['entry_state'] = $entry_state;
             }
         }
         smn_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int) $customers_id . "' and address_book_id = '" . (int) $default_address_id . "'");
         smn_redirect(smn_href_link(FILENAME_CUSTOMERS, smn_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id));
     } else {
         if ($error == true) {
             $cInfo = new objectInfo($_POST);
             $processed = true;
         }
     }
     break;
 case 'cvs_set':
     $customers_id_query = smn_db_query("select count(*) as last_value from " . TABLE_CUSTOMERS);
     $customers_id_total = smn_db_fetch_array($customers_id_query);
     $last_customers_id = $customers_id_total['last_value'];
     $orders_statuses = array();
     $orders_status_array = array();
     $orders_status_query = smn_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . $languages_id . "'");
         $currency_id = smn_db_prepare_input($_GET['cID']);
     }
     $title = smn_db_prepare_input($_POST['title']);
     $code = smn_db_prepare_input($_POST['code']);
     $symbol_left = smn_db_prepare_input($_POST['symbol_left']);
     $symbol_right = smn_db_prepare_input($_POST['symbol_right']);
     $decimal_point = smn_db_prepare_input($_POST['decimal_point']);
     $thousands_point = smn_db_prepare_input($_POST['thousands_point']);
     $decimal_places = smn_db_prepare_input($_POST['decimal_places']);
     $value = smn_db_prepare_input($_POST['value']);
     $sql_data_array = array('title' => $title, 'code' => $code, 'symbol_left' => $symbol_left, 'symbol_right' => $symbol_right, 'decimal_point' => $decimal_point, 'thousands_point' => $thousands_point, 'decimal_places' => $decimal_places, 'value' => $value);
     if ($action == 'insert') {
         smn_db_perform(TABLE_CURRENCIES, $sql_data_array);
         $currency_id = smn_db_insert_id();
     } elseif ($action == 'save') {
         smn_db_perform(TABLE_CURRENCIES, $sql_data_array, 'update', "currencies_id = '" . (int) $currency_id . "'");
     }
     if (isset($_POST['default']) && $_POST['default'] == 'on') {
         smn_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . smn_db_input($code) . "' where configuration_key = 'DEFAULT_CURRENCY'");
     }
     smn_redirect(smn_href_link(FILENAME_CURRENCIES, 'page=' . $_GET['page'] . '&cID=' . $currency_id));
     break;
 case 'deleteconfirm':
     $currencies_id = smn_db_prepare_input($_GET['cID']);
     $currency_query = smn_db_query("select currencies_id from " . TABLE_CURRENCIES . " where code = '" . DEFAULT_CURRENCY . "'");
     $currency = smn_db_fetch_array($currency_query);
     if ($currency['currencies_id'] == $currencies_id) {
         smn_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '' where configuration_key = 'DEFAULT_CURRENCY'");
     }
     smn_db_query("delete from " . TABLE_CURRENCIES . " where currencies_id = '" . (int) $currencies_id . "'");
     smn_redirect(smn_href_link(FILENAME_CURRENCIES, 'page=' . $_GET['page']));
         if ($banners_image->parse() == false || $banners_image->save() == false) {
             $banner_error = true;
         }
     }
 }
 if ($banner_error == false) {
     $db_image_location = smn_not_null($banners_image_local) && $_POST['delete_current_image'] != 1 ? $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, 'categories_id' => $categories_id, 'banners_html_text' => $banners_html_text);
     if ($action == 'insert') {
         $insert_sql_data = array('date_added' => 'now()', 'status' => '1');
         $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
         smn_db_perform(TABLE_BANNERS, $sql_data_array);
         $banners_id = smn_db_insert_id();
         $messageStack->add_session(SUCCESS_BANNER_INSERTED, 'success');
     } elseif ($action == 'update') {
         smn_db_perform(TABLE_BANNERS, $sql_data_array, 'update', "banners_id = '" . (int) $banners_id . "'");
         $messageStack->add_session(SUCCESS_BANNER_UPDATED, 'success');
     }
     if (smn_not_null($expires_date)) {
         list($day, $month, $year) = explode('/', $expires_date);
         $expires_date = $year . (strlen($month) == 1 ? '0' . $month : $month) . (strlen($day) == 1 ? '0' . $day : $day);
         smn_db_query("update " . TABLE_BANNERS . " set expires_date = '" . smn_db_input($expires_date) . "', expires_impressions = null where banners_id = '" . (int) $banners_id . "'");
     } elseif (smn_not_null($expires_impressions)) {
         smn_db_query("update " . TABLE_BANNERS . " set expires_impressions = '" . smn_db_input($expires_impressions) . "', expires_date = null where banners_id = '" . (int) $banners_id . "'");
     }
     if (smn_not_null($date_scheduled)) {
         list($day, $month, $year) = explode('/', $date_scheduled);
         $date_scheduled = $year . (strlen($month) == 1 ? '0' . $month : $month) . (strlen($day) == 1 ? '0' . $day : $day);
         smn_db_query("update " . TABLE_BANNERS . " set status = '0', date_scheduled = '" . smn_db_input($date_scheduled) . "' where banners_id = '" . (int) $banners_id . "'");
     }
     smn_redirect(smn_href_link(FILENAME_BANNER_MANAGER, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'bID=' . $banners_id));
       $languages = smn_get_languages();
       for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
         $language_id = $languages[$i]['id'];
         $sql_data_array = array('products_name' => smn_db_prepare_input($_POST['products_name'][$language_id]),
                                 'products_description' => $_POST['products_description'][$language_id],
                                 'products_url' => smn_db_prepare_input($_POST['products_url'][$language_id]),
                                 'products_head_title_tag' => $_POST['products_head_title_tag'][$language_id],
                                 'products_head_desc_tag' => $_POST['products_head_desc_tag'][$language_id],
                                 'products_head_keywords_tag' => $_POST['products_head_keywords_tag'][$language_id]);
         if (($action == 'insert_product')  && ($allow_insert == 'true'))  {
           $insert_sql_data = array('products_id' => $products_id,
                                    'language_id' => $language_id);
           $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
           smn_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
         } elseif ($action == 'update_store_product') {
           smn_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
         }
       }
       if (USE_CACHE == 'true') {
         smn_reset_cache_block('categories');
         smn_reset_cache_block('also_purchased');
       }
       smn_redirect(html_entity_decode(smn_href_link(FILENAME_STORE_PRODUCT_CATEGORIES, 'cPath=' . $cPath . '&ID='.$store_id.'&pID=' . $products_id)));
     }
   }
   break;
 case 'copy_to_confirm':
   if (isset($_POST['products_id']) && isset($_POST['categories_id'])) {
     $products_id = smn_db_prepare_input($_POST['products_id']);
     $categories_id = smn_db_prepare_input($_POST['categories_id']);
     if ($_POST['copy_as'] == 'link') {
         $sql = "\n        SELECT sum(affiliate_payment) as affiliate_payment\n          FROM " . TABLE_AFFILIATE_SALES . " \n          WHERE affiliate_id='" . $affiliate_payment['affiliate_id'] . "' and  affiliate_billing_status=99 \n        ";
         $affiliate_billing_query = smn_db_query($sql);
         $affiliate_billing = smn_db_fetch_array($affiliate_billing_query);
         // Get affiliate Informations
         $sql = "\n        SELECT a.*, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id \n          from " . TABLE_AFFILIATE . " a \n          left join " . TABLE_ZONES . " z on (a.affiliate_zone_id  = z.zone_id) \n          left join " . TABLE_COUNTRIES . " c on (a.affiliate_country_id = c.countries_id)\n          WHERE affiliate_id = '" . $affiliate_payment['affiliate_id'] . "' \n        ";
         $affiliate_query = smn_db_query($sql);
         $affiliate = smn_db_fetch_array($affiliate_query);
         // Get need tax informations for the affiliate
         $affiliate_tax_rate = smn_get_affiliate_tax_rate(AFFILIATE_TAX_ID, $affiliate['affiliate_country_id'], $affiliate['affiliate_zone_id']);
         $affiliate_tax = smn_round($affiliate_billing['affiliate_payment'] * $affiliate_tax_rate / 100, 2);
         // Netto-Provision
         $affiliate_payment_total = $affiliate_billing['affiliate_payment'] + $affiliate_tax;
         // Bill the order
         $affiliate['affiliate_state'] = smn_get_zone_code($affiliate['affiliate_country_id'], $affiliate['affiliate_zone_id'], $affiliate['affiliate_state']);
         $sql_data_array = array('affiliate_id' => $affiliate_payment['affiliate_id'], 'affiliate_payment' => $affiliate_billing['affiliate_payment'], 'affiliate_payment_tax' => $affiliate_tax, 'affiliate_payment_total' => $affiliate_payment_total, 'affiliate_payment_date' => 'now()', 'affiliate_payment_status' => '0', 'affiliate_firstname' => $affiliate['affiliate_firstname'], 'affiliate_lastname' => $affiliate['affiliate_lastname'], 'affiliate_street_address' => $affiliate['affiliate_street_address'], 'affiliate_suburb' => $affiliate['affiliate_suburb'], 'affiliate_city' => $affiliate['affiliate_city'], 'affiliate_country' => $affiliate['countries_name'], 'affiliate_postcode' => $affiliate['affiliate_postcode'], 'affiliate_company' => $affiliate['affiliate_company'], 'affiliate_state' => $affiliate['affiliate_state'], 'affiliate_address_format_id' => $affiliate['address_format_id']);
         smn_db_perform(TABLE_AFFILIATE_PAYMENT, $sql_data_array);
         $insert_id = smn_db_insert_id();
         // Set the Sales to Final State
         smn_db_query("update " . TABLE_AFFILIATE_SALES . " set affiliate_payment_id = '" . $insert_id . "', affiliate_billing_status = 1, affiliate_payment_date = now() where affiliate_id = '" . $affiliate_payment['affiliate_id'] . "' and affiliate_billing_status = 99");
         // Notify Affiliate
         if (AFFILIATE_NOTIFY_AFTER_BILLING == 'true') {
             $check_status_query = smn_db_query("select af.affiliate_email_address, ap.affiliate_lastname, ap.affiliate_firstname, ap.affiliate_payment_status, ap.affiliate_payment_date, ap.affiliate_payment_date from " . TABLE_AFFILIATE_PAYMENT . " ap, " . TABLE_AFFILIATE . " af where affiliate_payment_id  = '" . $insert_id . "' and af.affiliate_id = ap.affiliate_id ");
             $check_status = smn_db_fetch_array($check_status_query);
             $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_AFFILIATE_PAYMENT_NUMBER . ' ' . $insert_id . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . smn_catalog_href_link(FILENAME_CATALOG_AFFILIATE_PAYMENT_INFO, 'payment_id=' . $insert_id, 'NONSSL') . "\n" . EMAIL_TEXT_PAYMENT_BILLED . ' ' . smn_date_long($check_status['affiliate_payment_date']) . "\n\n" . EMAIL_TEXT_NEW_PAYMENT;
             smn_mail($check_status['affiliate_firstname'] . ' ' . $check_status['affiliate_lastname'], $check_status['affiliate_email_address'], EMAIL_TEXT_SUBJECT, nl2br($email), STORE_OWNER, AFFILIATE_EMAIL_ADDRESS);
         }
     }
     $messageStack->add_session(SUCCESS_BILLING, 'success');
     smn_redirect(smn_href_link(FILENAME_AFFILIATE_PAYMENT, smn_get_all_get_params(array('action')) . 'action=edit'));
     break;
 case 'update_payment':
Exemple #9
0
} else {
    if (smn_not_null(MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL)) {
        $email_body = '$_POST:' . "\n\n";
        foreach ($_POST as $key => $value) {
            $email_body .= $key . '=' . $value . "\n";
        }
        $email_body .= "\n" . '$_GET:' . "\n\n";
        foreach ($_GET as $key => $value) {
            $email_body .= $key . '=' . $value . "\n";
        }
        smn_mail('', MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL, 'PayPal IPN Invalid Process', $email_body, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
    }
    if (isset($_POST['invoice']) && is_numeric($_POST['invoice']) && $_POST['invoice'] > 0) {
        $invoice_query = smn_db_query("select orders_id from " . TABLE_ORDERS_INVOICE . " where orders_invoice_id = '" . $_POST['invoice'] . "'");
        while ($invoice_id = smn_db_fetch_array($invoice_query)) {
            $check_query = smn_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . $invoice_id . "' and customers_id = '" . (int) $_POST['custom'] . "'");
            if (smn_db_num_rows($check_query) > 0) {
                $comment_status = $_POST['payment_status'];
                if ($_POST['payment_status'] == 'Pending') {
                    $comment_status .= '; ' . $_POST['pending_reason'];
                } elseif ($_POST['payment_status'] == 'Reversed' || $_POST['payment_status'] == 'Refunded') {
                    $comment_status .= '; ' . $_POST['reason_code'];
                }
                smn_db_query("update " . TABLE_ORDERS . " set orders_status = '" . (MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID > 0 ? MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID : DEFAULT_ORDERS_STATUS_ID) . "', last_modified = now() where orders_id = '" . $invoice_id . "'");
                $sql_data_array = array('orders_id' => $invoice_id, 'orders_status_id' => MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID > 0 ? MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID : DEFAULT_ORDERS_STATUS_ID, 'date_added' => 'now()', 'customer_notified' => '0', 'comments' => 'PayPal IPN Invalid [' . $comment_status . ']');
                smn_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
            }
        }
    }
}
require 'includes/application_bottom.php';
         }
         $sql_data_array = array('affiliate_banners_title' => $affiliate_banners_title, 'affiliate_products_id' => $affiliate_products_id, 'affiliate_banners_image' => $db_image_location, 'affiliate_banners_group' => $affiliate_banners_group);
         if ($_GET['action'] == 'insert') {
             $insert_sql_data = array('affiliate_date_added' => 'now()', 'affiliate_status' => '1');
             $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
             smn_db_perform(TABLE_AFFILIATE_BANNERS, $sql_data_array);
             $affiliate_banners_id = smn_db_insert_id();
             // Banner ID 1 is generic Product Banner
             if ($affiliate_banners_id == 1) {
                 smn_db_query("update " . TABLE_AFFILIATE_BANNERS . " set affiliate_banners_id = affiliate_banners_id + 1");
             }
             $messageStack->add_session(SUCCESS_BANNER_INSERTED, 'success');
         } elseif ($_GET['action'] == 'update') {
             $insert_sql_data = array('affiliate_date_status_change' => 'now()');
             $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
             smn_db_perform(TABLE_AFFILIATE_BANNERS, $sql_data_array, 'update', 'affiliate_banners_id = \'' . $affiliate_banners_id . '\'');
             $messageStack->add_session(SUCCESS_BANNER_UPDATED, 'success');
         }
         smn_redirect(smn_href_link(FILENAME_AFFILIATE_BANNER_MANAGER, 'selected_box=affiliate&page=' . $_GET['page'] . '&abID=' . $affiliate_banners_id));
     } else {
         $_GET['action'] = 'new';
     }
     break;
 case 'deleteconfirm':
     $affiliate_banners_id = smn_db_prepare_input($_GET['abID']);
     $delete_image = smn_db_prepare_input($_POST['delete_image']);
     if ($delete_image == 'on') {
         $affiliate_banner_query = smn_db_query("select affiliate_banners_image from " . TABLE_AFFILIATE_BANNERS . " where affiliate_banners_id = '" . smn_db_input($affiliate_banners_id) . "'");
         $affiliate_banner = smn_db_fetch_array($affiliate_banner_query);
         if (is_file(DIR_FS_CATALOG_IMAGES . $affiliate_banner['affiliate_banners_image'])) {
             if (is_writeable(DIR_FS_CATALOG_IMAGES . $affiliate_banner['affiliate_banners_image'])) {
            if (!smn_validate_password($_POST['password_confirmation'], $check_pass['confirm_password'])) {
                smn_redirect(smn_href_link(FILENAME_ADMIN_ACCOUNT, 'action=check_account&error=password'));
            } else {
                //$confirm = 'confirm_account';
                smn_session_register('confirm_account');
                $confirm_account = '1';
                smn_redirect(smn_href_link(FILENAME_ADMIN_ACCOUNT, 'action=edit_process'));
            }
            break;
        case 'save_account':
            $admin_id = smn_db_prepare_input($_POST['id_info']);
            $admin_email_address = smn_db_prepare_input($_POST['admin_email_address']);
            $stored_email[] = 'NONE';
            $check_email_query = smn_db_query("select admin_email_address from " . TABLE_ADMIN . " where admin_id <> " . $admin_id . "");
            while ($check_email = smn_db_fetch_array($check_email_query)) {
                $stored_email[] = $check_email['admin_email_address'];
            }
            if (in_array($_POST['admin_email_address'], $stored_email)) {
                smn_redirect(smn_href_link(FILENAME_ADMIN_ACCOUNT, 'action=edit_process&error=email'));
            } else {
                $sql_data_array = array('admin_firstname' => smn_db_prepare_input($_POST['admin_firstname']), 'admin_lastname' => smn_db_prepare_input($_POST['admin_lastname']), 'admin_email_address' => smn_db_prepare_input($_POST['admin_email_address']), 'admin_password' => smn_encrypt_password(smn_db_prepare_input($_POST['admin_password'])), 'admin_modified' => 'now()');
                smn_db_perform(TABLE_ADMIN, $sql_data_array, 'update', 'admin_id = \'' . $admin_id . '\'');
                smn_mail($_POST['admin_firstname'] . ' ' . $_POST['admin_lastname'], $_POST['check_email_address'], ADMIN_EMAIL_SUBJECT, sprintf(ADMIN_EMAIL_TEXT, $hiddenPassword), $_POST['check_firstname'] . ' ' . $_POST['admin_lastname'], $_POST['check_email_address']);
                smn_redirect(smn_href_link(FILENAME_ADMIN_ACCOUNT, 'page=' . $_GET['page'] . '&mID=' . $admin_id));
            }
            break;
    }
}
$content_page = basename($_SERVER['PHP_SELF']);
require 'templates/default/layout.php';
require DIR_WS_INCLUDES . 'application_bottom.php';
                $coupon_type = 'S';
                $coupon_amount = 0;
            }
            $sql_data_array = array('coupon_active' => smn_db_prepare_input($_POST['coupon_status']), 'coupon_code' => smn_db_prepare_input($_POST['coupon_code']), 'store_id' => $store_id, 'coupon_amount' => smn_db_prepare_input($coupon_amount), 'coupon_type' => smn_db_prepare_input($coupon_type), 'uses_per_coupon' => smn_db_prepare_input($_POST['coupon_uses_coupon']), 'uses_per_user' => smn_db_prepare_input($_POST['coupon_uses_user']), 'coupon_minimum_order' => smn_db_prepare_input($_POST['coupon_min_order']), 'restrict_to_products' => smn_db_prepare_input($_POST['coupon_products']), 'restrict_to_categories' => smn_db_prepare_input($_POST['coupon_categories']), 'coupon_start_date' => $_POST['coupon_startdate'], 'coupon_expire_date' => $_POST['coupon_finishdate'], 'date_created' => $_POST['date_created'] != '0' ? $_POST['date_created'] : 'now()', 'date_modified' => 'now()');
            $languages = smn_get_languages();
            for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
                $language_id = $languages[$i]['id'];
                $sql_data_marray[$i] = array('coupon_name' => smn_db_prepare_input($_POST['coupon_name'][$language_id]), 'coupon_description' => smn_db_prepare_input($_POST['coupon_desc'][$language_id]));
            }
            if ($_GET['oldaction'] == 'voucheredit') {
                smn_db_perform(TABLE_COUPONS, $sql_data_array, 'update', "store_id = '" . $store_id . "' and coupon_id='" . (int) $coupon_id . "'");
                for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
                    $language_id = $languages[$i]['id'];
                    $update = smn_db_query("update " . TABLE_COUPONS_DESCRIPTION . " set coupon_name = '" . smn_db_prepare_input($_POST['coupon_name'][$language_id]) . "', coupon_description = '" . smn_db_prepare_input($_POST['coupon_desc'][$language_id]) . "' where coupon_id = '" . (int) $coupon_id . "' and store_id = '" . $store_id . "' and language_id = '" . $language_id . "'");
                }
            } else {
                $query = smn_db_perform(TABLE_COUPONS, $sql_data_array);
                $insert_id = smn_db_insert_id($query);
                for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
                    $language_id = $languages[$i]['id'];
                    $sql_data_marray[$i]['coupon_id'] = $insert_id;
                    $sql_data_marray[$i]['language_id'] = $language_id;
                    $sql_data_marray[$i]['store_id'] = $store_id;
                    smn_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_marray[$i]);
                }
            }
        }
}
$content_page = basename($_SERVER['PHP_SELF']);
require 'templates/default/layout.php';
require DIR_WS_INCLUDES . 'application_bottom.php';
         smn_db_perform(TABLE_MANUFACTURERS, $sql_data_array, 'update', "manufacturers_id = '" . (int) $manufacturers_id . "'");
     }
     if ($manufacturers_image = new upload('manufacturers_image', DIR_FS_CATALOG_IMAGES)) {
         smn_db_query("update " . TABLE_MANUFACTURERS . " set manufacturers_image = '" . $manufacturers_image->filename . "' where manufacturers_id = '" . (int) $manufacturers_id . "'");
     }
     $languages = smn_get_languages();
     for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
         $manufacturers_url_array = $_POST['manufacturers_url'];
         $language_id = $languages[$i]['id'];
         $sql_data_array = array('manufacturers_url' => smn_db_prepare_input($manufacturers_url_array[$language_id]));
         if ($action == 'insert') {
             $insert_sql_data = array('manufacturers_id' => $manufacturers_id, 'languages_id' => $language_id);
             $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
             smn_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array);
         } elseif ($action == 'save') {
             smn_db_perform(TABLE_MANUFACTURERS_INFO, $sql_data_array, 'update', "manufacturers_id = '" . (int) $manufacturers_id . "' and languages_id = '" . (int) $language_id . "'");
         }
     }
     if (USE_CACHE == 'true') {
         smn_reset_cache_block('manufacturers');
     }
     smn_redirect(smn_href_link(FILENAME_MANUFACTURERS, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'mID=' . $manufacturers_id));
     break;
 case 'deleteconfirm':
     $manufacturers_id = smn_db_prepare_input($_GET['mID']);
     if (isset($_POST['delete_image']) && $_POST['delete_image'] == 'on') {
         $manufacturer_query = smn_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int) $manufacturers_id . "'");
         $manufacturer = smn_db_fetch_array($manufacturer_query);
         $image_location = DIR_FS_DOCUMENT_ROOT . DIR_WS_CATALOG_IMAGES . $manufacturer['manufacturers_image'];
         if (file_exists($image_location)) {
             @unlink($image_location);
                
                          smn_db_perform(TABLE_AFFILIATE_NEWS, $sql_data_array);
                          $news_id = smn_db_insert_id();*/
                //not actually used ATM -- just there in case          $sql_data_array = array('date_added' => 'now()', //uses the inbuilt mysql function 'now'
                $sql_data_array = array('date_added' => 'now()', 'news_status' => '1');
                smn_db_perform(TABLE_AFFILIATE_NEWS, $sql_data_array);
                $news_id = smn_db_insert_id();
                //not actually used ATM -- just there in case
                $sql_data_array = array('affiliate_news_id' => $news_id, 'affiliate_news_languages_id' => $languages_id, 'affiliate_news_headlines' => $_POST['headline'], 'affiliate_news_contents' => $_POST['content']);
                smn_db_perform(TABLE_AFFILIATE_NEWS_CONTENTS, $sql_data_array);
            }
            smn_redirect(smn_href_link(FILENAME_AFFILIATE_NEWS));
            break;
        case 'update_affiliate_news':
            //user wants to modify a news article.
            if ($_GET['affiliate_news_id']) {
                /*Changed the update query to update the news details to affiliate_news_content table by Cimi */
                /* $sql_data_array = array('headline' => smn_db_prepare_input($_POST['headline']),
                                           'content'  => smn_db_prepare_input($_POST['content']) );
                                           
                   smn_db_perform(TABLE_AFFILIATE_NEWS, $sql_data_array, 'update', "news_id = '" . smn_db_prepare_input($_GET['affiliate_news_id']) . "'");*/
                $sql_data_array = array('affiliate_news_headlines' => smn_db_prepare_input($_POST['headline']), 'affiliate_news_contents' => smn_db_prepare_input($_POST['content']));
                smn_db_perform(TABLE_AFFILIATE_NEWS_CONTENTS, $sql_data_array, 'update', "affiliate_news_id = '" . smn_db_prepare_input($_GET['affiliate_news_id']) . "'");
            }
            smn_redirect(smn_href_link(FILENAME_AFFILIATE_NEWS));
            break;
    }
}
$content_page = basename($_SERVER['PHP_SELF']);
require 'templates/default/layout.php';
require DIR_WS_INCLUDES . 'application_bottom.php';
Exemple #15
0
     if (isset($_GET['masterFileID'])) {
         $sql_data_array = array('admin_files_name' => smn_db_prepare_input($_GET['fileName']), 'admin_tabs_to_files' => smn_db_prepare_input($_GET['masterFileID']), 'admin_files_is_tab' => '1', 'admin_files_to_boxes' => smn_db_prepare_input($_GET['boxID']));
     } else {
         $sql_data_array = array('admin_files_name' => smn_db_prepare_input($_GET['fileName']), 'admin_files_to_boxes' => smn_db_prepare_input($_GET['boxID']));
     }
     smn_db_perform(TABLE_ADMIN_FILES, $sql_data_array);
     $masterFileID = smn_db_insert_id();
     $tabDir = str_replace('.php', '', $_GET['fileName']);
     $directory = DIR_FS_TEMPLATES . 'content/tabs/' . $tabDir . '/';
     $tabs = array();
     if (is_dir($directory)) {
         $dir = dir($directory);
         while (($file = $dir->read()) !== false) {
             if ($file != '.' && $file != '..' && is_file($directory . $file)) {
                 $sql_data_array = array('admin_files_name' => smn_db_prepare_input($file), 'admin_files_is_tab' => '1', 'admin_tabs_to_files' => $masterFileID, 'admin_files_to_boxes' => smn_db_prepare_input($_GET['boxID']));
                 smn_db_perform(TABLE_ADMIN_FILES, $sql_data_array);
                 $fileID = smn_db_insert_id();
                 $tabs[] = '["' . $fileID . '", "' . $file . '"]';
             }
         }
     }
     echo '{
           success: true,
           file_id: "' . $masterFileID . '",
           tabs: [' . implode(',', $tabs) . ']
       }';
 } else {
     $admin_files_name = smn_db_prepare_input($_GET['fileName']);
     $admin_boxes_id = smn_db_prepare_input($_GET['boxID']);
     $Qcheck = smn_db_query('select admin_files_id from ' . TABLE_ADMIN_FILES . ' where admin_files_is_boxes = "0" and admin_files_to_boxes = "' . $admin_boxes_id . '" and admin_files_name = "' . $admin_files_name . '"');
     if (smn_db_num_rows($Qcheck)) {
 function saveSitePage($pageType, $action)
 {
     global $jQuery;
     $error = false;
     $page_name = smn_db_prepare_input($_POST['page_name']);
     $page_title = $_POST['page_title'];
     $text_content = $_POST['text_content'];
     $page_navbar = $_POST['page_navbar'];
     $page_heading = $_POST['page_heading'];
     $page_header = $_POST['page_header'];
     $sql_data_array = array('page_name' => $page_name, 'store_id' => $this->storeID, 'page_type' => $pageType);
     if ($action == 'new') {
         smn_db_perform(TABLE_DYNAMIC_PAGE_INDEX, $sql_data_array);
         $page_id = smn_db_insert_id();
     } elseif ($action == 'edit') {
         $page_id = $_POST['page_id'];
         smn_db_perform(TABLE_DYNAMIC_PAGE_INDEX, $sql_data_array, 'update', 'page_id = "' . $page_id . '"');
     }
     for ($i = 0, $n = sizeof($this->langArray); $i < $n; $i++) {
         $language_id = $this->langArray[$i]['id'];
         $sql_data_array = array('page_name' => $page_name, 'language_id' => $language_id, 'store_id' => $this->storeID, 'text_key' => '', 'text_content' => '', 'date_modified' => 'now()');
         $navbar_array = array_merge($sql_data_array, array('text_key' => 'NAVBAR_TITLE', 'text_content' => smn_db_prepare_input($page_navbar[$language_id])));
         $heading_array = array_merge($sql_data_array, array('text_key' => 'HEADING_TITLE', 'text_content' => smn_db_prepare_input($page_heading[$language_id])));
         $header_array = array_merge($sql_data_array, array('text_key' => 'HEADER_TITLE', 'text_content' => smn_db_prepare_input($page_header[$language_id])));
         $article_array = array('page_id' => $page_id, 'language_id' => $language_id, 'store_id' => $this->storeID, 'page_title' => smn_db_prepare_input($page_title[$language_id]), 'text_content' => smn_db_prepare_input($text_content[$language_id]), 'date_modified' => 'now()');
         if ($action == 'new') {
             smn_db_perform(TABLE_WEB_SITE_CONTENT, $navbar_array);
             smn_db_perform(TABLE_WEB_SITE_CONTENT, $heading_array);
             smn_db_perform(TABLE_WEB_SITE_CONTENT, $header_array);
             smn_db_perform(TABLE_ARTICLES, $article_array);
         } elseif ($action == 'edit') {
             smn_db_perform(TABLE_WEB_SITE_CONTENT, $navbar_array, 'update', 'page_name = "' . $page_name . '" and text_key = "NAVBAR_TITLE" and language_id = "' . $language_id . '" and store_id = "' . $this->storeID . '"');
             smn_db_perform(TABLE_WEB_SITE_CONTENT, $heading_array, 'update', 'page_name = "' . $page_name . '" and text_key = "HEADING_TITLE" and language_id = "' . $language_id . '" and store_id = "' . $this->storeID . '"');
             smn_db_perform(TABLE_WEB_SITE_CONTENT, $header_array, 'update', 'page_name = "' . $page_name . '" and text_key = "HEADER_TITLE" and language_id = "' . $language_id . '" and store_id = "' . $this->storeID . '"');
             smn_db_perform(TABLE_ARTICLES, $article_array, 'update', 'page_id = "' . $page_id . '" and language_id = "' . $language_id . '" and store_id = "' . $this->storeID . '"');
         }
     }
     if ($error === false) {
         $jsonResponse = array();
         for ($i = 0, $n = sizeof($this->langArray); $i < $n; $i++) {
             $lID = $this->langArray[$i]['id'];
             $jsonResponse[] = 'page_title_' . $lID . ': "' . $jQuery->jsonHtmlPrepare($page_title[$lID]) . '",
                                  text_content_' . $lID . ': "' . $jQuery->jsonHtmlPrepare($text_content[$lID]) . '",
                                  page_header_' . $lID . ': "' . $jQuery->jsonHtmlPrepare($page_header[$lID]) . '",
                                  page_heading_' . $lID . ': "' . $jQuery->jsonHtmlPrepare($page_heading[$lID]) . '",
                                  page_navbar_' . $lID . ': "' . $jQuery->jsonHtmlPrepare($page_navbar[$lID]) . '"';
         }
         $this->setJsonResponse('{
               success: true,
               page_id: "' . $page_id . '",
               page_name: "' . $page_name . '",
               date_modified: "' . date('Y-m-d') . '",
               page_type: "' . $pageType . '",
               ' . implode(',', $jsonResponse) . '
           }');
     } else {
         $this->setJsonResponse('{
               success: false,
               errorMsg: "There was an error saving the data."
           }');
     }
 }
Exemple #17
0
 function put_store_products()
 {
     global $cart, $store;
     $store_products_id = $store->smn_set_products_id($this->store_type);
     $product_model_query = smn_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int) $store_products_id . "'");
     $product_model = smn_db_fetch_array($product_model_query);
     $member_product = explode('_', $product_model['products_model']);
     $start_day = getdate();
     $day = $start_day['mday'];
     $month = $start_day['mon'];
     $year = $start_day['year'];
     $product_end_date = strftime('%Y', mktime(0, 0, 0, $month + (int) $member_product[1], $day, $year)) . '-' . strftime('%m', mktime(0, 0, 0, $month + (int) $member_product[1], $day, $year)) . '-' . strftime('%d', mktime(0, 0, 0, $month + (int) $member_product[1], $day, $year));
     $sql_data_array = array('store_id' => $this->store_id, 'products_id' => $store_products_id, 'customer_id' => $this->get_customers_id(), 'products_end_date' => $product_end_date);
     smn_db_perform(TABLE_MEMBER_ORDERS, $sql_data_array);
     $customer_first_name = $this->store_customers_data['customers_firstname'];
     $customer_default_address_id = $this->store_customers_data['customers_default_address_id'];
     $customer_country_id = $this->store_customers_data['entry_country_id'];
     $customer_zone_id = $this->store_customers_data['entry_zone_id'];
     $name = $this->store_customers_data['customers_firstname'] . ' ' . $this->store_customers_data['customers_lastname'];
     //add to the cart now......
     $cart->add_cart($store_products_id, $cart->get_quantity($store_products_id) + 1);
     // restore cart contents
     $cart->restore_contents();
 }
Exemple #18
0
 function before_process()
 {
     global $_POST, $language;
     require DIR_WS_LANGUAGES . $language . "/modules/payment/surepay.php";
     require DIR_WS_CLASSES . "sausurepay.php";
     #  Creditcard test AUTH:
     #     cc number: 4012000033330026   any future exp date
     #     $11 = AUTH     $21 = "REF"   $31 = "DCL"   any other may give "ERR"
     #     This test request uses total $1 shipping, and 1x$5 + 1x$5 goods,
     #     total $11. Just change the item quantities to try the other status.
     #  I have also found some bugs and weakneses in Surepays processing, here is a
     #  couple of them:
     #
     #   - Do not add % as character data, best off staying away from it totally.
     #     This can cause surepays servlets to crash and gives a 500 server error.
     #
     #   - Do not convert < > & ' " to the correct XML entities, surepays parser or
     #     data collector rejects any characterdata like &lt; and so on.
     #
     #   - Phone numbers in address are limited length (stay 11 digits or less), they
     #     claim to be "US domestic oriented" (?)
     #
     #   - What is the correct way to handle ref? Should the script handle and check
     #     avs and cvv2status responses to something automatically? If someone has
     #     a guideline to this would be appreciated.. (sausurepay@sauen.com)
     ## Syntax:
     ##  vobject_identifier: sausp (
     ##     boolean: live?
     ##    ,string: merchant id
     ##    ,string: password
     ##   [,array: extra pp.request parameters ]
     ##  )
     // --- Create the SurePay request object. ---
     // --- This is where you can change some of the settings. ---
     $amount = $_POST['surepay_total'];
     $shipping_cost = $_POST['surepay_shipping_cost'];
     if ($this->test_mode == true) {
         // --- Fill in the info for the fake auth requests. ---
         $shipping_cost = '0.00USD';
         $amount = '11.00USD';
         // Use this amount if you want to test: card okay.
         $amount = '31.00USD';
         // Use this amount if you want to test: card referred to voice center.
         $amount = '44.00USD';
         // Use this amount if you want to test: card declined.
         // -- Random valid generator.
         if (rand() % 2 == 1) {
             $amount = '11.00USD';
         }
     }
     // -- Figure out whether to use xml.test.surepay.com (test) or xml.surepay.com (live).
     $live = !$this->test_mode;
     $ssp = new sausp($live, $this->login, $this->password);
     if ($ssp->err) {
         die($ssp->err);
     }
     // --- Generate SurePay order id. ---
     // --   Note that this is not the same as the order_id in OS Commerce, which does
     // --   not exist until after a payment is approved.
     smn_db_perform(TABLE_SUREPAY_TRANSACTIONS, array(message => ''));
     $order_number = smn_db_insert_id();
     // --- Add miscellanous auth request info. ---
     // --   ecommercecode specifies the level of encryption( default is 07 - NONSSL, )
     // --   05 - secure w/ cardholder & merchant cert,
     // --   06 - secure w/ merchant cert
     // --   07 - NONSSL
     // --   08 - no security
     $auth = $ssp->add_auth(array('ordernumber' => $order_number, 'ecommerce' => 'true', 'ecommercecode' => '07', 'ipaddress' => $REMOTE_ADDR, 'shippingcost' => $shipping_cost, 'shippingcost2' => "0.00USD", 'taxamount' => $_POST['surepay_tax'], 'referringurl' => $HTTP_REFERER, 'browsertype' => $HTTP_USER_AGENT));
     if ($ssp->err) {
         die($ssp->err);
     }
     // --- Add the shipping address using the order info. ---
     $ssp->add_shipping_address($auth, array('fullname' => $_POST['surepay_delivery_fullname'], 'address1' => $_POST['surepay_delivery_address'], 'address2' => '', 'city' => $_POST['surepay_delivery_city'], 'state' => $_POST['surepay_delivery_state'], 'zip' => $_POST['surepay_delivery_postcode'], 'country' => $_POST['surepay_delivery_country'], 'phone' => $_POST['surepay_phone'], 'email' => $_POST['surepay_email']));
     if ($ssp->err) {
         die($ssp->err);
     }
     // --- Add the credit card info. ---
     ## Syntax:
     ##  object_identifier: add_creditcard (
     ##      object_identifier: parent object
     ##     ,string: card number
     ##     ,string: expiration (mm/yy)
     ##     ,int: cvv2 code from card
     ##    [,int: cvv2status (security mode) (0|1|9) default is 1 (In Use), 0 = off, 9 = no code available ]
     ##    [,array: billing address]
     ##  )
     $creditcard = $ssp->add_creditcard($auth, $this->cc_number, $this->cc_expires_month . "/" . $this->cc_expires_year, $this->cc_cvv2);
     // --- Add the billing address for the order. ---
     $ssp->add_billing_address($creditcard, array('fullname' => $_POST['surepay_fullname'], 'address1' => $_POST['surepay_address'], 'address2' => '', 'city' => $_POST['surepay_city'], 'state' => $_POST['surepay_state'], 'zip' => $_POST['surepay_postcode'], 'country' => $_POST['surepay_country'], 'phone' => $_POST['surepay_phone'], 'email' => $_POST['surepay_email']));
     if ($ssp->err) {
         die($ssp->err);
     }
     // --- Add total as lineitem ---
     // -- We only add one lineitem with the total right now.  If you wanted to, you could
     // --  rewrite this to use multiple lineitems to more accurately reflect the items
     // --  in the current order.
     ## Syntax:
     ##  object_identifier: add_lineitem (
     ##      object_identifier: parent object (The AUTH object)
     ##     ,int: quantity,
     ##     ,string: sku,
     ##     ,string: description,
     ##     ,string: unit cost (currency) [d..d]d.ccUSD
     ##     ,real: taxrate in decimal notation (0.08 = 8%)
     ##    [,array: options ]
     ##  )
     $item = $ssp->add_lineitem($auth, '1', 'ORDER_TOTAL', 'Order total for this order.', $amount, $_POST['surepay_tax_rate']);
     if ($ssp->err) {
         die($ssp->err);
     }
     // --- Generate the XML request for SurePay. ---
     $ssp->prepare_request();
     if ($ssp->err) {
         die($ssp->err);
     }
     // TODO: remove.  debug info
     if ($surepay_debug_mode) {
         echo "server: " . $ssp->serverurl;
         echo "</PRE><h2>The request xml we send:</H2><PRE>" . htmlentities($ssp->xml_request, ENT_QUOTES) . "\n<hr>";
     }
     // --- Send the request to SurePay. ---
     $ssp->submit_request();
     if ($ssp->err) {
         die($ssp->err);
     }
     // TODO: remove  debug info
     if ($surepay_debug_mode) {
         echo "</PRE><h2>The response xml we got back:</H2><PRE>" . htmlentities($ssp->xml_response, ENT_QUOTES) . "\n<hr>";
         die("\n<br>end");
     }
     $responsecount = $ssp->parse_response();
     if ($ssp->err) {
         die($ssp->err);
     }
     if (!$responsecount) {
         die("Invalid response count.\n");
     }
     // --- Check through the AUTH responses. ---
     $auths = $ssp->auths();
     if ($ssp->err) {
         die($ssp->err);
     }
     while (list($key, $ssp_order) = each($auths)) {
         // -- Store the transaction record in the SurePay table. ---
         $sql_data_array = array('auth_code' => $ssp->auth_authcode($ssp_order), 'transaction_id' => $ssp->auth_trans_id($ssp_order), 'message' => $ssp->auth_text($ssp_order));
         smn_db_perform(TABLE_SUREPAY_TRANSACTIONS, $sql_data_array, 'update', 'request_id = ' . $ssp_order);
         if ($ssp->auth_status($ssp_order) != 'AUTH') {
             // -- Redirect to error page.
             $err_msg = $ssp->auth_text($ssp_order);
             smn_redirect(smn_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . stripslashes(MODULE_PAYMENT_SUREPAY_TEXT_ERROR_DECLINED), 'NONSSL', true, false));
         }
         if ($ssp->err) {
             die($ssp->err);
         }
     }
 }
        if (is_object(${$payment})) {
            $email_order_store .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n";
            $payment_class = ${$payment};
            $email_order_store .= $payment_class->title . "\n\n";
            if ($payment_class->email_footer) {
                $email_order_store .= $payment_class->email_footer . "\n\n";
            }
        }
        smn_mail($vendor_details['customers_firstname'] . ' ' . $vendor_details['customers_lastname'], $vendor_details['customers_email_address'], EMAIL_TEXT_SUBJECT, $email_order_store, $store->get_store_owner(), $store->get_store_owner_email_address());
        for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
            $cart->remove($order->products[$i]['id']);
        }
        $start_day = getdate();
        $set_date = $start_day['mday'] . '-' . $start_day['mon'] . '-' . $start_day['year'];
        $sql_data_array = array('orders_id' => $insert_id, 'store_id' => $store_id, 'value' => $total_products_price, 'date' => $set_date);
        smn_db_perform(TABLE_ORDERS_TRACKING, $sql_data_array);
        $order_total_modules->apply_credit();
    }
}
/*End of code*/
$email_order .= '';
if ($set_member_product == 'true') {
    $email_order .= EMAIL_TEXT_MEMBER_PRODUCT . ' ' . $product_end_date . "\n\n";
}
// lets start with the email confirmation
$email_order .= $store->get_store_name() . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . smn_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'NONSSL', false) . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
if ($order->info['comments']) {
    $email_order .= smn_db_output($order->info['comments']) . "\n\n";
}
$email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n" . $products_ordered . EMAIL_SEPARATOR . "\n";
for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
     }
     if (empty($module)) {
         $messageStack->add(ERROR_NEWSLETTER_MODULE, 'error');
         $newsletter_error = true;
     }
     if ($newsletter_error == false) {
         $sql_data_array = array('title' => $title, 'content' => $content, 'module' => $newsletter_module);
         if ($action == 'insert') {
             $sql_data_array['date_added'] = 'now()';
             $sql_data_array['status'] = '0';
             $sql_data_array['locked'] = '0';
             $sql_data_array['store_id'] = $store_id;
             smn_db_perform(TABLE_NEWSLETTERS, $sql_data_array);
             $newsletter_id = smn_db_insert_id();
         } elseif ($action == 'update') {
             smn_db_perform(TABLE_NEWSLETTERS, $sql_data_array, 'update', "newsletters_id = '" . (int) $newsletter_id . "'");
         }
         smn_redirect(smn_href_link(FILENAME_NEWSLETTERS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'nID=' . $newsletter_id));
     } else {
         $action = 'new';
     }
     break;
 case 'deleteconfirm':
     $newsletter_id = smn_db_prepare_input($HTTP_GET_VARS['nID']);
     smn_db_query("delete from " . TABLE_NEWSLETTERS . " where newsletters_id = '" . (int) $newsletter_id . "'");
     smn_redirect(smn_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page']));
     break;
 case 'delete':
 case 'new':
     if (!isset($HTTP_GET_VARS['nID'])) {
         break;
 if (ACCOUNT_GENDER == 'true') {
     $sql_data_array['entry_gender'] = $gender;
 }
 if (ACCOUNT_COMPANY == 'true') {
     $sql_data_array['entry_company'] = $company;
 }
 if (ACCOUNT_STATE == 'true') {
     if ($zone_id > 0) {
         $sql_data_array['entry_zone_id'] = $zone_id;
         $sql_data_array['entry_state'] = '';
     } else {
         $sql_data_array['entry_zone_id'] = '0';
         $sql_data_array['entry_state'] = $state;
     }
 }
 smn_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
 $address_id = smn_db_insert_id();
 smn_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int) $address_id . "' where customers_id = '" . (int) $customer_id . "'");
 smn_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values ('" . (int) $customer_id . "', '0', now())");
 if (SESSION_RECREATE == 'True') {
     smn_session_recreate();
 }
 $customer_first_name = $firstname;
 $customer_default_address_id = $address_id;
 $customer_country_id = $country;
 $customer_zone_id = $zone_id;
 smn_session_register('customer_id');
 smn_session_register('customer_first_name');
 smn_session_register('customer_default_address_id');
 smn_session_register('customer_country_id');
 smn_session_register('customer_zone_id');
            }
            $store_info->send_store_email($gender);
            $error_text = $store_info->put_logo_image('update');
        } else {
            $customer_store_id = (int) $_GET['sID'];
            //update existing store here....
            $store_info->update_store_info();
            $error_text = $store_info->put_logo_image('update');
            $sql_store_array = array('store_status' => $store_status);
            smn_db_perform(TABLE_STORE_MAIN, $sql_store_array, 'update', "store_id = '" . (int) $_GET['sID'] . "'");
            $sql_member_array = array('products_id' => (int) $store_products_id);
            smn_db_perform(TABLE_MEMBER_ORDERS, $sql_member_array, 'update', "store_id = '" . (int) $_GET['sID'] . "'");
            if ((int) $_GET['sID'] != 1) {
                $sql_data_array = array('admin_groups_id' => (int) $new_store_type);
            }
            smn_db_perform(TABLE_ADMIN, $sql_data_array, 'update', "store_id = '" . (int) $_GET['sID'] . "'");
        }
        smn_redirect(smn_href_link(FILENAME_MANAGEMENT, 'sPath=' . $sPath . '&sID=' . (int) $customer_store_id));
    }
}
// check if the catalog image directory exists
if (is_dir(DIR_FS_CATALOG_IMAGES)) {
    if (!is_writeable(DIR_FS_CATALOG_IMAGES)) {
        $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
    }
} else {
    $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
}
$content_page = basename($_SERVER['PHP_SELF']);
require 'templates/default/layout.php';
require DIR_WS_INCLUDES . 'application_bottom.php';
            
                    if (ACCOUNT_DOB == 'true') $sql_data_array['affiliate_dob'] = smn_date_raw($affiliate_dob);
                    if (ACCOUNT_GENDER == 'true') $sql_data_array['affiliate_gender'] = $affiliate_gender;
                    if (ACCOUNT_COMPANY == 'true') {
                      $sql_data_array['affiliate_company'] = $affiliate_company;
                      $sql_data_array['affiliate_company_taxid'] =  $affiliate_company_taxid;
                    }
                    if (ACCOUNT_SUBURB == 'true') $sql_data_array['affiliate_suburb'] = $affiliate_suburb;
                    if (ACCOUNT_STATE == 'true') {
                      $sql_data_array['affiliate_state'] = $affiliate_state;
                      $sql_data_array['affiliate_zone_id'] = $affiliate_zone_id;
                    }
            
                    $sql_data_array['affiliate_date_account_last_modified'] = 'now()';*/
            $sql_data_array = array('affiliate_payment_check' => $affiliate_payment_check, 'affiliate_payment_paypal' => $affiliate_payment_paypal, 'affiliate_payment_bank_name' => $affiliate_payment_bank_name, 'affiliate_payment_bank_branch_number' => $affiliate_payment_bank_branch_number, 'affiliate_payment_bank_swift_code' => $affiliate_payment_bank_swift_code, 'affiliate_payment_bank_account_name' => $affiliate_payment_bank_account_name, 'affiliate_payment_bank_account_number' => $affiliate_payment_bank_account_number, 'affiliate_homepage' => $affiliate_homepage, 'affiliate_commission_percent' => $affiliate_commission_percent, 'affiliate_agb' => '1');
            if (ACCOUNT_COMPANY == 'true') {
                $sql_data_array['affiliate_company_taxid'] = $affiliate_company_taxid;
            }
            smn_db_perform(TABLE_AFFILIATE, $sql_data_array, 'update', "affiliate_id = '" . smn_db_input($affiliate_id) . "'");
            smn_redirect(smn_href_link(FILENAME_AFFILIATE, smn_get_all_get_params(array('acID', 'action')) . 'acID=' . $affiliate_id));
            break;
        case 'deleteconfirm':
            $affiliate_id = smn_db_prepare_input($_GET['acID']);
            affiliate_delete(smn_db_input($affiliate_id));
            smn_redirect(smn_href_link(FILENAME_AFFILIATE, smn_get_all_get_params(array('acID', 'action'))));
            break;
    }
}
$content_page = basename($_SERVER['PHP_SELF']);
require 'templates/default/layout.php';
require DIR_WS_INCLUDES . 'application_bottom.php';
}
$affiliate_total = smn_round($affiliate_total, 2);
// Check for individual commission
$affiliate_percentage = 0;
if (AFFILATE_INDIVIDUAL_PERCENTAGE == 'true') {
    $affiliate_commission_query = smn_db_query("select affiliate_commission_percent from " . TABLE_AFFILIATE . " where affiliate_id = '" . $affiliate_ref . "'");
    $affiliate_commission = smn_db_fetch_array($affiliate_commission_query);
    $affiliate_percent = $affiliate_commission['affiliate_commission_percent'];
}
if ($affiliate_percent < AFFILIATE_PERCENT) {
    $affiliate_percent = AFFILIATE_PERCENT;
}
$affiliate_payment = smn_round($affiliate_total * $affiliate_percent / 100, 2);
if ($HTTP_SESSION_VARS['affiliate_ref']) {
    $sql_data_array = array('affiliate_id' => $affiliate_ref, 'affiliate_date' => $affiliate_clientdate, 'affiliate_browser' => $affiliate_clientbrowser, 'affiliate_ipaddress' => $affiliate_clientip, 'affiliate_value' => $affiliate_total, 'affiliate_payment' => $affiliate_payment, 'affiliate_orders_id' => $insert_id, 'affiliate_clickthroughs_id' => $affiliate_clickthroughs_id, 'affiliate_percent' => $affiliate_percent, 'affiliate_salesman' => $affiliate_ref);
    smn_db_perform(TABLE_AFFILIATE_SALES, $sql_data_array);
    if (AFFILATE_USE_TIER == 'true') {
        $affiliate_tiers_query = smn_db_query("SELECT aa2.affiliate_id, (aa2.affiliate_rgt - aa2.affiliate_lft) as height\n                                                      FROM affiliate_affiliate AS aa1, affiliate_affiliate AS aa2\n                                                      WHERE  aa1.affiliate_root = aa2.affiliate_root \n                                                            AND aa1.affiliate_lft BETWEEN aa2.affiliate_lft AND aa2.affiliate_rgt\n                                                            AND aa1.affiliate_rgt BETWEEN aa2.affiliate_lft AND aa2.affiliate_rgt\n                                                            AND aa1.affiliate_id =  '" . $affiliate_ref . "'\n                                                      ORDER by height asc limit 1, " . AFFILIATE_TIER_LEVELS . " \n                                              ");
        $affiliate_tier_percentage = split("[;]", AFFILIATE_TIER_PERCENTAGE);
        $i = 0;
        while ($affiliate_tiers_array = smn_db_fetch_array($affiliate_tiers_query)) {
            $affiliate_percent = $affiliate_tier_percentage[$i];
            $affiliate_payment = smn_round($affiliate_total * $affiliate_percent / 100, 2);
            if ($affiliate_payment > 0) {
                $sql_data_array = array('affiliate_id' => $affiliate_tiers_array['affiliate_id'], 'affiliate_date' => $affiliate_clientdate, 'affiliate_browser' => $affiliate_clientbrowser, 'affiliate_ipaddress' => $affiliate_clientip, 'affiliate_value' => $affiliate_total, 'affiliate_payment' => $affiliate_payment, 'affiliate_orders_id' => $insert_id, 'affiliate_clickthroughs_id' => $affiliate_clickthroughs_id, 'affiliate_percent' => $affiliate_percent, 'affiliate_salesman' => $affiliate_ref);
                smn_db_perform(TABLE_AFFILIATE_SALES, $sql_data_array);
            }
            $i++;
        }
    }
}
                    // systemsmanager begin - Dec 1, 2005 security patch
                    //          $customer_country_id = $country_id;
                    $customer_country_id = $country;
                    // systemsmanager end
                    $customer_zone_id = $zone_id > 0 ? (int) $zone_id : '0';
                    if (isset($_POST['primary']) && $_POST['primary'] == 'on') {
                        $customer_default_address_id = $new_address_book_id;
                    }
                    $sql_data_array = array('customers_firstname' => $firstname, 'customers_lastname' => $lastname);
                    if (ACCOUNT_GENDER == 'true') {
                        $sql_data_array['customers_gender'] = $gender;
                    }
                    if (isset($_POST['primary']) && $_POST['primary'] == 'on') {
                        $sql_data_array['customers_default_address_id'] = $new_address_book_id;
                    }
                    smn_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int) $customer_id . "'");
                }
                $messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success');
            }
        }
        smn_redirect(smn_href_link(FILENAME_ADDRESS_BOOK, '', 'NONSSL'));
    }
}
if (isset($_GET['edit']) && is_numeric($_GET['edit'])) {
    $entry_query = smn_db_query("select entry_gender, entry_company, entry_firstname, entry_lastname, entry_street_address, entry_postcode, entry_city, entry_state, entry_zone_id, entry_country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $customer_id . "' and address_book_id = '" . (int) $_GET['edit'] . "'");
    if (!smn_db_num_rows($entry_query)) {
        $messageStack->add_session('addressbook', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY);
        smn_redirect(smn_href_link(FILENAME_ADDRESS_BOOK, '', 'NONSSL'));
    }
    $entry = smn_db_fetch_array($entry_query);
} elseif (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
        }
        $sql_data_array = array('affiliate_id' => $affiliate_ref, 'affiliate_clientdate' => $affiliate_clientdate, 'affiliate_clientbrowser' => $affiliate_clientbrowser, 'affiliate_clientip' => $affiliate_clientip, 'affiliate_clientreferer' => $affiliate_clientreferer, 'affiliate_products_id' => $affiliate_products_id, 'affiliate_banner_id' => $affiliate_banner_id);
        smn_db_perform(TABLE_AFFILIATE_CLICKTHROUGHS, $sql_data_array);
        $affiliate_clickthroughs_id = smn_db_insert_id();
        // Banner has been clicked, update stats:
        if ($affiliate_banner_id && $affiliate_ref) {
            $today = date('Y-m-d');
            $sql = "select * from " . TABLE_AFFILIATE_BANNERS_HISTORY . " where affiliate_banners_id = '" . $affiliate_banner_id . "' and  affiliate_banners_affiliate_id = '" . $affiliate_ref . "' and affiliate_banners_history_date = '" . $today . "'";
            $banner_stats_query = smn_db_query($sql);
            // Banner has been shown today
            if (smn_db_fetch_array($banner_stats_query)) {
                smn_db_query("update " . TABLE_AFFILIATE_BANNERS_HISTORY . " set affiliate_banners_clicks = affiliate_banners_clicks + 1 where affiliate_banners_id = '" . $affiliate_banner_id . "' and affiliate_banners_affiliate_id = '" . $affiliate_ref . "' and affiliate_banners_history_date = '" . $today . "'");
                // Initial entry if banner has not been shown
            } else {
                $sql_data_array = array('affiliate_banners_id' => $affiliate_banner_id, 'affiliate_banners_products_id' => $affiliate_products_id, 'affiliate_banners_affiliate_id' => $affiliate_ref, 'affiliate_banners_clicks' => '1', 'affiliate_banners_history_date' => $today);
                smn_db_perform(TABLE_AFFILIATE_BANNERS_HISTORY, $sql_data_array);
            }
        }
        // Set Cookie if the customer comes back and orders it counts
        setcookie('affiliate_ref', $affiliate_ref, time() + AFFILIATE_COOKIE_LIFETIME);
    }
    if ($HTTP_COOKIE_VARS['affiliate_ref']) {
        // Customer comes back and is registered in cookie
        $affiliate_ref = $HTTP_COOKIE_VARS['affiliate_ref'];
    }
}
// add the products model to the breadcrumb trail
if (isset($_GET['products_id'])) {
    $model_query = smn_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int) $set_product_id . "'");
    if (smn_db_num_rows($model_query)) {
        $model = smn_db_fetch_array($model_query);
            } elseif ($_GET['gID'] != 'edit_group') {
                $check_groups_name_query = smn_db_query("select admin_groups_name as group_name_new from " . TABLE_ADMIN_GROUPS . " where admin_groups_name like '%" . $name_replace . "%'");
                $check_duplicate = smn_db_num_rows($check_groups_name_query);
                if ($check_duplicate > 0) {
                    smn_redirect(smn_href_link(FILENAME_ADMIN_MEMBERS, 'gID=' . $_GET['gID'] . '&gName=used&action=new_group'));
                } else {
                    $sql_product_data_array = array('products_quantity' => '1000', 'products_model' => 'mem_6_', 'products_price' => smn_db_prepare_input($_POST['admin_groups_cost']), 'products_date_available' => date('Y-m-d'), 'store_id' => 1, 'products_weight' => '0', 'products_status' => '1', 'products_tax_class_id' => '', 'products_date_added' => 'now()', 'products_image' => '', 'manufacturers_id' => '');
                    smn_db_perform(TABLE_PRODUCTS, $sql_product_data_array);
                    $products_id = smn_db_insert_id();
                    smn_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int) $products_id . "', '1')");
                    $languages = smn_get_languages();
                    for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
                        $language_id = $languages[$i]['id'];
                        $sql_data_array = array('products_id' => $products_id, 'products_name' => smn_db_prepare_input($admin_groups_name), 'language_id' => $language_id, 'products_url' => HTTP_CATALOG_SERVER);
                        smn_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
                    }
                    $sql_data_array = array('admin_groups_name' => $admin_groups_name, 'admin_groups_store_type' => smn_db_prepare_input($_POST['admin_groups_store_types']), 'admin_groups_products_id' => $products_id, 'admin_sales_cost' => smn_db_prepare_input($_POST['admin_sales_cost']), 'admin_groups_max_products' => smn_db_prepare_input($_POST['admin_groups_max_products']));
                    smn_db_perform(TABLE_ADMIN_GROUPS, $sql_data_array);
                    $admin_groups_id = smn_db_insert_id();
                    $set_groups_id = smn_db_prepare_input($_POST['set_groups_id']);
                    $add_group_id = $set_groups_id . ',\'' . $admin_groups_id . '\'';
                    smn_db_query("alter table " . TABLE_ADMIN_FILES . " change admin_groups_id admin_groups_id set( " . $add_group_id . ") NOT NULL DEFAULT '1' ");
                    smn_redirect(smn_href_link(FILENAME_ADMIN_MEMBERS, 'gID=' . $admin_groups_id));
                }
            }
            break;
    }
}
$content_page = basename($_SERVER['PHP_SELF']);
require 'templates/default/layout.php';
require DIR_WS_INCLUDES . 'application_bottom.php';
 function update_store_admin_password()
 {
     $sql_data_array = array('admin_password' => $this->password);
     smn_db_perform(TABLE_ADMIN, $sql_data_array, 'update', 'customer_id = "' . $this->customer_id . '"');
 }
                    $language_id = $languages[$i]['id'];
                    $sql_data_array = array('text_content' => addslashes($_POST['file_content'][$language_id]), 'date_modified' => 'now()');
                    smn_db_perform($db_table, $sql_data_array, 'update', "page_name='" . $_POST['page_name'] . "' and text_key='" . $_POST['text_key'] . "' and language_id='" . $language_id . "' and store_id = '" . $store_id . "'");
                }
            } elseif ($_GET['type'] == 'save_mainpage') {
                for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
                    $language_id = $languages[$i]['id'];
                    $store_description = addslashes($_POST['mainpage']);
                    smn_db_query("update " . TABLE_STORE_DESCRIPTION . " set store_description = '" . $store_description . "' where language_id='" . $language_id . "' and store_id = '" . $store_id . "'");
                }
            } else {
                $languages = smn_get_languages();
                for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
                    $language_id = $languages[$i]['id'];
                    $sql_data_array = array('text_content' => addslashes($_POST['file_content'][$language_id]), 'date_modified' => 'now()');
                    smn_db_perform($db_table, $sql_data_array, 'update', "page_id='" . $_POST['page_id'] . "' and language_id='" . $language_id . "' and store_id = '" . $store_id . "'");
                }
            }
            smn_redirect(smn_href_link(FILENAME_TEXT_EDITOR));
            break;
    }
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php 
echo HTML_PARAMS;
?>
>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php 
echo CHARSET;
     $languages = smn_get_languages();
     for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
         $orders_status_name_array = $_POST['orders_status_name'];
         $language_id = $languages[$i]['id'];
         $sql_data_array = array('orders_status_name' => smn_db_prepare_input($orders_status_name_array[$language_id]), 'public_flag' => isset($HTTP_POST_VARS['public_flag']) && $HTTP_POST_VARS['public_flag'] == '1' ? '1' : '0', 'downloads_flag' => isset($HTTP_POST_VARS['downloads_flag']) && $HTTP_POST_VARS['downloads_flag'] == '1' ? '1' : '0');
         if ($action == 'insert') {
             if (empty($orders_status_id)) {
                 $next_id_query = smn_db_query("select max(orders_status_id) as orders_status_id from " . TABLE_ORDERS_STATUS . "");
                 $next_id = smn_db_fetch_array($next_id_query);
                 $orders_status_id = $next_id['orders_status_id'] + 1;
             }
             $insert_sql_data = array('orders_status_id' => $orders_status_id, 'language_id' => $language_id);
             $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
             smn_db_perform(TABLE_ORDERS_STATUS, $sql_data_array);
         } elseif ($action == 'save') {
             smn_db_perform(TABLE_ORDERS_STATUS, $sql_data_array, 'update', "orders_status_id = '" . (int) $orders_status_id . "' and language_id = '" . (int) $language_id . "'");
         }
     }
     if (isset($_POST['default']) && $_POST['default'] == 'on') {
         smn_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . smn_db_input($orders_status_id) . "' where configuration_key = 'DEFAULT_ORDERS_STATUS_ID'");
     }
     smn_redirect(smn_href_link(FILENAME_ORDERS_STATUS, 'page=' . $_GET['page'] . '&oID=' . $orders_status_id));
     break;
 case 'deleteconfirm':
     $oID = smn_db_prepare_input($_GET['oID']);
     $orders_status_query = smn_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'DEFAULT_ORDERS_STATUS_ID'");
     $orders_status = smn_db_fetch_array($orders_status_query);
     if ($orders_status['configuration_value'] == $oID) {
         smn_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '' where configuration_key = 'DEFAULT_ORDERS_STATUS_ID'");
     }
     smn_db_query("delete from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . smn_db_input($oID) . "'");