]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/task_functions.php
Referal overview finished and rewritten for refback extension
[mailer.git] / inc / libs / task_functions.php
index 9e073455fc2aa4d54db331066434afc3144bb659..d02865c36c2c3783d427069ee8a80c83b0a11f67 100644 (file)
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
+if (!defined('__SECURITY')) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
+
 //
 // The advanced overview shows detailed informations to your exchange script:
 //  - Unconfirmed / locked accounts
@@ -46,7 +47,7 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
 //
 function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
 {
-       global $_SESSION, $_CONFIG;
+       global $_CONFIG;
 
        // Init variables/arrays
        $EXTRAS = ""; $OUT = ""; $SQLs = array(); $WHATs = array(); $DESCRs = array(); $TITLEs = array();
@@ -57,18 +58,18 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
        if (!$JOBS_DONE) {
                // New extensions or updates found
                $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='%s' AND status='NEW' AND task_type='EXTENSION_UPDATE'",
-                array(GET_ADMIN_ID($_SESSION['admin_login'])), __FILE__, __LINE__);
+                array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
 
                $value = SQL_NUMROWS($result);
                SQL_FREERESULT($result);
 
                if ($value > 0) {
-                       define ('__TASK_UPDATE_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task&amp;type=updates\">".$value."</A>");
+                       define('__TASK_UPDATE_VALUE', "<A href=\"".URL."/modules.php?module=admin&amp;what=list_task&amp;type=updates\">".$value."</A>");
                } else {
-                       define ('__TASK_UPDATE_VALUE', "0");
+                       define('__TASK_UPDATE_VALUE', "0");
                }
        } else {
-               define ('__TASK_UPDATE_VALUE', "0");
+               define('__TASK_UPDATE_VALUE', "0");
        }
 
        //
@@ -150,7 +151,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
        // Solved tasks
        //
        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE status = 'SOLVED' AND assigned_admin='%s'",
-        array(GET_ADMIN_ID($_SESSION['admin_login'])), __FILE__, __LINE__);
+        array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
        $value = SQL_NUMROWS($result);
        SQL_FREERESULT($result);
 
@@ -164,7 +165,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
        // Your tasks
        //
        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='%s' AND status = 'NEW' AND task_type != 'EXTENSION_UPDATE'",
-        array(GET_ADMIN_ID($_SESSION['admin_login'])), __FILE__, __LINE__);
+        array(GET_ADMIN_ID(get_session('admin_login'))), __FILE__, __LINE__);
        $value = SQL_NUMROWS($result);
        SQL_FREERESULT($result);
 
@@ -254,7 +255,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
        // Sent bonus mails
        //
        if (GET_EXT_VERSION("bonus") >= "0.1.8") {
-               $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE data_type='SEND'", __FILE__, __LINE__);
+               $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE data_type='SEND' AND is_notify='N'", __FILE__, __LINE__);
                $value = SQL_NUMROWS($result);
                SQL_FREERESULT($result);
 
@@ -271,23 +272,19 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
 
        if (EXT_IS_ACTIVE("autopurge")) {
                // Start finding them...
-               $since = (time() - $_CONFIG['ap_in_since']);
-               $EXCLUDE_LIST = " AND d.userid != c.def_refid";
+               $since = $_CONFIG['ap_inactive_since'];
+               $EXCLUDE_LIST = " AND d.userid != ".$_CONFIG['def_refid']."";
 
                // Check for more extensions
-               if (EXT_IS_ACTIVE("beg"))     $EXCLUDE_LIST .= " AND d.userid != c.beg_uid";
-               if (EXT_IS_ACTIVE("bonus"))   $EXCLUDE_LIST .= " AND d.userid != c.bonus_uid";
-               if (EXT_IS_ACTIVE("doubler")) $EXCLUDE_LIST .= " AND d.userid != c.doubler_uid";
-
-               // Check for new holiday system
-               if (GET_EXT_VERSION("holiday") >= "0.1.3") {
-                       $EXCLUDE_LIST .= " AND d.holiday_active = 'N'";
-               }
+               if (EXT_IS_ACTIVE("beg"))                  $EXCLUDE_LIST .= " AND d.userid != ".$_CONFIG['beg_uid']."";
+               if (EXT_IS_ACTIVE("bonus"))                $EXCLUDE_LIST .= " AND d.userid != ".$_CONFIG['bonus_uid']."";
+               if (EXT_IS_ACTIVE("doubler"))              $EXCLUDE_LIST .= " AND d.userid != ".$_CONFIG['doubler_uid']."";
+               if (GET_EXT_VERSION("holiday") >= "0.1.3") $EXCLUDE_LIST .= " AND d.holiday_active='N'";
 
                // Check for all accounts
                $SQLs[] = "SELECT DISTINCT d.userid, d.email, d.last_online
-FROM "._MYSQL_PREFIX."_user_data AS d, "._MYSQL_PREFIX."_config AS c
-WHERE d.status='CONFIRMED' AND d.joined < ".$since." AND d.last_online < ".$since." AND d.ap_notified < ".$since."
+FROM "._MYSQL_PREFIX."_user_data AS d
+WHERE d.status='CONFIRMED' AND d.joined < (UNIX_TIMESTAMP() - ".$since.") AND d.last_online < ".$since." AND d.ap_notified < ".$since."
 ".$EXCLUDE_LIST."
 ORDER BY d.userid";
                $WHATs[]  = "list_autopurge";
@@ -296,10 +293,10 @@ ORDER BY d.userid";
        }
 
        if (GET_EXT_VERSION("sql_patches") >= "0.3.4") {
-               // Check for accounts without referral
+               // Check for accounts without referal
                $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE refid='0' ORDER BY userid";
-               $DESCRs[] = TAKS_ADMIN_LIST_ACCOUNT_NOREF;
-               $TITLEs[] = TAKS_ADMIN_LIST_ACCOUNT_NOREF_TITLE;
+               $DESCRs[] = TASK_ADMIN_LIST_ACCOUNT_NOREF;
+               $TITLEs[] = TASK_ADMIN_LIST_ACCOUNT_NOREF_TITLE;
                $WHATs[]  = "list_norefs";
        }
 
@@ -323,6 +320,14 @@ ORDER BY d.userid";
                $TITLEs[] = TASK_ADMIN_LIST_WERNIS_ALL_TITLE;
        }
 
+       if (EXT_IS_ACTIVE("primera")) {
+               // List new primera requests
+               $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_primera ORDER BY userid";
+               $WHATs[]  = "list_primera";
+               $DESCRs[] = TASK_ADMIN_LIST_PRIMERA_ALL;
+               $TITLEs[] = TASK_ADMIN_LIST_PRIMERA_ALL_TITLE;
+       }
+
        if (EXT_IS_ACTIVE("holiday")) {
                // List holiday requests
                $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_holidays ORDER BY userid";
@@ -336,11 +341,11 @@ ORDER BY d.userid";
                if (GET_EXT_VERSION("bonus") >= "0.6.9") {
                        // Add more bonus points here
                        $USE = "(0";
-                       if ($_CONFIG['bonus_click_yn'] == 'Y') $USE .= " + turbo_bonus";
-                       if ($_CONFIG['bonus_login_yn'] == 'Y') $USE .= " + login_bonus";
-                       if ($_CONFIG['bonus_order_yn'] == 'Y') $USE .= " + bonus_order";
-                       if ($_CONFIG['bonus_stats_yn'] == 'Y') $USE .= " + bonus_stats";
-                       if ($_CONFIG['bonus_ref_yn']   == 'Y') $USE .= " + bonus_ref";
+                       if ($_CONFIG['bonus_click_yn'] == "Y") $USE .= " + turbo_bonus";
+                       if ($_CONFIG['bonus_login_yn'] == "Y") $USE .= " + login_bonus";
+                       if ($_CONFIG['bonus_order_yn'] == "Y") $USE .= " + bonus_order";
+                       if ($_CONFIG['bonus_stats_yn'] == "Y") $USE .= " + bonus_stats";
+                       if ($_CONFIG['bonus_ref_yn']   == "Y") $USE .= " + bonus_ref";
                        $USE .= ")";
                } else {
                        // Old version ???
@@ -348,34 +353,41 @@ ORDER BY d.userid";
                }
 
                // Autopurge installed?
-               $LAST = ""; $ONLINE = "";
-               if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_inactive'] == 'Y') && ($_CONFIG['ap_in_since'] > 0)) {
+               $LAST = "";
+               if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['autopurge_inactive'] == "Y") && ($_CONFIG['ap_inactive_since'] > 0)) {
                        // Use last online timestamp to keep inactive members away from here
-                       $LAST   = " AND last_online >= ";
-                       $ONLINE = bigintval(time() - $_CONFIG['ap_in_since']);
+                       $LAST   = sprintf(" AND last_online >= (UNIX_TIMESTAMP() - %s)", $_CONFIG['ap_inactive_since']);
                }
 
-               $SQLs[]   = "SELECT ".$USE." AS active_bonus FROM "._MYSQL_PREFIX."_user_data
-WHERE status='CONFIRMED' AND ".$USE.">0".$LAST."".$ONLINE."
+               $SQLs[]   = "SELECT ".$USE." AS active_bonus
+FROM "._MYSQL_PREFIX."_user_data
+WHERE status='CONFIRMED' AND ".$USE.">0".$LAST."
 ORDER BY active_bonus DESC, userid";
                $WHATs[]  = "list_bonus";
                $DESCRs[] = TASK_ADMIN_LIST_BONUS;
                $TITLEs[] = TASK_ADMIN_LIST_BONUS_TITLE;
+
+               if (GET_EXT_VERSION("bonus") >= "0.8.7") {
+                       // List all notifications
+                       $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE is_notify='Y' ORDER BY timestamp DESC";
+                       $WHATs[]  = "list_notifications";
+                       $DESCRs[] = TASK_ADMIN_LIST_NOTIFICATIONS;
+                       $TITLEs[] = TASK_ADMIN_LIST_NOTIFICATIONS_TITLE;
+               }
        }
 
        if (GET_EXT_VERSION("beg") >= "0.1.2") {
                // Begging rallye
 
                // Autopurge installed?
-               $LAST = ""; $ONLINE = "";
-               if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_inactive'] == 'Y') && ($_CONFIG['ap_in_since'] > 0)) {
+               $LAST = "";
+               if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['autopurge_inactive'] == "Y") && ($_CONFIG['ap_inactive_since'] > 0)) {
                        // Use last online timestamp to keep inactive members away from here
-                       $LAST   = " AND last_online >= ";
-                       $ONLINE = bigintval(time() - $_CONFIG['ap_in_since']);
+                       $LAST   = sprintf(" AND last_online >= (UNIX_TIMESTAMP() - %s)", $_CONFIG['ap_inactive_since']);
                }
 
                $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_data
-WHERE status='CONFIRMED' AND beg_points>0".$LAST."".$ONLINE."
+WHERE status='CONFIRMED' AND beg_points>0".$LAST."
 ORDER BY beg_points DESC, userid";
                $WHATs[]  = "list_beg";
                $DESCRs[] = TASK_ADMIN_LIST_BEG;
@@ -395,7 +407,7 @@ ORDER BY beg_points DESC, userid";
        }
 
        //
-       // All referral banner
+       // All referal banner
        //
        $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_refbanner ORDER BY id";
        $WHATs[] = "refbanner";
@@ -403,7 +415,7 @@ ORDER BY beg_points DESC, userid";
        $TITLEs[] = TASK_ADMIN_LIST_REFBANNER_ALL_TITLE;
 
        //
-       // All activated referral banner
+       // All activated referal banner
        //
        $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_refbanner WHERE visible='Y' ORDER BY id";
        $WHATs[] = "refbanner";
@@ -516,6 +528,20 @@ ORDER BY beg_points DESC, userid";
                $TITLEs[] = TASK_ADMIN_LIST_ADMINS_ALL_TITLE;
        }
 
+       if (EXT_IS_ACTIVE("surfbar")) {
+               // List all URLs in surfbar
+               $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_surfbar_urls ORDER BY id";
+               $WHATs[]  = "list_surfbar_urls";
+               $DESCRs[] = TASK_ADMIN_LIST_SURFBAR_URLS_ALL;
+               $TITLEs[] = TASK_ADMIN_LIST_SURFBAR_URLS_ALL_TITLE;
+
+               // List all pending URLs in surfbar
+               $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_surfbar_urls WHERE status='PENDING' ORDER BY id";
+               $WHATs[]  = "unlock_surfbar_urls";
+               $DESCRs[] = TASK_ADMIN_LIST_SURFBAR_URLS_PENDING;
+               $TITLEs[] = TASK_ADMIN_LIST_SURFBAR_URLS_PENDING_TITLE;
+       }
+
        // Generate extra overview rows
        $EXTRAS .= TASK_CREATE_EXTRA_ROWS($SQLs, $WHATs, $DESCRs, $TITLEs);
 
@@ -533,10 +559,14 @@ ORDER BY beg_points DESC, userid";
 function TASK_CREATE_EXTRA_ROWS($SQLs, $WHATs, $DESCRs, $TITLEs){
        // Init
        $OUT = ""; $SW = 2; $MAX = sizeof($SQLs) - 1;
-       foreach ($SQLs as $key=>$sql) {
+       foreach ($SQLs as $key => $sql) {
                // Run SQL command, get line numbers and free memory
                $result = SQL_QUERY($sql, __FILE__, __LINE__);
+
+               // Get rows
                $value = SQL_NUMROWS($result);
+
+               // Free result
                SQL_FREERESULT($result);
 
                $content = array(
@@ -550,7 +580,7 @@ function TASK_CREATE_EXTRA_ROWS($SQLs, $WHATs, $DESCRs, $TITLEs){
                        if (empty($TITLEs[$key])) $TITLEs[$key] = TASK_ADMIN_UNKNOWN_LIST_TITLE;
                        $content['row_link'] = "<A href=\"".URL."/modules.php?module=admin&amp;what=".$WHATs[$key]."\" title=\"".$TITLEs[$key]."\">".$value."</A>";
                } else {
-                       $content['row_link'] = "0";
+                       $content['row_link'] = 0;
                }
 
                // Switch color
@@ -558,7 +588,7 @@ function TASK_CREATE_EXTRA_ROWS($SQLs, $WHATs, $DESCRs, $TITLEs){
 
                // And insert the final string into extras template
                $OUT .= LOAD_TEMPLATE("admin_overview_task_rows", true, $content);
-       }
+       } // END - if
 
        // Return output
        return LOAD_TEMPLATE("admin_overview_task_extras", true, $OUT);