コード例 #1
0
function cw_gb_get_category_value($category_id, $default_value)
{
    global $tables;
    if (empty($category_id)) {
        return empty($default_value) ? FALSE : $default_value;
    }
    $attr_val_id = cw_query_first_cell("SELECT av.value\n\t\t                    FROM {$tables['attributes_values']} av, {$tables['attributes']} a\n\t\t                    WHERE av.item_id={$category_id}\n\t\t                    \tAND av.item_type='C'\n\t\t                    \tAND a.attribute_id=av.attribute_id\n\t\t                    \tAND a.field='g:google_product_category'");
    if (empty($attr_val_id)) {
        // Get parent categories
        $parent_categories = array();
        cw_category_generate_path($category_id, $parent_categories);
        if (count($parent_categories)) {
            foreach ($parent_categories as $parent_category_id) {
                $attr_val_id = cw_query_first_cell("SELECT av.value\n\t\t                    FROM {$tables['attributes_values']} av, {$tables['attributes']} a\n\t\t                    WHERE av.item_id={$parent_category_id}\n\t\t                    \tAND av.item_type='C'\n\t\t                    \tAND a.attribute_id=av.attribute_id\n\t\t                    \tAND a.field='g:google_product_category'");
                if (!empty($attr_val_id)) {
                    break;
                }
            }
        }
    }
    if ($attr_val_id) {
        $attr_val = cw_query_first_cell("SELECT value FROM {$tables['attributes_default']} WHERE attribute_value_id = " . $attr_val_id);
        if (empty($attr_val)) {
            return empty($default_value) ? FALSE : $default_value;
        }
        return $attr_val;
    }
    return empty($default_value) ? FALSE : $default_value;
}
コード例 #2
0
function cw_config_update($category, $options)
{
    global $tables;
    $config_category_id = cw_query_first_cell("SELECT config_category_id FROM {$tables['config_categories']} WHERE category='{$category}'");
    $var_properties = cw_query_hash("SELECT name, type FROM {$tables['config']} WHERE config_category_id='{$config_category_id}'", "name", false, true);
    $section_data = array();
    foreach ($options as $key => $val) {
        if (isset($var_properties[$key])) {
            if ($var_properties[$key] == "numeric") {
                $val = doubleval(cw_convert_numeric($val));
            } elseif ($var_properties[$key] == "textarea") {
                $val = strtr($val, array("\r" => ''));
            } elseif ($var_properties[$key] == "multiselector") {
                $val = implode(";", $val);
            } elseif ($var_properties[$key] == "checkbox") {
                $val = in_array($val, array('on', '1', 'Y')) ? 'Y' : 'N';
            } elseif (in_array($var_properties[$key], array('shipping', 'memberships', 'doc_status'))) {
                $ret = array();
                if (is_array($val)) {
                    foreach ($val as $k => $v) {
                        $ret[$v] = 1;
                    }
                }
                $val = serialize($ret);
            }
            cw_array2update("config", array("value" => $val), "name='" . $key . "' AND config_category_id='" . $config_category_id . "'");
            $section_data[stripslashes($key)] = stripslashes($val);
        }
    }
}
コード例 #3
0
function cw_barcode_print_doc($doc_id, $options)
{
    global $tables, $user_account;
    $layout = cw_web_get_layout_by_id($options['template_id']);
    $doc = cw_doc_get($doc_id);
    $amount = $options['amount'];
    if (!$amount) {
        $amount = 1;
    }
    foreach ($doc['products'] as $product) {
        if (in_array($doc['type'], array('P', 'R', 'Q'))) {
            $product['supplier_code'] = $product['productcode'];
        } else {
            $product['supplier_code'] = cw_query_first_cell("select productcode from {$tables['products_supplied_amount']} where product_id='{$product_id}' order by date limit 1");
        }
        if ($layout['data']['use_tax']) {
            $taxes = $product['extra_data']['taxes'];
            cw_get_products_taxes($product, $user_account, false, $taxes, true);
            $_tmp_price = $product['price'];
            $product['price'] = $product['list_price'];
            cw_get_products_taxes($product, $user_account, false, $taxes, true);
            $product['list_price'] = $product['display_price'];
            $product['price'] = $_tmp_price;
        } else {
            $product['display_price'] = $product['price'];
        }
        for ($i = 0; $i < $product['amount'] * $amount; $i++) {
            $products[] = $product;
        }
    }
    cw_barcode_print($products, $layout, $options, 0);
}
コード例 #4
0
function cw_serials_delete($customer_id, $product_id, $serial)
{
    global $tables;
    $count = cw_query_first_cell("select count(*) from {$tables['serial_numbers']} where sn='{$serial}' and product_id='{$product_id}' and doc_id=0" . ($customer_id ? " and warehouse_customer_id='{$customer_id}'" : ""));
    if ($count) {
        db_query("delete from {$tables['serial_numbers']} where sn='{$serial}' and product_id='{$product_id}'" . ($customer_id ? " and warehouse_customer_id='{$customer_id}'" : ""));
    }
}
コード例 #5
0
function cw_mobile_get_mobile_host_attr_by_domain_id($domain_id)
{
    global $tables;
    $mobile_mobile_flag = cw_session_register('mobile_mobile_flag');
    cw_load('attributes');
    $current_language = cw_query_first_cell("SELECT value FROM {$tables['config']} WHERE name='default_customer_language'");
    $attributes = cw_func_call('cw_attributes_get', array('item_id' => $domain_id, 'item_type' => 'DM', 'language' => $current_language));
    return !empty($attributes['mobile_host']['value']) ? trim($attributes['mobile_host']['value']) : ($mobile_mobile_flag == 'on' && $_GET['mobile_version'] != 'off' ? cw_mobile_get_host() : '');
}
コード例 #6
0
function cw_objects_check_exist($object, $type = 'P')
{
    global $tables, $customer_id;
    if (is_numeric($object)) {
        $query = "SELECT object_id \r\n\t\t\t\t\tFROM {$tables['objects_set']} \r\n\t\t\t\t\tWHERE object_id = {$object} \r\n\t\t\t\t\t\tAND customer_id = {$customer_id} \r\n\t\t\t\t\t\tAND set_type = '{$type}'";
        return cw_query_first_cell($query) !== FALSE;
    }
    return FALSE;
}
コード例 #7
0
function cw_file_area_delete($type, $file_id)
{
    global $tables;
    $file = cw_query_first_cell("select file_path from " . $tables[$type] . " where file_id='{$file_id}'");
    if (is_file($file)) {
        @unlink($file);
    }
    db_query("delete from " . $tables[$type] . " where file_id='{$file_id}'");
}
コード例 #8
0
function cw_pages_by_url($url, $check_redirect = true)
{
    global $tables;
    $page_id = cw_query_first_cell("select * from {$tables['pages']} where url='{$url}'");
    $page_data = cw_pages_get_page_content($page_id);
    if ($check_redirect && $page_data['redirect']) {
        cw_header_location($page_data['redirect'], true, false, 301);
    }
    return $page_data;
}
コード例 #9
0
function cw_add_class_data($data, $product_id)
{
    global $tables;
    # Update class data
    $comp = $data['class'];
    $comp['product_id'] = $product_id;
    cw_unset($comp, "product_option_id");
    $comp = cw_addslashes($comp);
    $product_option_id = cw_query_first_cell("SELECT product_option_id FROM {$tables['product_options']} WHERE class = '{$comp['class']}' AND product_id = '{$comp['product_id']}'");
    $is_new = empty($product_option_id);
    if (!empty($product_option_id)) {
        cw_array2update("product_options", $comp, "product_option_id = '{$product_option_id}'");
    } else {
        $product_option_id = cw_array2insert("product_options", $comp);
    }
    # Update class multilanguage data
    db_query("DELETE FROM {$tables['product_options_lng']} WHERE product_option_id = '{$product_option_id}'");
    foreach ($data['product_options_lng'] as $v) {
        $v['product_option_id'] = $product_option_id;
        $v = cw_addslashes($v);
        cw_array2insert("product_options_lng", $v, true);
    }
    # Update class options
    $ids = array();
    foreach ($data['product_options_values'] as $k => $opt) {
        $opt['product_option_id'] = $product_option_id;
        $old_option_id = $opt['option_id'];
        cw_unset($opt, "option_id");
        $opt = cw_addslashes($opt);
        $option_id = cw_query_first_cell("SELECT option_id FROM {$tables['product_options_values']} WHERE product_option_id = '{$product_option_id}' AND name = '{$opt['name']}'");
        if (empty($option_id)) {
            $option_id = cw_array2insert("product_options_values", $opt);
        } else {
            cw_array2update("product_options_values", $opt, "option_id = '{$option_id}'");
        }
        $ids[$old_option_id] = $option_id;
    }
    # Update class option multilanguage data
    db_query("DELETE FROM {$tables['product_options_values_lng']} WHERE option_id = '{$option_id}'");
    foreach ($data['product_options_values_lng'] as $v) {
        if (!isset($ids[$v['option_id']])) {
            continue;
        }
        $v['option_id'] = $ids[$v['option_id']];
        $v = cw_addslashes($v);
        cw_array2insert("product_options_values_lng", $v, true);
    }
    # Detect and delete old product option class options
    $ids = cw_query_column("SELECT option_id FROM {$tables['product_options_values']} WHERE product_option_id = '{$product_option_id}' AND option_id NOT IN ('" . implode("','", $ids) . "')");
    if (!empty($ids)) {
        db_query("DELETE FROM {$tables['product_options_values']} WHERE product_option_id = '{$product_option_id}' AND option_id IN ('" . implode("','", $ids) . "')");
        db_query("DELETE FROM {$tables['product_options_values_lng']} WHERE option_id IN ('" . implode("','", $ids) . "')");
        db_query("DELETE FROM {$tables['products_options_ex']} WHERE option_id IN ('" . implode("','", $ids) . "')");
    }
}
コード例 #10
0
function cw_error_check_state($state, $section, &$full)
{
    global $tables;
    $display_states = cw_query_first_cell("select display_states from {$tables['map_countries']} where code = '{$section['country']}'") == 'Y';
    if (!$display_states) {
        return false;
    }
    if (empty($state) || !cw_user_check_state($state, $section['country'])) {
        return true;
    }
    return false;
}
コード例 #11
0
function cw_ebay_get_condition_value($var, $default_value)
{
    global $tables;
    if (isset($var['ebay_condition_id']) && is_numeric($var['ebay_condition_id'])) {
        $condition_value = cw_query_first_cell("SELECT value_key FROM {$tables['attributes_default']} WHERE attribute_value_id = " . $var['ebay_condition_id']);
        if (empty($condition_value)) {
            return $default_value;
        }
    } else {
        return $default_value;
    }
    return $condition_value;
}
コード例 #12
0
/**
 * State lookup by zip
 * Table is loaded from csv with fields ZipCode,City,StateCode
 * SQL: load data local infile '/tmp/zip.txt' replace into table cw_map_zip fields terminated by ',' lines terminated by "\r\n" Ignore 1 lines;
 **/
function cw_map_get_state_by_zip($zip)
{
    global $tables;
    if (empty($zip)) {
        return '';
    }
    for ($i = strlen($zip); $i >= 2; $i--) {
        $state = cw_query_first_cell("SELECT state FROM {$tables['map_zip']} WHERE zip like '" . substr($zip, 0, $i) . "%'");
        if (!empty($state)) {
            return $state;
        }
    }
    return '';
}
コード例 #13
0
function cw_ps_bundle_show($product_id)
{
    global $smarty, $tables, $config;
    $product_id = (int) $product_id;
    if (empty($product_id)) {
        return;
    }
    if ($_SERVER['REQUEST_METHOD'] != 'GET') {
        cw_ps_bundle_redirect($product_id);
    }
    $offer_id = cw_query_first_cell("SELECT offer_id FROM {$tables['ps_offers']} WHERE pid='{$product_id}' AND active='1'");
    $product_offer = cw_call('cw_ps_offer', array($offer_id));
    unset($product_offer['conditions']['P']['products'][$product_id]);
    $smarty->assign('product_offer', $product_offer);
    return $product_offer;
}
コード例 #14
0
function cw_session_start($sess_id = '')
{
    global $APP_SESSION_VARS, $APP_SESS_ID;
    global $tables, $config;
    # $sess_id should contain only '0'..'9' or 'a'..'z' or 'A'..'Z'
    if (strlen($sess_id) > 32 || !empty($sess_id) && !preg_match('!^[0-9a-zA-Z]+$!S', $sess_id)) {
        $sess_id = '';
    }
    $APP_SESSION_VARS = array();
    $l = 0;
    if (isset($_SERVER['REMOTE_PORT'])) {
        $l = $_SERVER['REMOTE_PORT'];
    }
    list($usec, $sec) = explode(' ', microtime());
    srand((double) $sec + (double) $usec * 1000000 + (double) $l);
    $curtime = cw_core_get_time();
    $expiry_time = $curtime + USE_SESSION_LENGTH;
    if ($sess_id) {
        $sess_data = cw_query_first("select * from {$tables['sessions_data']} where sess_id='{$sess_id}' and expiry>{$curtime}");
        if (!$sess_data) {
            $sess_id = '';
        }
    }
    if (empty($sess_id)) {
        do {
            $sess_id = md5(uniqid(rand()));
            $already_exists = false;
            $already_exists = cw_query_first_cell("select count(*) from {$tables['sessions_data']} where sess_id='{$sess_id}'") > 0;
        } while ($already_exists);
    }
    if ($sess_data) {
        $APP_SESSION_VARS = unserialize($sess_data['data']);
    } else {
        if (!defined("NEW_SESSION")) {
            define("NEW_SESSION", true);
        }
        db_query("REPLACE INTO {$tables['sessions_data']} (sess_id, start, expiry, data) VALUES('{$sess_id}', '{$curtime}', '{$expiry_time}', '')");
    }
    $APP_SESS_ID = $sess_id;
    global $app_config_file;
    setcookie(APP_SESSION_NAME, $APP_SESS_ID, 0, with_leading_slash_only($app_config_file['web']['web_dir'], true), $app_config_file['web']['http_host'], 0);
    if ($app_config_file['web']['http_host'] != $app_config_file['web']['https_host']) {
        setcookie(APP_SESSION_NAME, $APP_SESS_ID, 0, with_leading_slash_only($app_config_file['web']['web_dir'], true), $app_config_file['web']['https_host'], 0);
    }
}
コード例 #15
0
function cw_ppd_doc_change_status_C($doc_data, $return)
{
    global $tables, $config;
    if (empty($doc_data) || !is_array($doc_data)) {
        return $return;
    }
    $doc_data['doc_id'] = (int) $doc_data['doc_id'];
    $_download_exists = cw_query_first_cell('SELECT download_id FROM ' . $tables['ppd_downloads'] . ' WHERE order_id = \'' . $doc_data['doc_id'] . '\'');
    if (!empty($_download_exists) || empty($doc_data['products'])) {
        return $return;
    }
    $values_for_ins = array();
    $data = array();
    $data['order_id'] = $doc_data['doc_id'];
    $data['customer_id'] = $doc_data['userinfo']['customer_id'];
    $data['allowed_number'] = (int) $config['ppd']['ppd_loading_attempts'];
    $data['counter'] = 0;
    $data['expiration_date'] = cw_core_get_time() + (int) $config['ppd']['ppd_link_lifetime'] * 60 * 60;
    foreach ($doc_data['products'] as $product) {
        $files = cw_query('SELECT file_id FROM ' . $tables['ppd_files'] . ' WHERE product_id = \'' . $product['product_id'] . '\' AND active = 1 AND perms_owner >= 4 AND perms_all = 0 ORDER BY number');
        if (empty($files) || !is_array($files)) {
            continue;
        }
        $data['product_id'] = $product['product_id'];
        foreach ($files as $file) {
            $data['file_id'] = $file['file_id'];
            $_replace_data = cw_query_first_cell('SELECT download_id FROM ' . $tables['ppd_downloads'] . ' WHERE product_id = \'' . $data['product_id'] . '\' AND file_id = \'' . $data['file_id'] . '\'');
            if (!empty($_replace_data)) {
                $data['download_id'] = $_replace_data;
                $query = 'REPLACE INTO ' . $tables['ppd_downloads'] . ' (`' . implode('`, `', array_keys($data)) . '`) VALUES ' . '(\'' . implode('\', \'', $data) . '\')';
                db_query($query);
                unset($data['download_id']);
                continue;
            }
            $values_for_ins[] = '(\'' . implode('\', \'', $data) . '\')';
        }
    }
    if (empty($values_for_ins)) {
        return $return;
    }
    $query = 'INSERT INTO ' . $tables['ppd_downloads'] . ' (`' . implode('`, `', array_keys($data)) . '`) VALUES ' . implode(', ', $values_for_ins);
    db_query($query);
    return $return;
}
コード例 #16
0
function cw_product_filter_recalculate_price_ranges()
{
    global $tables;
    $price_ranges = cw_product_filter_get_price_ranges(PRICE_ATTRIBUTE_ID);
    if ($price_ranges) {
        $min_price = cw_query_first_cell("SELECT MIN(price) FROM {$tables['products_prices']}");
        $max_price = cw_query_first_cell("SELECT MAX(price) FROM {$tables['products_prices']}");
        $min['id'] = $min['val'] = $max['id'] = $max['val'] = 0;
        foreach ($price_ranges as $pr) {
            $r = cw_product_filter_get_price_range_values($pr['id']);
            if ($min_price > $r[1] || $max_price < $r[0]) {
                cw_array2update('attributes_default', array('active' => 0), "attribute_value_id='{$pr['id']}'");
                continue;
            }
            $price_ranges[$pr['id']]['min'] = $r[0];
            $price_ranges[$pr['id']]['max'] = $r[1];
            if ($min['id'] == 0) {
                $min['id'] = $max['id'] = $pr['id'];
                $min['val'] = $r[0];
                $max['val'] = $r[1];
            } else {
                if ($min['val'] > $r[0]) {
                    $min['val'] = $r[0];
                    $min['id'] = $pr['id'];
                }
                if ($max['val'] < $r[1]) {
                    $max['val'] = $r[1];
                    $max['id'] = $pr['id'];
                }
            }
        }
        if ($min_price != $min['val']) {
            cw_array2update('attributes_default', array('value_key' => $min_price . '-' . $price_ranges[$min['id']]['max']), "attribute_value_id='" . $min['id'] . "'");
        }
        if ($max_price != $max['val']) {
            cw_array2update('attributes_default', array('value_key' => $price_ranges[$max['id']]['min'] . '-' . $max_price), "attribute_value_id='" . $max['id'] . "'");
        }
    }
}
コード例 #17
0
function cw_product_shipping_option_shipping_get_rates($params, $return)
{
    //    cw_log_add('shipping_get_rates', array($params, $return));
    global $config, $tables;
    if (empty($config['product_shipping_options']['dummy_shipping_method'])) {
        return $return;
    }
    $shipping = cw_func_call('cw_shipping_search', array('data' => array('active' => 1, 'where' => array("shipping_id = '" . $config['product_shipping_options']['dummy_shipping_method'] . "'"))));
    $pso_shipping = reset($shipping);
    if (!empty($pso_shipping)) {
        $total_optional_rate = 0;
        $products = $params['cart']['products'];
        foreach ($products as $product) {
            $product_shipping_cost = cw_query_first_cell("select price from {$tables['product_shipping_options_values']} where shipping_id='{$product['product_shipping_option']}' and product_id='{$product['product_id']}'");
            if (!empty($product_shipping_cost)) {
                $total_optional_rate += floatval($product_shipping_cost);
            }
        }
        $shrate = array('rate_id' => 999999, 'shipping_id' => $pso_shipping['shipping_id'], 'zone_id' => 0, 'maxamount' => 0, 'minweight' => 0, 'maxweight' => 999999, 'mintotal' => 0, 'maxtotal' => 999999, 'rate' => $total_optional_rate, 'original_rate' => $total_optional_rate, 'item_rate' => 0.0, 'weight_rate' => 0.0, 'rate_p' => 0.0, 'warehouse_customer_id' => 0, 'type' => 'D', 'overweight' => 0.0, 'overweight_rate' => 0.0, 'apply_to' => 'ST');
        $return = array($pso_shipping['shipping_id'] => array_merge($shrate, $pso_shipping));
    }
    return $return;
}
コード例 #18
0
 function dumpTableContent($table, $schema, $fd)
 {
     global $sql_backup_rows;
     if ($fd === false) {
         print "{$schema}\n\n";
     } else {
         fwrite($fd, "{$schema}\n\n");
         echo cw_get_langvar_by_name("lbl_dumping_table_n", array("table" => $table), false, true) . "<br />\n";
     }
     $rows_cnt = 0;
     $current_row = 0;
     $count = cw_query_first_cell("SELECT count(*) FROM " . $table);
     if ($count < 1) {
         return;
     }
     for ($pos = 0; $count > 0; $count -= $sql_backup_rows, $pos += $sql_backup_rows) {
         $local_query = "SELECT * FROM {$table} LIMIT {$pos},{$sql_backup_rows}";
         $result = db_query($local_query);
         if ($result != FALSE) {
             $fields_cnt = mysql_num_fields($result);
             $rows_cnt = mysql_num_rows($result);
             // Checks whether the field is an integer or not
             for ($j = 0; $j < $fields_cnt; $j++) {
                 $field_set[$j] = mysql_field_name($result, $j);
                 $type = mysql_field_type($result, $j);
                 $field_num[$j] = ($type == 'tinyint' || $type == 'smallint' || $type == 'mediumint' || $type == 'int' || $type == 'bigint' || $type == 'timestamp') && (!defined("OVERRIDE_NUM_FIELD") || !constant("OVERRIDE_NUM_FIELD"));
             }
             // Sets the scheme
             $schema_insert = "INSERT INTO {$table} VALUES (";
             $search = array("", "\n", "\r", "");
             //\x08\\x09, not required
             $replace = array('0', '\\n', '\\r', '\\Z');
             $current_row = 0;
             while ($row = mysql_fetch_row($result)) {
                 $current_row++;
                 for ($j = 0; $j < $fields_cnt; $j++) {
                     if (!isset($row[$j])) {
                         $values[] = 'NULL';
                     } else {
                         if ($row[$j] == '0' || $row[$j] != '') {
                             // a number
                             if ($field_num[$j]) {
                                 $values[] = $row[$j];
                             } else {
                                 $values[] = "'" . str_replace($search, $replace, addslashes($row[$j])) . "'";
                             }
                         } else {
                             $values[] = "''";
                         }
                     }
                     // end if
                 }
                 // end for
                 // Extended inserts case
                 $insert_line = $schema_insert . implode(', ', $values) . ')';
                 unset($values);
                 // Send the line
                 if ($fd === false) {
                     print $insert_line . ";\n";
                     flush();
                 } else {
                     fwrite($fd, $insert_line . ";\n");
                     fflush($fd);
                 }
                 // loic1: send a fake header to bypass browser timeout if data
                 //        are bufferized
             }
             // end while
         }
         // end if ($result != FALSE)
         db_free_result($result);
         if ($fd !== false) {
             cw_flush(". ");
         }
     }
     // for
     if ($fd === false) {
         print "\n";
     } else {
         fwrite($fd, "\n");
         echo "<br />";
     }
 }
コード例 #19
0
         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) {
                 $id = $tmp_id;
                 $type = "P";
                 $hash_types[$type] = true;
                 continue;
             }
         }
     }
     db_free_result($result);
     break;
 }
 if (!zerolen($image_path) && !is_url($image_path)) {
     if (!file_exists($image_path) || !is_readable($image_path)) {
         $image_path = "";
     } elseif ($config['setup_images'][$type]['md5_check'] == 'Y') {
コード例 #20
0
        }
        # Recalculate cart totals after updating
        $products = cw_call('cw_products_in_cart', array($cart, $user_account));
        $cart = cw_func_call('cw_cart_calc', array('cart' => $cart, 'products' => $products, 'userinfo' => $user_account));
    }
    ?>
<script type="text/javascript">
<!--
if (window.opener) window.opener.location.reload();
window.close();
-->
</script>
<?php 
    exit;
}
if (!$min_avail) {
    $min_avail = cw_query_first_cell("SELECT min_amount FROM {$tables['products']} WHERE product_id = '{$product_id}'");
}
if (!$min_avail) {
    $min_avail = 1;
}
$smarty->assign('id', $id);
$smarty->assign('mode', $mode);
$smarty->assign('eventid', $eventid);
$smarty->assign('min_avail', $min_avail);
$smarty->assign('alert_msg', 'Y');
$smarty->assign('err', $err);
$smarty->assign('home_style', 'popup');
$smarty->assign('current_main_dir', 'addons');
$smarty->assign('current_section_dir', 'product_options/main/options');
$smarty->assign('main', 'popup');
コード例 #21
0
<?php

$salesman =& cw_session_register("salesman");
$salesman_click_id =& cw_session_register("salesman_click_id");
$salesman_saleman =& cw_session_register("salesman_saleman");
$salesman_membership =& cw_session_register("salesman_membership");
if ($_GET['saleman']) {
    $salesman_saleman = $saleman;
}
if ($_GET['level'] && $_GET['saleman']) {
    $salesman_membership = $level;
}
if ($customer_id) {
    $possible_salesman = cw_query_first_cell("select salesman_customer_id from {$tables['customers_relations']} where customer_id='{$customer_id}'");
    if ($possible_salesman) {
        $salesman = $possible_salesman;
    }
}
$_tmp_current_host = $app_http_host;
$_tmp = parse_url($current_location);
if (!empty($_tmp['host'])) {
    $_tmp_current_host = $_tmp['host'];
}
if (empty($salesman) && (!empty($_GET['salesman']) || !empty($_POST['salesman_customer_id']))) {
    #
    # Assign current salesman value
    #
    if (isset($_POST['salesman_customer_id']) && !empty($_POST['salesman_customer_id'])) {
        $salesman = $_POST['salesman_customer_id'];
    } else {
        $salesman = $_GET['salesman'];
コード例 #22
0
        $mysql_password = $app_config_file['sql']['password'];
        $mysql_host = $app_config_file['sql']['host'];
        $shell_comm = "echo {$arch_select_qry} | mysql --host={$mysql_host} --user={$mysql_user} --password={$mysql_password} {$mysql_db} > {$arch_log_name}";
        shell_exec($shell_comm);
        if (file_exists($arch_log_name)) {
            cw_add_top_message("Current log saved to archive: <a style='color:white' href='{$var_dirs_web['logs_archive']}/{$arch_log_file_name}'>{$arch_log_name}");
            if ($drop_archived == "1") {
                db_query("delete from ld using {$tables['logged_data']} as ld {$archive_where_string_qry}");
            }
        } else {
            cw_add_top_message('Cannot save log to file: ' . $arch_log_name, 'E');
        }
    }
    cw_header_location('index.php?target=logging');
}
$total_items = cw_query_first_cell("select count(*) from {$tables['logged_data']} as ld {$where_string_qry}");
$navigation = cw_core_get_navigation($target, $total_items, $page);
$navigation['script'] = 'index.php?target=' . $target;
$smarty->assign('navigation', $navigation);
$smarty->assign('page', $page);
$limit_qry = " LIMIT {$navigation['first_page']}, {$navigation['objects_per_page']}";
$logged_data = cw_query($s = "select ld.*, IF(ld.customer_id>0,1,0) as is_logged from {$tables['logged_data']} as ld {$where_string_qry} {$orderby_qry} {$limit_qry}");
$session_ids = array();
foreach ($logged_data as $ld_k => $ld_v) {
    $session_ids[$ld_v['cwsid']] = 1;
    $logged_data[$ld_k]['GET_POST'] = unserialize($ld_v['GET_POST']);
}
$smarty->assign('logged_data', $logged_data);
$_sess_data = cw_query("select * from {$tables['logged_data_sessions']} where cwsid in ('" . implode("', '", array_keys($session_ids)) . "')");
$sess_data = array();
foreach ($_sess_data as $s_data) {
コード例 #23
0
    cw_header_location('index.php?target=help&section=login_customer');
}
if ($mode == 'friends') {
    cw_include('addons/estore_gift/wishlist.php');
    $smarty->assign('allow_edit', false);
    $smarty->assign('main', 'friends');
} elseif ($mode == 'giftcert' || $mode == 'preview' || $mode == 'gc2cart' || $mode == 'modify_gc' || $action == 'delgc' || $action == "addgc2wl") {
    cw_include('addons/estore_gift/cert.php');
} elseif ($mode == 'gifts') {
    $access_status =& cw_session_register('access_status', array());
    if (!empty($cc)) {
        cw_include("addons/estore_gift/giftreg_confirm.php");
    }
    if (!empty($eventid)) {
        if (!empty($wlid)) {
            if (cw_query_first_cell("SELECT event_id FROM {$tables['wishlist']} WHERE wishlist_id='{$wild}'") == $eventid) {
                $wlid_eventid =& cw_session_register("wlid_eventid");
                $wlid_eventid = $eventid;
                cw_session_save("wlid_eventid");
            }
        }
        cw_include("addons/estore_gift/event_guestbook.php");
        cw_include("addons/estore_gift/giftreg_display.php");
    } else {
        cw_include("addons/estore_gift/giftreg_search.php");
    }
} elseif ($mode == 'events') {
    if (isset($_GET['event_id'])) {
        cw_include('addons/estore_gift/event.php');
    } else {
        cw_include('addons/estore_gift/events.php');
コード例 #24
0
function cw_get_parents($user)
{
    global $tables, $config;
    $parent = cw_query_first_cell("SELECT salesman_customer_id FROM {$tables['customers_relations']} WHERE customer_id='{$user}'");
    if ($parent) {
        $parents[] = array("customer_id" => $parent, "level" => cw_get_affiliate_level($parent));
        $parents = cw_array_merge($parents, cw_get_parents($parent));
    }
    return $parents;
}
コード例 #25
0
function cw_faq_generate_path($rubrik_id, &$path)
{
    global $tables;
    $parent = cw_query_first_cell("select parent_id from {$tables['faq_rubrik']} where rubrik_id='{$rubrik_id}'");
    if ($parent) {
        cw_faq_generate_path($parent, $path);
        $path[] = $parent;
    }
}
コード例 #26
0
<?php

cw_load('addons');
if ($action == 'update' && is_array($upd_addons)) {
    db_query("update {$tables['addons']} set active='0' where status>'" . constant('ADDON_TYPE_CORE') . "'");
    foreach ($upd_addons as $addon => $val) {
        db_query("update {$tables['addons']} set active='1' where addon='{$addon}'");
    }
    $disabled = cw_query_column("select addon from {$tables['addons']} where active = 0");
    db_query("update {$tables['addons']} set active=0 where parent in ('" . implode("', '", $disabled) . "')");
    cw_header_location("index.php?target={$target}&mode=addons");
}
if ($action == 'ajax_update') {
    db_query("update {$tables['addons']} set active=abs(active-1) where addon='{$addon}' and status>'" . constant('ADDON_TYPE_CORE') . "'");
    $active = cw_query_first_cell("select active from {$tables['addons']} where addon='{$addon}'");
    cw_add_ajax_block(array('id' => 'script', 'content' => '$("#' . $addon . '").removeClass("on").removeClass("off").addClass("' . ($active == 1 ? 'on' : 'off') . '");'));
    cw_add_ajax_block(array('id' => 'script', 'content' => '$("[parent=' . $addon . ']").parent().removeClass("addon_locked")' . ($active == 1 ? '' : '.addClass("addon_locked")') . ';'));
}
$addon = $_GET['addon'];
if (!empty($addon) && $mode == 'addons') {
    # kornev, TOFIX generally this should be removed
    if (is_file($app_main_dir . '/addons/' . $addon . '/admin/settings.php')) {
        cw_include('addons/' . $addon . '/admin/settings.php');
    }
    if ($REQUEST_METHOD == 'POST') {
        cw_header_location("index.php?target={$target}&mode=addons&addon={$addon}");
    }
    $smarty->assign('addon', $addon);
    $smarty->assign('addon_name', cw_get_langvar_by_name('addon_name_' . $addon));
    $location[] = array(cw_get_langvar_by_name('lbl_addons'), 'index.php?target=' . $target);
    $location[] = array($addon, '');
コード例 #27
0
function cw_ups_service_type($order)
{
    global $tables;
    if (empty($order['order']['shipping_id'])) {
        return false;
    }
    $shipping = cw_query_first_cell("SELECT shipping FROM {$tables['shipping']} WHERE code = 'UPS' AND shipping_id = '" . $order['order']['shipping_id'] . "'");
    if (empty($shipping)) {
        return false;
    }
    $str = false;
    if (strpos($shipping, "UPS Next Day Air A.M.") === 0 || strpos($shipping, "UPS Next Day Air") === 0 && strpos($shipping, "Early A.M.") !== false) {
        $str = "Next Day Air Early AM";
    } elseif (strpos($shipping, "UPS Next Day Air Saver") === 0) {
        $str = "Next Day Air Saver";
    } elseif (strpos($shipping, "UPS Next Day Air") === 0) {
        $str = "Next Day Air";
    } elseif (strpos($shipping, "UPS 2nd Day Air A.M.") === 0) {
        $str = "2nd Day Air AM";
    } elseif (strpos($shipping, "UPS 2nd Day Air") === 0) {
        $str = "2nd Day Air";
    } elseif (strpos($shipping, "UPS 3 Day Select") === 0) {
        $str = "3 Day Select";
    } elseif (strpos($shipping, "UPS Ground") === 0) {
        $str = "Ground";
    }
    return $str;
}
コード例 #28
0
function cw_dod_generate()
{
    global $tables, $config, $current_language;
    $generator = cw_query_first("select * from {$tables['dod_generators']} where active=1 and startdate<='" . time() . "' and enddate>'" . time() . "'  and dod_interval<>0 order by position asc, generator_id asc");
    if (!empty($generator)) {
        //check last generation date
        $last_gen_date = $generator['current_offer_date'];
        $hrs_since_last_generation = intval((time() - $last_gen_date) / 3600);
        $generate_again = false;
        if ($generator['dod_interval_type'] == 'D') {
            $generate_again = $hrs_since_last_generation >= $generator['dod_interval'] * 24;
            $offer_enddate = min($generator['enddate'], time() + $generator['dod_interval'] * 24 * 3600);
        } elseif ($generator['dod_interval_type'] == 'T') {
            $dod_period_hrs = intval(($generator['enddate'] - $generator['startdate']) / 3600);
            $hrs_interval = intval($dod_period_hrs / $generator['dod_interval']);
            $generate_again = $hrs_since_last_generation >= $hrs_interval;
            $offer_enddate = min($generator['enddate'], time() + $dod_period_hrs / $generator['dod_interval'] * 3600);
        }
        if ($generate_again || $_GET['force_generate']) {
            if (!empty($generator['used_pids'])) {
                $used_pids = explode(';', $generator['used_pids']);
            } else {
                $used_pids = array();
            }
            $dod_products = cw_query_column("select dbd.object_id from {$tables['dod_bonus_details']} dbd inner join {$tables['dod_bonuses']} db on db.generator_id=dbd.generator_id and db.bonus_id=dbd.bonus_id and db.type='" . DOD_DISCOUNT . "' where dbd.generator_id='{$generator['generator_id']}' and dbd.object_type='" . DOD_OBJ_TYPE_PRODS . "'");
            $dod_categories = cw_query_column("select dbd.object_id from {$tables['dod_bonus_details']} dbd inner join {$tables['dod_bonuses']} db on db.generator_id=dbd.generator_id and db.bonus_id=dbd.bonus_id and db.type='" . DOD_DISCOUNT . "' where dbd.generator_id='{$generator['generator_id']}' and dbd.object_type='" . DOD_OBJ_TYPE_CATS . "'");
            $dod_manufacturers = cw_query_column("select dbd.object_id from {$tables['dod_bonus_details']} dbd inner join {$tables['dod_bonuses']} db on db.generator_id=dbd.generator_id and db.bonus_id=dbd.bonus_id and db.type='" . DOD_DISCOUNT . "' where dbd.generator_id='{$generator['generator_id']}' and dbd.object_type='" . DOD_OBJ_TYPE_MANS . "'");
            $dod_attributes = cw_query("select dbd.*  from {$tables['dod_bonus_details']} dbd inner join {$tables['dod_bonuses']} db on db.generator_id=dbd.generator_id and db.bonus_id=dbd.bonus_id and db.type='" . DOD_DISCOUNT . "' where dbd.generator_id='{$generator['generator_id']}' and dbd.object_type='" . DOD_OBJ_TYPE_ATTR . "'");
            //select products by dod conditions
            $data = array();
            $dod_data_where_pids = '';
            if ($dod_products) {
                $dod_data_where_pids = "{$tables['products']}.product_id in ('" . implode("','", $dod_products) . "')";
            }
            if ($dod_categories) {
                $data['search_in_subcategories'] = 1;
                $data['category_ids'] = $dod_categories;
            }
            if ($dod_manufacturers) {
                $manufacturer_id_attribute = cw_query_first_cell("select attribute_id from {$tables['attributes']} where field='manufacturer_id' and addon='manufacturers'");
                if ($manufacturer_id_attribute) {
                    if (!isset($ret_params)) {
                        $ret_params = array();
                    }
                    if (!isset($ret_params['query_joins'])) {
                        $ret_params['query_joins'] = array();
                    }
                    $ret_params['query_joins']['atv_manufacturer'] = array('tblname' => 'attributes_values', 'on' => "{$tables['products']}.product_id=atv_manufacturer.item_id and atv_manufacturer.item_type='P' and atv_manufacturer.attribute_id = '{$manufacturer_id_attribute}' and atv_manufacturer.code in ('{$current_language}', '') and atv_manufacturer.value in ('" . implode("','", $dod_manufacturers) . "')", 'is_inner' => 1);
                }
            }
            if ($dod_attributes) {
                $param2_sql = array('eq' => '=', 'lt' => '<', 'le' => '<=', 'gt' => '>', 'ge' => '=>');
                foreach ($dod_attributes as $attr_data_k => $attr_data) {
                    $is_def_values = cw_query_first("select * from {$tables['attributes_default']} where attribute_value_id='{$attr_data['param1']}' and attribute_id='{$attr_data['object_id']}'");
                    //print_r($is_def_values);print("<br><br>");
                    $sql_operation = $param2_sql[$attr_data['param2']];
                    if (empty($sql_operation)) {
                        continue;
                    }
                    if (!isset($ret_params)) {
                        $ret_params = array();
                    }
                    if (!isset($ret_params['query_joins'])) {
                        $ret_params['query_joins'] = array();
                    }
                    if ($is_def_values) {
                        $ret_params['query_joins']['atv_dod_' . $attr_data_k] = array('tblname' => 'attributes_values', 'on' => "{$tables['products']}.product_id=atv_dod_{$attr_data_k}.item_id and atv_dod_{$attr_data_k}.item_type='P' and atv_dod_{$attr_data_k}.attribute_id = '{$attr_data['object_id']}' and atv_dod_{$attr_data_k}.code in ('{$current_language}', '')", 'is_inner' => 1);
                        $ret_params['query_joins']['atd_dod_' . $attr_data_k] = array('tblname' => 'attributes_default', 'on' => "atd_dod_{$attr_data_k}.attribute_value_id=atv_dod_{$attr_data_k}.value and atv_dod_{$attr_data_k}.attribute_id=atd_dod_{$attr_data_k}.attribute_id and atd_dod_{$attr_data_k}.value{$sql_operation}'" . addslashes($is_def_values['value']) . "'", 'is_inner' => 1);
                    } else {
                        $ret_params['query_joins']['atv_dod_' . $attr_data_k] = array('tblname' => 'attributes_values', 'on' => "{$tables['products']}.product_id=atv_dod_{$attr_data_k}.item_id and atv_dod_{$attr_data_k}.item_type='P' and atv_dod_{$attr_data_k}.attribute_id = '{$attr_data['object_id']}' and atv_dod_{$attr_data_k}.code in ('{$current_language}', '') and atv_dod_{$attr_data_k}.value{$sql_operation}'{$attr_data['param1']}'", 'is_inner' => 1);
                    }
                }
            }
            global $user_account, $current_area, $items_per_page_targets, $target;
            $items_per_page_targets[$target] = 1;
            $new_pid = 0;
            $safety_cnt = 1000;
            while (!$new_pid && $safety_cnt > 0) {
                if (!empty($data) || !empty($dod_data_where_pids)) {
                    $data['sort_field'] = 'rand';
                    $data['flat_search'] = 1;
                    $dod_data_where = array();
                    if (!empty($dod_data_where_pids)) {
                        $dod_data_where[] = $dod_data_where_pids;
                    }
                    if (!empty($used_pids)) {
                        $dod_data_where[] = "{$tables['products']}.product_id not in ('" . implode("','", $used_pids) . "')";
                    }
                    $data['where'] = implode(' and ', $dod_data_where);
                    list($products, $nav, $product_filter) = cw_func_call('cw_product_search', array('data' => $data, 'user_account' => $user_account, 'current_area' => $current_area, 'info_type' => 8, 'product_id_only' => 1), $ret_params);
                }
                $product = reset($products);
                //print_r(array('product'=>$product));print("<br><br>");
                $new_pid = $product['product_id'];
                if (!$new_pid) {
                    if ($generator['no_item_repeat']) {
                        break;
                    } else {
                        if (!empty($used_pids)) {
                            array_shift($used_pids);
                        } else {
                            break;
                        }
                    }
                }
                $safety_cnt--;
            }
            //die;
            if ($new_pid) {
                $used_pids[] = $new_pid;
            }
            $generator['used_pids'] = implode(';', $used_pids);
            $regenerate_offer = true;
            if ($regenerate_offer) {
                //regenerate offer
                if (!empty($generator['current_offer_id'])) {
                    $offer_ids = array($generator['current_offer_id']);
                    $offer_ids_query = implode("', '", $offer_ids);
                    db_query("DELETE FROM {$tables['ps_offers']} WHERE offer_id IN ('" . $offer_ids_query . "')");
                    db_query("DELETE FROM {$tables['ps_bonuses']} WHERE offer_id IN ('" . $offer_ids_query . "')");
                    db_query("DELETE FROM {$tables['ps_bonus_details']} WHERE offer_id IN ('" . $offer_ids_query . "')");
                    db_query("DELETE FROM {$tables['ps_conditions']} WHERE offer_id IN ('" . $offer_ids_query . "')");
                    db_query("DELETE FROM {$tables['ps_cond_details']} WHERE offer_id IN ('" . $offer_ids_query . "')");
                    db_query("DELETE FROM {$tables['attributes_values']} WHERE item_id IN ('" . $offer_ids_query . "') and item_type='PS'");
                    foreach ($offer_ids as $offer_id) {
                        cw_image_delete($offer_id, PS_IMG_TYPE);
                    }
                    cw_attributes_cleanup($offer_ids, PS_ATTR_ITEM_TYPE);
                    cw_cache_clean('shipping_rates');
                }
                if ($new_pid) {
                    cw_log_add('dod_generator', array('new DOD product selected' => $new_pid));
                    $new_offer_id = cw_array2insert('ps_offers', array('title' => 'Deal Of The Day', 'description' => $generator['description'], 'startdate' => time(), 'enddate' => $offer_enddate, 'active' => 1));
                }
                $current_offer_id = 0;
                if ($new_offer_id) {
                    $mdm_attribute_id = cw_query_first_cell("select attribute_id from {$tables['attributes']} where addon='multi_domains' and item_type='PS'");
                    if ($mdm_attribute_id) {
                        cw_array2insert('attributes_values', array('item_id' => $new_offer_id, 'attribute_id' => $mdm_attribute_id, 'value' => 0, 'code' => '', 'item_type' => 'PS'));
                    }
                    //copy bonus and bonus details
                    $dod_bonuses = cw_query("select * from {$tables['dod_bonuses']} where generator_id='{$generator['generator_id']}' and unused=0");
                    foreach ($dod_bonuses as $dod_bonus) {
                        $_dod_bonus = $dod_bonus;
                        unset($_dod_bonus['generator_id']);
                        $_dod_bonus['offer_id'] = $new_offer_id;
                        $new_bonus_id = cw_array2insert('ps_bonuses', $_dod_bonus);
                        if ($_dod_bonus['type'] == 'D' && $_dod_bonus['apply'] == 3) {
                            cw_array2insert('ps_bonus_details', array('bonus_id' => $new_bonus_id, 'offer_id' => $new_offer_id, 'object_id' => $new_pid, 'quantity' => 1, 'object_type' => DOD_OBJ_TYPE_PRODS));
                        } else {
                            $dod_bonus_details = cw_query("select * from {$tables['dod_bonus_details']} where generator_id='{$generator['generator_id']}' and bonus_id='{$dod_bonus['bonus_id']}'");
                            if (!empty($dod_bonus_details)) {
                                foreach ($dod_bonus_details as $dod_bonus_detail) {
                                    $_dod_bonus_detail = $dod_bonus_detail;
                                    unset($_dod_bonus_detail['generator_id']);
                                    $_dod_bonus_detail['offer_id'] = $new_offer_id;
                                    $_dod_bonus_detail['bonus_id'] = $new_bonus_id;
                                    cw_array2insert('ps_bonus_details', $_dod_bonus_detail);
                                }
                            }
                        }
                    }
                    $new_cond_id = cw_array2insert('ps_conditions', array('type' => 'P', 'total' => '0.00', 'offer_id' => $new_offer_id));
                    if ($new_cond_id) {
                        cw_array2insert('ps_cond_details', array('cond_id' => $new_cond_id, 'offer_id' => $new_offer_id, 'object_id' => $new_pid, 'quantity' => 1, 'object_type' => DOD_OBJ_TYPE_PRODS));
                    }
                    $current_offer_id = $new_offer_id;
                }
            }
            //update dod_generator fields
            cw_array2update('dod_generators', array('current_offer_id' => $current_offer_id, 'used_pids' => $generator['used_pids'], 'current_offer_date' => $current_offer_id ? time() : 0), "generator_id='{$generator['generator_id']}'");
            if ($current_offer_id && !empty($config['deal_of_day']['dod_news_template']) && $config['deal_of_day']['dod_newslist']) {
                $newslist = cw_query_first("select * from {$tables['newslists']} where list_id='" . $config['deal_of_day']['dod_newslist'] . "' and avail=1");
                if (!empty($newslist)) {
                    //create message
                    global $smarty;
                    $smarty->assign('promotion', $generator);
                    $smarty->assign('product_id', $new_pid);
                    $product_info = cw_func_call('cw_product_get', array('id' => $new_pid, 'user_account' => $user_account, 'info_type' => 65535));
                    $smarty->assign('product', $product_info);
                    $smarty->assign('news_message', $config['deal_of_day']['dod_news_template']);
                    $message = cw_display("addons/deal_of_day/admin/generate_news.tpl", $smarty, false, $newslist['lngcode']);
                    $smarty->assign('news_message', $config['deal_of_day']['dod_news_template_subject']);
                    $message_subject = cw_display("addons/deal_of_day/admin/generate_news.tpl", $smarty, false, $newslist['lngcode']);
                    //                    $message = $smarty->display('addons/deal_of_day/admin/generate_news.tpl');
                    print $message_subject . "<hr />" . $message;
                    if (!empty($message)) {
                        cw_array2insert('newsletter', array('subject' => $message_subject, 'body' => $message, 'created_date' => time(), 'send_date' => time(), 'updated_date' => time(), 'status' => 'N', 'list_id' => $config['deal_of_day']['dod_newslist'], 'show_as_news' => 1, 'allow_html' => 1));
                    }
                }
            }
        }
    }
    return $new_pid;
}
コード例 #29
0
<?php

if (cw_query_first_cell("SELECT COUNT(*) FROM {$tables['categories']} WHERE category_id='{$cat}'") == 0) {
    cw_header_location('index.php?target=categories');
}
$category_page =& cw_session_register('category_page');
$data = array();
$data['flat_search'] = 1;
$data['category_id'] = $cat;
$data['category_main'] = "Y";
$data['category_extra'] = "Y";
$data['page'] = $page;
$data['objects_per_page'] = $category_page['objects_per_page'];
$data['sort_field'] = $category_page['sort_field'];
$data['sort_direction'] = $category_page['sort_direction'];
list($products, $navigation) = cw_func_call('cw_product_search', array('data' => $data, 'user_account' => $user_account, 'current_area' => $current_area, 'info_type' => 0));
$navigation['script'] = 'index.php?target=' . $target . '&mode=' . $mode . '&cat=' . $cat;
$smarty->assign('navigation', $navigation);
$smarty->assign('products', $products);
$smarty->assign('current_category', cw_func_call('cw_category_get', array('cat' => $cat)));
$smarty->assign('main', 'category_products');
コード例 #30
0
 $list = cw_query_first("select * from {$tables['newslists']} WHERE list_id='{$list_id}'");
 if (empty($list['list_id'])) {
     $top_message['content'] = cw_get_langvar_by_name('msg_adm_err_newslist_not_exists');
     cw_header_location('index.php?target=' . $target);
 } else {
     if ($list['lngcode'] != $current_language && is_array($d_langs) && !in_array($list['lngcode'], $d_langs)) {
         cw_header_location("index.php?target={$target}&mode=modify&list_id={$list_id}&edit_lng={$list['lngcode']}&old_lng={$current_language}");
     }
 }
 $memberships = cw_query("select membership_id from {$tables['newslists_memberships']} where list_id='{$list['list_id']}'");
 if ($memberships) {
     foreach ($memberships as $val) {
         $list['memberships'][$val['membership_id']] = true;
     }
 }
 $list_idname = cw_query_first_cell("SELECT name FROM {$tables['newslists']} WHERE list_id='{$list_id}'");
 $smarty->assign('list_idname', $list_idname);
 $smarty->assign('list_id', $list_id);
 $smarty->assign('list', $list);
 # subscribers tabs
 $total_items = count($subscribers = cw_call('cw\\news\\get_subscribers', array($list_id)));
 if (!empty($total_items)) {
     $navigation = cw_core_get_navigation($target, $total_items, $page);
     $navigation['script'] = "index.php?target={$target}&js_tab=subscriptions&list_id=" . $list_id;
     $smarty->assign('navigation', $navigation);
     $subscribers = array_slice($subscribers, $navigation['first_page'], $navigation['objects_per_page']);
 }
 $smarty->assign('subscribers', $subscribers);
 # messages tab
 cw_load('map');
 $countries = cw_map_get_countries();