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