]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/surfbar_functions.php
Removed comment introduced by Profi-Concept, this comment should fine (in a much...
[mailer.git] / inc / libs / surfbar_functions.php
index 09e25ee44143dac3cf22e7c87de5142b250db058..bbb6daecaff267740a145f5d1a631c4761e1dde7 100644 (file)
@@ -14,8 +14,6 @@
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
@@ -40,7 +38,7 @@
 // Some security stuff...
 if (!defined('__SECURITY')) {
        die();
-}
+} // END - if
 
 // -----------------------------------------------------------------------------
 //                               Admin functions
@@ -189,8 +187,8 @@ function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
        $actionArray = SURFBAR_GET_ARRAY_FROM_STATUS($status);
 
        // Init HTML code
-       $OUT = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\">
-<tr>\n";
+       $OUT = '<table border="0" cellspacing="0" cellpadding="1" width="100%">
+<tr>';
 
        // Calculate width
        $width = round(100 / count($actionArray));
@@ -208,8 +206,8 @@ function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
        } // END - foreach
 
        // Close table
-       $OUT .= "</tr>
-</table>\n";
+       $OUT .= '</tr>
+</table>';
 
        // Return code
        return $OUT;
@@ -369,16 +367,16 @@ function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
        // Include fields only for action 'edit'
        if ($action == 'edit') {
                // Default is not limited
-               $urlData['limited_y'] = '';
-               $urlData['limited_n'] = ' checked="checked"';
-               $urlData['limited']   = 'false';
+               $urlData['limited_yes'] = '';
+               $urlData['limited_no']  = ' checked="checked"';
+               $urlData['limited']     = 'false';
 
                // Is this URL limited?
                if (SURFBAR_GET_VIEWS_MAX() > 0) {
                        // Then rewrite form data
-                       $urlData['limited_y'] = ' checked="checked"';
-                       $urlData['limited_n'] = '';
-                       $urlData['limited']   = 'true';
+                       $urlData['limited_yes'] = ' checked="checked"';
+                       $urlData['limited_no']  = '';
+                       $urlData['limited']     = 'true';
                } // END - if
        } // END - if
 
@@ -565,7 +563,7 @@ ORDER BY
                ), __FUNCTION__, __LINE__);
 
        // Is there at least one record?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Then load all!
                while ($dataRow = SQL_FETCHARRAY($result)) {
                        // Shall we group these results?
@@ -596,7 +594,6 @@ function SURFBAR_REGISTER_URL ($url, $userid, $status = 'PENDING', $addMode = 'r
        // Prepare content
        $content = merge_array($extraFields, array(
                'url'         => $url,
-               'frametester' => generateFrametesterUrl($url),
                'url_userid'  => $userid,
                'url_status'  => $status,
        ));
@@ -808,7 +805,7 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() {
 
 // Check if the "reload lock" of the current user is full, call this function
 // before you call SURFBAR_CHECK_RELOAD_LOCK().
-function SURFBAR_CHECK_RELOAD_FULL() {
+function SURFBAR_CHECK_RELOAD_FULL () {
        // Default is full!
        $isFull = true;
 
@@ -877,7 +874,7 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
        } // END - if
 
        // Is the exlude userid set?
-       if ($excludeUserId > 0) {
+       if (isValidUserId($excludeUserId)) {
                // Then add it
                $userids['url_userid'][$excludeUserId] = $excludeUserId;
        } // END - if
@@ -900,6 +897,9 @@ LIMIT 1",
        // Free result
        SQL_FREERESULT($result);
 
+       // Debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $cnt);
+
        // Return result
        return $cnt;
 }
@@ -1018,7 +1018,7 @@ function SURFBAR_LOCKDOWN_ID ($urlId) {
 function SURFBAR_PAY_POINTS () {
        // Remove it from the URL owner
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS().'', false);
-       if (SURFBAR_GET_USERID() > 0) {
+       if (isValidUserId(SURFBAR_GET_USERID())) {
                subtractPoints(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
        } // END - if
 
@@ -1077,6 +1077,9 @@ function SURFBAR_UPDATE_SALT_STATS () {
        // Update statistics record
        SURFBAR_UPDATE_INSERT_STATS_RECORD();
 
+       // Update salt
+       SURFBAR_GENERATE_VALIDATION_CODE(SURFBAR_GET_ID());
+
        // Simply store the salt from cache away in database...
        SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_salts` SET `salts_last_salt`='%s' WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1",
                array(
@@ -1142,9 +1145,9 @@ function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
        // Do we have a current user id?
        if ((isMember()) && ($limit == '0')) {
                // Then add this as well
-               $userids['url_userid'][getMemberId()]      = getMemberId();
-               $userids['points'][getMemberId()]   = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
-               $userids['notified'][getMemberId()] = '0';
+               $userids['url_userid'][getMemberId()] = getMemberId();
+               $userids['points'][getMemberId()]     = getTotalPoints(getMemberId());
+               $userids['notified'][getMemberId()]   = '0';
 
                // Get all userid except logged in one
                $result = SQL_QUERY_ESC("SELECT
@@ -1183,16 +1186,16 @@ ORDER BY
        // Load all userid
        while ($content = SQL_FETCHARRAY($result)) {
                // Get total points
-               $points = countSumTotalData($content['url_userid'], 'user_points', 'points') - countSumTotalData($content['url_userid'], 'user_data', 'used_points');
+               $points = getTotalPoints($content['url_userid']);
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['url_userid']},points={$points}", false);
 
                // Shall we add this to ignore?
                if ($points <= $limit) {
                        // Ignore this one!
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['url_userid']} has depleted points amount!", false);
-                       $userids['url_userid'][$content['url_userid']]      = $content['url_userid'];
-                       $userids['points'][$content['url_userid']]   = $points;
-                       $userids['notified'][$content['url_userid']] = $content['notified'];
+                       $userids['url_userid'][$content['url_userid']] = $content['url_userid'];
+                       $userids['points'][$content['url_userid']]     = $points;
+                       $userids['notified'][$content['url_userid']]   = $content['notified'];
                } // END - if
        } // END - while
 
@@ -1209,14 +1212,14 @@ ORDER BY
 // Determine how many users are Online in surfbar
 function SURFBAR_DETERMINE_TOTAL_ONLINE () {
        // Count all users in surfbar modue and return the value
-       $result = SQL_QUERY("SELECT
+       $result = SQL_QUERY('SELECT
        `stats_id`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_stats`
 WHERE
        (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`stats_last_surfed`)) <= {?online_timeout?}
 GROUP BY
-       `stats_userid` ASC", __FUNCTION__, __LINE__);
+       `stats_userid` ASC', __FUNCTION__, __LINE__);
 
        // Fetch count
        $cnt = SQL_NUMROWS($result);
@@ -1458,10 +1461,10 @@ LEFT JOIN
 ON
        sbu.url_id=l.locks_url_id
 WHERE
-       sbu.url_userid NOT IN (".implode(',', $userids).") AND
+       sbu.url_userid NOT IN (" . implode(',', $userids) . ") AND
        (sbu.url_views_allowed=0 OR (sbu.url_views_allowed > 0 AND sbu.url_views_max > 0)) AND
        sbu.url_status='ACTIVE'
-       ".$add."
+       " . $add . "
 GROUP BY
        sbu.url_id ASC", __FUNCTION__, __LINE__);
 
@@ -1505,7 +1508,7 @@ ORDER BY
        array(getMemberId()), __FUNCTION__, __LINE__);
 
        // Are there entries?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Load all rows
                while ($row = SQL_FETCHARRAY($result)) {
                        // Add the row
@@ -1530,7 +1533,7 @@ function SURFBAR_GET_ARRAY_FROM_STATUS ($status) {
                array($status), __FUNCTION__, __LINE__);
 
        // Some entries there?
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Load all actions
                // @TODO This can be somehow rewritten
                while ($content = SQL_FETCHARRAY($result)) {
@@ -1712,6 +1715,58 @@ LIMIT 1",
        return $nextId;
 }
 
+// ----------------------------------------------------------------------------
+// Wrapper function
+// ----------------------------------------------------------------------------
+
+// "Getter" for surfbar_dynamic_percent
+function getSurfbarDynamicPercent () {
+       // Do we have cache?
+       if (!isset($GLOBALS['surfbar_dynamic_percent'])) {
+               // Determine it
+               $GLOBALS['surfbar_dynamic_percent'] = getConfig('surfbar_dynamic_percent');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['surfbar_dynamic_percent'];
+}
+
+// "Getter" for surfbar_static_reward
+function getSurfbarStaticReward () {
+       // Do we have cache?
+       if (!isset($GLOBALS['surfbar_static_reward'])) {
+               // Determine it
+               $GLOBALS['surfbar_static_reward'] = getConfig('surfbar_static_reward');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['surfbar_static_reward'];
+}
+
+// "Getter" for surfbar_static_time
+function getSurfbarStaticTime () {
+       // Do we have cache?
+       if (!isset($GLOBALS['surfbar_static_time'])) {
+               // Determine it
+               $GLOBALS['surfbar_static_time'] = getConfig('surfbar_static_time');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['surfbar_static_time'];
+}
+
+// "Getter" for surfbar_max_order
+function getSurfbarMaxOrder () {
+       // Do we have cache?
+       if (!isset($GLOBALS['surfbar_max_order'])) {
+               // Determine it
+               $GLOBALS['surfbar_max_order'] = getConfig('surfbar_max_order');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['surfbar_max_order'];
+}
+
 // -----------------------------------------------------------------------------
 // PLEASE DO NOT ADD ANY OTHER FUNCTIONS BELOW THIS LINE IF THEY DON'T "WRAP"
 // THE $GLOBALS['surfbar_cache'] ARRAY!