/** * Remove all info about requirements of this CIP */ function do_remove() { foreach ($this->req as $id => $require) { $query = 'delete from ' . TABLE_CIP_DEPEND . ' where cip_ident = "' . $this->cip->getIdent() . '" and cip_ident_req= "' . $require . '" and cip_req_type=1'; vam_db_query($query); } }
function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows) { if (empty($current_page_number)) { $current_page_number = 1; } $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 = vam_db_query("select count(*) as total " . substr($sql_query, $pos_from, $pos_to - $pos_from)); $reviews_count = vam_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_rows_per_page * ($current_page_number - 1); if ($offset < 0) { $offset = 0; } $sql_query .= " limit " . $offset . ", " . $max_rows_per_page; }
function updateBill($login, $password, $txn, $status) { //обработка возможных ошибок авторизации if ($login != MODULE_PAYMENT_QIWI_ID) { return 150; } if (!empty($password) && $password != strtoupper(md5($txn . strtoupper(md5(MODULE_PAYMENT_QIWI_SECRET_KEY))))) { return 150; } // получаем номер заказа $transaction = intval($txn); // проверяем, есть ли такой заказ в базе $order_query = vam_db_query("select count(*) as total from " . TABLE_ORDERS . " where orders_id = '" . (int) $transaction . "'"); $order_exists = vam_db_fetch_array($order_query); if ($order_exists['total'] <= 0) { return 210; } // меняем статус заказа при условии оплаты счёта if ($status == 60) { $sql_data_array = array('orders_status' => MODULE_PAYMENT_QIWI_ORDER_STATUS_ID); vam_db_perform('orders', $sql_data_array, 'update', "orders_id='" . $transaction . "'"); $sql_data_arrax = array('orders_id' => $transaction, 'orders_status_id' => MODULE_PAYMENT_QIWI_ORDER_STATUS_ID, 'date_added' => 'now()', 'customer_notified' => '0', 'comments' => 'QIWI accepted this order payment'); vam_db_perform('orders_status_history', $sql_data_arrax); // Отправляем письмо клиенту и админу о смене статуса заказа require_once DIR_WS_CLASSES . 'order.php'; $order = new order($transaction); $vamTemplate = new vamTemplate(); // assign language to template for caching $vamTemplate->assign('language', $_SESSION['language']); $vamTemplate->caching = false; $vamTemplate->assign('tpl_path', 'templates/' . CURRENT_TEMPLATE . '/'); $vamTemplate->assign('logo_path', HTTP_SERVER . DIR_WS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/img/'); $vamTemplate->assign('NAME', $order->customer['firstname'] . ' ' . $order->customer['lastname']); $vamTemplate->assign('ORDER_NR', $transaction); $vamTemplate->assign('ORDER_LINK', vam_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $transaction, 'SSL')); $vamTemplate->assign('ORDER_DATE', vam_date_long($order->info['date_purchased'])); $lang_query = vam_db_query("select languages_id from " . TABLE_LANGUAGES . " where directory = '" . $_SESSION['language'] . "'"); $lang = vam_db_fetch_array($lang_query); $lang = $lang['languages_id']; if (!isset($lang)) { $lang = $_SESSION['languages_id']; } $orders_status_array = array(); $orders_status_query = vam_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . $lang . "'"); while ($orders_status = vam_db_fetch_array($orders_status_query)) { $orders_statuses[] = array('id' => $orders_status['orders_status_id'], 'text' => $orders_status['orders_status_name']); $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name']; } $vamTemplate->assign('ORDER_STATUS', $orders_status_array[MODULE_PAYMENT_QIWI_ORDER_STATUS_ID]); $html_mail = $vamTemplate->fetch(CURRENT_TEMPLATE . '/admin/mail/' . $_SESSION['language'] . '/change_order_mail.html'); $txt_mail = $vamTemplate->fetch(CURRENT_TEMPLATE . '/admin/mail/' . $_SESSION['language'] . '/change_order_mail.txt'); include_once DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/qiwi.php'; // create subject $order_subject = str_replace('{$nr}', $transaction, MODULE_PAYMENT_QIWI_EMAIL_SUBJECT); // send mail to admin vam_php_mail(EMAIL_BILLING_ADDRESS, EMAIL_BILLING_NAME, EMAIL_BILLING_ADDRESS, STORE_NAME, EMAIL_BILLING_FORWARDING_STRING, $order->customer['email_address'], $order->customer['firstname'], '', '', $order_subject, $html_mail, $txt_mail); // send mail to customer vam_php_mail(EMAIL_BILLING_ADDRESS, EMAIL_BILLING_NAME, $order->customer['email_address'], $order->customer['firstname'] . ' ' . $order->customer['lastname'], '', EMAIL_BILLING_REPLY_ADDRESS, EMAIL_BILLING_REPLY_ADDRESS_NAME, '', '', $order_subject, $html_mail, $txt_mail); } }
function vam_get_download($content_id) { $content_query = vam_db_query("SELECT\n\t\t\t\t\tcontent_file,\n\t\t\t\t\tcontent_read\n\t\t\t\t\tFROM " . TABLE_PRODUCTS_CONTENT . "\n\t\t\t\t\tWHERE content_id='" . $content_id . "'"); $content_data = vam_db_fetch_array($content_query); // update file counter vam_db_query("UPDATE \n\t\t\t" . TABLE_PRODUCTS_CONTENT . " \n\t\t\tSET content_read='" . ($content_data['content_read'] + 1) . "'\n\t\t\tWHERE content_id='" . $content_id . "'"); // original filename $filename = DIR_FS_CATALOG . 'media/products/' . $content_data['content_file']; $backup_filename = DIR_FS_CATALOG . 'media/products/backup/' . $content_data['content_file']; // create md5 hash id from original file $orign_hash_id = md5_file($filename); clearstatcache(); // create new filename with timestamp $timestamp = str_replace('.', '', microtime()); $timestamp = str_replace(' ', '', $timestamp); $new_filename = DIR_FS_CATALOG . 'media/products/' . $timestamp . strstr($content_data['content_file'], '.'); // rename file rename($filename, $new_filename); if (file_exists($new_filename)) { header("Content-type: application/force-download"); header("Content-Disposition: attachment; filename=" . $new_filename); @readfile($new_filename); // rename file to original name rename($new_filename, $filename); $new_hash_id = md5_file($filename); clearstatcache(); // check hash id of file again, if not same, get backup! if ($new_hash_id != $orign_hash_id) { copy($backup_filename, $filename); } } }
function vam_get_tax_title_class_id($tax_class_title) { $classes_query = vam_db_query("select tax_class_id from " . TABLE_TAX_CLASS . " WHERE tax_class_title = '" . $tax_class_title . "'"); $tax_class_array = vam_db_fetch_array($classes_query); $tax_class_id = $tax_class_array['tax_class_id']; return $tax_class_id; }
function vam_display_banner($action, $identifier) { if ($action == 'dynamic') { $banners_query = vam_db_query("select count(*) as count from " . TABLE_BANNERS . " where status = '1' and banners_group = '" . $identifier . "'"); $banners = vam_db_fetch_array($banners_query); if ($banners['count'] > 0) { $banner = vam_random_select("select banners_id, banners_title, banners_image, banners_html_text from " . TABLE_BANNERS . " where status = '1' and banners_group = '" . $identifier . "'"); } else { return '<b>VaM Shop ERROR! (vam_display_banner(' . $action . ', ' . $identifier . ') -> No banners with group \'' . $identifier . '\' found!</b>'; } } elseif ($action == 'static') { if (is_array($identifier)) { $banner = $identifier; } else { $banner_query = vam_db_query("select banners_id, banners_title, banners_image, banners_html_text from " . TABLE_BANNERS . " where status = '1' and banners_id = '" . $identifier . "'"); if (vam_db_num_rows($banner_query)) { $banner = vam_db_fetch_array($banner_query); } else { return '<b>VaM Shop ERROR! (vam_display_banner(' . $action . ', ' . $identifier . ') -> Banner with ID \'' . $identifier . '\' not found, or status inactive</b>'; } } } else { return '<b>VaM Shop ERROR! (vam_display_banner(' . $action . ', ' . $identifier . ') -> Unknown $action parameter value - it must be either \'dynamic\' or \'static\'</b>'; } if (vam_not_null($banner['banners_html_text'])) { $banner_string = $banner['banners_html_text']; } else { $banner_string = '<a href="' . vam_href_link(FILENAME_REDIRECT, 'action=banner&goto=' . $banner['banners_id']) . '" onclick="window.open(this.href); return false;">' . vam_image(DIR_WS_IMAGES . 'banner/' . $banner['banners_image'], $banner['banners_title']) . '</a>'; } vam_update_banner_display_count($banner['banners_id']); return $banner_string; }
function vam_get_products_stock($products_id) { $products_id = vam_get_prid($products_id); $stock_query = vam_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $stock_values = vam_db_fetch_array($stock_query); return $stock_values['products_quantity']; }
function vam_address_label($customers_id, $address_id = 1, $html = false, $boln = '', $eoln = "\n") { $address_query = vam_db_query("select entry_firstname as firstname, entry_secondname as secondname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, 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 = '" . $customers_id . "' and address_book_id = '" . $address_id . "'"); $address = vam_db_fetch_array($address_query); $format_id = vam_get_address_format_id($address['country_id']); return vam_address_format($format_id, $address, $html, $boln, $eoln); }
function affiliate_insert($sql_data_array, $affiliate_parent = 0) { // LOCK TABLES @mysql_query("LOCK TABLES " . TABLE_AFFILIATE . " WRITE"); if ($affiliate_parent > 0) { $affiliate_root_query = vam_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 = vam_db_fetch_array($affiliate_root_query)) { vam_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'] . " "); vam_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; vam_db_perform(TABLE_AFFILIATE, $sql_data_array); $affiliate_id = vam_db_insert_id(); } // no parent -> new root } else { $sql_data_array['affiliate_lft'] = '1'; $sql_data_array['affiliate_rgt'] = '2'; vam_db_perform(TABLE_AFFILIATE, $sql_data_array); $affiliate_id = vam_db_insert_id(); vam_db_query("update " . TABLE_AFFILIATE . " set affiliate_root = '" . $affiliate_id . "' where affiliate_id = '" . $affiliate_id . "' "); } // UNLOCK TABLES @mysql_query("UNLOCK TABLES"); return $affiliate_id; }
function vam_oe_customer_infos($customers_id) { $customer_query = vam_db_query("select a.entry_country_id, a.entry_zone_id from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " a where c.customers_id = '" . $customers_id . "' and c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id"); $customer = vam_db_fetch_array($customer_query); $customer_info_array = array('country_id' => $customer['entry_country_id'], 'zone_id' => $customer['entry_zone_id']); return $customer_info_array; }
function vam_get_customers_country($customers_id) { $customers_query = vam_db_query("select customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $customers_id . "'"); $customers = vam_db_fetch_array($customers_query); $address_book_query = vam_db_query("select entry_country_id from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . $customers['customers_default_address_id'] . "'"); $address_book = vam_db_fetch_array($address_book_query); return $address_book['entry_country_id']; }
function file_changers($file_path) { $result = vam_db_query("\n SELECT content_md5, modification_date, contrib\n FROM " . TABLE_CIP_FILE_INTEGRITY . "\n WHERE path_md5='" . md5($file_path) . "'\n ORDER BY modification_date"); while ($file_changer = vam_db_fetch_array($result)) { $array[] = array('path_md5' => $file_changer['path_md5'], 'content_md5' => $file_changer['content_md5'], 'modification_date' => $file_changer['modification_date'], 'contrib' => $file_changer['contrib']); } return $array; }
function currencies() { $this->currencies = array(); $currencies_query = vam_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES); while ($currencies = vam_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 get_price_range($current_category) { $sql = "SELECT MAX(p.products_price) max_price, MIN(p.products_price) min_price\n FROM " . TABLE_PRODUCTS . " p \n INNER JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ON p2c.products_id = p.products_id AND p2c.categories_id = " . $current_category . "\n WHERE p.products_status = '1'"; $res = vam_db_query($sql); $price_limit = vam_db_fetch_array($res); $result = "<script type='text/javascript'>\n\t\tvar min_price = " . $price_limit['min_price'] . ";\n\t\tvar max_price = " . $price_limit['max_price'] . ";\n </script>"; return $result; }
function vam_expire_specials() { $specials_query = vam_db_query("select specials_id from " . TABLE_SPECIALS . " where status = '1' and now() >= expires_date and expires_date > 0"); if (vam_db_num_rows($specials_query)) { while ($specials = vam_db_fetch_array($specials_query)) { vam_set_specials_status($specials['specials_id'], '0'); } } }
function vam_get_cross_sell_name($cross_sell_group, $language_id = '') { if (!$language_id) { $language_id = $_SESSION['languages_id']; } $cross_sell_query = vam_db_query("select groupname from " . TABLE_PRODUCTS_XSELL_GROUPS . " where products_xsell_grp_name_id = '" . $cross_sell_group . "' and language_id = '" . $language_id . "'"); $cross_sell = vam_db_fetch_array($cross_sell_query); return $cross_sell['groupname']; }
function vam_oe_get_options_values_name($products_options_values_id, $language = '') { if (empty($language)) { $language = $_SESSION['languages_id']; } $product_query = vam_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . $products_options_values_id . "' and language_id = '" . $language . "'"); $product = vam_db_fetch_array($product_query); return $product['products_options_values_name']; }
function vam_get_attributes_model($product_id, $attribute_name, $options_name, $language = '') { if ($language == '') { $language = $_SESSION['languages_id']; } $options_value_id_query = vam_db_query("SELECT\npa.attributes_model\nFROM\n" . TABLE_PRODUCTS_ATTRIBUTES . " pa\nInner Join " . TABLE_PRODUCTS_OPTIONS . " po ON po.products_options_id = pa.options_id\nInner Join " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov ON pa.options_values_id = pov.products_options_values_id\nWHERE\npo.language_id = '" . $language . "' AND\npo.products_options_name = '" . $options_name . "' AND\npov.language_id = '" . $language . "' AND\npa.products_id = '" . $product_id . "' AND \npov.products_options_values_name = '" . $attribute_name . "'"); $options_attr_data = vam_db_fetch_array($options_value_id_query); return $options_attr_data['attributes_model']; }
function vam_set_customer_status_upgrade($customer_id) { global $customer_notified; if ($_SESSION['customer_status_value']['customers_status_id'] == "' . DEFAULT_CUSTOMERS_STATUS_ID_NEWSLETTER .'" and $_SESSION['customer_status_value']['customers_is_newsletter'] == 0) { vam_db_query("update " . TABLE_CUSTOMERS . " set customers_status = '" . DEFAULT_CUSTOMERS_STATUS_ID . "' where customers_id = '" . $_SESSION['customer_id'] . "'"); vam_db_query("insert into " . TABLE_CUSTOMERS_STATUS_HISTORY . " (customers_id, new_value, old_value, date_added, customer_notified) values ('" . $_SESSION['customer_id'] . "', '" . DEFAULT_CUSTOMERS_STATUS_ID . "', '" . DEFAULT_CUSTOMERS_STATUS_ID_NEWSLETTER . "', now(), '" . $customer_notified . "')"); } return 1; }
function do_remove() { if ($_REQUEST['remove_data'] == '1') { if ($this->cip->is_ci()) { return $this->error; } vam_db_query("DELETE FROM " . TABLE_CONFIGURATION_GROUP . " WHERE configuration_group_key = '" . $this->data['key'] . "'"); } }
function vam_set_banner_status($banners_id, $status) { if ($status == '1') { return vam_db_query("update " . TABLE_BANNERS . " set status = '1', date_status_change = now(), date_scheduled = NULL where banners_id = '" . $banners_id . "'"); } elseif ($status == '0') { return vam_db_query("update " . TABLE_BANNERS . " set status = '0', date_status_change = now() where banners_id = '" . $banners_id . "'"); } else { return -1; } }
function db_query($blz) { $blz_query = vam_db_query("SELECT * from " . TABLE_BANKTRANSFER . " WHERE blz = '" . $blz . "'"); if (vam_db_num_rows($blz_query)) { $data = vam_db_fetch_array($blz_query); } else { $data = -1; } return $data; }
function vam_get_address_format_id($country_id) { $address_format_query = vam_db_query("select address_format_id as format_id from " . TABLE_COUNTRIES . " where countries_id = '" . $country_id . "'"); if (vam_db_num_rows($address_format_query)) { $address_format = vam_db_fetch_array($address_format_query); return $address_format['format_id']; } else { return '1'; } }
function vam_update_banner_display_count($banner_id) { $banner_check_query = vam_db_query("select count(*) as count from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and date_format(banners_history_date, '%Y%m%d') = date_format(now(), '%Y%m%d')"); $banner_check = vam_db_fetch_array($banner_check_query); if ($banner_check['count'] > 0) { vam_db_query("update " . TABLE_BANNERS_HISTORY . " set banners_shown = banners_shown + 1 where banners_id = '" . $banner_id . "' and date_format(banners_history_date, '%Y%m%d') = date_format(now(), '%Y%m%d')"); } else { vam_db_query("insert into " . TABLE_BANNERS_HISTORY . " (banners_id, banners_shown, banners_history_date) values ('" . $banner_id . "', 1, now())"); } }
function vam_get_zone_name($country_id, $zone_id, $default_zone) { $zone_query = vam_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . $country_id . "' and zone_id = '" . $zone_id . "'"); if (vam_db_num_rows($zone_query)) { $zone = vam_db_fetch_array($zone_query); return $zone['zone_name']; } else { return $default_zone; } }
/** * affiliate_get_status_array() * * @return array of available order status in current language **/ function affiliate_get_status_array() { $status_array = array(); $status_sql = "select orders_status_id, orders_status_name" . " FROM " . TABLE_ORDERS_STATUS . " WHERE language_id = " . $_SESSION['languages_id'] . " ORDER BY orders_status_id"; $status = vam_db_query($status_sql); while ($status_values = vam_db_fetch_array($status)) { $status_array[] = array('orders_status_id' => $status_values['orders_status_id'], 'orders_status_name' => $status_values['orders_status_name']); } return $status_array; }
function vam_get_spsr_zone_id($zone_id) { $spsr_zone_query = vam_db_query("select spsr_zone_id from " . TABLE_SPSR_ZONES . " where zone_id = '" . $zone_id . "'"); if (vam_db_num_rows($spsr_zone_query)) { $spsr_zone = vam_db_fetch_array($spsr_zone_query); $spsr_zone_id = $spsr_zone['spsr_zone_id']; return $spsr_zone_id; } else { return false; } }
function vam_get_languages_directory($code) { $language_query = vam_db_query("select languages_id, directory from " . TABLE_LANGUAGES . " where code = '" . $code . "'"); if (vam_db_num_rows($language_query)) { $lang = vam_db_fetch_array($language_query); $_SESSION['languages_id'] = $lang['languages_id']; return $lang['directory']; } else { return false; } }
function vam_check_stock_attributes($attribute_id, $products_quantity) { $stock_query = vam_db_query("SELECT\n attributes_stock\n FROM " . TABLE_PRODUCTS_ATTRIBUTES . "\n WHERE products_attributes_id='" . $attribute_id . "'"); $stock_data = vam_db_fetch_array($stock_query); $stock_left = $stock_data['attributes_stock'] - $products_quantity; $out_of_stock = ''; if ($stock_left < 0) { $out_of_stock = '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>'; } return $out_of_stock; }
function vam_banner_exists($action, $identifier) { if ($action == 'dynamic') { return vam_random_select("select banners_id, banners_title, banners_image, banners_html_text from " . TABLE_BANNERS . " where status = '1' and banners_group = '" . $identifier . "'"); } elseif ($action == 'static') { $banner_query = vam_db_query("select banners_id, banners_title, banners_image, banners_html_text from " . TABLE_BANNERS . " where status = '1' and banners_id = '" . $identifier . "'"); return vam_db_fetch_array($banner_query); } else { return false; } }