function product_stages_add()
{
    global $new_product_stage, $REQUEST_METHOD, $product_id, $default_status;
    if ($REQUEST_METHOD == "POST") {
        $new_stage_data = array('product_id' => $product_id, 'stage_lib_id' => $new_product_stage['stage_lib_id'], 'period' => $new_product_stage['period'], 'status' => !empty($default_status['new_product_stage']) ? '-1' : (!empty($new_product_stage['status']) ? serialize($new_product_stage['status']) : ''), 'active' => !empty($new_product_stage['active']) ? 1 : 0);
        cw_array2insert('product_stages_product_settings', $new_stage_data);
        cw_header_location("index.php?target=products&mode=details&product_id={$product_id}&js_tab=product_stages");
    }
}
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;
}
function ab_redirect($product_id = 0)
{
    global $app_catalogs, $target, $mode;
    $productid_url_param = null;
    if (!empty($product_id)) {
        $product_id = (int) $product_id;
        $productid_url_param = '&product_id=' . $product_id;
    }
    cw_header_location("{$app_catalogs['admin']}/index.php?target={$target}&mode={$mode}&js_tab=cms{$productid_url_param}");
}
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 delete()
{
    global $posted_data, $REQUEST_METHOD, $tables;
    if ($REQUEST_METHOD == "POST") {
        foreach ($posted_data as $lib_id => $stage_data) {
            if (!$stage_data['deleted']) {
                continue;
            }
            db_query("delete from {$tables['product_stages_library']} where stage_lib_id='{$lib_id}'");
            db_query("delete from {$tables['product_stages_product_settings']} where stage_lib_id='{$lib_id}'");
        }
        cw_header_location("index.php?target=product_stages");
    }
}
function cw_user_delete($params)
{
    global $var_dirs, $tables, $config;
    global $addons;
    global $smarty;
    extract($params);
    // damn extract
    //    $customer_id, $send_mail, $is_redirect = true
    $customer_id = isset($customer_id) ? $customer_id : 0;
    $send_mail = isset($send_mail) ? $send_mail : false;
    $is_redirect = isset($is_redirect) ? $is_redirect : true;
    cw_load('files', 'product', 'mail');
    $olduser_info = cw_user_get_info($customer_id, 65535);
    $to_customer = $olduser_info['language'];
    $usertype = $olduser_info['usertype'];
    if ($usertype == "A") {
        $users_count = cw_query_first_cell("SELECT COUNT(*) FROM {$tables['customers']} WHERE usertype='A'");
        if ($users_count == 1) {
            if ($is_redirect) {
                cw_header_location("index.php?target=error_message&error=last_admin");
            }
            return false;
        }
    }
    /*
    # kornev, TOFIX
    	if ($usertype == "B" && cw_query_first_cell("SELECT COUNT(*) FROM $tables[addons] WHERE addon='Salesman'") > 0) {
    		include $app_main_dir."/addons/Salesman/init.php";
    
    		db_query("delete FROM $tables[salesman_clicks] WHERE salesman_customer_id='$customer_id'");
    		db_query("delete FROM $tables[salesman_commissions] WHERE salesman_customer_id='$customer_id'");
    		db_query("delete FROM $tables[salesman_payment] WHERE salesman_customer_id='$customer_id'");
    		db_query("delete from $tables[salesman_views] WHERE salesman_customer_id='$customer_id'");
    		db_query("UPDATE $tables[customers_salesman_info] SET parent_customer_id=0 WHERE customer_id = '$customer_id' AND usertype = 'B'");
    	}
    */
    \Customer\delete($customer_id);
    $main_tables = array('register_fields_values', 'customers_ccinfo', 'customers_settings', 'customers_relations', 'customers_salesman_info', 'customers_customer_info', 'customers_warehouse_info', 'customers_system_info');
    foreach ($main_tables as $v) {
        db_query("delete from " . $tables[$v] . " where customer_id='{$customer_id}'");
    }
    $smarty->assign('userinfo', $olduser_info);
    $anonymous_user = cw_is_anonymous($olduser_info['email']);
    if (!$anonymous_user && $config['Email']['eml_profile_deleted'] == 'Y' && $send_mail) {
        cw_call('cw_send_mail', array($config['Company']['users_department'], $olduser_info['email'], 'mail/profile_deleted_subj.tpl', 'mail/profile_deleted.tpl'));
    }
    if (!$anonymous_user && $config['Email']['eml_profile_deleted_admin'] == 'Y' && $send_mail) {
        cw_call('cw_send_mail', array($olduser_info['email'], $config['Company']['users_department'], 'mail/profile_deleted_subj.tpl', 'mail/profile_admin_deleted.tpl', $config['default_admin_language']));
    }
}
function cw_refresh($product_id, $js_tab = '', $added = '')
{
    global $ge_id, $target;
    if (!empty($js_tab)) {
        $js_tab = "&js_tab=" . $js_tab;
    }
    if (!empty($ge_id)) {
        $redirect_ge_id = "&ge_id=" . $ge_id;
    }
    if ($product_id) {
        cw_header_location("index.php?target={$target}&mode=details&product_id=" . $product_id . $redirect_ge_id . $js_tab . $added);
    } else {
        cw_header_location("index.php?target={$target}&mode=add");
    }
}
function cw_dpi_refresh($product_id)
{
    global $app_catalogs, $target, $ge_id;
    $productid_url_param = null;
    if (!empty($product_id)) {
        $product_id = (int) $product_id;
        $productid_url_param = '&product_id=' . $product_id;
    }
    $ge_id_url_param = null;
    if (!empty($ge_id)) {
        $ge_id = (int) $ge_id;
        $ge_id_url_param = '&ge_id=' . $ge_id;
    }
    if (!empty($product_id)) {
        cw_header_location("{$app_catalogs['admin']}/index.php?target={$target}&mode=details&js_tab=dpi{$productid_url_param}{$ge_id_url_param}");
    } else {
        cw_header_location("{$app_catalogs['admin']}/index.php?target={$target}&mode=add");
    }
}
function cw_fbauth_user_logout()
{
    global $action;
    $fb_access_token = cw_session_register('fb_access_token');
    $fb_referer = cw_session_register('fb_referer');
    $referer_url = !empty($fb_referer) ? $fb_referer : 'index.php';
    cw_session_unregister('fb_referer');
    if ($fb_access_token) {
        $graph_url = "https://graph.facebook.com/me/permissions?method=delete&access_token=" . $fb_access_token;
        $result = cw_fbauth_get_ssl_page($graph_url);
        if ($result['error']) {
            $top_message = array('type' => 'E', 'content' => $result['error']);
            cw_header_location($referer_url, TRUE);
        }
        $result = json_decode($result['result']);
        if ($result) {
            cw_session_unregister('fb_access_token');
        }
    }
}
Esempio n. 11
0
function cw_payment_authorize_sim_run_processor($params, $return)
{
    if ($params['payment_data']['processor'] == authorize_sim_addon_name) {
        global $config, $tables, $current_location, $cart, $APP_SESS_ID;
        $addon_name = str_replace("-", "_", authorize_sim_addon_name);
        $asim_api_login_id = $config[$addon_name]['asim_api_login_id'];
        $asim_transaction_key = $config[$addon_name]['asim_transaction_key'];
        $asim_md5_hash = $config[$addon_name]['asim_md5_hash'];
        $asim_mode = $config[$addon_name]['asim_test_live_mode'];
        $asim_currency = $config[$addon_name]['asim_currency'];
        $asim_prefix = intval($config[$addon_name]['asim_prefix']);
        if (empty($asim_api_login_id) || empty($asim_transaction_key)) {
            $top_message = array("content" => "Enter your merchant credentials on settings page before running the payment.", "type" => "E");
            cw_header_location($current_location . "index.php?target=cart&mode=checkout");
        }
        define("AUTHORIZENET_API_LOGIN_ID", $asim_api_login_id);
        define("AUTHORIZENET_TRANSACTION_KEY", $asim_transaction_key);
        define("AUTHORIZENET_SANDBOX", $asim_mode == "live" ? FALSE : TRUE);
        define("AUTHORIZENET_MD5_SETTING", $asim_md5_hash);
        $payment_data = $params['payment_data'];
        $userinfo = $params['userinfo'];
        $doc_ids = $params['doc_ids'];
        $cart =& cw_session_register('cart');
        $time = time();
        $asim_amount = price_format($cart['info']['total']);
        $asim_fp_sequence = $asim_prefix . $time;
        $asim_fp_hash = AuthorizeNetDPM::getFingerprint($asim_api_login_id, $asim_transaction_key, $asim_amount, $asim_fp_sequence, $time);
        $asim_fp_timestamp = $time;
        $asim_relay_url = $current_location . '/index.php?target=' . authorize_sim_addon_target;
        // save $APP_SESS_ID
        $unique_id = strtolower(md5($asim_md5_hash . $asim_api_login_id . $userinfo['email']));
        db_query("INSERT INTO {$tables['payment_data']} (ref_id, session_id) VALUES ('{$unique_id}', '{$APP_SESS_ID}')");
        $card_expire_Month = intval($_POST['card_expire_Month']);
        $card_expire_Year = intval($_POST['card_expire_Year']);
        cw_func_call('cw_payment_create_form', array('url' => AUTHORIZENET_SANDBOX ? AuthorizeNetDPM::SANDBOX_URL : AuthorizeNetDPM::LIVE_URL, 'fields' => array('x_relay_response' => "FALSE", 'x_version' => "3.1", 'x_delim_char' => ",", 'x_delim_data' => "TRUE", 'x_amount' => $asim_amount, 'x_fp_sequence' => $asim_fp_sequence, 'x_fp_hash' => $asim_fp_hash, 'x_fp_timestamp' => $time, 'x_relay_response' => "TRUE", 'x_relay_url' => $asim_relay_url, 'x_login' => $asim_api_login_id, 'x_card_num' => $_POST['card_number'], 'x_exp_date' => date("m/y", mktime(0, 0, 0, $card_expire_Month, 1, $card_expire_Year)), 'x_card_code' => $_POST['card_cvv2'], 'x_first_name' => $_POST['first_name'], 'x_last_name' => $_POST['last_name'], 'x_address' => $_POST['address'], 'x_city' => $_POST['city'], 'x_state' => $_POST['state'], 'x_zip' => $_POST['zipcode'], 'x_country' => $_POST['country'], 'x_email' => $userinfo['email']), 'name' => $payment_data['title']));
        exit;
    }
    return $return;
}
<?php

// TODO: DELETE THIS CONTROLLER
if (!$addons['Gift_Registry']) {
    cw_header_location('index.php');
}
$access_status =& cw_session_register("access_status", array());
if ($mode == "preview") {
    $html_content = cw_query_first_cell("SELECT html_content FROM {$tables['giftreg_events']} WHERE event_id='{$eventid}'");
    if (!empty($html_content)) {
        echo $html_content;
    } else {
        echo "<br /><br /><br /><br /><h3 align=\"center\">" . cw_get_langvar_by_name("lbl_no_html_content", false, false, true) . "</h3>";
    }
    exit;
}
if (!empty($cc)) {
    # Confirm/Decline the participation by recipient
    # $cc - is a confirmation code passed via GET request
    cw_include('addons/Gift_Registry/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/Gift_Registry/event_guestbook.php');
    cw_include('addons/Gift_Registry/giftreg_display.php');
            if ($v['name']) {
                cw_profile_fields_add_section($v);
            }
        } else {
            cw_profile_fields_update_section($k, $v);
        }
    }
    cw_header_location("index.php?target={$target}&mode=fields&js_tab=addition_section");
}
if ($action == 'delete_sections') {
    foreach ($update as $k => $v) {
        if ($v['del'] == 'Y') {
            cw_profile_fields_delete_section($k);
        }
    }
    cw_header_location("index.php?target={$target}&mode=fields&js_tab=addition_section");
}
$membership_titles = array();
$usertypes_array = array();
$usertypes_array[$user_type] = '';
if (in_array($user_type, array('C'))) {
    $customer_memberships = cw_user_get_memberships($user_type);
    if (is_array($customer_memberships)) {
        foreach ($customer_memberships as $val) {
            $usertypes_array[$user_type . '_' . $val['membership_id']] = '';
            $membership_titles[$user_type . '_' . $val['membership_id']] = $val['membership'];
        }
    }
}
$smarty->assign('membership_titles', $membership_titles);
$smarty->assign('customer_memberships', $customer_memberships);
<?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');
Esempio n. 15
0
        $nwslt_object['fill_error'] = $fill_error;
        $nwslt_object['list'] = $list;
        cw_header_location("index.php?target={$target}&list_id=" . $list['list_id']);
    }
    cw_header_location("index.php?target={$target}&list_id=" . $list['list_id']);
}
$location[] = array(cw_get_langvar_by_name('lbl_news_management'), 'index.php?target=' . $target);
if (isset($_GET['list_id'])) {
    if (!empty($list_id)) {
        $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)) {
if ($REQUEST_METHOD == "POST" && $action == "update") {
    $poptions = $_POST['product_options'];
    if (!cw_check_product_options($product_id, $poptions)) {
        cw_header_location("index.php?target=popup_poptions&target={$target}&id={$id}&err=exception");
    }
    if ($mode == 'wishlist') {
        db_query("UPDATE {$tables['wishlist']} SET options = '" . addslashes(serialize($poptions)) . "' WHERE wishlist_id = '{$id}' AND event_id = '{$eventid}'");
    } else {
        $variant_id = cw_get_variant_id($product_options, $product_id);
        $amount = cw_warehouse_get_warehouse_avail($cart['products'][$cartindex]['warehouse'], $product_id, null, $variant_id);
        //		$amount = cw_get_options_amount($poptions, $cart['products'][$cartindex]['product_id']);
        if ($amount >= $cart['products'][$cartindex]['amount']) {
            $cart['products'][$cartindex]['options'] = $poptions;
            cw_unset($cart['products'][$cartindex], 'variant_id');
        } else {
            cw_header_location("index.php?target=popup_poptions&target={$target}&id={$id}&err=avail");
        }
        # 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;
}
        $mysql_db = $app_config_file['sql']['db'];
        $mysql_user = $app_config_file['sql']['user'];
        $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)) . "')");
                        cw_doc_make_relation($relation_doc_id, $rel_item_id, $v['amount']);
                    }
                    cw_doc_recalc($relation_doc_id);
                }
            }
            if ($doc_data['giftcerts'] && is_numeric($relation_doc_id)) {
                cw_doc_make_related_doc($doc_id, $relation_doc_id);
            }
        }
    }
    $secure_oid = $doc_ids;
} else {
    $doc_ids = $secure_oid;
}
cw_session_save();
if ($action == 'request_for_quote') {
    cw_call('cw_doc_change_status', array($doc_ids, "Q"));
    $request = $app_catalogs['customer'] . "/index.php?target=order-message&doc_ids=" . implode(",", $doc_ids);
    $cart = $secure_oid = array();
    cw_save_customer_cart($customer_id, $cart);
    cw_header_location($request);
} else {
    $return = cw_func_call('cw_payment_run_processor', array('payment_data' => $payment_data, 'doc_ids' => $doc_ids, 'userinfo' => $userinfo));
    if ($return && $payment_data['payment_type'] == 'cc') {
        $a = strlen($userinfo['card_cvv2']);
        $return['cvvmes'] = ($a ? $a . " digit(s)" : "not set") . " / ";
    }
    $return = cw_call('cw_payment_check_results', array($return));
    cw_call('cw_payment_stop', array($return));
}
exit;
    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, '');
    $smarty->assign('main', 'addon_settings');
} elseif (empty($addon)) {
    $addons = cw_addons_get();
    if (!isset($status) || empty($status)) {
        $status = constant('ADDON_TYPE_GENERAL');
    }
    foreach ($addons as $k => $v) {
        if ($v['status'] < $status) {
            unset($addons[$k]);
        }
<?php

global $docs_type;
$docs_type = 'O';
cw_load('doc');
$search_data =& cw_session_register('search_data');
$search_data['orders'][$docs_type]['warehouse_area'] = $customer_id;
if ($doc_id) {
    $doc_data = cw_call('cw_doc_get', array($request_prepared['doc_id'], 0));
    if ($customer_id != $doc_data['info']['warehouse_customer_id']) {
        cw_header_location("index.php?target=error_message&error=access_denied&id=40");
    }
    cw_include('include/orders/order.php');
} else {
    cw_include('include/orders/orders.php');
}
$smarty->assign('page_acl', '__18');
$smarty->assign('current_section_dir', 'orders');
<?php

global $docs_type;
$docs_type = 'O';
cw_load('doc');
if ($action == 'add') {
    $doc_id = cw_doc_create_empty($docs_type . '_');
    // Create temporary doc_type until first POST request
    cw_header_location("index.php?target={$target}&doc_id={$doc_id}&mode=edit");
} elseif ($doc_id) {
    cw_include('include/orders/order.php');
} else {
    cw_include('include/orders/orders.php');
}
$smarty->assign('page_acl', '__18');
        foreach ($rating as $attr_id => $vote) {
            // update vote value
            $exists = cw_query_first_cell("SELECT vote_id FROM {$tables['products_votes']} WHERE review_id = '{$review_id}' AND attribute_id ='{$attr_id}'");
            if ($exists) {
                cw_array2update('products_votes', array('vote_value' => $vote), "review_id = '{$review_id}' AND attribute_id ='{$attr_id}'");
            } else {
                cw_array2insert('products_votes', array('remote_ip' => $review_data['remote_ip'], 'vote_value' => $vote, 'product_id' => $review_data['product_id'], 'customer_id' => $review_data['customer_id'], 'review_id' => $review_id, 'attribute_id' => $attr_id));
            }
            cw_review_recalculate_avg_rating($review_data['product_id'], $attr_id);
        }
        cw_review_recalculate_avg_rating($review_data['product_id']);
        cw_add_top_message(cw_get_langvar_by_name('txt_thank_you_for_review'));
    } else {
        cw_add_top_message(cw_get_langvar_by_name('err_filling_form'), 'E');
    }
    cw_header_location("index.php?target=global_reviews");
}
$items_per_page_targets[$target] = 10;
$total_items = cw_call('cw_review_get_global_review', array());
$navigation = cw_core_get_navigation($target, $total_items, $page);
$global_reviews = cw_call('cw_review_get_global_review', array('', '', " ORDER BY {$tables['products_reviews']}.ctime DESC ", "LIMIT {$navigation['first_page']}, {$navigation['objects_per_page']}", FALSE));
$items_per_page_targets[$target] = PHP_INT_MAX;
$navigation['script'] = 'index.php?target=' . $target;
$smarty->assign('navigation', $navigation);
if (!empty($global_reviews)) {
    $rating_cond = "type='global_rating'";
    list($attributes, $nav) = cw_func_call('cw_attributes_search', array('data' => array('active' => 1, 'is_show' => 1, 'sort_field' => 'orderby')), array('where' => array($rating_cond)));
    if (!empty($attributes)) {
        foreach ($global_reviews as $rev_k => $rev_v) {
            $global_reviews[$rev_k]['votes'] = array();
            foreach ($attributes as $att) {
Esempio n. 23
0
<?php

if ($action == 'generate_group') {
    cw_load('doc');
    cw_doc_generate_group(array_keys($docs));
    cw_header_location("index.php?target={$target}&mode={$mode}&user={$user}");
}
$search =& cw_session_register('search');
if (isset($_GET['doc_type'])) {
    $search['placed_docs']['doc_type'] = $doc_type;
}
if (isset($_GET['fromdate'])) {
    if (empty($fromdate)) {
        $search['placed_docs']['basic']['creation_date_start'] = 0;
    } else {
        $search['placed_docs']['basic']['creation_date_start'] = cw_core_strtotime($fromdate);
    }
}
if (isset($_GET['todate'])) {
    if (empty($fromdate)) {
        $search['placed_docs']['basic']['creation_date_end'] = 0;
    } else {
        $search['placed_docs']['basic']['creation_date_end'] = cw_core_strtotime($todate) + 86399;
    }
}
$search['placed_docs']['basic']['customer_id'] = $user;
$_tmp_cond = $search_data['orders'];
if ($search['placed_docs']['doc_type']) {
    $docs_type = $search['placed_docs']['doc_type'];
} else {
    $docs_type = 'O';
    return false;
}
if (empty($request_prepared['doc_id'])) {
    return error('Param doc_id is empty');
}
cw_load('doc');
$order = cw_call('cw_doc_get', array($request_prepared['doc_id']));
if (!$order) {
    return error(cw_get_langvar_by_name('lbl_order_not_found'));
}
// Call action
$action_result = cw_call($action_function, array($order));
if (is_error($action_result)) {
    cw_add_top_message($action_result->getMessage(), 'E');
}
cw_header_location("index.php?target=docs_O&mode=details&js_tab=process&doc_id=" . $doc_id);
/* ================================================================================== */
/* Actions */
// Capture pre-authorized payment transaction
function cw_payment_process_capture($order)
{
    global $config;
    $doc_id = $order['doc_id'];
    $result = cw_call('cw_payment_do_capture', array($order));
    if (!is_error($result)) {
        cw_call('cw_doc_place_extras_data', array($doc_id, array('capture_status' => 'C', 'captured_amount' => $order['info']['total'])));
        cw_call('cw_doc_change_status', array($doc_id, cw_call('cw_payment_doc_status_after_capture', array($result))));
        cw_add_top_message($config['General']['currency_symbol'] . $order['info']['total'] . ' successfully captured, order status is changed to Processed');
    }
    return $result;
}
<?php

if (!$customer_id && !empty($mode) && $mode != 'wishlist') {
    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'])) {
function dod_redirect($generator_id = null, $action = null, $js_tab = null)
{
    global $app_catalogs, $target, $mode;
    $generator_condition = null;
    if (!is_null($generator_id) && $generator_id === 0) {
        $generator_condition = '&generator_id=';
    }
    if (!empty($generator_id)) {
        $generator_condition = '&generator_id=' . (int) $generator_id;
    }
    $action_condition = null;
    if (!empty($action)) {
        $action_condition = '&action=' . (string) $action;
    }
    $js_tab_condition = null;
    if (!empty($js_tab)) {
        $js_tab_condition = '&js_tab=' . (string) $js_tab;
    }
    cw_header_location("{$app_catalogs['admin']}/index.php?target={$target}&mode={$mode}{$action_condition}{$generator_condition}{$js_tab_condition}");
    //cw_header_location("$app_catalogs[admin]/index.php?target=$target&mode=$mode");
}
            // Update addresses in session from database
            $user_address =& cw_session_register('user_address', array());
            $user_address['current_address'] = cw_user_get_address($customer_id, 'current');
            $user_address['main_address'] = cw_user_get_address($customer_id, 'main');
            db_query("update {$tables['customers_system_info']} set last_login='******' where customer_id='{$customer_id}'");
            $current_language = $user_data['language'];
            $items_per_page_targets = cw_core_restore_navigation($customer_id);
            cw_include('init/lng.php');
            $cart =& cw_session_register('cart', array());
            if ($current_area == "C" && cw_is_cart_empty($cart)) {
                $cart = cw_user_get_stored_cart($customer_id);
            }
            $userinfo = cw_user_get_info($customer_id);
            $products = cw_call('cw_products_in_cart', array($cart, $userinfo));
            $cart = cw_func_call('cw_cart_calc', array('cart' => $cart, 'products' => $products, 'userinfo' => $userinfo));
            cw_event('on_login', array($customer_id, $current_area, 0));
            if (!empty($instagram_login_info['return_url'])) {
                cw_header_location($instagram_login_info['return_url']);
            } else {
                cw_header_location($instagram_redirect_url);
            }
        }
    } else {
        //For Guest user, get instagram login url
        $instagram_login_authUrl = $instagram->getLoginUrl();
        $smarty->assign('instagram_login_authUrl', $instagram_login_authUrl);
        if (!$is_ajax) {
            $instagram_login_info['return_url'] = $current_host_location . $_SERVER['REQUEST_URI'];
        }
    }
}
        $zone_data['warehouse_customer_id'] = $user_account['warehouse_customer_id'];
        $zone_data['zone_name'] = $zone_data['zone_name'] . " (clone)";
        foreach ($zone_data as $k => $v) {
            $zone_data[$k] = "'" . addslashes($v) . "'";
        }
        db_query("INSERT INTO {$tables['zones']} (" . implode(",", array_keys($zone_data)) . ") VALUES (" . implode(",", $zone_data) . ")");
        $new_zone_id = db_insert_id();
        $zone_elements = cw_query("SELECT * FROM {$tables['zone_element']} WHERE zone_id='{$zone_id}'");
        if (is_array($zone_elements)) {
            foreach ($zone_elements as $k => $zone_element) {
                db_query("INSERT INTO {$tables['zone_element']} (zone_id, field, field_type) VALUES ('{$new_zone_id}', '" . addslashes($zone_element['field']) . "', '{$zone_element['field_type']}')");
            }
        }
        $top_message['content'] = cw_get_langvar_by_name("msg_zone_cloned");
    }
    cw_header_location('index.php?target=' . $target . '&zone_id=' . $new_zone_id);
}
$location[] = array(cw_get_langvar_by_name("lbl_destination_zones"), "");
if ($mode == "add" or !empty($zone_id)) {
    #
    # Display zone details page
    #
    $location[count($location) - 1][1] = "index.php?target=zones";
    $location[] = array(cw_get_langvar_by_name("lbl_zone_details"), "");
    if (!empty($zone_id)) {
        $zone = cw_query_first("SELECT * FROM {$tables['zones']} WHERE zone_id='{$zone_id}' {$zones_condition}");
    }
    if (empty($zone)) {
        $action = "add";
    }
    #
 if ($_POST['local_file']) {
     if ($fd = cw_fopen($sqldump_file, "r", true)) {
         $source_file = "local";
     }
 }
 if ($source_file == "uploaded") {
     $userfile = cw_move_uploaded_file("userfile");
 } else {
     $userfile = $sqldump_file;
 }
 $fp = cw_fopen($userfile, "rb", true);
 if ($fp === false) {
     $top_message['content'] = cw_get_langvar_by_name("msg_adm_err_sql_file_not_found");
     $top_message['type'] = "E";
     cw_log_flag('log_database', 'DATABASE', $log_prefix . cw_get_langvar_by_name("msg_adm_err_sql_file_not_found", false, false, true));
     cw_header_location("index.php?target=db_backup");
 }
 $command = "";
 echo cw_get_langvar_by_name("lbl_please_wait", false, false, true) . "<br />\n";
 $cmdcnt = 0;
 while (!feof($fp)) {
     $c = fgets($fp, 1500000);
     $c = chop($c);
     $c = ereg_replace("^[ \t]*(#|-- |---*).*", "", $c);
     $command .= $c;
     if (ereg(";\$", $command)) {
         $command = ereg_replace(";\$", "", $command);
         /*
                     $flg = false;
                     foreach($deprecated_tables as $k) {
                         $flg |=     
Esempio n. 30
0
<?php

# [TOFIX]
# kornev, fix the whole area - move to addon
define('AREA_TYPE', 'B');
$current_area = AREA_TYPE;
$customer_id =& cw_session_register('customer_id');
$top_message =& cw_session_register('top_message', array());
if (!empty($top_message)) {
    $smarty->assign('top_message', $top_message);
    $top_message = '';
}
cw_include('init/lng.php');
cw_include('include/check_useraccount.php');
cw_include('include/area_sections.php');
$smarty->assign('current_target', $target);
if (!$addons['salesman']) {
    cw_header_location($app_catalogs['customer']);
}
$location = array();
$location[] = array(cw_get_langvar_by_name('lbl_area_salesman'), 'index.php');
cw_call('cw_auth_security');