582139eb9bfd159419d7152aa41d2f78827eac89
[mailer.git] / inc / libs / task_functions.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 08/03/2004 *
4  * ================                             Last change: 11/19/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : task_functions.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Special task functions                           *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Spezielle task-Funktionen                        *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.                                  *
22  *                                                                      *
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.                         *
27  *                                                                      *
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,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 //
41 // The advanced overview shows detailed informations to your exchange script:
42 //  - Unconfirmed / locked accounts
43 //  - Mails waiting to be approved
44 //  - Open tasks
45 //  - Your own tasks
46 //  - ...
47 //
48 function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
49 {
50         global $_CONFIG;
51
52         // Init variables/arrays
53         $EXTRAS = ""; $OUT = ""; $SQLs = array(); $WHATs = array(); $DESCRs = array(); $TITLEs = array();
54
55         // Chheck for new extensions and updates
56         $JOBS_DONE = OUTPUT_STANDARD_OVERVIEW($result_main);
57
58         if (!$JOBS_DONE) {
59                 // New extensions or updates found
60                 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='%s' AND status='NEW' AND task_type='EXTENSION_UPDATE'",
61                  array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
62
63                 $value = SQL_NUMROWS($result);
64                 SQL_FREERESULT($result);
65
66                 if ($value > 0) {
67                         define('__TASK_UPDATE_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task&amp;type=updates\">".$value."</A>");
68                 } else {
69                         define('__TASK_UPDATE_VALUE', "0");
70                 }
71         } else {
72                 define('__TASK_UPDATE_VALUE', "0");
73         }
74
75         //
76         // First check for all account status seperately
77         //
78         // Confirmed accounts
79         $result = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED'", __FILE__, __LINE__);
80         $value = SQL_NUMROWS($result);
81         SQL_FREERESULT($result);
82
83         if ($value > 0) {
84                 define('__CONFIRMED_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_user&amp;mode=confirmed\">".$value."</A>");
85         } else {
86                 define('__CONFIRMED_VALUE', "0");
87         }
88
89         // Unconfirmed accounts
90         $result = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='UNCONFIRMED'", __FILE__, __LINE__);
91         $value = SQL_NUMROWS($result);
92         SQL_FREERESULT($result);
93
94         if ($value > 0) {
95                 define('__UNCONFIRMED_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=chk_regs\">".$value."</A>");
96         } else {
97                 define('__UNCONFIRMED_VALUE', "0");
98         }
99
100         // And locked accounts
101         $result = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='LOCKED'", __FILE__, __LINE__);
102         $value = SQL_NUMROWS($result);
103         SQL_FREERESULT($result);
104
105         if ($value > 0) {
106                 define('__LOCKED_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_user&amp;mode=locked\">".$value."</A>");
107         } else {
108                 define('__LOCKED_VALUE', "0");
109         }
110
111         //
112         // Unassigned tasks
113         //
114         $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='0' AND status != 'DELETED'", __FILE__, __LINE__);
115         $value = SQL_NUMROWS($result);
116         SQL_FREERESULT($result);
117
118         if ($value > 0) {
119                 define('__TASK_NEW_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task&amp;type=unassigned\">".$value."</A>");
120         } else {
121                 define('__TASK_NEW_VALUE', "0");
122         }
123
124         //
125         // Closed tasks
126         //
127         $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE status = 'CLOSED'", __FILE__, __LINE__);
128         $value = SQL_NUMROWS($result);
129         SQL_FREERESULT($result);
130
131         if ($value > 0) {
132                 define('__TASK_CLOSED_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task&amp;type=closed\">".$value."</A>");
133         } else {
134                 define('__TASK_CLOSED_VALUE', "0");
135         }
136
137         //
138         // Deleted tasks
139         //
140         $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE status = 'DELETED'", __FILE__, __LINE__);
141         $value = SQL_NUMROWS($result);
142         SQL_FREERESULT($result);
143
144         if ($value > 0) {
145                 define('__TASK_DELETED_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task&amp;type=deleted\">".$value."</A>");
146         } else {
147                 define('__TASK_DELETED_VALUE', "0");
148         }
149
150         //
151         // Solved tasks
152         //
153         $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE status = 'SOLVED' AND assigned_admin='%s'",
154          array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
155         $value = SQL_NUMROWS($result);
156         SQL_FREERESULT($result);
157
158         if ($value > 0) {
159                 define('__TASK_SOLVED_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task&amp;type=solved\">".$value."</A>");
160         } else {
161                 define('__TASK_SOLVED_VALUE', "0");
162         }
163
164         //
165         // Your tasks
166         //
167         $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='%s' AND status = 'NEW' AND task_type != 'EXTENSION_UPDATE'",
168          array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
169         $value = SQL_NUMROWS($result);
170         SQL_FREERESULT($result);
171
172         if ($value > 0) {
173                 define('__TASK_YOUR_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task\">".$value."</A>");
174         } else {
175                 define('__TASK_YOUR_VALUE', "0");
176         }
177
178         //
179         // Mails waiting to be approved
180         //
181         $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_pool WHERE data_type='ADMIN'", __FILE__, __LINE__);
182         $value = SQL_NUMROWS($result);
183         SQL_FREERESULT($result);
184
185         if ($value > 0) {
186                 define('__MAIL_ADMIN_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=unlock_emails\">".$value."</A>");
187         } else {
188                 define('__MAIL_ADMIN_VALUE', "0");
189         }
190
191         //
192         // Unfinished mail orders
193         //
194         $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_pool WHERE data_type='TEMP'", __FILE__, __LINE__);
195         $value = SQL_NUMROWS($result);
196         SQL_FREERESULT($result);
197
198         if ($value > 0) {
199                 define('__MAIL_TEMP_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=email_details\">".$value."</A>");
200         } else {
201                 define('__MAIL_TEMP_VALUE', "0");
202         }
203
204         //
205         // Sent mail orders
206         //
207         $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_pool WHERE data_type='SEND'", __FILE__, __LINE__);
208         $value = SQL_NUMROWS($result);
209         SQL_FREERESULT($result);
210
211         if ($value > 0) {
212                 define('__MAIL_SEND_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=email_archiv\">".$value."</A>");
213         } else {
214                 define('__MAIL_SEND_VALUE', "0");
215         }
216
217         //
218         // Autopurged mails
219         //
220         if (EXT_IS_ACTIVE("autopurge")) {
221                 $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED'", __FILE__, __LINE__);
222                 $value = SQL_NUMROWS($result);
223                 SQL_FREERESULT($result);
224
225                 if ($value > 0) {
226                         define('__MAIL_DELETED_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=email_details\">".$value."</A>");
227                 } else {
228                         define('__MAIL_DELETED_VALUE', "0");
229                 }
230
231                 //
232                 // Autopurged bonus mails
233                 //
234                 if (GET_EXT_VERSION("bonus") >= "0.1.8") {
235                         $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE data_type='DELETED'", __FILE__, __LINE__);
236                         $value = SQL_NUMROWS($result);
237                         SQL_FREERESULT($result);
238
239                         if ($value > 0) {
240                                 define('__MAIL_BONUS_AP_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=email_details\">".$value."</A>");
241                         } else {
242                                 define('__MAIL_BONUS_AP_VALUE', "0");
243                         }
244                 } elseif (EXT_IS_ACTIVE("bonus")) {
245                         define('__MAIL_BONUS_AP_VALUE', ADMIN_EXT_BONUS_OUTDATED_1."0.1.8".ADMIN_EXT_BONUS_OUTDATED_2);
246                 } else {
247                         define('__MAIL_BONUS_AP_VALUE', "<FONT class=\"admin_note\">".ADMIN_EXT_BONUS_404."</FONT>");
248                 }
249         } else {
250                 define('__MAIL_BONUS_AP_VALUE', "<FONT class=\"admin_note\">".ADMIN_EXT_AUTOPURGE_404."</FONT>");
251                 define('__MAIL_DELETED_VALUE', "<FONT class=\"admin_note\">".ADMIN_EXT_AUTOPURGE_404."</FONT>");
252         }
253
254         //
255         // Sent bonus mails
256         //
257         if (GET_EXT_VERSION("bonus") >= "0.1.8") {
258                 $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE data_type='SEND' AND is_notify='N'", __FILE__, __LINE__);
259                 $value = SQL_NUMROWS($result);
260                 SQL_FREERESULT($result);
261
262                 if ($value > 0) {
263                         define('__MAIL_BONUS_SEND_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=email_details\">".$value."</A>");
264                 } else {
265                         define('__MAIL_BONUS_SEND_VALUE', "0");
266                 }
267         } elseif (EXT_IS_ACTIVE("bonus")) {
268                 define('__MAIL_BONUS_SEND_VALUE', ADMIN_EXT_BONUS_OUTDATED_1."0.1.8".ADMIN_EXT_BONUS_OUTDATED_2);
269         } else {
270                 define('__MAIL_BONUS_SEND_VALUE', ADMIN_EXT_BONUS_404);
271         }
272
273         if (EXT_IS_ACTIVE("autopurge")) {
274                 // Start finding them...
275                 $since = $_CONFIG['ap_inactive_since'];
276                 $EXCLUDE_LIST = " AND d.userid != ".$_CONFIG['def_refid']."";
277
278                 // Check for more extensions
279                 if (EXT_IS_ACTIVE("beg"))                  $EXCLUDE_LIST .= " AND d.userid != ".$_CONFIG['beg_uid']."";
280                 if (EXT_IS_ACTIVE("bonus"))                $EXCLUDE_LIST .= " AND d.userid != ".$_CONFIG['bonus_uid']."";
281                 if (EXT_IS_ACTIVE("doubler"))              $EXCLUDE_LIST .= " AND d.userid != ".$_CONFIG['doubler_uid']."";
282                 if (GET_EXT_VERSION("holiday") >= "0.1.3") $EXCLUDE_LIST .= " AND d.holiday_active='N'";
283
284                 // Check for all accounts
285                 $SQLs[] = "SELECT DISTINCT d.userid, d.email, d.last_online
286 FROM "._MYSQL_PREFIX."_user_data AS d
287 WHERE d.status='CONFIRMED' AND d.joined < (UNIX_TIMESTAMP() - ".$since.") AND d.last_online < ".$since." AND d.ap_notified < ".$since."
288 ".$EXCLUDE_LIST."
289 ORDER BY d.userid";
290                 $WHATs[]  = "list_autopurge";
291                 $DESCRs[] = TASK_ADMIN_INACTIVE_AUTOPURGE;
292                 $TITLEs[] = TASK_ADMIN_INACTIVE_AUTOPURGE_TITLE;
293         }
294
295         if (GET_EXT_VERSION("sql_patches") >= "0.3.4") {
296                 // Check for accounts without referral
297                 $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE refid='0' ORDER BY userid";
298                 $DESCRs[] = TASK_ADMIN_LIST_ACCOUNT_NOREF;
299                 $TITLEs[] = TASK_ADMIN_LIST_ACCOUNT_NOREF_TITLE;
300                 $WHATs[]  = "list_norefs";
301         }
302
303         if (EXT_IS_ACTIVE("payout")) {
304                 // List new payout requests
305                 $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_payouts WHERE status='NEW' ORDER BY userid";
306                 $WHATs[]  = "list_payouts";
307                 $DESCRs[] = TASK_ADMIN_LIST_PAYOUTS_WAITING;
308                 $TITLEs[] = TASK_ADMIN_LIST_PAYOUTS_WAITING_TITLE;
309                 $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_payouts ORDER BY userid";
310                 $WHATs[]  = "list_payouts";
311                 $DESCRs[] = TASK_ADMIN_LIST_PAYOUTS_ALL;
312                 $TITLEs[] = TASK_ADMIN_LIST_PAYOUTS_ALL_TITLE;
313         }
314
315         if (EXT_IS_ACTIVE("wernis")) {
316                 // List new wernis requests
317                 $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_wernis ORDER BY userid";
318                 $WHATs[]  = "list_wernis";
319                 $DESCRs[] = TASK_ADMIN_LIST_WERNIS_ALL;
320                 $TITLEs[] = TASK_ADMIN_LIST_WERNIS_ALL_TITLE;
321         }
322
323         if (EXT_IS_ACTIVE("primera")) {
324                 // List new primera requests
325                 $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_primera ORDER BY userid";
326                 $WHATs[]  = "list_primera";
327                 $DESCRs[] = TASK_ADMIN_LIST_PRIMERA_ALL;
328                 $TITLEs[] = TASK_ADMIN_LIST_PRIMERA_ALL_TITLE;
329         }
330
331         if (EXT_IS_ACTIVE("holiday")) {
332                 // List holiday requests
333                 $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_holidays ORDER BY userid";
334                 $WHATs[]  = "list_holiday";
335                 $DESCRs[] = TASK_ADMIN_LIST_HOLIDAYS;
336                 $TITLEs[] = TASK_ADMIN_LIST_HOLIDAYS_TITLE;
337         }
338
339         if (GET_EXT_VERSION("bonus") >= "0.2.3") {
340                 // Active rallye
341                 if (GET_EXT_VERSION("bonus") >= "0.6.9") {
342                         // Add more bonus points here
343                         $USE = "(0";
344                         if ($_CONFIG['bonus_click_yn'] == "Y") $USE .= " + turbo_bonus";
345                         if ($_CONFIG['bonus_login_yn'] == "Y") $USE .= " + login_bonus";
346                         if ($_CONFIG['bonus_order_yn'] == "Y") $USE .= " + bonus_order";
347                         if ($_CONFIG['bonus_stats_yn'] == "Y") $USE .= " + bonus_stats";
348                         if ($_CONFIG['bonus_ref_yn']   == "Y") $USE .= " + bonus_ref";
349                         $USE .= ")";
350                 } else {
351                         // Old version ???
352                         $USE = "turbo_bonus";
353                 }
354
355                 // Autopurge installed?
356                 $LAST = "";
357                 if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['autopurge_inactive'] == "Y") && ($_CONFIG['ap_inactive_since'] > 0)) {
358                         // Use last online timestamp to keep inactive members away from here
359                         $LAST   = sprintf(" AND last_online >= (UNIX_TIMESTAMP() - %s)", $_CONFIG['ap_inactive_since']);
360                 }
361
362                 $SQLs[]   = "SELECT ".$USE." AS active_bonus
363 FROM "._MYSQL_PREFIX."_user_data
364 WHERE status='CONFIRMED' AND ".$USE.">0".$LAST."
365 ORDER BY active_bonus DESC, userid";
366                 $WHATs[]  = "list_bonus";
367                 $DESCRs[] = TASK_ADMIN_LIST_BONUS;
368                 $TITLEs[] = TASK_ADMIN_LIST_BONUS_TITLE;
369
370                 if (GET_EXT_VERSION("bonus") >= "0.8.7") {
371                         // List all notifications
372                         $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE is_notify='Y' ORDER BY timestamp DESC";
373                         $WHATs[]  = "list_notifications";
374                         $DESCRs[] = TASK_ADMIN_LIST_NOTIFICATIONS;
375                         $TITLEs[] = TASK_ADMIN_LIST_NOTIFICATIONS_TITLE;
376                 }
377         }
378
379         if (GET_EXT_VERSION("beg") >= "0.1.2") {
380                 // Begging rallye
381
382                 // Autopurge installed?
383                 $LAST = "";
384                 if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['autopurge_inactive'] == "Y") && ($_CONFIG['ap_inactive_since'] > 0)) {
385                         // Use last online timestamp to keep inactive members away from here
386                         $LAST   = sprintf(" AND last_online >= (UNIX_TIMESTAMP() - %s)", $_CONFIG['ap_inactive_since']);
387                 }
388
389                 $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_data
390 WHERE status='CONFIRMED' AND beg_points>0".$LAST."
391 ORDER BY beg_points DESC, userid";
392                 $WHATs[]  = "list_beg";
393                 $DESCRs[] = TASK_ADMIN_LIST_BEG;
394                 $TITLEs[] = TASK_ADMIN_LIST_BEG_TITLE;
395         }
396
397         if (EXT_IS_ACTIVE("doubler")) {
398                 // List waiting payouts
399                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_doubler WHERE completed='N' ORDER BY id";
400                 $WHATs[]  = "list_doubler&amp;mode=waiting&amp;select=all";
401                 $DESCRs[] = TASK_ADMIN_LIST_DOUBLER_WAITING;
402                 $TITLEs[] = TASK_ADMIN_LIST_DOUBLER_WAITING_TITLE;
403                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_doubler ORDER BY id";
404                 $WHATs[]  = "list_doubler";
405                 $DESCRs[] = TASK_ADMIN_LIST_DOUBLER_ALL;
406                 $TITLEs[] = TASK_ADMIN_LIST_DOUBLER_ALL_TITLE;
407         }
408
409         //
410         // All referral banner
411         //
412         $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_refbanner ORDER BY id";
413         $WHATs[] = "refbanner";
414         $DESCRs[] = TASK_ADMIN_LIST_REFBANNER_ALL;
415         $TITLEs[] = TASK_ADMIN_LIST_REFBANNER_ALL_TITLE;
416
417         //
418         // All activated referral banner
419         //
420         $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_refbanner WHERE visible='Y' ORDER BY id";
421         $WHATs[] = "refbanner";
422         $DESCRs[] = TASK_ADMIN_LIST_REFBANNER_ACTIVE;
423         $TITLEs[] = TASK_ADMIN_LIST_REFBANNER_ACTIVE_TITLE;
424
425         //
426         // All extensions
427         //
428         $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_extensions ORDER BY id";
429         $WHATs[] = "extensions";
430         $DESCRs[] = TASK_ADMIN_LIST_EXTENSIONS_ALL;
431         $TITLEs[] = TASK_ADMIN_LIST_EXTENSIONS_ALL_TITLE;
432
433         //
434         // All activated extensions
435         //
436         $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_extensions WHERE ext_active='Y' ORDER BY id";
437         $WHATs[] = "extensions&amp;active=Y";
438         $DESCRs[] = TASK_ADMIN_LIST_EXTENSIONS_ACTIVE;
439         $TITLEs[] = TASK_ADMIN_LIST_EXTENSIONS_ACTIVE_TITLE;
440
441         if (EXT_IS_ACTIVE("engine")) {
442                 // List all export accounts
443                 $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_engine_accounts ORDER BY id";
444                 $WHATs[] = "list_engine";
445                 $DESCRs[] = TASK_ADMIN_LIST_ENGINE;
446
447                 // List all pending accounts
448                 $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_engine_accounts WHERE status='UNCONFIRMED' ORDER BY id";
449                 $WHATs[] = "unlock_engine";
450                 $DESCRs[] = TASK_ADMIN_UNLOCK_ENGINE;
451
452                 // List all safes
453                 $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_engine_safe ORDER BY id";
454                 $WHATs[] = "list_engine&amp;mode=safe";
455                 $DESCRs[] = TASK_ADMIN_LIST_ENGINE_SAFES;
456
457                 // List all export URLs
458                 $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_engine_urls ORDER BY id";
459                 $WHATs[] = "engine_urls";
460                 $DESCRs[] = TASK_ADMIN_LIST_ENGINE_URLS;
461         }
462
463         if (EXT_IS_ACTIVE("sponsor")) {
464                 // List all sponsors
465                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_sponsor_data ORDER BY id";
466                 $WHATs[]  = "list_sponsor";
467                 $DESCRs[] = TASK_ADMIN_LIST_SPONSOR;
468                 $TITLEs[] = TASK_ADMIN_LIST_SPONSOR_TITLE;
469
470                 // List confirmed sponsor accounts
471                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_sponsor_data WHERE status='CONFIRMED' ORDER BY id";
472                 $WHATs[]  = "list_sponsor";
473                 $DESCRs[] = TASK_ADMIN_LIST_SPONSOR_CONFIRMED;
474                 $TITLEs[] = TASK_ADMIN_LIST_SPONSOR_CONFIRMED_TITLE;
475
476                 // List unconfirmed sponsor accounts
477                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_sponsor_data WHERE status='UNCONFIRMED' ORDER BY id";
478                 $WHATs[]  = "list_sponsor";
479                 $DESCRs[] = TASK_ADMIN_LIST_SPONSOR_UNCONFIRMED;
480                 $TITLEs[] = TASK_ADMIN_LIST_SPONSOR_UNCONFIRMED_TITLE;
481
482                 // List locked sponsor accounts
483                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_sponsor_data WHERE status='LOCKED' ORDER BY id";
484                 $WHATs[]  = "list_sponsor";
485                 $DESCRs[] = TASK_ADMIN_LIST_SPONSOR_LOCKED;
486                 $TITLEs[] = TASK_ADMIN_LIST_SPONSOR_LOCKED_TITLE;
487
488                 // List waiting sponsor accounts to be approved
489                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_sponsor_data WHERE status='PENDING' ORDER BY id";
490                 $WHATs[]  = "unlock_sponsor";
491                 $DESCRs[] = TASK_ADMIN_LIST_SPONSOR_PENDING;
492                 $TITLEs[] = TASK_ADMIN_LIST_SPONSOR_PENDING_TITLE;
493
494                 // Waiting payments
495                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_sponsor_orders WHERE pay_status='PENDING' ORDER BY id";
496                 $WHATs[]  = "list_sponsor_pays";
497                 $DESCRs[] = TASK_ADMIN_LIST_SPONSOR_ORDERS;
498                 $TITLEs[] = TASK_ADMIN_LIST_SPONSOR_ORDERS_TITLE;
499         }
500
501         if (EXT_IS_ACTIVE("country")) {
502                 // List country codes
503                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_countries ORDER BY id";
504                 $WHATs[]  = "list_country";
505                 $DESCRs[] = TASK_ADMIN_LIST_COUNTRY;
506                 $TITLEs[] = TASK_ADMIN_LIST_COUNTRY_TITLE;
507         }
508
509         if (EXT_IS_ACTIVE("theme")) {
510                 // List all themes
511                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_themes ORDER BY id";
512                 $WHATs[]  = "theme_edit";
513                 $DESCRs[] = TASK_ADMIN_LIST_THEME_ALL;
514                 $TITLEs[] = TASK_ADMIN_LIST_THEME_ALL_TITLE;
515
516                 // List active themes
517                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_active='Y' ORDER BY id";
518                 $WHATs[]  = "theme_edit";
519                 $DESCRs[] = TASK_ADMIN_LIST_THEME_ACTIVE;
520                 $TITLEs[] = TASK_ADMIN_LIST_THEME_ACTIVE_TITLE;
521         }
522
523         if (EXT_IS_ACTIVE("admins")) {
524                 // List all administrator logins
525                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_admins ORDER BY id";
526                 $WHATs[]  = "admins_edit";
527                 $DESCRs[] = TASK_ADMIN_LIST_ADMINS_ALL;
528                 $TITLEs[] = TASK_ADMIN_LIST_ADMINS_ALL_TITLE;
529         }
530
531         if (EXT_IS_ACTIVE("surfbar")) {
532                 // List all URLs in surfbar
533                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_surfbar_urls ORDER BY id";
534                 $WHATs[]  = "list_surfbar_urls";
535                 $DESCRs[] = TASK_ADMIN_LIST_SURFBAR_URLS_ALL;
536                 $TITLEs[] = TASK_ADMIN_LIST_SURFBAR_URLS_ALL_TITLE;
537
538                 // List all pending URLs in surfbar
539                 $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_surfbar_urls WHERE status='PENDING' ORDER BY id";
540                 $WHATs[]  = "unlock_surfbar_urls";
541                 $DESCRs[] = TASK_ADMIN_LIST_SURFBAR_URLS_PENDING;
542                 $TITLEs[] = TASK_ADMIN_LIST_SURFBAR_URLS_PENDING_TITLE;
543         }
544
545         // Generate extra overview rows
546         $EXTRAS .= TASK_CREATE_EXTRA_ROWS($SQLs, $WHATs, $DESCRs, $TITLEs);
547
548         // If empty just keep a forced-space left for CSS issues
549         if (empty($EXTRAS)) $EXTRAS = "&nbsp;";
550
551         // Add compiled string to constant for final template
552         define('__OVERVIEW_EXTRA_TABLE', $EXTRAS);
553
554         // Simply load the template... :-)
555         LOAD_TEMPLATE("admin_overview_task");
556 }
557
558 //
559 function TASK_CREATE_EXTRA_ROWS($SQLs, $WHATs, $DESCRs, $TITLEs){
560         // Init
561         $OUT = ""; $SW = 2; $MAX = sizeof($SQLs) - 1;
562         foreach ($SQLs as $key => $sql) {
563                 // Run SQL command, get line numbers and free memory
564                 $result = SQL_QUERY($sql, __FILE__, __LINE__);
565
566                 // Get rows
567                 $value = SQL_NUMROWS($result);
568
569                 // Free result
570                 SQL_FREERESULT($result);
571
572                 $content = array(
573                         'row_descr' => $DESCRs[$key],
574                         'row_sw'    => $SW,
575                         'bottom'    => "",
576                 );
577
578                 if ($key < $MAX) $content['bottom'] = "bottom2";
579                 if (($value > 0) && (!empty($WHATs[$key]))) {
580                         if (empty($TITLEs[$key])) $TITLEs[$key] = TASK_ADMIN_UNKNOWN_LIST_TITLE;
581                         $content['row_link'] = "<A href=\"".URL."/modules.php?module=admin&amp;what=".$WHATs[$key]."\" title=\"".$TITLEs[$key]."\">".$value."</A>";
582                 } else {
583                         $content['row_link'] = 0;
584                 }
585
586                 // Switch color
587                 $SW = 3 - $SW;
588
589                 // And insert the final string into extras template
590                 $OUT .= LOAD_TEMPLATE("admin_overview_task_rows", true, $content);
591         } // END - if
592
593         // Return output
594         return LOAD_TEMPLATE("admin_overview_task_extras", true, $OUT);
595 }
596 //
597 ?>