function cw_checkout_show_cart($action) { global $smarty; $top_message =& cw_session_register('top_message'); $smarty->assign('top_message', $top_message); $top_message = array(); $cart =& cw_session_register('cart', array()); $smarty->assign('cart', $cart); $smarty->assign('action', $action); header("Content-type: application/xml"); cw_display('customer/checkout/xml_cart.tpl', $smarty); die; }
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 cw_send_mail($from, $to, $subject_template, $body_template, $language = null, $crypted = false, $is_pdf = false, $files = array()) { global $smarty; global $current_language; if (empty($to)) { return; } $to = cw_real_mail_address($to); $language = $language ? $language : $current_language; $mail_subject = chop(cw_display($subject_template, $smarty, false, $language)); $mail_message = cw_display($body_template, $smarty, false, $language); $_files = implode(",", $files); cw_array2insert('mail_spool', cw_addslashes(array('mail_from' => $from, 'mail_to' => $to, 'subject' => $mail_subject, 'body' => $mail_message, 'crypted' => $crypted, 'pdf_copy' => $is_pdf, 'files' => $_files))); return; }
function cw_web_get_layout_inner($sql) { global $tables, $smarty, $top_message; $data = cw_query_first("select * from {$tables['layouts']} where {$sql}"); $data['data'] = unserialize($data['data']); $smarty->assign('layout', $data); $templates = cw_query("select * from {$tables['layouts_templates']} where layout_id='{$data['layout_id']}' order by orderby"); if (is_array($templates)) { foreach ($templates as $template) { $template['content'] = cw_display($template['template'], $smarty, false); preg_match_all('/id[ ]*=[ ]*"(.*)"/Uims', $template['content'], $out); $template['sub_ids'] = $out[1]; $data['parts'][] = $template; } } unset($smarty->_included_files); $data['elements'] = cw_query("select le.* from {$tables['layouts_elements']} as le where le.layout_id='{$data['layout_id']}' and display='none'"); return $data; }
function cw_spam($message, $recipients, $send_language, $list_id) { global $config, $smarty; global $current_language, $tables; global $app_main_dir; $saved_language = $current_language; $current_language = $send_language; $email_spec = "###EMAIL###"; $smarty->assign('email', $email_spec); $smarty->assign('list_id', $list_id); $signature_template = "mail/newsletter_signature.tpl"; $sign_delim = "\n\n"; $message['headers'] = array("Content-Type" => "text/html"); $sign_delim = "<br /><br />"; $signature = cw_display($signature_template, $smarty, false); $extra = array("Content-Type" => "text/html"); foreach ($recipients as $recipient) { cw_send_simple_mail($config['news']['newsletter_email'], $recipient, $message['subject'], $message['body'] . $sign_delim . preg_replace("/{$email_spec}/S", $recipient, $signature), $extra); } $current_language = $saved_language; }
function dod_get_coupons_ajax() { global $smarty, $dod_type; $smarty->assign('dod_coupons', dod_get_coupons()); $smarty->assign('dod_type', $dod_type); //$smarty->fetch('addons/deal_of_day/admin/coupons.tpl', null, null, true); cw_display('addons/deal_of_day/admin/coupons.tpl', $smarty); exit(0); }
<?php # kornev, TOFIX require $app_main_dir . "/include/popup_print_sn.php"; cw_display("main/popup_print_sn.tpl", $smarty);
} } cw_header_location("index.php?target=salesman_report"); } elseif ($action == 'export') { $smarty->assign("delimiter", $delimiter); $report = cw_query("SELECT {$tables['customers']}.*, {$tables['salesman_plans']}.min_paid, SUM(IF({$tables['docs']}.status NOT IN ('P', 'C'), {$tables['salesman_payment']}.commissions, 0)) as sum, SUM(IF({$tables['salesman_payment']}.paid = 'Y' AND {$tables['docs']}.status IN ('P', 'C'), {$tables['salesman_payment']}.commissions, 0)) as sum_paid, SUM(IF({$tables['salesman_payment']}.paid <> 'Y' AND {$tables['docs']}.status IN ('P', 'C'), {$tables['salesman_payment']}.commissions, 0)) as sum_nopaid, IF(SUM(IF(({$tables['salesman_payment']}.paid <> 'Y' AND {$tables['docs']}.status IN ('P', 'C')), {$tables['salesman_payment']}.commissions, 0)) >= {$tables['salesman_plans']}.min_paid, 'Y', '') as is_paid FROM {$tables['customers']}, {$tables['salesman_payment']}, {$tables['salesman_commissions']}, {$tables['salesman_plans']}, {$tables['docs']} WHERE {$tables['salesman_plans']}.plan_id = {$tables['salesman_commissions']}.plan_id AND {$tables['salesman_commissions']}.salesman_customer_id={$tables['customers']}.customer_id AND {$tables['customers']}.customer_id={$tables['salesman_payment']}.salesman_customer_id AND {$tables['docs']}.doc_id = {$tables['salesman_payment']}.doc_id AND {$tables['customers']}.usertype = 'B' AND {$tables['customers']}.status = 'Y' GROUP BY {$tables['customers']}.customer_id" . ($use_limit == 'Y' ? " HAVING is_paid = 'Y'" : "")); if ($report) { foreach ($report as $key => $value) { foreach ($value as $rk => $rv) { $report[$key][$rk] = '"' . str_replace("\"", "\"\"", $report[$key][$rk]) . '"'; } } } $smarty->assign("report", $report); header("Content-Type: text/csv"); header("Content-Disposition: attachment; filename=salesman_report.csv"); cw_display("admin/main/salesman_report_export.tpl", $smarty); exit; } $result = cw_query("SELECT {$tables['customers']}.customer_id, {$tables['salesman_plans']}.min_paid, SUM(IF({$tables['docs']}.status NOT IN ('P', 'C'), {$tables['salesman_payment']}.commissions, 0)) as sum, SUM(IF({$tables['salesman_payment']}.paid = 'Y' AND {$tables['docs']}.status IN ('P', 'C'), {$tables['salesman_payment']}.commissions, 0)) as sum_paid, SUM(IF({$tables['salesman_payment']}.paid <> 'Y' AND {$tables['docs']}.status IN ('P', 'C'), {$tables['salesman_payment']}.commissions, 0)) as sum_nopaid, IF(SUM(IF(({$tables['salesman_payment']}.paid <> 'Y' AND {$tables['docs']}.status IN ('P', 'C')), {$tables['salesman_payment']}.commissions, 0)) >= {$tables['salesman_plans']}.min_paid, 'Y', '') as is_paid FROM {$tables['customers']}, {$tables['salesman_payment']}, {$tables['salesman_commissions']}, {$tables['salesman_plans']}, {$tables['docs']} WHERE {$tables['salesman_plans']}.plan_id = {$tables['salesman_commissions']}.plan_id AND {$tables['salesman_commissions']}.salesman_customer_id={$tables['customers']}.customer_id AND {$tables['customers']}.customer_id={$tables['salesman_payment']}.salesman_customer_id AND {$tables['docs']}.doc_id = {$tables['salesman_payment']}.doc_id AND {$tables['customers']}.usertype = 'B' AND {$tables['customers']}.status = 'Y' GROUP BY {$tables['customers']}.customer_id" . ($use_limit == 'Y' ? " HAVING is_paid = 'Y'" : "")); if ($result) { foreach ($result as $k => $v) { if ($v['is_paid']) { $is_paid = 'Y'; } } $smarty->assign("is_paid", $is_paid); } $smarty->assign("result", $result); $smarty->assign('use_limit', $use_limit); $smarty->assign('main', 'report');
cw_load('barcode'); cw_barcode_get($barcode, $type, $width, $height); exit; } if ($mode == 'categories') { cw_include('include/ajax/categories.php'); } if (in_array($mode, array('counties', 'states', 'regions', 'cities'))) { cw_include('include/map/ajax_countries.php'); } if ($mode == 'aom') { cw_include('include/orders/order_edit_ajax.php'); } // < Old style AJAX JSON requests if ($mode == 'map') { /* mode "map" acceptes following parameters country - country code state - state code name - name of fields, which will be extended by [state] and [country] */ cw_include('include/map/ajax_map.php'); } if (!empty($top_message)) { $top_message = array(); } $smarty->assign('is_ajax', $is_ajax); $smarty->assign('ajax_blocks', $ajax_blocks); // XML AJAX response header('Content-type: text/xml'); cw_display('main/ajax/ajax_response.tpl', $smarty); exit(0);
<?php # kornev 42779 define('OFFERS_DONT_SHOW_NEW', 1); if (!defined('APP_START')) { die('Access denied'); } include $app_main_dir . '/salesman/auth.php'; cw_include('addons/faq/include/faq_printing.php'); cw_display("customer/main/faq_printing.tpl", $smarty);
<?php cw_load('category'); $smarty->assign('subcategories', cw_category_get_subcategories($cat, $current_category)); $smarty->assign('current_category', $current_category); $smarty->assign('name', $name); $smarty->assign('id', $id); $smarty->assign('index', $index); $smarty->assign('el_name', $el_name); $smarty->assign('multiple', $multiple); $smarty->assign('parent_category_id', $cat); $smarty->assign('return_type', $return_type); cw_display('main/ajax/categories.tpl', $smarty); exit(0);
function cw_doc_print($doc_data, $mode) { global $smarty, $current_area, $app_skins_dirs; cw_load('web'); if ($doc_data['info']['layout_id']) { $layout = cw_web_get_layout_by_id($doc_data['info']['layout_id']); } else { $layout = cw_web_get_layout('docs_' . $doc_data['type']); } $smarty->assign('layout_data', $layout); $smarty->assign('doc', $doc_data); $smarty->assign('current_section', ''); $smarty->assign('main', 'order_print'); $smarty->assign('home_style', 'iframe'); $smarty->assign('is_printing', true); if ($mode == 'print') { cw_display($app_skins_dirs[$current_area] . '/index.tpl', $smarty); } elseif ($mode == 'print_pdf' || ($mode = 'print_aom_pdf')) { cw_load('pdf'); cw_pdf_generate(cw_get_langvar_by_name('lbl_doc_info_' . $doc_data['type'], false, false, true), $app_skins_dirs[$current_area] . '/index.tpl'); } }
function ps_get_zones_ajax() { global $smarty; $smarty->assign('ps_zones', ps_get_zones()); //$smarty->fetch('addons/promotion_suite/admin/zones.tpl', null, null, true); cw_display('addons/promotion_suite/admin/zones.tpl', $smarty); exit(0); }
} $distribution = $var_dirs['files'] . $distribution; $remote_file = false; $fd = cw_fopen($distribution, "rb"); } else { $remote_file = true; $fd = fopen($distribution, "rb"); } if ($fd) { $fname = basename($distribution); header("Content-type: application/force-download"); header("Content-Disposition: attachment; filename=\"{$fname}\""); if (!$remote_file) { $size = filesize($distribution); header("Content-length: {$size}"); } fpassthru($fd); fclose($fd); } else { # If no such distributive $smarty->assign('product', $result['product']); # Assign the current location line cw_display("addons/egoods/no_distributive.tpl", $smarty); exit; } } else { db_query("DELETE FROM {$tables['download_keys']} WHERE expires <= '" . time() . "'"); # Assign the current location line cw_display("addons/egoods/wrong_key.tpl", $smarty); exit; }
<?php cw_load('user'); $smarty->assign('el_membership', $el_membership); $smarty->assign('memberships', cw_user_get_memberships($usertype)); cw_display('main/ajax/memberships.tpl', $smarty); exit(0);
} # # If gcindex is empty - add # overwise - update # if (!$fill_error && !$amount_error) { if (!empty($addons['Gift_Certificates']) && $action == "addgc2wl") { cw_include('addons/Wishlist/wishlist.php'); } if ($mode == "preview") { $smarty->assign('giftcerts', array($giftcert)); header("Content-Type: text/html"); header("Content-Disposition: inline; filename=giftcertificates.html"); $_tmp_smarty_debug = $smarty->debugging; $smarty->debugging = false; cw_display("addons/Gift_Certificates/gc_customer_print.tpl", $smarty); $smarty->debugging = $_tmp_smarty_debug; exit; } if (isset($gcindex) && isset($cart['giftcerts'][$gcindex])) { $cart['giftcerts'][$gcindex] = $giftcert; } else { $cart['giftcerts'][] = $giftcert; } cw_header_location("index.php?target=cart"); } } elseif ($action == "delgc") { # # Remove GC from cart # array_splice($cart['giftcerts'], $gcindex, 1);
<?php if (!defined('APP_START')) { die('Access denied'); } cw_load('accounting'); $smarty->assign('subcategories', cw_accounting_get_subcategories($cat, $current_category)); $smarty->assign('current_category', $current_category); $smarty->assign('name', $name); $smarty->assign('id', $id); $smarty->assign('index', $index); $smarty->assign('name', $name); $smarty->assign('el_name', $el_name); $smarty->assign('multiple', $multiple); $smarty->assign('parent_category_id', $cat); cw_display('main/ajax/accounting_categories.tpl', $smarty); exit(0);
} $location[] = array(cw_get_langvar_by_name('lbl_doc_info_O'), ''); $smarty->assign('product_layout_elements', cw_call('cw_web_get_product_layout_elements', array())); $smarty->assign('orders', $orders); $smarty->assign('doc_ids', $doc_ids); $smarty->assign('current_section_dir', 'cart'); $smarty->assign('main', 'order_message'); if ($_GET['standalone_mode'] == 'Y') { if (is_array($doc_ids)) { $doc_id = $doc_ids[0]; } elseif (is_numeric($doc_ids)) { $doc_id = $doc_ids; } $doc_data = cw_call('cw_doc_get', array($doc_id)); if ($doc_data['info']['layout_id']) { $layout = cw_web_get_layout_by_id($doc_data['info']['layout_id']); } else { $layout = cw_call('cw_web_get_layout', array('docs_' . $doc_data['type'], $_GET['is_email_invoice'] == 'Y')); } $smarty->assign('layout_data', $layout); $smarty->assign('info', $doc_data['info']); $smarty->assign('products', $doc_data['products']); $smarty->assign('doc', $doc_data); if ($_GET['is_email_invoice'] == 'Y') { $smarty->assign('is_email_invoice', $_GET['is_email_invoice']); cw_display('mail/docs/customer.tpl', $smarty); } else { cw_display('customer/cart/order_message.tpl', $smarty); } exit; }
$cart_prods[$k] = $v; } } $cart["products"] = $cart_prods; } else { $cart = ""; } cw_header_location("cart.php?{$QUERY_STRING}"); } $cart = cw_func_call('cw_cart_actions', array('action' => $action, 'products' => $products, 'userinfo' => $userinfo), $cart); if ($action == 'ajax_update') { $wcart = cw_func_call('cw_cart_get_warehouses_cart', array('cart' => $cart, 'products' => $products, 'userinfo' => $userinfo)); $smarty->assign('warehouses_cart', $wcart); $smarty->assign('expired', !count($products)); $smarty->assign('products', $products); cw_display('customer/cart/ajax_cart_js.tpl', $smarty); exit(0); } # kornev, check the requirements before the checkout if ($mode == 'checkout') { if (cw_is_cart_empty($cart)) { cw_header_location('index.php?target=' . $target); } cw_session_unregister('secure_oid'); if ($cart['info']['display_subtotal'] < $config['General']['minimal_order_amount'] && $config['General']['minimal_order_amount'] > 0) { cw_header_location('index.php?target=error_message&error=min_order'); } if ($config['General']['maximum_order_amount'] > 0 && $cart['info']['display_subtotal'] > $config['General']['maximum_order_amount']) { cw_header_location("index.php?target=error_message&max_order"); } if ($config['General']['maximum_order_items'] > 0 && cw_cart_count_items($cart) > $config['General']['maximum_order_items']) {
function cw_order_messages_process_new_emails($condition = "") { global $tables, $config; global $take_messages_debug; cw_load('doc', 'user'); $new_emails = cw_query("select * from {$tables['mail_rpool']} {$condition}"); if (empty($new_emails)) { return; } $processed_mail_ids = array(); foreach ($new_emails as $email) { if (strpos($email['body'], '--------- please reply above this line ----------') !== false) { $bodyparts = explode("--------- please reply above this line ----------", $email['body']); if (!empty($bodyparts[0])) { $email['body'] = $bodyparts[0]; } } //remove RE, FWD etc from subject $clean_subject = cw_order_messages_remove_re($email['subject']); //cw_log_add("order_messages_process_new_emails",array('clean_subject'=>$clean_subject)); if ($take_messages_debug == 'Y') { print_r(array('clean_subject' => $clean_subject)); print "<br>"; } $related_threads = cw_query($s = "select {$tables['order_messages_messages']}.*, {$tables['order_messages_threads']}.doc_id from {$tables['order_messages_messages']} left join {$tables['order_messages_threads']} on {$tables['order_messages_threads']}.thread_id={$tables['order_messages_messages']}.thread_id where {$tables['order_messages_messages']}.subject = '{$clean_subject}'"); //cw_log_add("order_messages_process_new_emails", array('related_threads'=>$related_threads, 'sql'=>$s)); if ($take_messages_debug == 'Y') { print_r(array('related_threads' => $related_threads, 'sql' => $s)); print "<br>"; } if (!empty($related_threads)) { foreach ($related_threads as $doc_thread) { $doc_data = cw_call('cw_doc_get', array($doc_thread['doc_id'], 8192)); if ($email['mail_from'] == $doc_data['userinfo']['email']) { $new_message_id = cw_array2insert('order_messages_messages', array('thread_id' => $doc_thread['thread_id'], 'sender_id' => $doc_data['userinfo']['customer_id'], 'recepient_id' => $doc_thread['author_id'], 'author_id' => $doc_data['userinfo']['customer_id'], 'date' => time(), 'subject' => addslashes($email['subject']), 'body' => addslashes($email['body']), 'read_status' => 0)); //notify recipient over email when reply is processed cw_order_messages_notify_other_respondent($new_message_id, $doc_thread['author_id'], $doc_thread['doc_id']); $processed_mail_ids[] = $email['mail_id']; break; } elseif (cw_query_first_cell("select count(*) from {$tables['customers']} where usertype='A' and email='{$email['mail_from']}'")) { $admin_id = cw_query_first_cell("select customer_id from {$tables['customers']} where usertype='A' and email='{$email['mail_from']}'"); $recepient_ids = array(); if ($doc_thread['sender_id'] != $admin_id) { $recepient_ids[] = $doc_thread['sender_id']; } if ($doc_thread['recepient_id'] != $admin_id) { $recepient_ids[] = $doc_thread['recepient_id']; } $new_message_id = cw_array2insert('order_messages_messages', array('thread_id' => $doc_thread['thread_id'], 'sender_id' => $admin_id, 'recepient_id' => $recepient_ids[0], 'author_id' => $admin_id, 'date' => time(), 'subject' => addslashes($email['subject']), 'body' => addslashes($email['body']), 'read_status' => 0)); //notify recipient over email when reply is processed foreach ($recepient_ids as $recepient_id) { cw_order_messages_notify_other_respondent($new_message_id, $recepient_id, $doc_thread['doc_id']); } $processed_mail_ids[] = $email['mail_id']; break; } else { $supplier_info = array(); foreach ($doc_data['products'] as $doc_product) { if ($doc_product['supplier_customer_id']) { $supplier_info = cw_user_get_info($doc_product['supplier_customer_id'], 1); if ($supplier_info['email'] == $email['mail_from']) { break; } $supplier_info = array(); } } if (!empty($supplier_info)) { $new_message_id = cw_array2insert('order_messages_messages', array('thread_id' => $doc_thread['thread_id'], 'sender_id' => $supplier_info['customer_id'], 'recepient_id' => $doc_thread['author_id'], 'author_id' => $supplier_info['customer_id'], 'date' => time(), 'subject' => addslashes($email['subject']), 'body' => addslashes($email['body']), 'read_status' => 0)); //notify recipient over email when reply is processed cw_order_messages_notify_other_respondent($new_message_id, $doc_thread['author_id'], $doc_thread['doc_id']); $processed_mail_ids[] = $email['mail_id']; break; } } } } else { //detect thread by {thread_id} or create new thread by #SW [doc_id] //cw_log_add("order_messages_process_new_emails", "detect thread by {thread_id}"); if ($take_messages_debug == 'Y') { print_r(array("detect thread by {thread_id}")); print "<br>"; } $email_thread_id = intval(cw_order_messages_take_out_from_tags($email['subject'], "{", "}", false)); $related_thread = cw_query_first("select {$tables['order_messages_threads']}.* from {$tables['order_messages_threads']} where {$tables['order_messages_threads']}.thread_id='{$email_thread_id}'"); if (empty($related_thread)) { $email_thread_id = 0; } //cw_log_add("order_messages_process_new_emails",array("email_thread_id"=>$email_thread_id)); if ($take_messages_debug == 'Y') { print_r(array("email_thread_id" => $email_thread_id)); print "<br>"; } if (empty($email_thread_id) && strpos($email['subject'], "#") !== false) { $_parts = explode("#", cw_order_messages_remove_doc_prefix($email['subject'])); $extracted_doc_id = intval(trim($_parts[1])); //cw_log_add("order_messages_process_new_emails", array("extracted_doc_id"=>$extracted_doc_id)); if ($take_messages_debug == 'Y') { print_r(array("extracted_doc_id" => $extracted_doc_id)); print "<br>"; } if ($extracted_doc_id) { $doc_data = cw_call('cw_doc_get', array($extracted_doc_id, 8192)); if (!empty($doc_data)) { $email_thread_id = cw_array2insert('order_messages_threads', array('doc_id' => $extracted_doc_id, 'type' => 'A')); } } //cw_log_add("order_messages_process_new_emails", array("created new thread"=>$email_thread_id)); if ($take_messages_debug == 'Y') { print_r(array("created new thread" => $email_thread_id)); print "<br>"; } if (!empty($email_thread_id)) { $related_thread = $email_thread_id; } } if (empty($related_thread)) { continue; } $email_sender_id = cw_query_first_cell("select customer_id from {$tables['customers']} where email='{$email['mail_from']}'"); //cw_log_add("order_messages_process_new_emails", array("$email[mail_from] email_sender_id $email_sender_id")); if ($take_messages_debug == 'Y') { print_r(array("{$email['mail_from']} email_sender_id {$email_sender_id}")); print "<br>"; } if (empty($email_sender_id)) { continue; } //is sender email related to detected thread $is_email_allowed = cw_query_first_cell("select count(*) from {$tables['order_messages_messages']} where {$tables['order_messages_messages']}.thread_id='{$email_thread_id}' and ({$tables['order_messages_messages']}.sender_id='{$email_sender_id}' or {$tables['order_messages_messages']}.recepient_id='{$email_sender_id}' or {$tables['order_messages_messages']}.author_id='{$email_sender_id}')"); if (!$is_email_allowed) { $is_email_allowed = cw_query_first_cell("select count(*) from {$tables['docs_user_info']} dui, {$tables['docs']} d, {$tables['order_messages_threads']} omt where omt.thread_id='{$email_thread_id}' and omt.doc_id=d.doc_id and d.doc_info_id=dui.doc_info_id and dui.email='{$email['mail_from']}'"); } //cw_log_add("order_messages_process_new_emails", "<br>is_email_allowed $is_email_allowed<br>"); if ($take_messages_debug == 'Y') { print_r(array("<br>is_email_allowed {$is_email_allowed}<br>")); print "<br>"; } if ($is_email_allowed) { //get other respondends in thread $other_respondent_id = cw_query_first_cell("select sender_id from {$tables['order_messages_messages']} where thread_id='{$email_thread_id}' and sender_id != '{$email_sender_id}'"); //cw_log_add("order_messages_process_new_emails","<br>other_respondent_id $other_respondent_id<br>"); if ($take_messages_debug == 'Y') { print_r(array("<br>other_respondent_id {$other_respondent_id}<br>")); print "<br>"; } if (empty($other_respondent_id)) { $other_respondent_id = cw_query_first_cell("select recepient_id from {$tables['order_messages_messages']} where thread_id='{$email_thread_id}' and recepient_id != '{$email_sender_id}'"); } if (empty($other_respondent_id) || cw_query_first_cell("select count(*) from {$tables['customers']} where usertype='A' and customer_id='{$other_respondent_id}'")) { //use default id to sent email if (!empty($config['order_messages']['default_recepient_admin_email'])) { $default_recepient_admin_email = $config['order_messages']['default_recepient_admin_email']; } $other_respondent_id = cw_query_first_cell("select customer_id from {$tables['customers']} where usertype='A' and email='{$default_recepient_admin_email}'"); //cw_log_add("order_messages_process_new_emails","<br>selected default recepient ($default_recepient_admin_email): customer_id = $other_respondent_id<br>"); if ($take_messages_debug == 'Y') { print_r(array("<br>selected default recepient ({$default_recepient_admin_email}): customer_id = {$other_respondent_id}<br>")); print "<br>"; } } if (!empty($other_respondent_id)) { global $smarty, $current_language; $rnd_key = time(); $smarty->assign('message', array('subject' => $rnd_key, 'thread_id' => $email_thread_id)); $smarty->assign('doc_id', $related_thread['doc_id']); $language = $language ? $language : $current_language; $order_subject_template = 'addons/order_messages/mail/customer_subj.tpl'; $test_subject = chop(cw_display($order_subject_template, $smarty, false, $language)); //cw_log_add("order_messages_process_new_emails","<br>test subject: $test_subject<br>"); if ($take_messages_debug == 'Y') { print_r(array("<br>test subject: {$test_subject}<br>")); print "<br>"; } $subject_parts = explode($rnd_key, $test_subject); $extracted_replied_subject = str_replace($subject_parts, "", $email['subject']); //cw_log_add("order_messages_process_new_emails","<br>extracted_replied_subject $extracted_replied_subject<br>"); if ($take_messages_debug == 'Y') { print_r(array("<br>extracted_replied_subject {$extracted_replied_subject}<br>")); print "<br>"; } $new_message_id = cw_array2insert('order_messages_messages', array('thread_id' => $email_thread_id, 'sender_id' => $email_sender_id, 'recepient_id' => $other_respondent_id, 'author_id' => $email_sender_id, 'date' => time(), 'subject' => addslashes($extracted_replied_subject), 'body' => addslashes($email['body']), 'read_status' => 0)); cw_order_messages_notify_other_respondent($new_message_id, $other_respondent_id, $related_thread['doc_id']); $processed_mail_ids[] = $email['mail_id']; } } } } //if ($take_messages_debug != "Y") if (!empty($processed_mail_ids)) { db_query("delete from {$tables['mail_rpool']} where mail_id in ('" . implode("','", $processed_mail_ids) . "')"); } return $processed_mail_ids; }
} else { $file_upload_data[$type] = $val; } } } cw_session_save(); $smarty->assign('type', $type); $smarty->assign('imgid', $imgid); $smarty->assign('id', $id); $smarty->assign('multiple', $available_images[$type]['multiple']); $smarty->assign('file_upload_data', $file_upload_data[$type]); $smarty->assign('current_main_dir', 'main'); $smarty->assign('current_section_dir', 'image_selection'); $smarty->assign('main', 'image_selection_close'); $smarty->assign('home_style', 'iframe'); cw_display($app_skins_dirs[$current_area] . '/index.tpl', $smarty); exit; } $_table = $tables[$type]; $_field = $available_images[$type] == 'U' ? "id" : "imageid"; $smarty->assign('multiple', $available_images[$type]['multiple']); $smarty->assign('tabs', empty($tabs) ? '' : explode(',', $tabs)); $smarty->assign('type', $type); $smarty->assign('imgid', $imgid); $smarty->assign('id', $id); $smarty->assign('multiple_id', $id); $smarty->assign('parent_window', $parent_window); $smarty->assign('upload_max_filesize', ini_get('upload_max_filesize')); $smarty->assign('current_main_dir', 'main'); $smarty->assign('current_section_dir', 'image_selection'); $smarty->assign('main', 'image_selection');
<?php if ($action == 'ajax_update') { $smarty->assign('cod_types', cw_shipping_get_cod_types()); $smarty->assign('user_selection', cw_query_first_cell("select cod_delivery_type_id from {$tables['customers_customer_info']} where customer_id='{$user}'")); cw_display('admin/shipping/cod_types_ajax_js.tpl', $smarty); exit(0); } if ($action == 'update' && is_array($update_types)) { foreach ($update_types as $k => $v) { if ($k) { $v['cod_type_id'] = $k; } if (!$k && !$v['title']) { continue; } cw_array2insert('shipping_cod_types', $v, true); } cw_header_location("index.php?target={$target}&js_update=1" . ($iframe ? '&iframe=1' : '')); } if ($action == 'delete' && is_array($del)) { foreach ($del as $cod_type_id => $val) { cw_shipping_delete_cod_type($cod_type_id); } cw_header_location("index.php?target={$target}&js_update=1" . ($iframe ? '&iframe=1' : '')); } $smarty->assign('js_update', $js_update && $iframe); $smarty->assign('cod_types', cw_shipping_get_cod_types()); $location[] = array(cw_get_langvar_by_name('lbl_cod_types'), ''); $smarty->assign('main', 'cod_types'); if ($iframe) {
} } $smarty->assign('results', $results); } } $smarty->assign('filter', $filter_surveys[$survey_id]); $smarty->assign('is_filter', !empty($filter_surveys[$survey_id]['date_from']) && !empty($filter_surveys[$survey_id]['date_to'])); } } if ($mode == 'preview') { $smarty->assign('mode', $mode); $smarty->assign('home_style', 'popup'); $smarty->assign('current_main_dir', 'addons'); $smarty->assign('current_section_dir', 'survey'); $smarty->assign('main', 'survey_preview'); $smarty->assign('current_section', ''); if ($action == 'fill') { $smarty->assign('main', 'customer_view_message'); } cw_display('admin/index.tpl', $smarty); exit(0); } $location[] = array(cw_get_langvar_by_name('lbl_survey_surveys'), 'index.php?target=surveys'); $location[] = array(cw_get_langvar_by_name('lbl_survey_modify_survey'), ''); $smarty->assign('survey', $survey); $smarty->assign('survey_id', $survey_id); $smarty->assign('js_tab', $js_tab); $smarty->assign('show', $show); $smarty->assign('dialog_tools_data', $dialog_tools_data); $smarty->assign('survey_types', cw_get_survey_types()); $smarty->assign('answers_types', cw_get_answers_types());
<?php # kornev 42779 define('OFFERS_DONT_SHOW_NEW', 1); if (!defined('APP_START')) { die('Access denied'); } include $app_main_dir . '/salesman/auth.php'; $is_product_faq = true; $redirect = "faq_popup.php"; cw_include('addons/faq/include/faq.php'); $smarty->assign('addition', $addition); cw_display("customer/main/faq_popup.tpl", $smarty);
<?php cw_load('map'); $name = $_GET['name']; $country = $_GET['country']; $state = $_GET['state']; include_once $app_main_dir . '/include/templater/plugins/modifier.id.php'; $name = str_ends_with($name, '[country]') ? substr($name, 0, strlen($name) - 9) : $name; if (empty($country)) { $country = $config['General']['default_country']; } $countries = cw_call('cw_map_get_countries', array($name)); $smarty->assign('countries', $countries); $smarty->assign('name', $name . '[country]'); $smarty->assign('default', $country); cw_add_ajax_block(array('id' => smarty_modifier_id($name) . 'country', 'action' => 'replace', 'content' => cw_display('main/map/_countries.tpl', $smarty, false))); $states = cw_map_get_states($country); $smarty->assign('states', $states); $smarty->assign('name', $name . '[state]'); $smarty->assign('default', $state); cw_add_ajax_block(array('id' => smarty_modifier_id($name) . 'state', 'action' => 'replace', 'content' => cw_display('main/map/_states.tpl', $smarty, false)));
function cw_display_service_footer() { global $smarty; if (defined("SERVICE_HEADER")) { cw_display("main/service_footer.tpl", $smarty); cw_flush(); } }
<?php $type = strtolower($type); if (!in_array($type, array("mcsc", "vbv")) || $config['CMPI']['cmpi_enabled'] != 'Y') { cw_close_window(); } $smarty->assign('popup_title', cw_get_langvar_by_name("lbl_cmpi_vbv", false, false, true)); $smarty->assign('template_name', 'main/cmpi_".$type.".tpl'); cw_display("help/popup_info.tpl", $smarty); die;
$target = isset($_REQUEST['target']) ? $_REQUEST['target'] : 'index'; define('APP_START', 1); $request_prepared = array(); define('APP_AREA', $area); include_once $app_main_dir . '/init.php'; cw_include($area . '/auth.php'); cw_event('on_before_' . $target); cw_event('on_before_' . $target . '_' . $action); cw_include($area . '/' . $target . '.php'); if (defined('IS_AJAX') && !defined('PREVENT_XML_OUT')) { cw_include($area . '/ajax.php'); exit(0); } $__script_microtime = microtime(true) - $__start_mictotime; $__bech_display_id = cw_bench_open_tag('DISPLAY', 'POINT', ''); cw_display($area . '/index.tpl', $smarty, true); cw_bench_close_tag($__bech_display_id); $__smarty_microtime = microtime(true) - $__start_mictotime - $__script_microtime; // Time end if (!defined('IS_AJAX')) { // Time end $__output_microtime = 'Runtime: ' . sprintf("%.4f", $__smarty_microtime + $__script_microtime) . ' (SCRIPT: ' . sprintf("%.4f", $__script_microtime) . '; SMARTY: ' . sprintf("%.4f", $__smarty_microtime) . ')'; if (!$app_config_file['debug']['development_mode']) { $__output_microtime = '<!-- ' . $__output_microtime . ' -->'; } else { // echo '<!-- SQL queries: ';asort($__sql_counter);var_dump($__sql_counter); // echo "<br/>\n"; } echo $__output_microtime; } cw_bench_close_tag($__bech_main_id);
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; }
function cw_pdf_generate($file, $template, $save_to_file = false, $landscape = false, $pages_limit = 0, $page_margins = array('10', '10', '10', '10'), $show_pages = true) { global $smarty, $var_dirs, $current_location; set_time_limit(2700); ini_set('memory_limit', '512M'); $smarty->assign('is_pdf', true); # kornev, only for A4 && 1024 p/wide $wcr = $hcr = 1024 / 210; $smarty->assign('wcr', $wcr); $smarty->assign('hcr', $hcr); if ($save_to_file && $file) { $html = $file; } else { $html = cw_display($template, $smarty, false); } parse_config_file(HTML2PS_DIR . 'html2ps.config'); $pipeline = PipelineFactory::create_default_pipeline('', ''); $pipeline->fetchers[] = new MyFetcherMemory($html, $current_location); if ($save_to_file) { $pipeline->destination = new MyDestinationFile($save_to_file); } else { $pipeline->destination = new DestinationDownload($file); } if ($show_pages) { $pipeline->pre_tree_filters[] = new PreTreeFilterHeaderFooter('', '<div>' . cw_get_langvar_by_name('lbl_page', null, false, true) . ' ##PAGE## / ##PAGES## </div>'); } $pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields(); $media =& Media::predefined('A4'); $media->set_landscape($landscape); $media->set_margins(array('left' => $page_margins[3], 'right' => $page_margins[1], 'top' => $page_margins[0], 'bottom' => $page_margins[2])); $media->set_pixels(1024); $g_config = array('cssmedia' => 'print', 'scalepoints' => '1', 'renderimages' => true, 'renderlinks' => false, 'renderfields' => false, 'renderforms' => false, 'mode' => 'html', 'encoding' => '', 'debugbox' => false, 'pdfversion' => '1.4', 'smartpagebreak' => true, 'draw_page_border' => false, 'html2xhtml' => false, 'method' => 'fpdf', 'pages_limit' => $pages_limit); $pipeline->configure($g_config); $pipeline->process_batch(array(''), $media); if (!$save_to_file) { exit(0); } }