2 /************************************************************************
3 * MXChange v0.2.1 Start: 11/09/2003 *
4 * =============== Last change: 04/21/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-stats.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Statistics over send mails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Statistik ueber gesendete Mails *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38 } elseif (!IS_MEMBER()) {
39 LOAD_URL("modules.php?module=index");
42 // Add description as navigation point
43 ADD_DESCR("member", __FILE__);
46 $main_content = array();
48 // Load waiting/pending orders
49 $result = SQL_QUERY_ESC("SELECT id, cat_id, payment_id, subject, url, timestamp, target_send, data_type, zip
50 FROM "._MYSQL_PREFIX."_pool
51 WHERE sender=%s AND data_type != 'SEND'
52 ORDER BY timestamp DESC",
53 array($GLOBALS['userid']), __FILE__, __LINE__);
55 // Are there mails left in pool?
56 if (SQL_NUMROWS($result) > 0) {
59 while ($data = SQL_FETCHARRAY($result)) {
60 // Is the ZIP code set? If not, set dashes
61 if (empty($data['zip'])) $data['zip'] = "---";
63 // Prepare content for output
67 'cat' => GET_CATEGORY($data['cat_id']),
68 'pay' => GET_PAYMENT($data['payment_id']),
69 'subj' => COMPILE_CODE($data['subject']),
70 'url' => DEREFERER($data['url']),
71 'stamp' => MAKE_DATETIME($data['timestamp'], "2"),
72 'recs' => $data['target_send'],
73 'type' => TRANSLATE_POOL_TYPE($data['data_type']),
78 $OUT .= LOAD_TEMPLATE("member_pool_row", true, $content);
85 $main_content['pool'] = LOAD_TEMPLATE("member_pool_table", true, $OUT);
88 $main_content['pool'] = LOAD_TEMPLATE("admin_settings_saved", true, MEMBER_NO_MAILS_IN_POOL);
92 SQL_FREERESULT($result);
96 $result = SQL_QUERY_ESC("SELECT id, cat_id, payment_id, subject, url, timestamp_ordered, max_rec, timestamp_send, clicks
97 FROM "._MYSQL_PREFIX."_user_stats
99 ORDER BY timestamp_ordered DESC",
100 array($GLOBALS['userid']), __FILE__, __LINE__);
102 if (SQL_NUMROWS($result) > 0) {
103 // Mail orders are in pool so we can display them
105 while ($data = SQL_FETCHROW($result)) {
106 // Prepare data for the template
109 'cat' => GET_CATEGORY($data[1]),
110 'pay' => GET_PAYMENT($data[2]),
111 'subj' => COMPILE_CODE($data[3]),
112 'url' => DEREFERER($data[4]),
113 'stamp' => MAKE_DATETIME($data[5], "2"),
115 'sent' => MAKE_DATETIME($data[7], "2"),
117 'perc' => COMPILE_CODE($data[8] / $data[6] * 100)."%",
120 // Load row template and switch colors
121 $OUT .= LOAD_TEMPLATE("member_stats_row", true, $content);
125 // Load main template
126 $main_content['stats'] = LOAD_TEMPLATE("member_stats_table", true, $OUT);
128 // No mail orders fond
129 $main_content['stats'] = LOAD_TEMPLATE("admin_settings_saved", true, MEMBER_NO_MAILS_IN_STATS);
133 SQL_FREERESULT($result);
135 // Load main template
136 LOAD_TEMPLATE("member_stats_pool", false, $main_content);