function smn_update_whos_online()
{
    global $customer_id;
    if (smn_session_is_registered('customer_id')) {
        $wo_customer_id = $customer_id;
        $customer_query = smn_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int) $customer_id . "'");
        $customer = smn_db_fetch_array($customer_query);
        $wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
    } else {
        $wwo_full_name = 'Guest';
    }
    $wo_session_id = smn_session_id();
    $wo_ip_address = getenv('REMOTE_ADDR');
    $wo_last_page_url = getenv('REQUEST_URI');
    $current_time = time();
    $xx_mins_ago = $current_time - 900;
    // remove entries that have expired
    smn_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");
    $stored_customer_query = smn_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . smn_db_input($wo_session_id) . "'");
    $stored_customer = smn_db_fetch_array($stored_customer_query);
    if ($stored_customer['count'] > 0) {
        smn_db_query("update " . TABLE_WHOS_ONLINE . " set customer_id = '" . (int) $wo_customer_id . "', full_name = '" . smn_db_input($wo_full_name) . "', ip_address = '" . smn_db_input($wo_ip_address) . "', time_last_click = '" . smn_db_input($current_time) . "', last_page_url = '" . smn_db_input($wo_last_page_url) . "' where session_id = '" . smn_db_input($wo_session_id) . "'");
    } else {
        smn_db_query("insert into " . TABLE_WHOS_ONLINE . " (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url) values ('" . (int) $wo_customer_id . "', '" . smn_db_input($wo_full_name) . "', '" . smn_db_input($wo_session_id) . "', '" . smn_db_input($wo_ip_address) . "', '" . smn_db_input($current_time) . "', '" . smn_db_input($current_time) . "', '" . smn_db_input($wo_last_page_url) . "')");
    }
}
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 smn_get_category_description($category_id, $language_id)
{
    global $store_id;
    $category_query = smn_db_query("select categories_description from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $category_id . "' and language_id = '" . $language_id . "' and store_id = '" . $store_id . "'");
    $category = smn_db_fetch_array($category_query);
    return $category['categories_description'];
}
function smn_get_header_tag_products_desc($product_id)
{
    global $languages_id, $_GET;
    $product_header_tags = smn_db_query("select products_head_desc_tag from " . TABLE_PRODUCTS_DESCRIPTION . " where language_id = '" . (int) $languages_id . "' and products_id = '" . (int) $_GET['products_id'] . "'");
    $product_header_tags_values = smn_db_fetch_array($product_header_tags);
    return $product_header_tags_values['products_head_desc_tag'];
}
 function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows)
 {
     if (empty($current_page_number)) {
         $current_page_number = 1;
     }
     if (!isset($query_num_rows)) {
         $pos_to = strlen($sql_query);
         $pos_from = strpos($sql_query, ' from', 0);
         $pos_group_by = strpos($sql_query, ' group by', $pos_from);
         if ($pos_group_by < $pos_to && $pos_group_by != false) {
             $pos_to = $pos_group_by;
         }
         $pos_having = strpos($sql_query, ' having', $pos_from);
         if ($pos_having < $pos_to && $pos_having != false) {
             $pos_to = $pos_having;
         }
         $pos_order_by = strpos($sql_query, ' order by', $pos_from);
         if ($pos_order_by < $pos_to && $pos_order_by != false) {
             $pos_to = $pos_order_by;
         }
         $reviews_count_query = smn_db_query("select count(*) as total " . substr($sql_query, $pos_from, $pos_to - $pos_from));
         $reviews_count = smn_db_fetch_array($reviews_count_query);
         $query_num_rows = $reviews_count['total'];
     }
     $num_pages = ceil($query_num_rows / $max_rows_per_page);
     if ($current_page_number > $num_pages) {
         $current_page_number = $num_pages;
     }
     $offset = max($max_rows_per_page * ($current_page_number - 1), 0);
     // systemsmanager begin - Dec 1, 2005 security patch
     //      $sql_query .= " limit " . $offset . ", " . $max_rows_per_page;
     $sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page;
     // systemsmanager end
 }
Beispiel #6
0
 function query($order_id)
 {
     global $store_id;
     $order_query = smn_db_query("select customers_name, customers_company, customers_street_address, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where store_id = '" . $store_id . "' and orders_id = '" . (int) $order_id . "'");
     $order = smn_db_fetch_array($order_query);
     $totals_query = smn_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int) $order_id . "' order by sort_order");
     while ($totals = smn_db_fetch_array($totals_query)) {
         $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text']);
     }
     $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order['orders_status'], 'last_modified' => $order['last_modified']);
     $this->customer = array('name' => $order['customers_name'], 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address']);
     $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']);
     $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], 'street_address' => $order['billing_street_address'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']);
     $index = 0;
     $orders_products_query = smn_db_query("select orders_products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int) $order_id . "'");
     while ($orders_products = smn_db_fetch_array($orders_products_query)) {
         $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'final_price' => $orders_products['final_price']);
         $subindex = 0;
         $attributes_query = smn_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int) $order_id . "' and orders_products_id = '" . (int) $orders_products['orders_products_id'] . "'");
         if (smn_db_num_rows($attributes_query)) {
             while ($attributes = smn_db_fetch_array($attributes_query)) {
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']);
                 $subindex++;
             }
         }
         $index++;
     }
 }
function getConfigValue($gID, $cID)
{
    global $filter;
    $configuration_query = smn_db_query("select configuration_value, use_function from " . TABLE_CONFIGURATION . " where configuration_id = '" . $cID . "' and configuration_group_id = '" . (int) $gID . "'" . $filter . " order by sort_order");
    $configuration = smn_db_fetch_array($configuration_query);
    if (smn_not_null($configuration['use_function'])) {
        $use_function = $configuration['use_function'];
        if (ereg('->', $use_function)) {
            $class_method = explode('->', $use_function);
            if (!is_object(${$class_method[0]})) {
                include DIR_WS_CLASSES . $class_method[0] . '.php';
                ${$class_method[0]} = new $class_method[0]();
            }
            $cfgValue = smn_call_function($class_method[1], $configuration['configuration_value'], ${$class_method[0]});
        } else {
            $cfgValue = smn_call_function($use_function, $configuration['configuration_value']);
        }
    } else {
        $cfgValue = $configuration['configuration_value'];
    }
    if (empty($cfgValue) && !is_numeric($cfgValue)) {
        $cfgValue = '&nbsp;';
    }
    return $cfgValue;
}
 function currencies()
 {
     $this->currencies = array();
     $currencies_query = smn_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES);
     while ($currencies = smn_db_fetch_array($currencies_query)) {
         $this->currencies[$currencies['code']] = array('title' => $currencies['title'], 'symbol_left' => $currencies['symbol_left'], 'symbol_right' => $currencies['symbol_right'], 'decimal_point' => $currencies['decimal_point'], 'thousands_point' => $currencies['thousands_point'], 'decimal_places' => $currencies['decimal_places'], 'value' => $currencies['value']);
     }
 }
function smn_delete_store($prefix)
{
    global $languages;
    if ($prefix != '') {
        $DB_tables = array(TABLE_ADMIN, TABLE_CATEGORIES, TABLE_CATEGORIES_DESCRIPTION, TABLE_CONFIGURATION, TABLE_LANGUAGES, TABLE_NEWSLETTERS, TABLE_ORDERS_TRACKING, TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD, TABLE_PRODUCTS_NOTIFICATIONS, TABLE_PRODUCTS_OPTIONS, TABLE_PRODUCTS_OPTIONS_VALUES, TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS, TABLE_REVIEWS, TABLE_REVIEWS_DESCRIPTION, TABLE_TAX_CLASS, TABLE_TAX_RATES, TABLE_GEO_ZONES, TABLE_ZONES_TO_GEO_ZONES, TABLE_ARTICLES, TABLE_WEB_SITE_CONTENT, TABLE_DYNAMIC_PAGE_INDEX, TABLE_SPECIALS, TABLE_STORE_MAIN, TABLE_STORE_COSTS, TABLE_STORE_TO_CATEGORIES, TABLE_STORE_DESCRIPTION, TABLE_STORE_REVIEWS, TABLE_MEMBER_ORDERS);
        //delete all DB table rows associated with the store....
        foreach ($DB_tables as $table_name) {
            smn_db_query("delete from " . $table_name . " WHERE store_id = '" . $prefix . "'");
        }
        //remove products from system
        $product_categories_query = smn_db_query("select products_id from " . TABLE_PRODUCTS . " where store_id = '" . (int) $prefix . "'");
        while ($product_categories = smn_db_fetch_array($product_categories_query)) {
            $product_id = (int) $product_categories['products_id'];
            smn_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $product_id . "'");
            smn_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            smn_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            $product_reviews_query = smn_db_query("select reviews_id from " . TABLE_REVIEWS . " where products_id = '" . $product_id . "'");
            while ($product_reviews = smn_db_fetch_array($product_reviews_query)) {
                smn_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . $product_reviews['reviews_id'] . "' and store_id = '" . (int) $prefix . "'");
            }
            smn_db_query("delete from " . TABLE_REVIEWS . " where products_id = '" . $product_id . "' and store_id = '" . (int) $prefix . "'");
            if (USE_CACHE == 'true') {
                smn_reset_cache_block('categories');
                smn_reset_cache_block('also_purchased');
            }
        }
        //remove orders from system
        $store_orders_query = smn_db_query("select orders_id from " . TABLE_ORDERS . " where store_id = '" . (int) $prefix . "'");
        while ($store_orders = smn_db_fetch_array($store_orders_query)) {
            smn_db_query("delete from " . TABLE_ORDERS_TRACKING . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_STATUS_HISTORY . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
            smn_db_query("delete from " . TABLE_ORDERS_TOTAL . " WHERE orders_id = '" . (int) $store_orders['orders_id'] . "'");
        }
        //delete the stores image directory and files from the system
        $dir = DIR_FS_CATALOG . 'images/' . $prefix . '_images';
        smn_deldir($dir);
        /*
            //delete any saved orders in the DB tables associated with this store		
           $saved_store_order_query = smn_db_query("select saved_order_id from " . TABLE_SAVED_ORDERS . " WHERE saved_store_id = '". $prefix_id ."'");
           if (smn_db_num_rows($store_query)){	
              while ($saved_store_order = smn_db_fetch_array($saved_store_order_query)){
                 smn_db_query("delete from " . TABLE_SAVED_ORDERS_PRODUCTS . " where saved_order_id = '" . $saved_store_order['saved_order_id'] . "'");
                 smn_db_query("delete from " . TABLE_SAVED_ORDERS_PRODUCTS_ATTRIBUTES . " where saved_order_id = '" . $saved_store_order['saved_order_id'] . "'");
              }
                  
              smn_db_query("delete from " . TABLE_SAVED_ORDERS . " where saved_store_id = '". $prefix_id ."'");
           }*/
    }
    return $store_deleted = 'true';
}
Beispiel #10
0
function smn_expire_specials()
{
    $specials_query = smn_db_query("select specials_id from " . TABLE_SPECIALS . " where status = '1' and now() >= expires_date and expires_date > 0");
    if (smn_db_num_rows($specials_query)) {
        while ($specials = smn_db_fetch_array($specials_query)) {
            smn_set_specials_status($specials['specials_id'], '0');
        }
    }
}
 function template_setup()
 {
     // set the template and theme parameters (can be modified through the administration interface)
     if (ALLOW_STORE_TEMPLATE == 'true') {
         $template_query = smn_db_query("select thema as themeKey, template_name as templateValue from " . TABLE_TEMPLATE . " where template_id = '" . TEMPLATE_ID . "'");
     } else {
         $template_query = smn_db_query("select thema as themeKey, template_name as templateValue from " . TABLE_TEMPLATE . " where template_id = '" . DEFAULT_TEMPLATE_ID . "'");
     }
     $this->template = smn_db_fetch_array($template_query);
 }
 function remove()
 {
     global $store_id;
     $keys = '';
     $keys_array = $this->keys();
     for ($i = 0; $i < sizeof($keys_array); $i++) {
         $keys .= "'" . $keys_array[$i] . "',";
     }
     $keys = substr($keys, 0, -1);
     smn_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ") and store_id = '" . $store_id . "'");
 }
 function paymentModuleInfo($pmInfo_array)
 {
     $this->payment_code = $pmInfo_array['payment_code'];
     for ($i = 0, $n = sizeof($pmInfo_array) - 1; $i < $n; $i++) {
         $key_value_query = smn_db_query("select configuration_title, configuration_value, configuration_description from " . TABLE_CONFIGURATION . " where configuration_key = '" . $pmInfo_array[$i] . "'");
         $key_value = smn_db_fetch_array($key_value_query);
         $this->keys[$pmInfo_array[$i]]['title'] = $key_value['configuration_title'];
         $this->keys[$pmInfo_array[$i]]['value'] = $key_value['configuration_value'];
         $this->keys[$pmInfo_array[$i]]['description'] = $key_value['configuration_description'];
     }
 }
 function send($newsletter_id)
 {
     $mail_query = smn_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
     $mimemessage = new email(array('X-Mailer: oscMall bulk mailer'));
     $mimemessage->add_html($this->content);
     $mimemessage->build_message();
     while ($mail = smn_db_fetch_array($mail_query)) {
         $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
     }
     $newsletter_id = smn_db_prepare_input($newsletter_id);
     smn_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . smn_db_input($newsletter_id) . "'");
 }
Beispiel #15
0
function smn_get_languages_directory($code)
{
    global $languages_id;
    $language_query = smn_db_query("select languages_id, directory from " . TABLE_LANGUAGES . " where code = '" . smn_db_input($code) . "'");
    if (smn_db_num_rows($language_query)) {
        $language = smn_db_fetch_array($language_query);
        $languages_id = $language['languages_id'];
        return $language['directory'];
    } else {
        return false;
    }
}
function smn_get_affiliate_tax_rate($class_id, $country_id, $zone_id)
{
    $tax_query = smn_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za ON tr.tax_zone_id = za.geo_zone_id left join " . TABLE_GEO_ZONES . " tz ON tz.geo_zone_id = tr.tax_zone_id WHERE (za.zone_country_id IS NULL OR za.zone_country_id = '0' OR za.zone_country_id = '" . $country_id . "') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '" . $zone_id . "') AND tr.tax_class_id = '" . $class_id . "' GROUP BY tr.tax_priority");
    if (smn_db_num_rows($tax_query)) {
        $tax_multiplier = 0;
        while ($tax = smn_db_fetch_array($tax_query)) {
            $tax_multiplier += $tax['tax_rate'];
        }
        return $tax_multiplier;
    } else {
        return 0;
    }
}
 function splitPageResults($query, $max_rows, $count_key = '*', $page_holder = 'page')
 {
     global $_GET, $_POST;
     $this->sql_query = $query;
     $this->page_name = $page_holder;
     if (isset($_GET[$page_holder])) {
         $page = $_GET[$page_holder];
     } elseif (isset($_POST[$page_holder])) {
         $page = $_POST[$page_holder];
     } else {
         $page = '';
     }
     if (empty($page) || !is_numeric($page)) {
         $page = 1;
     }
     $this->current_page_number = $page;
     $this->number_of_rows_per_page = $max_rows;
     $pos_to = strlen($this->sql_query);
     $pos_from = strpos($this->sql_query, ' from', 0);
     $pos_group_by = strpos($this->sql_query, ' group by', $pos_from);
     if ($pos_group_by < $pos_to && $pos_group_by != false) {
         $pos_to = $pos_group_by;
     }
     $pos_having = strpos($this->sql_query, ' having', $pos_from);
     if ($pos_having < $pos_to && $pos_having != false) {
         $pos_to = $pos_having;
     }
     $pos_order_by = strpos($this->sql_query, ' order by', $pos_from);
     if ($pos_order_by < $pos_to && $pos_order_by != false) {
         $pos_to = $pos_order_by;
     }
     if (strpos($this->sql_query, 'distinct') || strpos($this->sql_query, 'group by')) {
         $count_string = 'distinct ' . smn_db_input($count_key);
     } else {
         $count_string = smn_db_input($count_key);
     }
     $count_query = smn_db_query("select count(" . $count_string . ") as total " . substr($this->sql_query, $pos_from, $pos_to - $pos_from));
     $count = smn_db_fetch_array($count_query);
     $this->number_of_rows = $count['total'];
     $this->number_of_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page);
     if ($this->current_page_number > $this->number_of_pages) {
         $this->current_page_number = $this->number_of_pages;
     }
     $offset = max($this->number_of_rows_per_page * ($this->current_page_number - 1), 0);
     // systemsmanager begin - Dec 1, 2005 security patch
     //      $this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;
     $this->sql_query .= " limit " . max($offset, 0) . ", " . $this->number_of_rows_per_page;
     // systemsmanager end
 }
Beispiel #18
0
 function payment($module = '')
 {
     global $payment, $language, $PHP_SELF, $store_id, $cart;
     if (defined('MODULE_PAYMENT_INSTALLED') && smn_not_null(MODULE_PAYMENT_INSTALLED)) {
         $this->modules = explode(';', MODULE_PAYMENT_INSTALLED);
         $include_modules = array();
         $prepare_module_string = str_replace('.php', '', MODULE_PAYMENT_INSTALLED);
         $initial_module_string = str_replace(";", "' or page_name= '", $prepare_module_string);
         $text_contents_conditions = " and page_name= '" . $initial_module_string . "'";
         $content_query = smn_db_query("select text_key, text_content from " . TABLE_WEB_SITE_CONTENT . " where store_id = '" . $store_id . "' " . $text_contents_conditions);
         while ($text_contents = smn_db_fetch_array($content_query)) {
             define($text_contents['text_key'], $text_contents['text_content']);
         }
         if (smn_not_null($module) && in_array($module . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1), $this->modules)) {
             $this->selected_module = $module;
             $include_modules[] = array('class' => $module, 'file' => $module . '.php');
             $text_contents_conditions = " and page_name= '" . $module . "'";
         } else {
             reset($this->modules);
             if (smn_get_configuration_key_value('MODULE_PAYMENT_FREECHARGER_STATUS') and ($cart->show_total() == 0 and $cart->show_weight == 0)) {
                 $this->selected_module = $module;
                 $include_modules[] = array('class' => 'freecharger', 'file' => 'freecharger.php');
             } else {
                 // All Other Payment Modules
                 while (list(, $value) = each($this->modules)) {
                     $class = substr($value, 0, strrpos($value, '.'));
                     // Don't show Free Payment Module
                     if ($class != 'freecharger') {
                         $include_modules[] = array('class' => $class, 'file' => $value);
                     }
                 }
             }
         }
         for ($i = 0, $n = sizeof($include_modules); $i < $n; $i++) {
             include DIR_WS_MODULES . 'payment/' . $include_modules[$i]['file'];
             $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class']();
         }
         // if there is only one payment method, select it as default because in
         // checkout_confirmation.php the $payment variable is being assigned the
         // $_POST['payment'] value which will be empty (no radio button selection possible)
         if (smn_count_payment_modules() == 1 && (!isset($GLOBALS[$payment]) || isset($GLOBALS[$payment]) && !is_object($GLOBALS[$payment]))) {
             $payment = $include_modules[0]['class'];
         }
         if (smn_not_null($module) && in_array($module, $this->modules) && isset($GLOBALS[$module]->form_action_url)) {
             $this->form_action_url = $GLOBALS[$module]->form_action_url;
         }
     }
 }
Beispiel #19
0
function get_db_cache($sql, &$var, $filename, $refresh = false)
{
    $var = array();
    // check for the refresh flag and try to the data
    if ($refresh == true || !read_cache($var, $filename)) {
        // Didn' get cache so go to the database.
        //      $conn = mysql_connect("localhost", "apachecon", "apachecon");
        $res = smn_db_query($sql);
        //      if ($err = mysql_error()) trigger_error($err, E_USER_ERROR);
        // loop through the results and add them to an array
        while ($rec = smn_db_fetch_array($res)) {
            $var[] = $rec;
        }
        // write the data to the file
        write_cache($var, $filename);
    }
}
Beispiel #20
0
 function language($lng = '')
 {
     global $store_id;
     $this->languages = array('ar' => 'ar([-_][[:alpha:]]{2})?|arabic', 'bg' => 'bg|bulgarian', 'br' => 'pt[-_]br|brazilian portuguese', 'ca' => 'ca|catalan', 'cs' => 'cs|czech', 'da' => 'da|danish', 'de' => 'de([-_][[:alpha:]]{2})?|german', 'el' => 'el|greek', 'en' => 'en([-_][[:alpha:]]{2})?|english', 'es' => 'es([-_][[:alpha:]]{2})?|spanish', 'et' => 'et|estonian', 'fi' => 'fi|finnish', 'fr' => 'fr([-_][[:alpha:]]{2})?|french', 'gl' => 'gl|galician', 'he' => 'he|hebrew', 'hu' => 'hu|hungarian', 'id' => 'id|indonesian', 'it' => 'it|italian', 'ja' => 'ja|japanese', 'ko' => 'ko|korean', 'ka' => 'ka|georgian', 'lt' => 'lt|lithuanian', 'lv' => 'lv|latvian', 'nl' => 'nl([-_][[:alpha:]]{2})?|dutch', 'no' => 'no|norwegian', 'pl' => 'pl|polish', 'pt' => 'pt([-_][[:alpha:]]{2})?|portuguese', 'ro' => 'ro|romanian', 'ru' => 'ru|russian', 'sk' => 'sk|slovak', 'sr' => 'sr|serbian', 'sv' => 'sv|swedish', 'th' => 'th|thai', 'tr' => 'tr|turkish', 'uk' => 'uk|ukrainian', 'tw' => 'zh[-_]tw|chinese traditional', 'zh' => 'zh|chinese simplified');
     $this->catalog_languages = array();
     if (ALLOW_STORE_SITE_TEXT == 'true') {
         $use_store_id = $store_id;
     } else {
         $use_store_id = 1;
     }
     $languages_query = smn_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " where store_id = '" . $use_store_id . "' order by sort_order");
     while ($languages = smn_db_fetch_array($languages_query)) {
         $this->catalog_languages[$languages['code']] = array('id' => $languages['languages_id'], 'name' => $languages['name'], 'image' => $languages['image'], 'directory' => $languages['directory']);
     }
     $this->browser_languages = '';
     $this->language = '';
     $this->set_language($lng);
 }
Beispiel #21
0
function smn_language_list()
{
    $left = false;
    $smn_language_list_array[] = array('id' => '', 'text' => TEXT_NONE);
    $language_query = smn_db_query("select name from " . TABLE_LANGUAGES . " order by sort_order");
    while ($languages = smn_db_fetch_array($language_query)) {
        $language_array[] = $languages['name'];
    }
    if ($dir = dir(DIR_FS_CATALOG_LANGUAGES . 'install')) {
        while ($file = $dir->read()) {
            if ($file != '.' && $file != '..' && !is_dir($file)) {
                $list_file = explode('_', $file);
                if (!in_array($list_file[0], $language_array)) {
                    $smn_language_list_array[] = array('id' => $list_file[0], 'text' => $list_file[0]);
                }
            }
        }
    }
    $dir->close();
    return $smn_language_list_array;
}
Beispiel #22
0
 function shipping($module = '')
 {
     global $language, $PHP_SELF, $store_id, $cart;
     if (defined('MODULE_SHIPPING_INSTALLED') && smn_not_null(MODULE_SHIPPING_INSTALLED)) {
         $this->modules = explode(';', MODULE_SHIPPING_INSTALLED);
         $prepare_module_string = str_replace('.php', '', MODULE_SHIPPING_INSTALLED);
         $initial_module_string = str_replace(";", "' or page_name= '", $prepare_module_string);
         $text_contents_conditions = " and page_name= '" . $initial_module_string . "'";
         $content_query = smn_db_query("select text_key, text_content from " . TABLE_WEB_SITE_CONTENT . " where store_id = '" . $store_id . "' " . $text_contents_conditions);
         while ($text_contents = smn_db_fetch_array($content_query)) {
             define($text_contents['text_key'], $text_contents['text_content']);
         }
         $include_modules = array();
         if (smn_not_null($module) && in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1), $this->modules)) {
             $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, strrpos($PHP_SELF, '.') + 1));
             $text_contents_conditions = " and page_name= '" . $module . "'";
         } else {
             reset($this->modules);
             if (smn_get_configuration_key_value('MODULE_SHIPPING_FREESHIPPER_STATUS') and $cart->show_weight() == 0) {
                 $include_modules[] = array('class' => 'freeshipper', 'file' => 'freeshipper.php');
             } else {
                 // All Other Shipping Modules
                 while (list(, $value) = each($this->modules)) {
                     $class = substr($value, 0, strrpos($value, '.'));
                     // Don't show Free Shipping Module
                     if ($class != 'freeshipper') {
                         $include_modules[] = array('class' => $class, 'file' => $value);
                     }
                 }
             }
         }
         for ($i = 0, $n = sizeof($include_modules); $i < $n; $i++) {
             include DIR_WS_MODULES . 'shipping/' . $include_modules[$i]['file'];
             $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class']();
         }
     }
 }
  
  This source file is subject to version 2.0 of the GPL license,   
  that is bundled with this package in the file LICENSE. If you
  did not receive a copy of the oscMall System license and are unable 
  to obtain it through the world-wide-web, please send a note to    
  license@systemsmanager.net so we can mail you a copy immediately.
*/
include DIR_WS_CLASSES . 'phplot.php';
$year = $_GET['year'] ? $_GET['year'] : date('Y');
$month = $_GET['month'] ? $_GET['month'] : date('n');
$days = date('t', mktime(0, 0, 0, $month)) + 1;
$stats = array();
for ($i = 1; $i < $days; $i++) {
    $stats[] = array($i, '0', '0');
}
$banner_stats_query = smn_db_query("select dayofmonth(banners_history_date) as banner_day, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and month(banners_history_date) = '" . $month . "' and year(banners_history_date) = '" . $year . "'");
while ($banner_stats = smn_db_fetch_array($banner_stats_query)) {
    $stats[$banner_stats['banner_day'] - 1] = array($banner_stats['banner_day'], $banner_stats['value'] ? $banner_stats['value'] : '0', $banner_stats['dvalue'] ? $banner_stats['dvalue'] : '0');
}
$graph = new PHPlot(600, 350, 'images/graphs/banner_daily-' . $banner_id . '.' . $banner_extension);
$graph->SetFileFormat($banner_extension);
$graph->SetIsInline(1);
$graph->SetPrintImage(0);
$graph->SetSkipBottomTick(1);
$graph->SetDrawYGrid(1);
$graph->SetPrecisionY(0);
$graph->SetPlotType('lines');
$graph->SetPlotBorderType('left');
$graph->SetTitleFontSize('4');
$graph->SetTitle(sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0, 0, 0, $month)), $year));
$graph->SetBackgroundColor('white');
      <input type="hidden" name="page_name" value="<?php 
        echo $_GET['page_name'];
        ?>
">
      <input type="hidden" name="text_key" value="<?php 
        echo $_GET['text_key'];
        ?>
">
<?php 
    }
    $languages = smn_get_languages();
    for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
        if ($page_id) {
            $text_query_raw = smn_db_query("select * from " . TABLE_ARTICLES . " where  page_id= '" . $_GET['page_id'] . "' and language_id = '" . $languages[$i]['id'] . "' and store_id = '" . $store_id . "'");
        } else {
            $text_query_raw = smn_db_query("select * from " . $db_table . " where  text_key = '" . $_GET['text_key'] . "' and page_name='" . $_GET['page_name'] . "' and language_id = '" . $languages[$i]['id'] . "' and store_id = '" . $store_id . "'");
        }
        $language_list_query = smn_db_fetch_array($text_query_raw);
        if ($page_id) {
            ?>
          <tr>
            <td class="main"><?php 
            echo TEXT_CURRENT_TEXT;
            ?>
</td>
          </tr>
           <tr>
            <td class="main"><?php 
            echo $text_list_query['page_title'];
            ?>
</td>
               }';
            exit;
            break;
        case 'uninstallModule':
            $moduleInfo = new store_modules($moduleType, $moduleName);
            $moduleInfo->uninstallModule($moduleName);
            echo '{ success: true }';
            exit;
            break;
        case 'saveModuleSettings':
            while (list($key, $value) = each($_POST['configuration'])) {
                if (is_array($value)) {
                    $value = implode(", ", $value);
                    $value = ereg_replace(", --none--", "", $value);
                }
                smn_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "' and store_id = '" . $customer_store_id . "'");
            }
            $moduleInfo = new store_modules($moduleType, $moduleName);
            $module = $moduleInfo->moduleClass($moduleName);
            echo '{
                   success: true,
                   title: "' . addslashes($module->title) . '",
                   code: "' . $module->code . '",
                   sort_order: "' . $module->sort_order . '",
                   status: "' . ($module->enabled ? 'true' : 'false') . '"
               }';
            exit;
            break;
    }
}
/* Common Elements For Tabs - BEGIN */
         if ($check['total'] < '1') {
           smn_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (store_id, products_id, categories_id) values ('" . (int)$store_id . "', '" . (int)$products_id . "', '" . (int)$categories_id . "')");
         }
       } else {
         $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
       }
     } elseif ($_POST['copy_as'] == 'duplicate') {
       $product_query = smn_db_query("select store_id, products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
       $product = smn_db_fetch_array($product_query);
       smn_db_query("insert into " . TABLE_PRODUCTS . " (store_id, products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . (int)$store_id . "', '" . smn_db_input($product['products_quantity']) . "', '" . smn_db_input($product['products_model']) . "', '" . smn_db_input($product['products_image']) . "', '" . smn_db_input($product['products_price']) . "',  now(), '" . smn_db_input($product['products_date_available']) . "', '" . smn_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");
       $dup_products_id = smn_db_insert_id();
       $description_query = smn_db_query("select language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
       while ($description = smn_db_fetch_array($description_query)) {
         smn_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . smn_db_input($description['products_name']) . "', '" . smn_db_input($description['products_description']) . "', '" . smn_db_input($description['products_head_title_tag']) . "', '" . smn_db_input($description['products_head_desc_tag']) . "', '" . smn_db_input($description['products_head_keywords_tag']) . "', '" . smn_db_input($description['products_url']) . "', '0')");
       }    
       smn_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (store_id, products_id, categories_id) values ('" . (int)$store_id . "', '" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
       $products_id = $dup_products_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=' . $categories_id . '&ID='.$store_id.'&pID=' . $products_id)));
   break;
 case 'new_product_preview':
     if (! checkVoucherPermissions($store_id, $_POST['products_model'])) {
       $messageStack->add(ERROR_VENDORS_CANT_ADD_VOUCHERS, 'error');
       $allow_insert = 'false';
     } else {
       // copy image only if modified
<?php

/*
  Copyright (c) 2002 - 2006 SystemsManager.Net

  SystemsManager Technologies
  oscMall System Version 4
  http://www.systemsmanager.net
  
  Portions Copyright (c) 2002 osCommerce
  
  This source file is subject to version 2.0 of the GPL license,   
  that is bundled with this package in the file LICENSE. If you
  did not receive a copy of the oscMall System license and are unable 
  to obtain it through the world-wide-web, please send a note to    
  license@systemsmanager.net so we can mail you a copy immediately.
*/
global $page_name;
if (!smn_session_is_registered('affiliate_id')) {
    $navigation->set_snapshot();
    smn_redirect(smn_href_link(FILENAME_AFFILIATE, '', 'NONSSL'));
}
$breadcrumb->add(NAVBAR_TITLE, smn_href_link(FILENAME_AFFILIATE_CLICKS, '', 'NONSSL'));
$affiliate_clickthroughs_raw = "\n    select a.*, pd.products_name from " . TABLE_AFFILIATE_CLICKTHROUGHS . " a \n    left join " . TABLE_PRODUCTS . " p on (p.products_id = a.affiliate_products_id) \n    left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on (pd.products_id = p.products_id and pd.language_id = '" . $languages_id . "') \n    where a.affiliate_id = '" . $affiliate_id . "'  ORDER BY a.affiliate_clientdate desc\n    ";
$affiliate_clickthroughs_split = new splitPageResults($affiliate_clickthroughs_raw, MAX_DISPLAY_SEARCH_RESULTS);
$affiliate_clickthroughs_numrows_raw = "select count(*) as count from " . TABLE_AFFILIATE_CLICKTHROUGHS . " where affiliate_id = '" . $affiliate_id . "'";
$affiliate_clickthroughs_query = smn_db_query($affiliate_clickthroughs_numrows_raw);
$affiliate_clickthroughs_numrows = smn_db_fetch_array($affiliate_clickthroughs_query);
$affiliate_clickthroughs_numrows = $affiliate_clickthroughs_numrows['count'];
?>
 
        echo '{
              success: false,
              errors: {
                   message: "' . addslashes(str_replace("\n", '', nl2br($messageStack->outputPlain('account_edit')))) . '"
              }
             }';
    }
    exit;
}
$account_query = smn_db_query("select c.*, ab.* from " . TABLE_CUSTOMERS . " c,  " . TABLE_ADDRESS_BOOK . " ab  where ab.customers_id = '" . (int) $customer_id . "' and c.customers_id = '" . (int) $customer_id . "' and ab.address_book_id = c.customers_default_address_id");
$account = smn_db_fetch_array($account_query);
$breadcrumb->add(NAVBAR_TITLE_1, smn_href_link(FILENAME_ACCOUNT, 'ID=' . $store_id, 'NONSSL'));
$breadcrumb->add(NAVBAR_TITLE_2, smn_href_link(FILENAME_ACCOUNT_EDIT, 'ID=' . $store_id, 'NONSSL'));
$store_categories = $spath_setup->smn_get_store_category_tree('0', '', '0');
$countries = smn_get_countries();
$Qzone = smn_db_query('select zone_name from ' . TABLE_ZONES . ' where (zone_code = "' . strtoupper($customerInfo->address_data['entry_state']) . '" || zone_name = "' . $customerInfo->address_data['entry_state'] . '")');
if (smn_db_num_rows($Qzone)) {
    $zone = smn_db_fetch_array($Qzone);
    $customerInfo->address_data['entry_state'] = $zone['zone_name'];
}
/* Common Elements For Tabs - BEGIN */
$commonCancelButton = $jQuery->getPluginClass('button', array('id' => 'cancel_button', 'text' => 'Cancel'));
$commonDeleteButton = $jQuery->getPluginClass('button', array('id' => 'delete_button', 'text' => 'Delete'));
$commonSaveButton = $jQuery->getPluginClass('button', array('id' => 'save_button', 'type' => 'submit', 'text' => 'Save'));
/* Common Elements For Tabs - END */
/* Setup Tabs - BEGIN */
$jQuery->setGlobalVars(array('languages', 'languages_id', 'store_id', 'commonSaveButton', 'commonDeleteButton', 'commonCancelButton', 'account', 'customerInfo', 'customer_store_id', 'affiliate_id', 'customersStore', 'store_categories', 'countries'));
$tabsArray = array();
$tabsArray[] = array('tabID' => 'tab-contact', 'filename' => 'tab_contact.php', 'text' => ACCOUNT_TAB_CONTACT);
$tabsArray[] = array('tabID' => 'tab-personal', 'filename' => 'tab_personal.php', 'text' => ACCOUNT_TAB_PERSONAL);
if (smn_session_is_registered('customer_store_id')) {
<?php

/*
  Copyright (c) 2002 - 2005 SystemsManager.Net

  SystemsManager Technologies
  oscMall System Version 4
  http://www.systemsmanager.net
  
  Portions Copyright (c) 2002 osCommerce
  
  This source file is subject to version 2.0 of the GPL license,   
  that is bundled with this package in the file LICENSE. If you
  did not receive a copy of the oscMall System license and are unable 
  to obtain it through the world-wide-web, please send a note to    
  license@systemsmanager.net so we can mail you a copy immediately.
*/
$xx_mins_ago = time() - 900;
require 'includes/application_top.php';
require DIR_WS_CLASSES . 'currencies.php';
$currencies = new currencies();
// remove entries that have expired
smn_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");
$content_page = basename($_SERVER['PHP_SELF']);
require 'templates/default/layout.php';
require DIR_WS_INCLUDES . 'application_bottom.php';
                <td class="main" width="50%" valign="top"><?php 
        echo TEXT_SELECT_OTHER_SHIPPING_DESTINATION;
        ?>
</td>
                <td class="main" width="50%" valign="top" align="right"><?php 
        echo '<b>' . TITLE_PLEASE_SELECT . '</b><br>' . smn_image(DIR_WS_IMAGES . 'arrow_east_south.gif');
        ?>
</td>
                <td><?php 
        echo smn_draw_separator('pixel_trans.gif', '10', '1');
        ?>
</td>
              </tr>
<?php 
        $radio_buttons = 0;
        $addresses_query = smn_db_query("select address_book_id, entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $customer_id . "'");
        while ($addresses = smn_db_fetch_array($addresses_query)) {
            $format_id = smn_get_address_format_id($addresses['country_id']);
            ?>
              <tr>
                <td><?php 
            echo smn_draw_separator('pixel_trans.gif', '10', '1');
            ?>
</td>
                <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php 
            if ($addresses['address_book_id'] == $sendto) {
                echo '                  <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
            } else {
                echo '                  <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";
            }