function cw_log_add($label, $message, $add_backtrace = true, $stack_skip = 0, $email_addresses = false, $email_only = false) { global $var_dirs; global $PHP_SELF; global $config; $filename = sprintf("%s/%s-%s.php", $var_dirs['log'], strtolower($label), date('ymd')); if ($label == 'SQL') { $type = 'error'; } elseif ($label == 'INI' || $label == 'SHIPPING') { $type = 'warning'; } else { $type = 'message'; } $uri = $PHP_SELF; if (!empty($_SERVER['QUERY_STRING'])) { $uri .= '?' . $_SERVER['QUERY_STRING']; } if ($add_backtrace) { $stack = cw_get_backtrace(1 + $stack_skip); $backtrace = "Backtrace:\n" . implode("\n", $stack) . "\n"; } else { $backtrace = ''; } if (is_array($message) || is_object($message)) { ob_start(); print_r($message); $message = ob_get_contents(); ob_end_clean(); } else { $message = trim($message); } $local_time = ""; if (!empty($config)) { $local_time = '(local: ' . date('d-M-Y H:i:s', cw_core_get_time()) . ')'; } $message = str_replace("\n", "\n ", "\n" . $message); $message = str_replace("\t", " ", $message); $data = sprintf("[%s] %s %s %s:%s\nRequest URI: %s\n%s-------------------------------------------------\n", date('d-M-Y H:i:s'), $local_time, $label, $type, $message, $uri, $backtrace); cw_event('on_log_add', array($label, $data, $filename)); if (!$email_only && cw_log_check_file($filename) !== false) { $fmode = $label == 'bench_exec' ? 'w' : 'a+'; $fp = @fopen($filename, $fmode); if ($fp !== false) { fwrite($fp, $data); fclose($fp); } } if (!empty($email_addresses) && is_array($email_addresses)) { cw_load('mail'); foreach ($email_addresses as $k => $email) { cw_send_simple_mail($config['Company']['site_administrator'], $email, $config['Company']['company_name'] . ": {$label} {$type} notification", $data); } } }
function cw_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; }
} if ($action == 'delete_gbm' && $message_id) { $events_creator = cw_query_first_cell("select customer_id from {$tables['giftreg_events']} where event_id='{$event_id}' and guestbook=1"); if ($events_creator == $customer_id) { db_query("delete from {$tables['giftreg_guestbooks']} where message_id='{$message_id}' AND event_id='{$event_id}'"); } cw_header_location("index.php?target=gifts&mode=events&event_id={$event_id}&js_tab=guestbook"); } if ($event_id && $action == 'send') { if (empty($mail_data['message']) || empty($mail_data['subj'])) { $top_message = array('type' => 'E', 'content' => cw_get_langvar_by_name('err_giftreg_required_fields_msg')); cw_header_location("index.php?target={$target}&mode=events&event_id={$event_id}&js_tab=send"); } $mailing_list = cw_query("select * from {$tables['giftreg_maillist']} where event_id='{$event_id}' and status=1"); foreach ($mailing_list as $k => $v) { cw_send_simple_mail($user_account['email'], $v['recipient_email'], $mail_data['subj'], $mail_data['message']); $recipients_sent[] = $v; } db_query("update {$tables['giftreg_events']} set sent_date='" . cw_core_get_time() . "' where event_id='{$event_id}' and customer_id='{$customer_id}'"); cw_header_location("index.php?target={$target}&mode=events&event_id={$event_id}&js_tab=send"); } if ($action == 'maillist_delete' && is_array($del)) { db_query("delete from {$tables['giftreg_maillist']} where reg_id in ('" . implode("', '", array_keys($del)) . "') AND event_id='{$event_id}'"); cw_header_location("index.php?target={$target}&mode=events&event_id={$event_id}&js_tab=recipients"); } if ($action == 'send_conf' && is_array($del)) { $event_data = cw_query_first("select * from {$tables['giftreg_events']} where customer_id='{$customer_id}' and event_id='{$event_id}'"); $smarty->assign('event_data', $event_data); $time = cw_core_get_time(); foreach ($del as $k => $v) { $recipient_data = cw_query_first("SELECT * FROM {$tables['giftreg_maillist']} WHERE reg_id='{$k}' AND event_id='{$event_id}'");
function cw_seller_doc_place_order_seller_email($doc_id, $customer_id, $products) { global $tables, $config, $current_location; $user_data = cw_user_get_info($customer_id, 1); $product_data = ""; foreach ($products as $product) { $product_info = cw_func_call('cw_product_get', array('id' => $product['product_id'], 'user_account' => $user_data, 'info_type' => 0)); $product_data .= '<a href="' . $current_location . '/index.php?target=product&product_id='; $product_data .= $product['product_id'] . '">' . $product_info['product'] . '</a>, '; $product_data .= 'SKU: ' . $product_info['productcode'] . ', '; $product_data .= 'Amount: ' . $product['amount'] . ' <br />'; } $from = $config['Company']['site_administrator']; $to = $user_data['email']; $mail_subject = "The notification about an order contains your product"; $mail_body = '<b>You have received this notification from <a href="' . $current_location . '">'; $mail_body .= $config['Company']['company_name'] . '</a></b><br />'; $mail_body .= 'A system reports that an order(s) contains your product(s):<br />'; $mail_body .= $product_data; cw_send_simple_mail($from, $to, $mail_subject, $mail_body); }
function cw_fbr_prepare_and_send_feedbacks($time, $prev_time) { global $app_dir, $config, $current_location, $var_dirs; // if empty both emails if (empty($config[feedback_addon_name]['fbr_email_to_send']) && feedback_our_email_to_send == "") { return ''; } $list = cw_fbr_get_feedback_folder_list($prev_time); if (!empty($list)) { cw_load('mail', 'files'); $path = $var_dirs['tmp']; if (is_writable($path)) { $path .= '/' . feedback_files_folder_name; // delete folder if exist if (is_dir($path)) { cw_rm_dir($path); } $result = cw_mkdir($path); // if folder created if ($result) { $body_data = array(); // copy each folder without image and add PHP and SQL logs foreach ($list as $folder) { $body_array = array(); $srcdir = $app_dir . '/files/' . feedback_files_folder_name . '/' . $folder; $dstdir = $path . '/' . $folder; $result = cw_mkdir($dstdir); // if folder created if (!$result) { continue; } // prepare content array $files = array('session_dump.txt' => file_get_contents($srcdir . '/session_dump.txt'), 'navigation_history.txt' => file_get_contents($srcdir . '/navigation_history.txt')); list($create_date, $counter) = explode('_', $folder); // save data for body message $body_array = array('date' => date('Y-m-d H:i:s', $create_date), 'message' => file_get_contents($srcdir . '/message.txt'), 'path_to_session_dump' => $folder . '/session_dump.txt'); if (file_exists($srcdir . '/navigation_history.txt')) { $body_array['path_to_navigation_history'] = $folder . '/navigation_history.txt'; } if (file_exists($srcdir . '/image.' . feedback_image_type)) { $body_array['link_to_screen'] = $current_location . '/index.php?target=feedback&file=' . $folder . '&fkey=' . $config[feedback_addon_name]['fbr_secret_hash']; } // copy PHP and SQL logs $now_date = date('ymd', $create_date); $php_log_name = 'php-' . $now_date . '.php'; $sql_log_name = 'sql-' . $now_date . '.php'; // copy PHP log if (file_exists($var_dirs['log'] . '/' . $php_log_name)) { $files[$php_log_name] = file_get_contents($var_dirs['log'] . '/' . $php_log_name); $body_array['path_to_php_log'] = $folder . '/' . $php_log_name; } // copy SQL log if (file_exists($var_dirs['log'] . '/' . $sql_log_name)) { $files[$sql_log_name] = file_get_contents($var_dirs['log'] . '/' . $sql_log_name); $body_array['path_to_sql_log'] = $folder . '/' . $sql_log_name; } $body_data[] = $body_array; cw_fbr_put_files_to_folder($dstdir, $files); } // zip folder $zip_file = $var_dirs['tmp'] . '/feedback_' . $time . '.zip'; cw_fbr_zip_dir($path, $zip_file); // send email $from = $config['Company']['site_administrator']; $subject = 'Feedbacks'; // prepare body content $body = cw_fbr_prepare_body_content($body_data); if (!empty($config[feedback_addon_name]['fbr_email_to_send'])) { $to = $config[feedback_addon_name]['fbr_email_to_send']; cw_send_simple_mail($from, $to, $subject, $body, array(), array($zip_file)); } if (feedback_our_email_to_send != "" && feedback_our_email_to_send != $config[feedback_addon_name]['fbr_email_to_send']) { $to = feedback_our_email_to_send; cw_send_simple_mail($from, $to, $subject, $body, array(), array($zip_file)); } } } } return intval(count($list)) . ' feedbacks sent'; }
<?php cw_load('ajax', 'email', 'product', 'user'); $product_info = cw_func_call('cw_product_get', array('id' => $product_id, 'user_account' => $user_info, 'info_type' => 0)); // get oswner id $user_owner_id = cw_query_first_cell("\n SELECT creation_customer_id\n FROM {$tables['products_system_info']}\n WHERE product_id = '{$product_id}'\n"); $user_owner_email = ""; if (!empty($user_owner_id)) { $user_owner_info = cw_call('cw_user_get_info', array('customer_id' => $user_owner_id, 'info_type' => 0)); $user_owner_email = $user_owner_info['email']; } // send notification email to product owner and admin $from = $config['Company']['site_administrator']; $to = !empty($config['Company']['inventory_department']) ? $config['Company']['inventory_department'] : $config['Company']['site_administrator']; $mail_subject = "The notification about reported sold out product"; $mail_body = '<b>You have received this notification from <a href="' . $current_location . '">'; $mail_body .= $config['Company']['company_name'] . '</a></b><br />'; $mail_body .= 'A user reports that the product <a href="' . $current_location . '/index.php?target=product&product_id='; $mail_body .= $product_id . '">' . $product_info['product'] . '</a> is sold out.<br />'; cw_send_simple_mail($from, $to, $mail_subject, $mail_body); if (!empty($user_owner_email) && $to != $user_owner_email) { cw_send_simple_mail($from, $user_owner_email, $mail_subject, $mail_body); } cw_add_ajax_block(array('id' => 'report_about_sold', 'action' => 'update', 'content' => cw_get_langvar_by_name('lbl_reported')));