]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Surfbar continued (unfinished) and some updates:
[mailer.git] / inc / mysql-manager.php
index c4803ae00bd7d0d40acc5bb3457978d65a50a505..5433a771ee5f5ac4f3929ba7b891a657c4a07eea 100644 (file)
@@ -583,10 +583,16 @@ function WHAT_IS_VALID($act, $wht, $type="guest")
 //
 function IS_MEMBER()
 {
-       global $status, $LAST;
+       global $status, $LAST, $cacheArray;
        if (!is_array($LAST)) $LAST = array();
        $ret = false;
 
+       // is the cache entry there?
+       if (isset($cacheArray['is_member'])) {
+               // Then return it
+               return $cacheArray['is_member'];
+       } // END - if
+
        // Fix "deleted" cookies first
        FIX_DELETED_COOKIES(array('userid', 'u_hash', 'lifetime'));
 
@@ -639,29 +645,26 @@ function IS_MEMBER()
                unset($GLOBALS['userid']);
        }
 
+       // Cache status
+       $cacheArray['is_member'] = $ret;
+
        // Return status
        return $ret;
 }
 //
-function UPDATE_LOGIN_DATA ($UPDATE=true) {
+function UPDATE_LOGIN_DATA () {
        global $LAST, $_CONFIG;
        if (!is_array($LAST)) $LAST = array();
 
-       // Are the required cookies set?
-       if ((!isset($GLOBALS['userid'])) || (!isSessionVariableSet('u_hash')) || (!isSessionVariableSet('lifetime'))) {
-               // Nope, then return here to caller function
-               return false;
-       } else {
-               // Secure user ID
-               $GLOBALS['userid'] = bigintval(get_session('userid'));
-       }
+       // Recheck if logged in
+       if (!IS_MEMBER()) return false;
+
+       // Secure user ID
+       $GLOBALS['userid'] = bigintval(get_session('userid'));
 
        // Extract last online time (life) and how long is auto-login valid (time)
        $newl = time() + bigintval(get_session('lifetime'));
 
-       // Recheck if logged in
-       if (!IS_MEMBER()) return false;
-
        // Load last module and last online time
        $result = SQL_QUERY_ESC("SELECT last_module, last_online FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) == 1) {
@@ -926,20 +929,15 @@ function GET_ACTION ($MODE, &$wht)
        } elseif (!empty($GLOBALS['action'])) {
                // Get it directly from URL
                return $GLOBALS['action'];
-       } else {
-               // Everything else will be touched after checking the module has a menu assigned
        }
        //* DEBUG: */ echo __LINE__."*".$ret."*<br />\n";
 
-       if (MODULE_HAS_MENU($MODE))
-       {
+       if (MODULE_HAS_MENU($MODE)) {
                // Rewriting modules to menu
-               switch ($MODE)
-               {
+               switch ($MODE) {
                        case "index": $MODE = "guest";  break;
                        case "login": $MODE = "member"; break;
-                               break;
-               }
+               } // END - switch
 
                // Guest and member menu is "main" as the default
                if (empty($ret)) $ret = "main";
@@ -950,11 +948,11 @@ function GET_ACTION ($MODE, &$wht)
                if (SQL_NUMROWS($result) == 1) {
                        // Load action value and pray that this one is the right you want... ;-)
                        list($ret) = SQL_FETCHROW($result);
-               }
+               } // END - if
 
                // Free memory
                SQL_FREERESULT($result);
-       }
+       } // END - if
 
        // Return action value
        return $ret;
@@ -965,9 +963,11 @@ function GET_CATEGORY ($cid) {
        $ret = _CATEGORY_404;
 
        // Is the category id set?
-       if (!empty($cid)) {
-
-               // Lookup the category
+       if ($cid == "0") {
+               // No category
+               $ret = _CATEGORY_NONE;
+       } elseif ($cid > 0) {
+               // Lookup the category in database
                $result = SQL_QUERY_ESC("SELECT cat FROM "._MYSQL_PREFIX."_cats WHERE id=%s LIMIT 1",
                        array(bigintval($cid)), __FILE__, __LINE__);
                if (SQL_NUMROWS($result) == 1) {
@@ -1198,8 +1198,14 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
                                // Direct payment shall be notified about
                                define('__POINTS_VALUE', $ref_points);
 
+                               // Prepare content
+                               $content = array(
+                                       'text'   => REASON_DIRECT_PAYMENT,
+                                       'points' => TRANSLATE_COMMA($ref_points)
+                               );
+
                                // Load message
-                               $msg = LOAD_EMAIL_TEMPLATE("add-points", REASON_DIRECT_PAYMENT, $uid);
+                               $msg = LOAD_EMAIL_TEMPLATE("add-points", $content, $uid);
 
                                // And sent it away
                                SEND_EMAIL($email, SUBJECT_DIRECT_PAYMENT, $msg);
@@ -1520,7 +1526,7 @@ WHERE p.userid=%s", array(bigintval($uid)), __FILE__, __LINE__);
        }
 
        // Now a mail to the user and that's all...
-       $msg = LOAD_EMAIL_TEMPLATE("del-user", $reason, $uid);
+       $msg = LOAD_EMAIL_TEMPLATE("del-user", array('text' => $reason), $uid);
        SEND_EMAIL($uid, ADMIN_DEL_ACCOUNT, $msg);
 
        // Ok, delete the account!