function cw_var_dump()
{
    static $count = 0;
    global $customer_id;
    $args = func_get_args();
    $msg = "<div align=\"left\"><pre><font>";
    $log = "Logged as: {$customer_id}\n";
    if (!empty($args)) {
        foreach ($args as $index => $variable_content) {
            $msg .= "<b>Debug [" . $index . '/' . $count . "]:</b> ";
            $log .= "Debug [" . $index . '/' . $count . "]: ";
            ob_start();
            var_dump($variable_content);
            $data = ob_get_contents();
            ob_end_clean();
            $msg .= htmlspecialchars($data) . "\n";
            $log .= $data . "\n";
        }
    } else {
        $msg .= '<b>Debug notice:</b> try to use cw_var_dump($varname1,$varname2); ' . "\n";
        $log .= 'Debug notice: try to use cw_print_r($varname1,$varname2); ' . "\n";
    }
    $msg .= "</font></pre></div>";
    if (defined('IS_AJAX')) {
        cw_ajax_add_block(array('id' => 'cw_var_dump', 'content' => $log, 'action' => 'console'));
    } else {
        echo $msg;
    }
    $count++;
}
function dashboard_system_messages_show()
{
    global $smarty;
    cw_system_messages_show($_GET['type']);
    $sections = array(0 => 'system_messages', 1 => 'awaiting_actions', 2 => 'system_info');
    $section_name = $sections[$_GET['type']];
    $system_messages = cw_system_messages($_GET['type'], true);
    $smarty->assign($section_name, $system_messages);
    cw_ajax_add_block(array('id' => 'dashboard_name_' . $section_name, 'template' => 'addons/dashboard/admin/sections/' . $section_name . '.tpl'));
    cw_ajax_add_block(array('id' => $section_name . '_bottom', 'action' => 'hide'));
}
function dod_get_attr_ajax()
{
    global $smarty, $tables;
    global $attribute_id, $bd_id;
    $value = $operation = $quantity = '';
    if (!empty($bd_id)) {
        // extract from DB certain condition details
        $bonus_details = cw_query_first("SELECT * FROM {$tables['dod_bonus_details']} WHERE bd_id='{$bd_id}'");
        $attribute_id = $bonus_details['object_id'];
        $quantity = $bonus_details['quantity'];
        $value = $bonus_details['param1'];
        $operation = $bonus_details['param2'];
    }
    if (empty($attribute_id)) {
        return false;
    }
    cw_load('attributes');
    $attribute = cw_func_call('cw_attributes_get_attribute', array('attribute_id' => $attribute_id));
    $attribute['value'] = $value;
    $attribute['values'] = array($value);
    $smarty->assign(array('attribute' => $attribute, 'index' => empty($bd_id) ? time() : 'bd_id' . $bd_id, 'quantity' => $quantity, 'value' => $value, 'operation' => $operation));
    cw_ajax_add_block(array('action' => 'append', 'id' => 'dod_attributes', 'template' => 'addons/deal_of_day/admin/attribute_row.tpl'));
    return true;
}
<?php

# [TOFIX]
# kornev, move to addon
$product_info = cw_func_call('cw_product_get', array('id' => $product_id, 'user_account' => $user_account, 'info_type' => 136));
$smarty->assign('product', $product_info);
include $app_main_dir . '/include/products/send_to_friend.php';
$smarty->assign('main', 'popup_send2friend');
$smarty->assign('home_style', 'popup');
if (defined('IS_AJAX') && constant('IS_AJAX')) {
    cw_ajax_add_block(array('id' => 'send_to_friend_dialog', 'template' => 'customer/main/send_to_friend.tpl'));
    cw_ajax_add_block(array('id' => 'script', 'content' => 'sm("send_to_friend_dialog", send_to_friend_dialog_width, send_to_friend_dialog_height, false, send_to_friend_dialog_title)'));
}
<?php

cw_load('attributes');
$attribute = cw_func_call('cw_attributes_get_attribute', array('attribute_id' => $_GET['attribute_id']));
$attribute['value'] = $_GET['value'];
$attribute['values'] = array($_GET['value']);
$smarty->assign(array('attribute' => $attribute, 'index' => empty($cd_id) ? time() : 'cd_id' . str_replace('cd_id', '', $cd_id), 'value' => $_GET['value'], 'operation' => $_GET['operation'], 'no_extra_cmp' => $_GET['no_extra_cmp']));
$smarty->assign('posted_name', $posted_name);
cw_ajax_add_block(array('action' => 'append', 'id' => 'select_attributes', 'template' => 'main/select/attribute_row.tpl'));
function cw_add_top_message($msg, $type = 'I')
{
    global $top_message;
    static $priority = array('I' => 0, 'W' => 1, 'E' => 2);
    if (!in_array($type, array('I', 'W', 'E'))) {
        $type = 'I';
    }
    if (is_array($msg)) {
        $msg = implode("\n", $msg);
    }
    if (!empty($top_message['content'])) {
        $top_message['content'] .= "\n";
    }
    $top_message['content'] .= $msg;
    if ($priority[$top_message['type']] < $priority[$type]) {
        $top_message['type'] = $type;
    }
    if (defined('IS_AJAX') and constant('IS_AJAX')) {
        cw_load('ajax');
        cw_ajax_add_block(array('id' => 'top_message', 'content' => nl2br($top_message['content'])), 'top_message');
        cw_ajax_add_block(array('id' => 'top_message_type', 'action' => 'ignore', 'content' => $top_message['type']), 'top_message_type');
        cw_ajax_add_block(array('id' => 'script', 'content' => 'show_top_message("' . $top_message['type'] . '")'), 'top_message_script');
    }
    return $top_message;
}
                cw_func_call('cw_user_delete', array('customer_id' => $user, 'send_mail' => true));
            }
            $top_message = array('content' => cw_get_langvar_by_name('msg_adm_users_del'), 'type' => 'I');
        } else {
            $top_message = array('content' => cw_get_langvar_by_name('msg_adm_warn_users_sel'), 'type' => 'W');
        }
        cw_session_unregister('users_to_delete');
        cw_header_location('index.php?target=' . $target . '&mode=search');
    }
    $users_to_delete['user'] = $user;
    $mode = 'delete';
    cw_header_location("index.php?target={$target}&mode=delete");
}
if ($mode == 'delete') {
    $users_to_delete =& cw_session_register("users_to_delete");
    if (is_array($users_to_delete['user'])) {
        $users = array();
        foreach ($users_to_delete['user'] as $k => $v) {
            $users[] = cw_call('cw_user_get_info', array($k, 1));
        }
        $smarty->assign('users', $users);
        $smarty->assign('current_section_dir', 'users');
        $smarty->assign('main', 'delete_confirmation');
    } else {
        $top_message = array('content' => cw_get_langvar_by_name('msg_adm_warn_users_sel'), 'type' => 'W');
    }
}
if (defined('IS_AJAX') && constant('IS_AJAX')) {
    cw_ajax_add_block(array('id' => 'delete_confirm', 'template' => 'admin/users/delete_confirmation.tpl'));
    cw_ajax_add_block(array('id' => 'script', 'content' => 'sm("delete_confirm",0,0,1,"' . cw_get_langvar_by_name('txt_delete_users_top_text') . '");'));
}
$top_message =& cw_session_register('top_message', array());
if (!$product_id) {
    cw_header_location("index.php?target=error_message&error=access_denied&id=48");
}
$antibot_err =& cw_session_register("antibot_err");
$antibot_page = "on_send_to_friend";
if (!empty($addons['image_verification']) && $show_antibot_arr[$antibot_page] == 'Y') {
    if (isset($antibot_input_str) && !empty($antibot_input_str)) {
        $antibot_err = cw_validate_image($antibot_validation_val[$antibot_page], $antibot_input_str);
    } else {
        $antibot_err = true;
    }
    if (defined('IS_AJAX') && constant('IS_AJAX') && $spambot_ajax_check == 'Y') {
        $antibot_validation_val[$antibot_page]['used'] = 'N';
        $smarty->assign('antibot_err', $antibot_err ? 'Y' : 'N');
        cw_ajax_add_block(array('id' => 'spambot_ajax_check_res', 'template' => 'addons/image_verification/spambot_ajax_check.tpl'));
    }
}
$send_to_friend_info =& cw_session_register("send_to_friend_info");
if ($action == 'send') {
    if ($email && $from && $name && !$antibot_err) {
        cw_load('mail');
        $smarty->assign("product", $product_info);
        $smarty->assign("name", $name);
        $smarty->assign("message", $from);
        cw_call('cw_send_mail', array($config['Company']['support_department'], $email, "mail/wishlist/send2friend_subj.tpl", "mail/wishlist/send2friend.tpl"));
        cw_add_top_message(cw_get_langvar_by_name('txt_send2friend_send'));
        $send_to_friend_info['fill_err'] = $send_to_friend_info['antibot_err'] = false;
    } else {
        $top_message['content'] = cw_get_langvar_by_name("err_filling_form");
        if ($antibot_err) {
        $_att = $arr['att'];
        if (is_array($_att[$request_prepared['att_id']])) {
            foreach ($_att[$request_prepared['att_id']] as $k => $v) {
                if (in_array($v, $request_prepared['value_selected'])) {
                    unset($_att[$request_prepared['att_id']], $k);
                    $ns = preg_replace("|att\\[{$request_prepared['att_id']}\\]\\[\\w*\\]={$v}|", '', $ns);
                }
            }
        } else {
            $ns = preg_replace("|att\\[{$request_prepared['att_id']}\\]\\[\\w*\\]={$request_prepared['value_id']}|", '', $ns);
            unset($_att[$request_prepared['att_id']]);
        }
        $att = $_att;
    }
    $url = urldecode(htmlspecialchars_decode(cw_core_assign_addition_params($ns, array('att' => $att))));
    cw_ajax_add_block(array('id' => 'url', 'content' => cw_call('cw_clean_url_get_seo_url', array($url))));
}
/* TODO: rework AJAX to use XML */
// Old style AJAX JSON requests
if (in_array($action, array('load_address', 'update_address', 'delete_address', 'load_addresses'))) {
    global $user, $self_modification;
    $user = $customer_id;
    $self_modification = 1;
}
if ($mode == 'get_css') {
    header('Content-Type: text/css');
    echo $config['CSS']['store'];
    exit;
}
if ($mode == 'cart_update') {
    $action = 'ajax_update';
/**
 *  Alias for cw_ajax_add_block() for compatibility
 */
function cw_add_ajax_block($arr, $key = null)
{
    return cw_ajax_add_block($arr, $key);
}