function cw_fbauth_user_login($user) { global $tables, $current_area; cw_load('crypt', 'user', 'mail'); $user_data = cw_query_first("SELECT customer_id, email, password\n\t\t\t\t\t\t\t\t\tFROM {$tables['customers']} \n\t\t\t\t\t\t\t\t\tWHERE oauth_uid='" . $user['id'] . "' AND oauth_type='F' \n\t\t\t\t\t\t\t\t\t\tAND usertype='" . $current_area . "' \n\t\t\t\t\t\t\t\t\t\tAND status='Y'"); if (!empty($user_data)) { // login user global $email, $password, $action; $email = $user_data['email']; $password = text_decrypt($user_data['password']); $action = 'login'; cw_include('include/login.php'); } else { // create user $register = array(); $register['email'] = $user['email']; if (strpos($user['email'], "proxymail.facebook.com") !== FALSE) { cw_header_location("index.php?target=fb_auth_get_email", TRUE); } $register['password'] = $register['password2'] = md5(uniqid('cw_', TRUE), TRUE); $register['usertype'] = $current_area; $partner_membership =& cw_session_register('partner_membership'); $register['membership_id'] = $partner_membership; $customer_id = cw_user_create_profile($register); $identifiers =& cw_session_register('identifiers', array()); $identifiers[$current_area] = array('customer_id' => $customer_id); $customer = array('oauth_uid' => $user['id']); cw_array2update('customers', $customer, "customer_id='{$customer_id}'"); $address = array('main' => 1, 'firstname' => $user['first_name'], 'lastname' => $user['last_name']); $additional_info = array('sex' => $user['gender'] == 'male' ? 1 : 0); $userinfo = array('addresses' => $address, 'additional_info' => $additional_info); cw_user_update($userinfo, $customer_id, $customer_id); cw_user_send_modification_mail($customer_id, TRUE); } }
function cw_import_chipstation_login() { global $config; cw_load('http'); $post = array('op=login', 'name=Your_Account', 'username='******'import_chipstation']['chipstation_login'], 'password='******'import_chipstation']['chipstation_password'], 'ricorda=0'); $result = cw_http_post_request('www.chipstation.it', '/modules.php', implode('&', $post), array()); return $result[2]; }
function cw_import_cosmos_el_login() { global $config; cw_load('http'); $post = array('user='******'import_cosmos_el']['cosmos_el_login'], 'pwd=' . $config['import_cosmos_el']['cosmos_el_password'], 'master=0', 'submit= Login'); $result = cw_http_post_request('www.cosmosel.it', '/Portale/Cosmos/B2B/it/do-login', implode('&', $post), array()); return $result[2]; }
function cw_import_esprinet_login() { global $config; cw_load('http'); $post = array('VarHttps=NO', 'Codice=' . $config['import_esprinet']['esprinet_customer'], 'utente=' . $config['import_esprinet']['esprinet_login'], 'pwd=' . $config['import_esprinet']['esprinet_password'], 'B2=Effettua il Login'); $result = cw_http_post_request('it.esprinet.com', '/dealer/check_dealer.asp', implode('&', $post), array()); return $result[2]; }
function smarty_function_select_category($params, &$smarty) { extract($params); if (empty($assign)) { $smarty->trigger_error("assign: missing 'assign' parameter"); return; } cw_load('category'); $smarty->assign($assign, cw_func_call('cw_category_get', array('cat' => $category_id))); }
function smarty_function_select_user_title($params, &$smarty) { extract($params); if (empty($assign)) { $smarty->trigger_error("assign: missing 'assign' parameter"); return; } cw_load('user'); $smarty->assign($assign, cw_user_get_titles()); }
function smarty_function_select_tnt_services($params, &$smarty) { extract($params); if (empty($assign)) { $smarty->trigger_error("assign: missing 'assign' parameter"); return; } cw_load('tnt'); $smarty->assign($assign, cw_tnt_get_services($country)); }
function smarty_function_select_bestsellers($params, &$smarty) { extract($params); if (empty($assign)) { $smarty->trigger_error("assign: missing 'assign' parameter"); return; } cw_load('bestseller'); $smarty->assign($assign, cw_bestseller_get_menu($category_id)); }
function smarty_function_select_country($params, &$smarty) { extract($params); if (empty($assign)) { $smarty->trigger_error("assign: missing 'assign' parameter"); return; } cw_load('map'); $smarty->assign($assign, cw_call('cw_map_get_countries')); }
function on_add_cart(&$cart, $added_product) { global $smarty; cw_load('ajax', 'product'); $product_id = $cart['products'][$added_product['productindex']]['product_id']; $product = cw_func_call('cw_product_get', array('id' => $product_id, 'info_type' => 0 | 128)); $product = cw_array_merge($product, $added_product); $smarty->assign('product', $product); cw_add_ajax_block(array('id' => 'add2cart_popup', 'action' => 'update', 'template' => 'addons/ajax_add2cart/add2cart_popup.tpl'), 'add2cart_popup'); cw_add_ajax_block(array('id' => 'script', 'content' => 'sm("add2cart_popup",add2cart_popup_width,add2cart_popup_height, true, "' . $added_product['added_amount'] . ($added_product['added_amount'] > 1 ? ' items' : ' item') . ' added to cart")'), 'add2cart_popup_script'); }
function cw_log_add($label, $message, $add_backtrace = true, $stack_skip = 0, $email_addresses = false, $email_only = false) { global $var_dirs; global $PHP_SELF; global $config; $filename = sprintf("%s/%s-%s.php", $var_dirs['log'], strtolower($label), date('ymd')); if ($label == 'SQL') { $type = 'error'; } elseif ($label == 'INI' || $label == 'SHIPPING') { $type = 'warning'; } else { $type = 'message'; } $uri = $PHP_SELF; if (!empty($_SERVER['QUERY_STRING'])) { $uri .= '?' . $_SERVER['QUERY_STRING']; } if ($add_backtrace) { $stack = cw_get_backtrace(1 + $stack_skip); $backtrace = "Backtrace:\n" . implode("\n", $stack) . "\n"; } else { $backtrace = ''; } if (is_array($message) || is_object($message)) { ob_start(); print_r($message); $message = ob_get_contents(); ob_end_clean(); } else { $message = trim($message); } $local_time = ""; if (!empty($config)) { $local_time = '(local: ' . date('d-M-Y H:i:s', cw_core_get_time()) . ')'; } $message = str_replace("\n", "\n ", "\n" . $message); $message = str_replace("\t", " ", $message); $data = sprintf("[%s] %s %s %s:%s\nRequest URI: %s\n%s-------------------------------------------------\n", date('d-M-Y H:i:s'), $local_time, $label, $type, $message, $uri, $backtrace); cw_event('on_log_add', array($label, $data, $filename)); if (!$email_only && cw_log_check_file($filename) !== false) { $fmode = $label == 'bench_exec' ? 'w' : 'a+'; $fp = @fopen($filename, $fmode); if ($fp !== false) { fwrite($fp, $data); fclose($fp); } } if (!empty($email_addresses) && is_array($email_addresses)) { cw_load('mail'); foreach ($email_addresses as $k => $email) { cw_send_simple_mail($config['Company']['site_administrator'], $email, $config['Company']['company_name'] . ": {$label} {$type} notification", $data); } } }
function cw_ps_products_in_cart_pre($cart, $user_info) { $special_offers_apply =& cw_session_register("special_offers_apply"); # Delete all free added products if (is_array($cart['products'])) { foreach ($cart['products'] as $kk => $vv) { if ($vv["promotion_suite"]["free_product"] == 'Y') { cw_call('cw_delete_from_cart', array(&$cart, $vv['cartid'])); } } } # / Delete all free added products if (!empty($special_offers_apply['free_products'])) { foreach ($special_offers_apply['free_products'] as $pid => $qty) { # # Add product to the cart # $product = cw_func_call('cw_product_get', array('id' => $pid, 'info_type' => 8192)); $avail_amount = $product['avail']; $qty = min($qty, $avail_amount); $min_amount = $product['min_amount']; if ($qty >= $min_amount) { cw_load('warehouse'); $possible_warehouses = cw_warehouse_get_avails_customer($pid); $warehouse = key($possible_warehouses); $add_product = array(); $add_product["product_id"] = $pid; $add_product["amount"] = $qty; $add_product["product_options"] = ""; $add_product["price"] = 0.0; // warehouse is required, otherwise free product will be placed as separate order $add_product['warehouse_customer_id'] = $warehouse; // do to use cw_warehouse_add_to_cart_simple. It operates with global $cart while we use here local $cart copy // $result = cw_call('cw_warehouse_add_to_cart_simple', array($pid, $qty, '', 0.00)); $result = cw_call('cw_add_to_cart', array(&$cart, $add_product)); # Adjust just added product foreach ($cart['products'] as $ck => $cv) { if ($cv["cartid"] == $result['cartid']) { $cart['products'][$ck]["promotion_suite"]["free_product"] = true; // mark just added product as offered } } } else { unset($special_offers_apply['free_products'][$pid]); } } // foreach } // if return new EventReturn($cart['products'], array($cart, $user_info)); // replace cart in input params for main function }
function order_tracking_redirect() { global $smarty, $request_prepared; cw_load('doc'); $order = cw_call('cw_doc_get', array($request_prepared['doc_id'], 0)); if (empty($order) || $order['info']['tracking'] != $request_prepared['tracking']) { cw_header_location('index.php?target=error_message&error=access_denied&id=59'); } $smarty->assign('order', $order); $form = cw_display('addons/shipping_system/tracking.tpl', $smarty, false); echo $form; exit; }
function estimate_cart() { global $request_prepared; $user_address =& cw_session_register('user_address', array()); // Declare session var for addresses $user_address['current_address']['zipcode'] = $request_prepared['zipcode']; $user_address['current_address']['state'] = $request_prepared['state']; $user_address['current_address']['country'] = $request_prepared['country']; if (empty($user_address['current_address']['state']) && $user_address['current_address']['country'] == 'US') { cw_load('map'); $user_address['current_address']['state'] = cw_call('cw_map_get_state_by_zip', array($user_address['current_address']['zipcode'])); } cw_header_location('index.php?target=cart'); }
function cw_salesman_change_discount_status($id, $status) { global $tables, $smarty; db_query("update {$tables['discount_coupons']} set status='{$status}' where coupon='{$id}'"); cw_load('mail', 'user'); $coupon = cw_query_first("select * from {$tables['discount_coupons']} where coupon='{$id}'"); if (!$coupon) { return; } $smarty->assign('coupon', $coupon); $userinfo = cw_user_get_info($coupon['customer_id']); $smarty->assign('userinfo', $userinfo); cw_call('cw_send_mail', array($config['Company']['orders_department'], $userinfo['email'], 'mail/salesman_coupon_subj.tpl', 'mail/salesman_coupon.tpl')); }
function smarty_function_select_config($params, &$smarty) { extract($params); if (empty($assign)) { $smarty->trigger_error("assign: missing 'assign' parameter"); return; } if (empty($category)) { $smarty->trigger_error("assign: missing 'category' parameter"); return; } cw_load('config'); $smarty->assign($assign, cw_config_get_category($category)); }
function smarty_function_select_webmaster_image($params, &$smarty) { extract($params); if (empty($assign)) { $smarty->trigger_error("assign: missing 'assign' parameter"); return; } if (empty($image)) { $smarty->trigger_error("assign: missing 'image' parameter"); return; } cw_load('in_images'); $smarty->assign($assign, cw_in_images_assign($image)); }
function smarty_modifier_attribute_data($value) { cw_load('attributes'); $data = ""; $use_description =& cw_session_register('use_description', true); if (preg_match('/(\\w+)\\.name/', $value, $matches)) { // Get attribute name by field $field_name = $matches[1]; if (!empty($field_name)) { $attribute_id = cw_attributes_get_attribute_by_field($field_name); $attribute = cw_func_call('cw_attributes_get_attribute', array('attribute_id' => $attribute_id)); $data = $attribute['name']; } } else { if (preg_match('/(\\w+)\\.value/', $value, $matches)) { // Get attribute value by field global $product_filter; $pf =& $product_filter; $field_name = $matches[1]; if ($pf && $field_name) { foreach ($pf as $pf_value) { if ($pf_value['field'] == $field_name) { if ($pf_value['selected']) { foreach ($pf_value['selected'] as $pfs_value) { if (isset($pf_value['values'][$pfs_value])) { $data = $pf_value['values'][$pfs_value]['name']; } } } } } } } else { if ($use_description && preg_match('/(\\w+)\\.description/', $value, $matches)) { // Get attribute value by field $field_name = $matches[1]; if (!empty($field_name)) { global $smarty; $attribute_id = cw_attributes_get_attribute_by_field($field_name); $attribute = cw_func_call('cw_attributes_get_attribute', array('attribute_id' => $attribute_id)); $use_description = false; require_once $smarty->_get_plugin_filepath('function', 'eval'); $data = smarty_function_eval(array('var' => $attribute['description']), $smarty); $use_description = true; } } } } return $data; }
function cw_license_api($command, $params = array()) { global $app_config_file; cw_load('http'); $params['target'] = 'license_server'; $params['mode'] = $command; $params['license'] = cw_license_id(); $params['domain'] = $app_config_file['web']['http_host']; foreach ($params as $k => $v) { $param .= '&' . urlencode($k) . "=" . urlencode($v); } // return array(0=>head, 1=>body, 2=>cookie) $return = cw_http_get_request(SERVICE_SERVER, SERVICE_SERVER_SCRIPT, $param); $return = unserialize(trim($return[1])); return $return; }
function cw_top_menu_make_sql_query() { global $tables, $app_web_dir; cw_load('category'); $pcats_ = cw_func_call('cw_category_search', array('data' => array('active' => 1, 'all' => 1))); $pcats_ = $pcats_[0]; foreach ($pcats_ as $v) { extract($v); $mid = 'p' . $category_id; $pmid = $parent_id; if ($pmid != 0) { $pmid = 'p' . $pmid; } $title = $category; $pcount = $product_count_web; //$link="$app_web_dir/?target=index&cat=$category_id"; $link = cw_call('cw_core_get_html_page_url', array(array('var' => 'index', 'cat' => $category_id))); $pos = $tm_pos; $active = $tm_active; $title2 = $tm_title; $type = 'pcat'; if (APP_AREA != 'customer' || $active != 0) { $pcats[] = compact('mid', 'pmid', 'title', 'pcount', 'link', 'pos', 'active', 'title2', 'type'); } } unset($pcats_); $fields = "CONCAT('u',category_id) as mid, CONCAT(parent_id_tag,parent_id) as pmid, category as title,\n"; $fields .= "0 as pcount, link, pos, active, '' as title2, 'ucat' as type\n"; if (APP_AREA == 'customer') { $where = "where active=1"; } else { $where = ""; } $sql = "select {$fields} from {$tables['top_menu_user_categories']} {$where};"; $ucats = cw_query($sql); $cats = array_merge($pcats, $ucats); foreach ($cats as $k => $v) { $sorter[$k] = $v['pos']; } array_multisort($sorter, $cats); return $cats; }
function cw_messages_create_new_message($customer_id, $sender_name, $recipient_id, $recipient_email, $subject, $body, $conversation_id) { global $config, $current_location; cw_load('email'); // sent message (incoming folder) $new_message_id = cw_array2insert('messages', array('subject' => $subject, 'body' => $body, 'sender_id' => $customer_id, 'recipient_id' => $recipient_id, 'sending_date' => cw_core_get_time(), 'conversation_id' => !empty($conversation_id) ? $conversation_id : 0, 'conversation_customer_id' => $recipient_id)); // duplicate for sent folder $current_conversation_id = !empty($conversation_id) ? $conversation_id : $new_message_id; $duplicate_message_id = cw_array2insert('messages', array('subject' => $subject, 'body' => $body, 'sender_id' => $customer_id, 'recipient_id' => $recipient_id, 'sending_date' => cw_core_get_time(), 'read_status' => 1, 'conversation_id' => $current_conversation_id, 'conversation_customer_id' => $customer_id, 'type' => 2, 'link_id' => $new_message_id)); // unite message if they have not been united $data = array('link_id' => $duplicate_message_id); if (empty($conversation_id)) { $data['conversation_id'] = $new_message_id; } cw_array2update('messages', $data, "message_id = '{$new_message_id}'"); // send notification email to recipient // notification is sent from system email and says about new received message from Sender at <sitename> $from = $config['Company']['site_administrator']; /* $mail_subject = "The notification of a new message"; $mail_body = '<b>You have received a new message from "' . $sender_name . '" at <a href="' . $current_location . '">'; $mail_body .= $config['Company']['company_name'] . '</a></b><br />'; $mail_body .= '<b>Subject:</b> ' . $subject . '<br />'; $mail_body .= '<b>Body:</b> ' . nl2br($body) . '<br />'; $mail_body .= '<a href="' . $current_location . '/index.php?target=message_box&mode=new'; $mail_body .= '&contact_id=' . $customer_id . '&conversation_id=' . $current_conversation_id . '">Link to reply</a><br />'; cw_send_simple_mail($from, $recipient_email, $mail_subject, $mail_body); */ global $smarty; $smarty->assign('sender_name', $sender_name); $smarty->assign('current_location', $current_location); $smarty->assign('config', $config); $smarty->assign('subject', $subject); $smarty->assign('body', $body); $smarty->assign('customer_id', $customer_id); $smarty->assign('recipient_id', $recipient_id); $smarty->assign('current_conversation_id', $current_conversation_id); $smarty->assign('new_message_id', $new_message_id); cw_call('cw_send_mail', array($from, $recipient_email, 'addons/messaging_system/mail/new_message_subj.tpl', 'addons/messaging_system/mail/new_message.tpl')); return $new_message_id; }
function cw_ps_bundle_build($action, $category, $category_src, $filter, $products_number, $discount, $disctype) { global $tables; $from_tbls['pc'] = 'products_categories'; $fields[] = 'pc.product_id'; if ($products_number < 2) { $products_number = 2; } if ($category != 0) { cw_load('category'); $subcats = cw_call('cw_category_get_subcategory_ids', array($category)); $where[] = 'pc.category_id IN ("' . join('","', $subcats) . '")'; } $query_joins['o'] = array('tblname' => 'ps_offers', 'on' => 'o.pid = pc.product_id'); if ($filter) { if ($filter['without']) { $where_auto[] = 'auto is NULL'; } if ($filter['auto']) { $where_auto[] = 'auto = 1'; } if ($filter['manual']) { $where_auto[] = 'auto = 0'; } $where[] = '(' . join(' OR ', $where_auto) . ')'; } $sql = cw_db_generate_query($fields, $from_tbls, $query_joins, $where); $pids = cw_query_column($sql); $products_number--; $subcats = cw_call('cw_category_get_subcategory_ids', array($category_src)); $where_src = '1'; if ($category_src != 0) { $where_src = "pc.category_id IN ('" . join("','", $subcats) . "')"; } foreach ($pids as $pid) { $new_pids = cw_query("SELECT pc.product_id as id\n\t\tFROM {$tables['products_categories']} pc \n\t\tWHERE {$where_src} AND pc.product_id!='{$pid}' \n\t\tORDER BY RAND() LIMIT {$products_number}"); $data = array('discount' => $discount, 'disctype' => $disctype, 'bundle' => $new_pids, 'auto' => 1); $offer_id = cw_call('cw_ps_offer_bundle_update', array($pid, $data)); } }
function cw_cleanup_cache($type = "") { global $smarty, $app_dir; cw_load('files'); $result = FALSE; if (!in_array($type, array("", "tpl", "cache"))) { $type = ""; } if ($type == "tpl") { $result = $smarty->clear_compiled_tpl(); cw_rm_dir($app_dir . '/var/templates'); } elseif ($type == "cache") { $result = $smarty->clear_all_cache(); cw_rm_dir($app_dir . '/var/cache'); } elseif ($type == "") { $result = $smarty->clear_compiled_tpl(); $result &= $smarty->clear_all_cache(); cw_rm_dir($app_dir . '/var/templates'); cw_rm_dir($app_dir . '/var/cache'); } return $result; }
function cw_xls_get_image($product_id) { global $tables, $var_dirs, $available_images, $app_dir; $info = cw_query_first("SELECT image_path, date FROM " . $tables['products_images_thumb'] . " WHERE id='{$product_id}'"); if ($info) { $file_name = $var_dirs['tmp'] . "/exel_image_" . $product_id . "_" . $info['date'] . '.bmp'; } else { $info['image_path'] = $var_dirs['images'] . '/' . $available_images['products_images_thumb']['default_image']; $file_name = $var_dirs['tmp'] . "/exel_image_default.bmp"; } if (!is_file($file_name)) { cw_load('image'); if (!is_file($info['image_path'])) { $info['image_path'] = $var_dirs['images'] . '/' . $available_images['products_images_thumb']['default_image']; $file_name = $var_dirs['tmp'] . "/exel_image_default.bmp"; } if (is_file($info['image_path'])) { cw_image_convert($info['image_path'], $file_name); } @unlink($tmpfname); } return $file_name; }
function smarty_function_select_categories($params, &$smarty) { extract($params); if (empty($assign)) { $smarty->trigger_error("assign: missing 'assign' parameter"); return; } if ($remove_root && !$current_category_id) { return false; } cw_load('category', 'image'); if ($remove_root) { $path = cw_category_get_path($current_category_id); $category_id = array_shift($path); } $categories = cw_category_get_subcategories($category_id, $current_category_id); if ($params['images']) { foreach ($categories as $k => $v) { $categories[$k]['image'] = cw_image_get('categories_images_thumb', $v['category_id']); } } $smarty->assign($assign, $categories); }
function cw_bestseller_get_menu($category_id, $limit = 0, $info_type = 288, $att = array()) { global $addons, $config, $tables, $user_account, $current_area; $data = array(); $data['all'] = true; $data['flat_search'] = true; if ($config['General']['disable_outofstock_products'] == 'Y') { $data['min_avail'] = 0; } if ($category_id) { $data['category_id'] = $category_id; } $data['where'] = "IFNULL({$tables['products_stats']}.views_stats,0) > 0 and IFNULL({$tables['products_stats']}.sales_stats,0) > 0"; $data['sort_condition'] = "{$tables['products_stats']}.sales_stats DESC, {$tables['products_stats']}.views_stats DESC"; $data['limit'] = $limit ? $limit : $config['bestsellers']['number_of_bestsellers']; $data['attributes'] = $att; cw_load('product'); $return = cw_func_call('cw_product_search', array('data' => $data, 'user_account' => $user_account, 'current_area' => $current_area, 'info_type' => $info_type)); if (!$limit) { return $return[0]; } return $return; }
function smarty_function_tunnel($params, &$smarty) { global $cw_allowed_tunnels; if (empty($params['func'])) { $smarty->trigger_error("tunnel: missing 'func' parameter"); return; } if (!in_array($params['func'], $cw_allowed_tunnels, true)) { $smarty->trigger_error("tunnel: function {$params['func']} is not allowed for call from templates", E_USER_ERROR); return; } if ($params['load']) { cw_load($params['load']); } $assign = $params['assign']; $func = $params['func']; if ($params['via'] == 'cw_call') { // order and number of params is important for cw_call() // we accept only paramX as params $func_params = array(); foreach ($params as $k => $v) { if (strpos($k, 'param') !== false) { $func_params[$k] = $v; } } ksort($func_params); $result = cw_call($params['func'], $func_params); } else { unset($params['load'], $params['func'], $params['assign']); $result = cw_func_call($func, $params); } if ($assign) { $smarty->assign($assign, $result); } else { echo $result; } }
<?php set_time_limit(2700); cw_load('files'); define("OVERRIDE_NUM_FIELD", false); $sqldump_file = $var_dirs['tmp'] . "/cw_dump.sql"; $file_exists = file_exists($sqldump_file); # # While restoring database re-establish connection with mysql server before every Nth table row # $sql_reconnect_count = 5000; # # Make tables backup by selecting N rows per query # global $sql_backup_rows; $sql_backup_rows = 200; $smarty->assign('sqldump_file', $sqldump_file); $smarty->assign('file_exists', $file_exists); $log_prefix = "Customer id: {$customer_id}\nIP: {$REMOTE_ADDR}\nOperation: {$action}\n----\n"; $deprecated_tables = array('cw_configuration_changes_log'); # # Dump database code # if ($REQUEST_METHOD == "POST" && $action == "backup") { function dumpTableContent($table, $schema, $fd) { global $sql_backup_rows; if ($fd === false) { print "{$schema}\n\n"; } else { fwrite($fd, "{$schema}\n\n");
<?php cw_load('map'); if ($mode == 'cities' && $country) { cw_include('include/map/cities.php'); $smarty->assign('main', 'cities'); $location[] = array(cw_get_langvar_by_name('lbl_cities'), ''); } elseif ($mode == 'regions' && $country) { cw_include('include/map/regions.php'); $smarty->assign('main', 'regions'); $location[] = array(cw_get_langvar_by_name('lbl_regions'), ''); } elseif ($mode == 'states' && $country) { cw_include('include/map/states.php'); $smarty->assign('main', 'states'); $location[] = array(cw_get_langvar_by_name('lbl_states'), ''); } elseif ($mode == 'counties' && $country) { cw_include('include/map/counties.php'); $smarty->assign('main', 'counties'); $location[] = array(cw_get_langvar_by_name('lbl_counties'), ''); } else { cw_include('include/map/countries.php'); $smarty->assign('main', 'countries'); $location[] = array(cw_get_langvar_by_name('lbl_countries_management'), ''); }
} } $orig_type = $type; if (zerolen($image_path) && isset($available_images[$type]) && !empty($tables[$type]) && !empty($id)) { $hash_types = array(); $i = 0; $max_attempts = 1; while ($i++ < $max_attempts) { # counting attempts to prevent infinite loop $_table = $tables[$type]; $_field = $available_images[$type]['type'] == "U" ? "id" : "image_id"; $result = db_query("SELECT image_path, image_type, md5, image_size, filename FROM {$_table} WHERE {$_field}='{$id}' LIMIT 1"); if ($result && db_num_rows($result) > 0) { list($image_path, $image_type, $md5, $image_size, $_filename) = db_fetch_row($result); if (zerolen($image_path) && !zerolen($_filename)) { cw_load("image"); $image_path = cw_image_dir($type) . "/" . $_filename; } db_free_result($result); break; } if ($is_substitute) { if (!empty($config['substitute_images'][$type]) && isset($config['available_images'][$config['substitute_images'][$type]]) && !isset($hash_types[$config['substitute_images'][$type]])) { $type = $config['substitute_images'][$type]; $hash_types[$type] = true; continue; } # kornev, TOFIX if ($type == "W") { $tmp_id = cw_query_first_cell("SELECT product_id FROM {$tables['product_variants']} WHERE variant_id = '{$id}'"); if ($tmp_id) {