/** * Standard aed_module delete actualiser. */ function _export_quiz() { require_code('files2'); $quiz_id = post_param_integer('quiz_id'); $data = get_quizz_data_for_csv($quiz_id); make_csv($data, 'quiz.csv'); }
/** * Actulizer to build csv from the selected filters * * @param boolean Whether to avoid exit (useful for unit test). */ function _order_export($inline = false) { require_code('shopping'); $start_date = get_input_date('start_date', true); $end_date = get_input_date('end_date', true); $order_status = post_param('order_status'); $filename = 'Orders_' . $order_status . '__' . get_timezoned_date($start_date, false, false, false, true) . '-' . get_timezoned_date($end_date, false, false, false, true) . '.csv'; $orders = array(); $data = array(); $cond = "t1.add_date BETWEEN " . strval($start_date) . " AND " . strval($end_date); if ($order_status != 'all') { $cond .= " AND t1.order_status='" . db_escape_string($order_status) . "'"; } $qry = "SELECT t1.*,(t2.included_tax*t2.p_quantity) as \t\n\t\t\t\t\t\t\t\ttax_amt,t3.address_name,t3.address_street,t3.address_city,t3.address_zip,\n\t\t\t\t\t\t\t\tt3.address_country,t3.receiver_email\n\t\t\t\t\t\t\t\tFROM " . get_table_prefix() . "shopping_order t1\n\t\t\t\t\t\t\t\tLEFT JOIN " . get_table_prefix() . "shopping_order_details t2 ON t1.id = t2.order_id\n\t\t\t\t\t\t\t\tLEFT JOIN " . get_table_prefix() . "shopping_order_addresses t3 ON t1.id = t3.order_id\n\t\t\t\t\t\t\t\tWHERE " . $cond; $row = $GLOBALS['SITE_DB']->query($qry); remove_duplicate_rows($row); foreach ($row as $order) { $orders[do_lang('ORDER_NUMBER')] = strval($order['id']); $orders[do_lang('ORDERED_DATE')] = get_timezoned_date($order['add_date'], true, false, true, true); $orders[do_lang('ORDER_PRICE')] = $order['tot_price']; $orders[do_lang('ORDER_STATUS')] = do_lang($order['order_status']); $orders[do_lang('ORDER_TAX_OPT_OUT')] = $order['tax_opted_out'] ? do_lang('YES') : do_lang('NO'); $orders[do_lang('TOTAL_TAX_PAID')] = is_null($order['tax_amt']) ? float_format(0.0, 2) : float_format($order['tax_amt'], 2); $orders[do_lang('ORDERED_PRODUCTS')] = get_ordered_product_list_string($order['id']); $orders[do_lang('ORDERED_BY')] = $GLOBALS['FORUM_DRIVER']->get_username($order['c_member']); $address = array(); $address['name'] = array_key_exists('address_name', $order) ? $order['address_name'] : NULL; $address['city'] = array_key_exists('address_city', $order) ? $order['address_city'] : NULL; $address['zip'] = array_key_exists('address_zip', $order) ? $order['address_zip'] : NULL; $address['country'] = array_key_exists('address_country', $order) ? $order['address_country'] : NULL; if (!is_null($address['name'])) { $full_address = implode(chr(10), $address); } else { $full_address = ""; } $orders[do_lang('FULL_ADDRESS')] = $full_address; $data[] = $orders; } require_code('files2'); make_csv($data, $filename, !$inline, !$inline); }
/** * The UI to show download statistics. * * @param object The stats module object * @param string The screen type * @return tempcode The UI */ function downloads($ob, $type) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS')))); require_lang('downloads'); //This will show a plain bar chart with all the downloads listed $title = get_page_title('SECTION_DOWNLOADS'); // Handle time range if (get_param_integer('dated', 0) == 0) { $title = get_page_title('SECTION_DOWNLOADS'); return $ob->get_between($title, false, NULL, do_lang_tempcode('DOWNLOAD_STATS_RANGE')); } $time_start = get_input_date('time_start', true); $time_end = get_input_date('time_end', true); if (!is_null($time_end)) { $time_end += 60 * 60 * 24 - 1; } // So it is end of day not start if (is_null($time_start) && is_null($time_end)) { $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('id', 'num_downloads', 'name')); } else { if (is_null($time_start)) { $time_start = 0; } if (is_null($time_end)) { $time_end = time(); } $title = get_page_title('SECTION_DOWNLOADS_RANGE', true, array(escape_html(get_timezoned_date($time_start, false)), escape_html(get_timezoned_date($time_end, false)))); $rows = $GLOBALS['SITE_DB']->query('SELECT id,num_downloads,name FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'download_downloads WHERE add_date>' . strval($time_start) . ' AND add_date<' . strval($time_end)); } //$rows=array(array('id'=>1,'num_downloads'=>10,'name'=>3),array('id'=>2,'num_downloads'=>20,'name'=>4)); if (count($rows) < 1) { return warn_screen($title, do_lang_tempcode('NO_DATA')); } $downloads = array(); foreach ($rows as $i => $row) { if (!array_key_exists('num_downloads', $row)) { $row['num_downloads'] = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'download_logging WHERE id=' . strval($row['id'])); $rows[$i] = $row; } $downloads[get_translated_text($row['name']) . ' (#' . strval($row['id']) . ')'] = $row['num_downloads']; } $start = get_param_integer('start', 0); $max = get_param_integer('max', 30); $csv = get_param_integer('csv', 0) == 1; if ($csv) { if (function_exists('set_time_limit')) { @set_time_limit(0); } $start = 0; $max = 10000; } $sortables = array('num_downloads' => do_lang_tempcode('COUNT_DOWNLOADS')); $test = explode(' ', get_param('sort', 'num_downloads DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sort'; if ($sort_order == 'ASC') { asort($downloads); } else { arsort($downloads); } require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('TITLE'), do_lang_tempcode('COUNT_DOWNLOADS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); $real_data = array(); $i = 0; foreach ($downloads as $download_name => $value) { if ($i < $start) { $i++; continue; } elseif ($i >= $start + $max) { break; } $fields->attach(results_entry(array(escape_html($download_name), escape_html(integer_format($value))))); $real_data[] = array('Download name' => $download_name, 'Tally' => $value); $i++; } $list = results_table(do_lang_tempcode('SECTION_DOWNLOADS'), $start, 'start', $max, 'max', count($downloads), $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort', new ocp_tempcode()); if ($csv) { make_csv($real_data, 'download_stats.csv'); } $output = create_bar_chart(array_slice($downloads, $start, $max), do_lang('TITLE'), do_lang('COUNT_DOWNLOADS'), '', ''); $ob->save_graph('Global-Downloads', $output); $graph = do_template('STATS_GRAPH', array('GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/Global-Downloads.xml', 'TITLE' => do_lang_tempcode('SECTION_DOWNLOADS'), 'TEXT' => do_lang_tempcode('DESCRIPTION_DOWNLOADS_STATISTICS'))); return do_template('STATS_SCREEN', array('_GUID' => '4b8e0478231473d690e947ffc4580840', 'TITLE' => $title, 'GRAPH' => $graph, 'STATS' => $list)); }
/** * Purchase log ajax code starts here */ function wpsc_purchlog_resend_email() { global $wpdb; $siteurl = get_option('siteurl'); $log_id = $_GET['email_buyer_id']; if (is_numeric($log_id)) { $selectsql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`= " . $log_id . " LIMIT 1"; $purchase_log = $wpdb->get_row($selectsql, ARRAY_A); if ($purchase_log['gateway'] == "testmode" && $purchase_log['processed'] < 2) { $message = get_option("wpsc_email_receipt"); $message_html = "<h2 style='font-size:16px;font-weight:bold;color:#000;border:0px;padding-top: 0px;' >" . TXT_WPSC_YOUR_ORDER . "</h2>"; } else { $message = get_option("wpsc_email_receipt"); $message_html = $message; } $order_url = $siteurl . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php&purchcaseid=" . $purchase_log['id']; $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase_log['id'] . ""; $cart = $wpdb->get_results($cartsql, ARRAY_A); if ($purchase_log['shipping_country'] != '') { $billing_country = $purchase_log['billing_country']; $shipping_country = $purchase_log['shipping_country']; } else { $country = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . get_option('country_form_field') . "' LIMIT 1", ARRAY_A); $billing_country = $country[0]['value']; $shipping_country = $country[0]['value']; } $email_form_field = $wpdb->get_results("SELECT `id`,`type` FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `order` ASC LIMIT 1", ARRAY_A); $email_address = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_SUBMITED_FORM_DATA . "` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . $email_form_field[0]['id'] . "' LIMIT 1", ARRAY_A); $email = $email_address[0]['value']; $previous_download_ids = array(0); if ($cart != null) { foreach ($cart as $row) { $link = ""; $productsql = "SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`=" . $row['prodid'] . ""; $product_data = $wpdb->get_results($productsql, ARRAY_A); if ($product_data[0]['file'] > 0) { if ($purchase_log['email_sent'] != 1) { $wpdb->query("UPDATE `" . WPSC_TABLE_DOWNLOAD_STATUS . "` SET `active`='1' WHERE `fileid`='" . $product_data[0]['file'] . "' AND `purchid` = '" . $purchase_log['id'] . "' LIMIT 1"); } if ($purchase_log['processed'] >= 2) { $download_data = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `fileid`='" . $product_data[0]['file'] . "' AND `purchid`='" . $purchase_log['id'] . "' AND (`cartid` = '" . $row['id'] . "' OR `cartid` IS NULL) AND `id` NOT IN (" . make_csv($previous_download_ids) . ") LIMIT 1", ARRAY_A); if ($download_data != null) { if ($download_data['uniqueid'] == null) { // if the uniqueid is not equal to null, its "valid", regardless of what it is $link = $siteurl . "?downloadid=" . $download_data['id']; } else { $link = $siteurl . "?downloadid=" . $download_data['uniqueid']; } } $previous_download_ids[] = $download_data['id']; $order_status = 4; } } do_action('wpsc_confirm_checkout', $purchase_log['id']); $shipping = nzshpcrt_determine_item_shipping($row['prodid'], $row['quantity'], $shipping_country); if (isset($_SESSION['quote_shipping'])) { $shipping = $_SESSION['quote_shipping']; } $total_shipping += $shipping; if ($product_data[0]['special'] == 1) { $price_modifier = $product_data[0]['special_price']; } else { $price_modifier = 0; } $total += $row['price'] * $row['quantity']; $message_price = nzshpcrt_currency_display($row['price'] * $row['quantity'], $product_data[0]['notax'], true); $shipping_price = nzshpcrt_currency_display($shipping, 1, true); $variation_sql = "SELECT * FROM `" . WPSC_TABLE_CART_ITEM_VARIATIONS . "` WHERE `cart_id`='" . $row['id'] . "'"; $variation_data = $wpdb->get_results($variation_sql, ARRAY_A); $variation_count = count($variation_data); if ($variation_count > 1) { $variation_list = " ("; if ($purchase['gateway'] != 'testmode') { if ($gateway['internalname'] == $purch_data[0]['gateway']) { $gateway_name = $gateway['name']; } } else { $gateway_name = "Manual Payment"; } $i = 0; foreach ($variation_data as $variation) { if ($i > 0) { $variation_list .= ", "; } $value_id = $variation['value_id']; $value_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_VARIATION_VALUES . "` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A); $variation_list .= $value_data[0]['name']; $i++; } $variation_list .= ")"; } else { if ($variation_count == 1) { $value_id = $variation_data[0]['value_id']; $value_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_VARIATION_VALUES . "` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A); $variation_list = " (" . $value_data[0]['name'] . ")"; } else { $variation_list = ''; } } if ($link != '') { $product_list .= " - " . $product_data['name'] . stripslashes($variation_list) . " " . $message_price . " " . TXT_WPSC_CLICKTODOWNLOAD . ":\n {$link}\n"; $product_list_html .= " - " . $product_data['name'] . stripslashes($variation_list) . " " . $message_price . " <a href='{$link}'>" . TXT_WPSC_CLICKTODOWNLOAD . "</a>\n"; } else { $plural = ''; if ($row['quantity'] > 1) { $plural = "s"; } $product_list .= " - " . $row['quantity'] . " " . $product_data[0]['name'] . $variation_list . " " . $message_price . "\n"; if ($shipping > 0) { $product_list .= " - " . TXT_WPSC_SHIPPING . ":" . $shipping_price . "\n\r"; } $product_list_html .= " - " . $row['quantity'] . " " . $product_data[0]['name'] . $variation_list . " " . $message_price . "\n"; if ($shipping > 0) { $product_list_html .= " - " . TXT_WPSC_SHIPPING . ":" . $shipping_price . "\n\r"; } } $report .= " - " . $product_data[0]['name'] . $variation_list . " " . $message_price . "\n"; } if ($purchase_log['discount_data'] != '') { $coupon_data = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_COUPON_CODES . "` WHERE coupon_code='" . $wpdb->escape($purchase_log['discount_data']) . "' LIMIT 1", ARRAY_A); if ($coupon_data['use-once'] == 1) { $wpdb->query("UPDATE `" . WPSC_TABLE_COUPON_CODES . "` SET `active`='0', `is-used`='1' WHERE `id`='" . $coupon_data['id'] . "' LIMIT 1"); } } //$wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `active`='1' WHERE `fileid`='".$product_data[0]['file']."' AND `purchid` = '".$purchase_log['id']."' LIMIT 1"); $total_shipping += $purchase_log['base_shipping']; $total = $total + $total_shipping - $purchase_log['discount_value']; // $message.= "\n\r"; $product_list .= "Your Purchase No.: " . $purchase_log['id'] . "\n\r"; if ($purchase_log['discount_value'] > 0) { $discount_email .= TXT_WPSC_DISCOUNT . ": " . nzshpcrt_currency_display($purchase_log['discount_value'], 1, true) . "\n\r"; } $total_shipping_email .= TXT_WPSC_TOTALSHIPPING . ": " . nzshpcrt_currency_display($total_shipping, 1, true) . "\n\r"; $total_price_email .= TXT_WPSC_TOTAL . ": " . nzshpcrt_currency_display($total, 1, true) . "\n\r"; $product_list_html .= "Your Purchase No.: " . $purchase_log['id'] . "\n\n\r"; if ($purchase_log['discount_value'] > 0) { $discount_html .= TXT_WPSC_DISCOUNT . ": " . nzshpcrt_currency_display($purchase_log['discount_value'], 1, true) . "\n\r"; } $total_shipping_html .= TXT_WPSC_TOTALSHIPPING . ": " . nzshpcrt_currency_display($total_shipping, 1, true) . "\n\r"; $total_price_html .= TXT_WPSC_TOTAL . ": " . nzshpcrt_currency_display($total, 1, true) . "\n\r"; if (isset($_GET['ti'])) { $message .= "\n\r" . TXT_WPSC_YOURTRANSACTIONID . ": " . $_GET['ti']; $message_html .= "\n\r" . TXT_WPSC_YOURTRANSACTIONID . ": " . $_GET['ti']; $report .= "\n\r" . TXT_WPSC_TRANSACTIONID . ": " . $_GET['ti']; } else { $report_id = "Purchase No.: " . $purchase_log['id'] . "\n\r"; } $message = str_replace('%product_list%', $product_list, $message); $message = str_replace('%total_shipping%', $total_shipping_email, $message); $message = str_replace('%total_price%', $total_price_email, $message); //$message = str_replace('%order_status%',get_option('blogname'),$message); $message = str_replace('%shop_name%', get_option('blogname'), $message); $report = str_replace('%product_list%', $report_product_list, $report); $report = str_replace('%total_shipping%', $total_shipping_email, $report); $report = str_replace('%total_price%', $total_price_email, $report); $report = str_replace('%shop_name%', get_option('blogname'), $report); $message_html = str_replace('%product_list%', $product_list_html, $message_html); $message_html = str_replace('%total_shipping%', $total_shipping_html, $message_html); $message_html = str_replace('%total_price%', $total_price_email, $message_html); $message_html = str_replace('%shop_name%', get_option('blogname'), $message_html); // exit($message_html); if ($email != '') { add_filter('wp_mail_from', 'wpsc_replace_reply_address', 0); add_filter('wp_mail_from_name', 'wpsc_replace_reply_name', 0); if ($purchase_log['processed'] < 2) { $payment_instructions = strip_tags(get_option('payment_instructions')); $message = TXT_WPSC_ORDER_PENDING . "\n\r" . $payment_instructions . "\n\r" . $message; $resent = (bool) wp_mail($email, TXT_WPSC_ORDER_PENDING_PAYMENT_REQUIRED, $message); $sent = 1; } else { $resent = (bool) wp_mail($email, TXT_WPSC_PURCHASERECEIPT, $message); $sent = 1; } //echo "$message<br />"; //exit($email); remove_filter('wp_mail_from_name', 'wpsc_replace_reply_name'); remove_filter('wp_mail_from', 'wpsc_replace_reply_address'); } } } $sendback = wp_get_referer(); if (isset($sent)) { $sendback = add_query_arg('sent', $sent, $sendback); } wp_redirect($sendback); exit; }
/** * The UI to show page view statistics. * * @return tempcode The UI */ function page_stats() { //This will show a plain bar chart with all the pages listed // Handle time range if (get_param_integer('dated', 0) == 0) { $title = get_page_title('PAGES_STATISTICS'); return $this->get_between($title, true); } $time_start = get_input_date('time_start', true); $time_end = get_input_date('time_end', true); if (!is_null($time_end)) { $time_end += 60 * 60 * 24 - 1; } // So it is end of day not start if (is_null($time_start)) { $time_start = 0; } if (is_null($time_end)) { $time_end = time(); } $first_stat = $GLOBALS['SITE_DB']->query_value_null_ok('stats', 'MIN(date_and_time)'); if ($time_end < $first_stat) { warn_exit(do_lang_tempcode('NO_DATA_SPECIFIC')); } $start = get_param_integer('start', 0); $max = get_param_integer('max', 30); $csv = get_param_integer('csv', 0) == 1; if ($csv) { if (function_exists('set_time_limit')) { @set_time_limit(0); } $start = 0; $max = 10000; /*$time_start=0; Actually, this is annoying. We have legitimate reason to filter, and cannot re-filter the data in Excel retro-actively $time_end=time();*/ } $title = get_page_title('PAGES_STATISTICS_RANGE', true, array(escape_html(get_timezoned_date($time_start, false)), escape_html(get_timezoned_date($time_end, false)))); $rows = $GLOBALS['SITE_DB']->query_select('stats', array('the_page'), NULL, 'GROUP BY the_page ORDER BY COUNT(*) DESC', 3000); if (count($rows) < 1) { return warn_screen($title, do_lang_tempcode('NO_DATA')); } $views = array(do_lang('_ALL') => 0); $total = 0; foreach ($rows as $row) { $page = $row['the_page']; $matches = array(); if (preg_match('#^/?([^/]+)/pages/([^/]+)/(\\w\\w/)?([^/\\.]+)\\.(php|txt|htm)$#', $page, $matches) == 1 && $matches[4] == 'catalogues' && addon_installed('catalogues') && $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)', NULL, '', true) < 300) { require_lang('catalogues'); $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title'), NULL, '', NULL, NULL, true); foreach ($categories as $cat) { $where = db_string_equal_to('the_page', $page); if (substr($page, 0, 6) == 'pages/') { $where .= ' OR ' . db_string_equal_to('the_page', '/' . $page); } // Legacy compatibility $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'stats WHERE (' . $where . ') AND s_get LIKE \'' . db_encode_like('<param>page=catalogues</param>\\n<param>type=category</param>\\n<param>id=' . strval($cat['id']) . '</param>%') . '\' AND date_and_time>' . strval((int) $time_start) . ' AND date_and_time<' . strval((int) $time_end)); $views[do_lang('CATALOGUE_CATEGORY') . ': ' . get_translated_text($cat['cc_title'])] = array($count, $page); $total += $count; } continue; } else { $page2 = page_path_to_pagelink($page); if ($page2 == '') { $page2 = $page; } } $where = db_string_equal_to('the_page', $page); if (substr($page, 0, 6) == 'pages/') { $where .= ' OR ' . db_string_equal_to('the_page', '/' . $page); } // Legacy compatibility $views[$page2] = array($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'stats WHERE (' . $where . ') AND date_and_time>' . strval((int) $time_start) . ' AND date_and_time<' . strval((int) $time_end)), $page); $total += $views[$page2][0]; } $views[do_lang('_ALL')] = array($total, NULL); $sortables = array('views' => do_lang_tempcode('COUNT_VIEWS')); $test = explode(' ', get_param('sort', 'views DESC'), 2); if (count($test) == 1) { $test[1] = 'DESC'; } list($sortable, $sort_order) = $test; if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sort'; global $M_SORT_KEY; $M_SORT_KEY = 0; uasort($views, 'multi_sort'); if ($sort_order == 'DESC') { $views = array_reverse($views, true); } require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('URL'), do_lang_tempcode('COUNT_VIEWS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); $i = 0; $real_data = array(); foreach ($views as $url => $_value) { if ($i < $start) { $i++; continue; } elseif ($i >= $start + $max) { break; } list($value, $page) = $_value; $real_data[] = array('Page/URL' => is_null($page) ? $url : $page, 'Tally' => $value); $fields->attach(results_entry(array(is_null($page) ? make_string_tempcode(escape_html($url)) : hyperlink(build_url(array('page' => '_SELF', 'type' => '_page', 'iscreen' => $page), '_SELF'), escape_html($url)), escape_html(integer_format($value))))); $i++; } unset($views['(' . do_lang('ALL') . ')']); $list = results_table(do_lang_tempcode('PAGES_STATISTICS'), $start, 'start', $max, 'max', count($views), $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort', new ocp_tempcode()); if ($csv) { make_csv($real_data, 'page_stats.csv'); } $output = create_bar_chart(array_slice($views, $start, $max), do_lang('PAGE'), do_lang('COUNT_VIEWS'), '', ''); $this->save_graph('Global-Views', $output); $graph = do_template('STATS_GRAPH', array('_GUID' => 'ea79fdc013046ef94992daeab961f2da', 'GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/Global-Views.xml', 'TITLE' => do_lang_tempcode('PAGES_STATISTICS'), 'TEXT' => do_lang_tempcode('DESCRIPTION_PAGES_STATISTICS'))); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS')))); return do_template('STATS_SCREEN', array('_GUID' => 'cfe7d5aee8aa3c0d3a54bd3bf2d09e7f', 'TITLE' => $title, 'GRAPH' => $graph, 'STATS' => $list)); }
function cart_product_list_string($licensecolumn) { // the function is for displaying the list of products // if $licensecolumn is False we don't diplay extra columns global $wpdb, $result_no_license_text; $siteurl = get_option('siteurl'); $current_item = 0; $total = 0; $cart = isset($_SESSION['nzshpcrt_cart']) ? $_SESSION['nzshpcrt_cart'] : ""; $result = '<table class=\'productcart\'>'; $result_no_license_text = '<table class=\'productcart\'>'; if (isset($cart) && $cart != '') { foreach ($cart as $key => $cart_item) { $current_item = $current_item + 1; $product_id = $cart_item->product_id; $quantity = $cart_item->quantity; $number =& $quantity; $product_variations = $cart_item->product_variations; $variation_count = count($product_variations); if ($variation_count >= 1) { $variation_list = " ("; $i = 0; foreach ($product_variations as $value_id) { if ($i > 0) { $variation_list .= ", "; } $value_data = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "variation_values` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A); $variation_list .= str_replace(" ", " ", stripslashes($value_data[0]['name'])); $i++; } $variation_list .= ")"; } else { $variation_list = ''; } $sql = "SELECT `wp_product_list`.*, `wp_product_files`.`width`, `wp_product_files`.`height`, `wp_product_brands`.`name` as brand, `wp_product_categories`.`name` as kategoria FROM `wp_product_list`, `wp_product_files`, `wp_product_brands`, `wp_product_categories` WHERE wp_product_list.id='{$product_id}' AND `wp_product_list`.`active`='1' AND `wp_product_list`.`visible`='1' AND `wp_product_list`.`file` = `wp_product_files`.`id` AND `wp_product_brands`.`id` = `wp_product_list`.`brand` AND `wp_product_list`.`category` = `wp_product_categories`.`id` ORDER BY `wp_product_list`.`id` DESC LIMIT 1"; $product_list = $wpdb->get_results($sql, ARRAY_A); if (!$licensecolumn) { // download link start $link = ""; $previous_download_ids = array(0); $sessionid = $_GET['sessionid']; $selectsql = "SELECT * FROM `wp_purchase_logs` WHERE `sessionid`= " . $sessionid . " LIMIT 1"; $check = $wpdb->get_results($selectsql, ARRAY_A); //pokazh($product_list,"product_list"); if (isset($product_list[0]['file']) && isset($check[0]['id']) && $product_list[0]['file'] > 0) { $wpdb->query("UPDATE `wp_download_status` SET `active`='1' WHERE `fileid`='" . $product_list[0]['file'] . "' AND `purchid` = '" . $check[0]['id'] . "' LIMIT 1"); $download_data = $wpdb->get_results("SELECT * FROM `wp_download_status` WHERE `fileid`='" . $product_list[0]['file'] . "' AND `purchid`='" . $check[0]['id'] . "' AND `id` NOT IN (" . make_csv($previous_download_ids) . ") LIMIT 1", ARRAY_A); $download_data = $download_data[0]; /* * for security reason add to url for hires images sid - last 6 simbols of idhash * */ $sql = "SELECT `idhash` FROM `wp_product_files` WHERE `id`=" . $product_list[0]['file'] . " LIMIT 1"; $idhash_data = $wpdb->get_results($sql, ARRAY_A); if ($idhash_data != null) { $idhash = "&sid=" . substr($idhash_data[0]['idhash'], -6); } $site_tmp = includeTrailingCharacter($siteurl, "/"); $link = $site_tmp . "?downloadid=" . $download_data['id'] . $idhash; $previous_download_ids[] = $download_data['id']; } /// download link stop } $result .= "<tr>"; $result .= " <td style='width:144px;'>"; $result_no_license_text .= "<tr>"; $result_no_license_text .= " <td style='width:144px;'>"; $basepath = get_option('siteurl'); $imagedir = $basepath . "/wp-content/plugins/wp-shopping-cart/images/"; $previewdir = $basepath . "/wp-content/plugins/wp-shopping-cart/product_images/"; $result .= "<a href='" . $previewdir . $product_list[0]['image'] . "'><img border='0' src='" . $imagedir . $product_list[0]['image'] . "'></a>"; $result .= " </td>"; $result .= " <td>"; $result_no_license_text .= "<a href='" . $previewdir . $product_list[0]['image'] . "'><img border='0' src='" . $imagedir . $product_list[0]['image'] . "'></a>"; $result_no_license_text .= " </td>"; $result_no_license_text .= " <td>"; $_size = $product_list[0]['width'] . "px X " . $product_list[0]['height'] . "px;"; $_bigpictext = "<b>Номер:</b> " . $product_list[0]['id']; $_bigpictext .= "<br /><b>Автор:</b> " . $product_list[0]['brand']; $_bigpictext .= "<br /><b>Название: </b> " . nl2br(stripslashes($product_list[0]['name'])); $_bigpictext .= "<br /><b>Категория: </b> " . $product_list[0]['kategoria']; $_bigpictext .= "<br /><b>Описание: </b> " . nl2br(stripslashes($product_list[0]['description'])); $_bigpictext .= "<br /><b>Тэги: </b>" . nl2br(stripslashes($product_list[0]['additional_description'])); $_bigpictext .= "<br /><b>Размер:</b> " . $_size; $_bigpictext .= "<br /><b>Цена (без скидки):</b> " . $_SESSION['nzshpcrt_cart'][$key]->price . " руб."; $_bigpictext .= "<br /><b>Лицензия:</b> " . license_name($_SESSION['nzshpcrt_cart'][$key]->license); $_SESSION['nzshpcrt_cart'][$key]->author = $product_list[0]['brand']; $result .= "<div style='font-size: 8pt !important;'>" . $_bigpictext . "</div>"; $result .= " </td>"; $result_no_license_text .= "<div style='font-size: 8pt !important;'>" . $_bigpictext . "</div>"; $result_no_license_text .= " </td>"; if ($licensecolumn) { $result .= " <td width='240'>"; $result .= "<form name='licenses' id='licenses' onsubmit='submitform(this);return false;' action='" . $siteurl . "/?page_id=29' method='POST'>"; $result_no_license_text .= " <td width='240'>"; $result_no_license_text .= "<form name='licenses' id='licenses' onsubmit='submitform(this);return false;' action='" . $siteurl . "/?page_id=29' method='POST'>"; $ch1 = ischecked('l1_price', $product_list[0]['id']); $result .= "<input name='license' value='l1_price' type='radio' {$ch1} />"; $result .= round($product_list[0]['l1_price']) . " руб. "; $result .= "<a title='ваша лицензия' href='#' onclick=\"javascript:window.open('" . $siteurl . "/wp-content/plugins/wp-shopping-cart/license.php?l=1&item=" . $current_item . "','текст ограниченной лицензии','height=480,width=640,scrollbars=yes');\">ограниченная</a> <br />"; $result_no_license_text .= "<input name='license' value='l1_price' type='radio' {$ch1} />"; $result_no_license_text .= round($product_list[0]['l1_price']) . " руб. "; $result_no_license_text .= "<a title='ваша лицензия' href='#' onclick=\"javascript:window.open('" . $siteurl . "/wp-content/plugins/wp-shopping-cart/license.php?l=1&item=" . $current_item . "','текст ограниченной лицензии','height=480,width=640,scrollbars=yes');\">ограниченная</a> <br />"; $ch2 = ischecked('l2_price', $product_list[0]['id']); $result .= "<input name='license' value='l2_price' type='radio' {$ch2} />"; $result .= round($product_list[0]['l2_price']) . " руб. <a title='ваша лицензия' href='#' onclick=\"javascript:window.open('" . $siteurl . "/wp-content/plugins/wp-shopping-cart/license.php?l=2&item=" . $current_item . "','текст стандартной лицензии','height=480,width=640,scrollbars=yes');\">стандартная</a><br />"; $result_no_license_text .= "<input name='license' value='l2_price' type='radio' {$ch2} />"; $result_no_license_text .= round($product_list[0]['l2_price']) . " руб. <a title='ваша лицензия' href='#' onclick=\"javascript:window.open('" . $siteurl . "/wp-content/plugins/wp-shopping-cart/license.php?l=2&item=" . $current_item . "','текст стандартной лицензии','height=480,width=640,scrollbars=yes');\">стандартная</a><br />"; $ch3 = ischecked('l3_price', $product_list[0]['id']); $result .= "<input name='license' value='l3_price' type='radio' {$ch3} />"; $result .= round($product_list[0]['l3_price']) . " руб. <a title='ваша лицензия' href='#' onclick=\"javascript:window.open('" . $siteurl . "/wp-content/plugins/wp-shopping-cart/license.php?l=3&item=" . $current_item . "','текст расширенной лицензии','height=480,width=640,scrollbars=yes');\">расширенная</a>"; $result .= "<input value='" . $product_list[0]['id'] . "' name='prodid' type='hidden'> <br /><br />"; $result .= "<input id='searchsubmit' value='Сменить лицензию' type='submit'> </form>"; $result .= " </td>"; $result_no_license_text .= "<input name='license' value='l3_price' type='radio' {$ch3} />"; $result_no_license_text .= round($product_list[0]['l3_price']) . " руб. <a title='ваша лицензия' href='#' onclick=\"javascript:window.open('" . $siteurl . "/wp-content/plugins/wp-shopping-cart/license.php?l=3&item=" . $current_item . "','текст расширенной лицензии','height=480,width=640,scrollbars=yes');\">расширенная</a>"; $result_no_license_text .= "<input value='" . $product_list[0]['id'] . "' name='prodid' type='hidden'> <br /><br />"; $result_no_license_text .= "<input id='searchsubmit' value='Сменить лицензию' type='submit'> </form>"; $result_no_license_text .= " </td>"; } if (isset($product_list[0]['price'])) { $total += $number * $product_list[0]['price']; } if ($licensecolumn) { // License select $result .= " <td width='70'>"; $result .= "<a href='" . get_option('shopping_cart_url') . "&remove=" . $key . "'>Убрать из заказа</a>"; $result .= " </td>"; } else { // Download link $current_user = wp_get_current_user(); $result .= " <td width='140'>"; $result_no_license_text .= " <td width='140'>"; if (isset($current_user) && $current_user->ID == '106') { $result .= "<a href='" . get_option('siteurl') . "/demo/demo.jpg' style='background-color:#33ff99;padding:7px;border:1px #a3a598 solid;text-decoration:none;margin-top:16px;'>Скачать demo</a>"; $result_no_license_text .= "<a href='" . get_option('siteurl') . "/demo/demo.jpg' style='background-color:#33ff99;padding:7px;border:1px #a3a598 solid;text-decoration:none;margin-top:16px;'>Скачать demo</a>"; } else { $result .= "<a href='{$link}' style='background-color:#33ff99;padding:7px;border:1px #a3a598 solid;text-decoration:none;margin-top:16px;'>Скачать</a>"; $result_no_license_text .= "<a href='{$link}' style='background-color:#33ff99;padding:7px;border:1px #a3a598 solid;text-decoration:none;margin-top:16px;'>Скачать</a>"; } $result .= " </td>"; $result_no_license_text .= " </td>"; } $result .= "</tr>"; $result_no_license_text .= "</tr>"; // License text if (!$licensecolumn) { if ($_SESSION['nzshpcrt_cart'][$current_item]->price == '250.00') { $lic_type = 1; } elseif ($_SESSION['nzshpcrt_cart'][$current_item]->price == '500.00') { $lic_type = 2; } elseif ($_SESSION['nzshpcrt_cart'][$current_item]->price == '2500.00') { $lic_type = 3; } else { $lic_type = 1; } $license_text = get_license($current_item, $lic_type); $result .= "<tr>"; $result .= "<td colspan=3> <a id='displayText" . $current_item . "' href='javascript:toggle(" . $current_item . ");'>[+] показать текст лицензии</a><div id='toggleText" . $current_item . "' style='display:none;background-color:#FFFFCC;padding:8px;'><br />"; $result .= $license_text; $result .= "</div></td>"; $result .= "</tr>"; } } // end of: foreach($cart as $key => $cart_item) } else { return ''; } $result .= '</table>'; $result_no_license_text .= '</table>'; $result .= "<script language='javascript'> "; $result .= "function toggle(item) {"; $result .= "var ele = document.getElementById('toggleText'+item);"; $result .= "var text = document.getElementById('displayText'+item);"; $result .= "if(ele.style.display == 'block') {"; $result .= "\t\tele.style.display = 'none';"; $result .= "\ttext.innerHTML = '[+] показать текст лицензии<br />';"; $result .= "}"; $result .= "else {"; $result .= "\tele.style.display = 'block';"; $result .= "\ttext.innerHTML = '[-] скрыть текст лицензии<br />';"; $result .= "}"; $result .= "} "; $result .= "</script>"; //$result .= ("<pre>SESSION:".print_r($_SESSION,true)."</pre>"); return $result; }
function referrer_report_script($ret = false) { $member_id = get_param_integer('member_id', NULL); if (!has_zone_access(get_member(), 'adminzone') && $member_id !== get_member()) { access_denied('ZONE_ACCESS', 'adminzone'); } require_lang('referrals'); $csv = get_param_integer('csv', 0) == 1; $where = db_string_not_equal_to('i_email_address', '') . ' AND i_inviter<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()); if ($member_id !== NULL) { $where .= ' AND referrer.id=' . strval($member_id); } $max = get_param_integer('max', $csv ? 10000 : 30); $start = get_param_integer('start', 0); $data = array(); $table = 'f_invites i LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referrer ON referrer.id=i_inviter LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referee ON referee.m_email_address=i_email_address'; $referrals = $GLOBALS['FORUM_DB']->query('SELECT i_time AS time,referrer.id AS referrer_id,referrer.m_username AS referrer,referrer.m_email_address AS referrer_email,referee.id AS referee_id,referee.m_username AS referee,referee.m_email_address AS referee_email,i_taken AS qualified FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where . ' ORDER BY i_time DESC', $max, $start); $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where); if (count($referrals) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } foreach ($referrals as $ref) { $data_row = array(); $data_row[do_lang('DATE_TIME')] = get_timezoned_date($ref['time'], true, true, false, true); if (is_null($member_id)) { if ($csv) { $deleted = true; $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referrer']; } else { $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer_id']) ? '' : strval($ref['referrer_id']); } $data_row[do_lang('TYPE_REFERRER') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = $ref['referrer_email']; $data_row[do_lang('QUALIFIED_REFERRER')] = do_lang(referrer_is_qualified($ref['referrer_id']) ? 'YES' : 'NO'); } $deleted = false; if (is_null($ref['referee'])) { $deleted = $ref['qualified'] == 1; //!is_null($GLOBALS['SITE_DB']->query_value_null_ok('adminlogs','id',array('the_type'=>'DELETE_MEMBER','param_b'=>TODO Unfortunately we can't tell))); } if ($csv) { $data_row[do_lang('REFEREE')] = is_null($ref['referee']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referee']; } else { $data_row[do_lang('REFEREE')] = is_null($ref['referee_id']) ? '' : strval($ref['referee_id']); } $data_row[do_lang('REFEREE') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = is_null($ref['referee_email']) ? '' : $ref['referee_email']; $data_row[do_lang('QUALIFIED_REFERRAL')] = do_lang($ref['qualified'] == 1 ? 'YES' : 'NO'); $data[] = $data_row; } if ($csv) { require_code('files2'); make_csv($data, (is_null($member_id) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($member_id)) . ' referrals.csv'); } else { require_code('templates_results_table'); $fields_title = new ocp_tempcode(); $fields = new ocp_tempcode(); foreach ($data as $i => $data_row) { if ($i == 0) { $fields_title->attach(results_field_title(array_keys($data_row))); } foreach ($data_row as $key => $val) { if ($key == do_lang('REFEREE') || $key == do_lang('TYPE_REFERRER')) { if ($val == '') { $val = do_lang('UNKNOWN'); } else { $val = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($val, true); } } $data_row[$key] = escape_html($val); } $fields->attach(results_entry($data_row)); } $table = results_table(do_lang('REFERRALS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields); if ($ret) { return $table; } $title = get_page_title('REFERRALS'); $out = new ocp_tempcode(); $out->attach($title); $out->attach($table); $out = globalise($out, NULL, '', true); $out->evaluate_echo(); } return NULL; }
function transaction_results($sessionid, $echo_to_screen = true, $transaction_id = null) { global $wpdb, $_SESSION, $Debug, $_GET; //why are autoglobal arrays here? $curgateway = get_option('payment_gateway'); $errorcode = ''; $order_status = 2; $siteurl = get_option('siteurl'); /* * {Notes} Double check that $Echo_To_Screen is a boolean value */ $echo_to_screen = !is_bool($echo_to_screen) ? true : $echo_to_screen; if (is_numeric($sessionid)) { $report = TXT_WPSC_EMAILMSG2; $selectsql = "SELECT * FROM `" . $wpdb->prefix . "purchase_logs` WHERE `sessionid`= " . $sessionid . " LIMIT 1"; $purchase_log = $wpdb->get_row($selectsql, ARRAY_A); if ($purchase_log['gateway'] == "testmode" && $purchase_log['processed'] < 2) { $message = "" . TXT_WPSC_YOUR_ORDER . ":\n"; $message_html = "<h2 style='padding-top: 0px;' >" . TXT_WPSC_YOUR_ORDER . "</h2>"; } else { $message = TXT_WPSC_EMAILMSG1; $message_html = $message; } $order_url = $siteurl . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php&purchcaseid=" . $purchase_log['id']; if ($_GET['ipn_request'] != 'true' and get_option('paypal_ipn') == 1) { if ($purchase_log == null) { echo TXT_WPSC_ORDER_FAILED; if (get_option('purch_log_email') != null && $purchase_log['email_sent'] != 1) { mail(get_option('purch_log_email'), TXT_WPSC_NEW_ORDER_PENDING_SUBJECT, TXT_WPSC_NEW_ORDER_PENDING_BODY . $order_url, "From: " . get_option('return_email') . ""); } return false; } else { if ($purchase_log['email_sent'] != 1 && $purchase_log['processed'] < 2) { //added by Thomas on 20/6/2007 echo TXT_WPSC_ORDER_PENDING . "<p style='margin: 1em 0px 0px 0px;' >" . nl2br(get_option('payment_instructions')) . "</p>"; if ($purchase_log['gateway'] != 'testmode') { if (get_option('purch_log_email') != null && $purchase_log['email_sent'] != 1) { mail(get_option('purch_log_email'), TXT_WPSC_NEW_ORDER_PENDING_SUBJECT, TXT_WPSC_NEW_ORDER_PENDING_BODY . $order_url, "From: " . get_option('return_email') . ""); } return false; } } } } else { if ($purchase_log['processed'] < 2) { //added by Thomas on 20/6/2007 echo TXT_WPSC_ORDER_PENDING . "<p style='margin: 1em 0px 0px 0px;' >" . nl2br(get_option('payment_instructions')) . "</p>"; if ($purchase_log['gateway'] != 'testmode') { if (get_option('purch_log_email') != null && $purchase_log['email_sent'] != 1) { mail(get_option('purch_log_email'), TXT_WPSC_NEW_ORDER_PENDING_SUBJECT, TXT_WPSC_NEW_ORDER_PENDING_BODY . $order_url, "From: " . get_option('return_email') . ""); } return false; } } } $cartsql = "SELECT * FROM `" . $wpdb->prefix . "cart_contents` WHERE `purchaseid`=" . $purchase_log['id'] . ""; $cart = $wpdb->get_results($cartsql, ARRAY_A); if ($purchase_log['shipping_country'] != '') { $billing_country = $purchase_log['billing_country']; $shipping_country = $purchase_log['shipping_country']; } else { $country = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "submited_form_data` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . get_option('country_form_field') . "' LIMIT 1", ARRAY_A); $billing_country = $country[0]['value']; $shipping_country = $country[0]['value']; } $email_form_field = $wpdb->get_results("SELECT `id`,`type` FROM `" . $wpdb->prefix . "collect_data_forms` WHERE `type` IN ('email') AND `active` = '1' ORDER BY `order` ASC LIMIT 1", ARRAY_A); $email_address = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "submited_form_data` WHERE `log_id`=" . $purchase_log['id'] . " AND `form_id` = '" . $email_form_field[0]['id'] . "' LIMIT 1", ARRAY_A); $email = $email_address[0]['value']; $previous_download_ids = array(0); if ($cart != null && $errorcode == 0) { foreach ($cart as $row) { $link = ""; $productsql = "SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `id`=" . $row['prodid'] . ""; $product_data = $wpdb->get_results($productsql, ARRAY_A); if ($product_data[0]['file'] > 0) { if ($purchase_log['email_sent'] != 1) { $wpdb->query("UPDATE `" . $wpdb->prefix . "download_status` SET `active`='1' WHERE `fileid`='" . $product_data[0]['file'] . "' AND `purchid` = '" . $purchase_log['id'] . "' LIMIT 1"); } /* $digitalsql = "SELECT * FROM `".$wpdb->prefix."cart_contents` WHERE purchaseid=".$purchase_log['id'].""; $digital = $wpdb->get_results($digitalsql,ARRAY_A); $digitalsql = "SELECT * FROM `".$wpdb->prefix."cart_item_variations` WHERE `cart_id`=".$digital[0]['id'].""; $digital = $wpdb->get_results($digitalsql,ARRAY_A); $digitalsql = "SELECT * FROM `".$wpdb->prefix."variation_priceandstock` WHERE `variation_id_1`=".$digital[0]['value_id']." AND product_id=".$product_data[0]['id'].""; $digital = $wpdb->get_results($digitalsql,ARRAY_A);*/ $downloadable = '1'; // if ($digital[0]['file'] == '1'){ // $downloadable='1'; // } if ($downloadable) { $download_data = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "download_status` WHERE `fileid`='" . $product_data[0]['file'] . "' AND `purchid`='" . $purchase_log['id'] . "' AND `id` NOT IN (" . make_csv($previous_download_ids) . ") LIMIT 1", ARRAY_A); $download_data = $download_data[0]; if ($download_data['uniqueid'] == null) { // if the uniqueid is not equal to null, its "valid", regardless of what it is $link = $siteurl . "?downloadid=" . $download_data['id']; } else { $link = $siteurl . "?downloadid=" . $download_data['uniqueid']; } $previous_download_ids[] = $download_data['id']; $order_status = 4; } } do_action('wpsc_confirm_checkout', $purchase_log['id']); $shipping = nzshpcrt_determine_item_shipping($row['prodid'], $row['quantity'], $shipping_country); $total_shipping += $shipping; if ($product_data[0]['special'] == 1) { $price_modifier = $product_data[0]['special_price']; } else { $price_modifier = 0; } $total += $row['price'] * $row['quantity']; $message_price = nzshpcrt_currency_display($row['price'] * $row['quantity'], $product_data[0]['notax'], true); $shipping_price = nzshpcrt_currency_display($shipping, 1, true); $variation_sql = "SELECT * FROM `" . $wpdb->prefix . "cart_item_variations` WHERE `cart_id`='" . $row['id'] . "'"; $variation_data = $wpdb->get_results($variation_sql, ARRAY_A); $variation_count = count($variation_data); if ($variation_count > 1) { $variation_list = " ("; if ($purchase['gateway'] != 'testmode') { if ($gateway['internalname'] == $purch_data[0]['gateway']) { $gateway_name = $gateway['name']; } } else { $gateway_name = "Manual Payment"; } $i = 0; foreach ($variation_data as $variation) { if ($i > 0) { $variation_list .= ", "; } $value_id = $variation['value_id']; $value_data = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "variation_values` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A); $variation_list .= $value_data[0]['name']; $i++; } $variation_list .= ")"; } else { if ($variation_count == 1) { $value_id = $variation_data[0]['value_id']; $value_data = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "variation_values` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A); $variation_list = " (" . $value_data[0]['name'] . ")"; } else { $variation_list = ''; } } if ($link != '') { $message .= " - " . $product_data[0]['name'] . $variation_list . " " . $message_price . " " . TXT_WPSC_CLICKTODOWNLOAD . ": {$link}\n"; $message_html .= " - " . $product_data[0]['name'] . $variation_list . " " . $message_price . " <a href='{$link}'>" . TXT_WPSC_DOWNLOAD . "</a>\n"; } else { $plural = ''; if ($row['quantity'] > 1) { $plural = "s"; } $message .= " - " . $row['quantity'] . " " . $product_data[0]['name'] . $variation_list . " " . $message_price . "\n - " . TXT_WPSC_SHIPPING . ":" . $shipping_price . "\n\r"; $message_html .= " - " . $row['quantity'] . " " . $product_data[0]['name'] . $variation_list . " " . $message_price . "\n - " . TXT_WPSC_SHIPPING . ":" . $shipping_price . "\n\r"; } $report .= " - " . $product_data[0]['name'] . $variation_list . " " . $message_price . "\n"; } if ($purchase_log['discount_data'] != '') { $coupon_data = $wpdb->get_row("SELECT * FROM `" . $wpdb->prefix . "wpsc_coupon_codes` WHERE coupon_code='" . $wpdb->escape($purchase_log['discount_data']) . "' LIMIT 1", ARRAY_A); if ($coupon_data['use-once'] == 1) { $wpdb->query("UPDATE `" . $wpdb->prefix . "wpsc_coupon_codes` SET `active`='0', `is-used`='1' WHERE `id`='" . $coupon_data['id'] . "' LIMIT 1"); } } //$wpdb->query("UPDATE `".$wpdb->prefix."download_status` SET `active`='1' WHERE `fileid`='".$product_data[0]['file']."' AND `purchid` = '".$purchase_log['id']."' LIMIT 1"); $total_shipping = nzshpcrt_determine_base_shipping($total_shipping, $shipping_country); $total = $total + $total_shipping - $purchase_log['discount_value']; // $message.= "\n\r"; $message .= "Your Purchase No.: " . $purchase_log['id'] . "\n\r"; if ($purchase_log['discount_value'] > 0) { $message .= TXT_WPSC_DISCOUNT . ": " . nzshpcrt_currency_display($purchase_log['discount_value'], 1, true) . "\n\r"; } $message .= TXT_WPSC_TOTALSHIPPING . ": " . nzshpcrt_currency_display($total_shipping, 1, true) . "\n\r"; $message .= TXT_WPSC_TOTAL . ": " . nzshpcrt_currency_display($total, 1, true) . "\n\r"; $message_html .= "Your Purchase No.: " . $purchase_log['id'] . "\n\n\r"; if ($purchase_log['discount_value'] > 0) { $message_html .= TXT_WPSC_DISCOUNT . ": " . nzshpcrt_currency_display($purchase_log['discount_value'], 1, true) . "\n\r"; } $message_html .= TXT_WPSC_TOTALSHIPPING . ": " . nzshpcrt_currency_display($total_shipping, 1, true) . "\n\r"; $message_html .= TXT_WPSC_TOTAL . ": " . nzshpcrt_currency_display($total, 1, true) . "\n\r"; if (isset($_GET['ti'])) { $message .= "\n\r" . TXT_WPSC_YOURTRANSACTIONID . ": " . $_GET['ti']; $message_html .= "\n\r" . TXT_WPSC_YOURTRANSACTIONID . ": " . $_GET['ti']; $report .= "\n\r" . TXT_WPSC_TRANSACTIONID . ": " . $_GET['ti']; } else { $report_id = "Purchase No.: " . $purchase_log['id'] . "\n\r"; } if ($email != '' && $purchase_log['email_sent'] != 1) { if ($purchase_log['processed'] < 2) { $payment_instructions = strip_tags(get_option('payment_instructions')); $message = TXT_WPSC_ORDER_PENDING . "\n\r" . $payment_instructions . "\n\r" . $message; mail($email, TXT_WPSC_ORDER_PENDING_PAYMENT_REQUIRED, $message, "From: " . get_option('return_email') . ""); } else { mail($email, TXT_WPSC_PURCHASERECEIPT, $message, "From: " . get_option('return_email') . ""); } } $report_user = TXT_WPSC_CUSTOMERDETAILS . "\n\r"; $form_sql = "SELECT * FROM `" . $wpdb->prefix . "submited_form_data` WHERE `log_id` = '" . $purchase_log['id'] . "'"; $form_data = $wpdb->get_results($form_sql, ARRAY_A); if ($form_data != null) { foreach ($form_data as $form_field) { $form_sql = "SELECT * FROM `" . $wpdb->prefix . "collect_data_forms` WHERE `id` = '" . $form_field['form_id'] . "' LIMIT 1"; $form_data = $wpdb->get_results($form_sql, ARRAY_A); $form_data = $form_data[0]; if ($form_data['type'] == 'country') { $report_user .= $form_data['name'] . ": " . get_country($form_field['value']) . "\n"; } else { $report_user .= $form_data['name'] . ": " . $form_field['value'] . "\n"; } } } $report_user .= "\n\r"; $report = $report_user . $report_id . $report; if (get_option('purch_log_email') != null && $purchase_log['email_sent'] != 1) { mail(get_option('purch_log_email'), TXT_WPSC_PURCHASEREPORT, $report, "From: " . get_option('return_email') . ""); } if ($purchase_log['gateway'] == 'testmode' && $purchase_log['processed'] < 2) { echo "<br />" . nl2br(str_replace("\$", '\\$', $message_html)); return; } $_SESSION['nzshpcrt_cart'] = ''; $_SESSION['nzshpcrt_cart'] = array(); if (true === $echo_to_screen) { echo '<div class="wrap">'; if ($sessionid != null) { echo TXT_WPSC_THETRANSACTIONWASSUCCESSFUL . "<br />"; echo "<br />" . nl2br(str_replace("\$", '\\$', $message_html)); } echo '</div>'; } } else { if (true === $echo_to_screen) { echo '<div class="wrap">'; echo TXT_WPSC_BUYPRODUCTS; echo '</div>'; } } if ($purchase_log['email_sent'] != 1 and $sessionid != '') { if (preg_match("/^[\\w\\s._,-]+\$/", $transaction_id)) { $transact_id_sql = "`transactid` = '" . $transaction_id . "',"; } $update_sql = "UPDATE `" . $wpdb->prefix . "purchase_logs` SET {$transact_id_sql} `date` = '" . time() . "',`email_sent` = '1', `processed` = '{$order_status}' WHERE `sessionid` = " . $sessionid . " LIMIT 1"; $wpdb->query($update_sql); } } }
/** * The UI to show OCF posting rates. * * @param object The stats module object * @param string The screen type * @return tempcode The UI */ function posting_rates($ob, $type) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('SITE_STATISTICS')))); require_lang('ocf'); //This will show a plain bar chart with all the downloads listed $title = get_page_title('POSTING_RATES'); // Handle time range if (get_param_integer('dated', 0) == 0) { $title = get_page_title('POSTING_RATES'); $extra_fields = new ocp_tempcode(); require_code('form_templates'); $extra_fields->attach(form_input_tick(do_lang_tempcode('HOURLY_BREAKDOWNS'), do_lang_tempcode('DESCRIPTION_HOURLY_BREAKDOWNS'), 'hourly', false)); return $ob->get_between($title, false, $extra_fields); } $time_start = get_input_date('time_start', true); $time_end = get_input_date('time_end', true); if (!is_null($time_end)) { $time_end += 60 * 60 * 24 - 1; } // So it is end of day not start if (is_null($time_start)) { $time_start = 0; } if (is_null($time_end)) { $time_end = time(); } $title = get_page_title('SECTION_POSTING_RATES_RANGE', true, array(escape_html(get_timezoned_date($time_start, false)), escape_html(get_timezoned_date($time_end, false)))); $poster_exception = ''; foreach (explode(',', get_param('poster_exception', '')) as $e) { if (trim($e) == '') { continue; } $poster_exception .= 'p_poster<>' . strval(intval($e)) . ' AND '; } $csv = get_param_integer('csv', 0) == 1; if ($csv) { $time_start = 0; $time_end = time(); $hourly = false; } $rows = $GLOBALS['FORUM_DB']->query('SELECT p_time FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE ' . $poster_exception . 'p_time>' . strval($time_start) . ' AND p_time<' . strval($time_end)); if (count($rows) < 1) { return warn_screen($title, do_lang_tempcode('NO_DATA')); } $hourly = get_param_integer('hourly', 0) == 1; //($time_end-$time_start)<=60*60*24*2; $iterate_months = floatval($time_end - $time_start) / (60.0 * 60.0 * 24.0) > 100.0; // Gather data $posting_rates = array(); if ($hourly) { for ($i = 0; $i < 24; $i++) { $date = str_pad(strval($i), 2, '0', STR_PAD_LEFT) . ':00'; $posting_rates[$date] = 0; } } else { if ($iterate_months) { $year = intval(date('Y', $time_start)); $month = intval(date('m', $time_start)); while (mktime(0, 0, 0, $month - 1, 0, $year) < $time_end) { $date = date('Y/m', mktime(0, 0, 0, $month, 0, $year)); $posting_rates[$date] = 0; $month++; if ($month == 13) { $month = 1; $year++; } } } else { for ($i = $time_start - 60 * 60 * 12; $i <= $time_end + 60 * 60 * 12; $i += 60 * 60 * 24) { $date = date('Y/m/d', $i); $posting_rates[$date] = 0; } } } foreach ($rows as $row) { if ($hourly) { $date = date('H', $row['p_time']) . ':00'; } else { if ($iterate_months) { $date = date('Y/m', $row['p_time']); } else { $date = date('Y/m/d', $row['p_time']); } } $posting_rates[$date]++; } $start = 0; $max = 1000; // Little trick, as we want all to fit $sortables = array(); require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('COUNT_TOTAL')), $sortables); $fields = new ocp_tempcode(); $real_data = array(); $i = 0; foreach ($posting_rates as $date => $value) { $fields->attach(results_entry(array(escape_html($date), escape_html(integer_format($value))))); $real_data[] = array('Date/Time' => $date, 'Tally' => $value); $i++; } $list = results_table(do_lang_tempcode('POSTING_RATES'), $start, 'start', $max, 'max', count($posting_rates), $fields_title, $fields, $sortables, '', '', 'sort', new ocp_tempcode()); if ($csv) { make_csv($real_data, 'posting_rates.csv'); } $output = create_bar_chart($posting_rates, do_lang('DATE'), do_lang('COUNT_TOTAL'), '', ''); $ob->save_graph('Global-Posting_rates', $output); $graph = do_template('STATS_GRAPH', array('GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/Global-Posting_rates.xml', 'TITLE' => do_lang_tempcode('POSTING_RATES'), 'TEXT' => do_lang_tempcode('DESCRIPTION_POSTING_RATES'))); return do_template('STATS_SCREEN', array('TITLE' => $title, 'GRAPH' => $graph, 'STATS' => $list)); }