]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/surfbar_functions.php
A lot code rewritten:
[mailer.git] / inc / libs / surfbar_functions.php
index 26f2aef2342e3771b9c47e22c14dcd81115e3ff1..3939b0e40774716a310ddefc47c7f45934b8a9a2 100644 (file)
@@ -309,7 +309,7 @@ function SURFBAR_MEMBER_RETREAT_ACTION ($urlData) {
 function SURFBAR_MEMBER_BOOKNOW_ACTION ($urlData) {
        // Create the data array for next function call
        $data = array(
-       $urlData['id'] => $urlData
+               $urlData['id'] => $urlData
        );
 
        // Simply change the status here
@@ -366,12 +366,6 @@ function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
        // Translate some data if present
        $content = SURFBAR_PREPARE_CONTENT_FOR_TEMPLATE($content);
 
-       // Is the lock reason empty?
-       if (empty($urlData['lock_reason'])) {
-               // Fix it to three dashes
-               $urlData['lock_reason'] = '---';
-       } // END - if
-
        // Include fields only for action 'edit'
        if ($action == 'edit') {
                // Default is not limited
@@ -418,7 +412,7 @@ function SURFBAR_MEMBER_EXECUTE_ACTION ($action, $urlData) {
                } // END - if
        } else {
                // Not found!
-               addFatalMessage(__FUNCTION__, __LINE__, getMessage('MEMBER_SURFBAR_EXECUTE_ACTION_404'), $functionName);
+               addFatalMessage(__FUNCTION__, __LINE__, '{--MEMBER_SURFBAR_EXECUTE_ACTION_404--}', $functionName);
        }
 
        // Return status
@@ -488,14 +482,14 @@ function SURFBAR_HANDLE_LOW_POINTS () {
        $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS(getConfig('surfbar_warn_low_points'));
 
        // "Walk" through all URLs
-       foreach ($userids['userid'] as $userid => $dummy) {
+       foreach ($userids['url_userid'] as $userid => $dummy) {
                // Is the last notification far enougth away to notify again?
                if ((time() - $userids['notified'][$userid]) >= getConfig('surfbar_low_interval')) {
                        // Prepare content
                        $content = array(
-                               'userid'   => $userid,
-                               'points'   => $userids['points'][$userid],
-                               'notified' => $userids['notified'][$userid]
+                               'url_userid' => $userid,
+                               'points'     => $userids['points'][$userid],
+                               'notified'   => $userids['notified'][$userid]
                        );
 
                        // Notify this user
@@ -681,13 +675,13 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
        $content = SURFBAR_PREPARE_CONTENT_FOR_TEMPLATE($content);
 
        // Send the notification out
-       return sendAdminNotification($subject, $templateName, $content, $content['userid']);
+       return sendAdminNotification($subject, $templateName, $content, $content['url_userid']);
 }
 
 // Notify the user about the performed action
 function SURFBAR_NOTIFY_USER ($messageType, $content) {
        // Skip notification if userid is zero
-       if ($content['userid'] == '0') {
+       if ($content['url_userid'] == '0') {
                return false;
        } // END - if
 
@@ -702,17 +696,17 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) {
        // Is the subject line there?
        if ((substr($subject, 0, 1) == '!') && (substr($subject, -1, 1) == '!')) {
                // Set default subject if following eval() wents wrong
-               $subject = getMessage('MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT');
+               $subject = '{--MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT--}';
        } // END - if
 
        // Translate some data if present
        $content = SURFBAR_PREPARE_CONTENT_FOR_TEMPLATE($content);
 
        // Load template
-       $mailText = loadEmailTemplate($templateName, $content, $content['userid']);
+       $mailText = loadEmailTemplate($templateName, $content, $content['url_userid']);
 
        // Send the email
-       return sendEmail($content['userid'], $subject, $mailText);
+       return sendEmail($content['url_userid'], $subject, $mailText);
 }
 
 // Translates some data for template usage
@@ -731,7 +725,7 @@ function translateSurfbarLimit ($limit) {
        // Is this zero?
        if ($limit == '0') {
                // Unlimited!
-               $return = getMessage('MEMBER_SURFBAR_UNLIMITED_VIEWS');
+               $return = '{--MEMBER_SURFBAR_UNLIMITED_VIEWS--}';
        } else {
                // Translate comma
                $return = translateComma($limit);
@@ -883,7 +877,7 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
        $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS();
 
        // If we dont get any user ids back, there are no URLs
-       if (count($userids['userid']) == 0) {
+       if (count($userids['url_userid']) == 0) {
                // No user ids found, no URLs!
                return 0;
        } // END - if
@@ -891,7 +885,7 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
        // Is the exlude userid set?
        if ($excludeUserId > 0) {
                // Then add it
-               $userids['userid'][$excludeUserId] = $excludeUserId;
+               $userids['url_userid'][$excludeUserId] = $excludeUserId;
        } // END - if
 
        // Get amount from database
@@ -900,7 +894,7 @@ function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_urls`
 WHERE
-       `url_userid` NOT IN (".implode(', ', $userids['userid']).") AND
+       `url_userid` NOT IN (".implode(', ', $userids['url_userid']).") AND
        `url_status`='%s'
 LIMIT 1",
                array($status), __FUNCTION__, __LINE__
@@ -1015,7 +1009,7 @@ function SURFBAR_CHECK_VALIDATION_CODE ($urlId, $check, $salt) {
 
 // Lockdown the userid/id combination (reload lock)
 function SURFBAR_LOCKDOWN_ID ($urlId) {
-       //* DEBUG: */ outputHtml('LOCK!');
+       //* DEBUG: */ debugOutput('LOCK!');
        ///* DEBUG: */ return;
        // Just add it to the database
        SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)",
@@ -1146,15 +1140,15 @@ LIMIT 1",
 function SURFBAR_DETERMINE_DEPLETED_USERIDS ($limit=0) {
        // Init array
        $userids = array(
-               'userid'      => array(),
-               'points'   => array(),
-               'notified' => array(),
+               'url_userid'   => array(),
+               'points'       => array(),
+               'notified'     => array(),
        );
 
        // Do we have a current user id?
        if ((isMember()) && ($limit == '0')) {
                // Then add this as well
-               $userids['userid'][getMemberId()]      = getMemberId();
+               $userids['url_userid'][getMemberId()]      = getMemberId();
                $userids['points'][getMemberId()]   = countSumTotalData(getMemberId(), 'user_points', 'points') - countSumTotalData(getMemberId(), 'user_data', 'used_points');
                $userids['notified'][getMemberId()] = '0';
 
@@ -1195,16 +1189,16 @@ ORDER BY
        // Load all userid
        while ($content = SQL_FETCHARRAY($result)) {
                // Get total points
-               $points = countSumTotalData($content['userid'], 'user_points', 'points') - countSumTotalData($content['userid'], 'user_data', 'used_points');
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "userid={$content['userid']},points={$points}", false);
+               $points = countSumTotalData($content['url_userid'], 'user_points', 'points') - countSumTotalData($content['url_userid'], 'user_data', 'used_points');
+               //* 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['userid']} has depleted points amount!", false);
-                       $userids['userid'][$content['userid']]      = $content['userid'];
-                       $userids['points'][$content['userid']]   = $points;
-                       $userids['notified'][$content['userid']] = $content['notified'];
+                       //* 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'];
                } // END - if
        } // END - while
 
@@ -1290,7 +1284,7 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array())
 
        // Update the status now
        // ---------- Comment out for debugging/developing member actions! ---------
-       //SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `status`='%s' WHERE `id`=%s LIMIT 1",
+       //SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `status`='%s' WHERE `url_id`=%s LIMIT 1",
        //      array($newStatus, bigintval($urlId)), __FUNCTION__, __LINE__);
        // ---------- Comment out for debugging/developing member actions! ---------
 
@@ -1303,7 +1297,7 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array())
        // ---------- Comment out for debugging/developing member actions! ---------
 
        // Prepare content for notification routines
-       $data[$urlId]['userid']         = $data[$urlId]['userid'];
+       $data[$urlId]['url_userid']  = $data[$urlId]['url_userid'];
        $data[$urlId]['frametester'] = generateFrametesterUrl($data[$urlId]['url']);
        $data[$urlId]['reward']      = translateComma(getConfig('surfbar_static_reward'));
        $data[$urlId]['costs']       = translateComma(getConfig('surfbar_static_costs'));
@@ -1599,7 +1593,7 @@ function SURFBAR_DETERMINE_NEXT_ID ($urlId = '0') {
                $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS();
 
                // Get maximum randomness factor
-               $maxRand = SURFBAR_GET_MAX_RANDOM($userids['userid'], $add);
+               $maxRand = SURFBAR_GET_MAX_RANDOM($userids['url_userid'], $add);
 
                // If more than one URL can be called generate the random number!
                if ($maxRand > 1) {
@@ -1630,7 +1624,7 @@ LEFT JOIN
 ON
        sbu.url_id=l.locks_url_id
 WHERE
-       sbu.url_userid NOT IN (".implode(',', $userids['userid']).") AND
+       sbu.url_userid NOT IN (".implode(',', $userids['url_userid']).") AND
        sbu.url_status='ACTIVE' AND
        (sbu.url_views_allowed=0 OR (sbu.url_views_allowed > 0 AND sbu.url_views_max > 0))
        ".$add."