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