Code style changed, ext-user continued:
[mailer.git] / inc / libs / surfbar_functions.php
index 6b62afbc0cc3866ca8dd21b015bfe1482773b0ce..bcb6e6ca07f577ed3743c92cf805a6c7393c447a 100644 (file)
@@ -50,27 +50,27 @@ function doSurfbarAdminAddUrl ($url, $limit, $reload) {
        if (!isAdmin()) {
                // Not an admin
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s: Not admin.", $url, $limit, $reload));
-               return false;
+               return FALSE;
        } elseif (!isUrlValid($url)) {
                // URL invalid
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s: Invalid URL.", $url, $limit, $reload));
-               return false;
+               return FALSE;
        } elseif (ifSurfbarHasUrlUserId($url, 0)) {
                // URL already found in surfbar!
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s: Already added.", $url, $limit, $reload));
-               return false;
+               return FALSE;
        } elseif (!ifSurfbarMemberAllowedMoreUrls()) {
                // No more allowed!
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s: No more URLs allowed.", $url, $limit, $reload));
-               return false;
+               return FALSE;
        } elseif ('' . ($limit + 0) . '' != '' . $limit . '') {
                // Invalid limit entered
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s: Invalid limit entered.", $url, $limit, $reload));
-               return false;
+               return FALSE;
        } elseif ('' . ($reload + 0) . '' != '' . $reload . '') {
                // Invalid amount entered
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot add URL=%s,limit=%s,reload=%s: Invalid reload entered.", $url, $limit, $reload));
-               return false;
+               return FALSE;
        }
 
        // Register the new URL
@@ -83,19 +83,19 @@ function doSurfbarAdminMigrateUrl ($url, $userid) {
        if (!isAdmin()) {
                // Not an admin
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot migrate URL: Not admin, url=' . $url . ',userid=' . $userid);
-               return false;
+               return FALSE;
        } elseif (!isUrlValid($url)) {
                // URL invalid
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot migrate URL: Invalid URL, url=' . $url . ',userid=' . $userid);
-               return false;
+               return FALSE;
        } elseif (ifSurfbarHasUrlUserId($url, $userid)) {
                // URL already found in surfbar!
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot migrate URL: Already added, url=' . $url . ',userid=' . $userid);
-               return false;
+               return FALSE;
        } elseif (!ifSurfbarMemberAllowedMoreUrls($userid)) {
                // No more allowed!
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot migrate URL: Maximum exceeded, url=' . $url . ',userid=' . $userid);
-               return false;
+               return FALSE;
        }
 
        // Register the new URL
@@ -108,19 +108,19 @@ function doSurfbarAdminUnlockUrlIds ($IDs) {
        if (!isAdmin()) {
                // Not admin or invalid ids array
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Not admin');
-               return false;
+               return FALSE;
        } elseif (!is_array($IDs)) {
                // No array
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: IDs type ' . gettype($IDs) . '!=array');
-               return false;
+               return FALSE;
        } elseif (count($IDs) == 0) {
                // Empty array
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: IDs is empty');
-               return false;
+               return FALSE;
        }
 
        // Set to true to make AND expression valid if first URL got unlocked
-       $done = true;
+       $done = TRUE;
 
        // Update the status for all ids
        foreach ($IDs as $id => $dummy) {
@@ -138,19 +138,19 @@ function doSurfbarAdminRejectUrlIds ($IDs) {
        if (!isAdmin()) {
                // Not admin or invalid ids array
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Not admin');
-               return false;
+               return FALSE;
        } elseif (!is_array($IDs)) {
                // No array
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: IDs type ' . gettype($IDs) . '!=array');
-               return false;
+               return FALSE;
        } elseif (count($IDs) == 0) {
                // Empty array
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: IDs is empty');
-               return false;
+               return FALSE;
        }
 
        // Set to true to make AND expression valid if first URL got unlocked
-       $done = true;
+       $done = TRUE;
 
        // Update the status for all ids
        foreach ($IDs as $id => $dummy) {
@@ -172,23 +172,23 @@ function doSurfbarMemberAddUrl ($url, $limit) {
        if (!isMember()) {
                // Not a member
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: isMember()=false');
-               return false;
+               return FALSE;
        } elseif ((!isUrlValid($url)) && (!isAdmin())) {
                // URL invalid
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Invalid, url=' . $url . ',limit=' . $limit);
-               return false;
+               return FALSE;
        } elseif (ifSurfbarHasUrlUserId($url, getMemberId())) {
                // URL already found in surfbar!
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Already found, url=' . $url . ',limit=' . $limit);
-               return false;
+               return FALSE;
        } elseif (!ifSurfbarMemberAllowedMoreUrls(getMemberId())) {
                // No more allowed!
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Maximum exceeded, url=' . $url . ',limit=' . $limit);
-               return false;
+               return FALSE;
        } elseif (''.($limit + 0).'' != ''.$limit.'') {
                // Invalid amount entered
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Invalid limit, url=' . $url . ',limit=' . $limit);
-               return false;
+               return FALSE;
        }
 
        // Register the new URL
@@ -207,7 +207,7 @@ function generateSurfbarMemberActions ($urlId, $status) {
        $OUT = '';
        foreach ($actionArray as $actionId => $action) {
                // Add form for this action
-               $OUT .= loadTemplate('member_list_surfbar_form', true, array(
+               $OUT .= loadTemplate('member_list_surfbar_form', TRUE, array(
                        'width'  => $width,
                        'url_id' => bigintval($urlId),
                        'action' => strtolower($action)
@@ -215,7 +215,7 @@ function generateSurfbarMemberActions ($urlId, $status) {
        } // END - foreach
 
        // Load main template
-       $output = loadTemplate('member_list_surfbar_table', true, $OUT);
+       $output = loadTemplate('member_list_surfbar_table', TRUE, $OUT);
 
        // Return code
        return $output;
@@ -224,25 +224,25 @@ function generateSurfbarMemberActions ($urlId, $status) {
 // Do the member form request
 function doSurfbarMemberByFormData ($formData, $urlArray) {
        // By default no action is performed
-       $performed = false;
+       $performed = FALSE;
 
        // Is this a member?
        if (!isMember()) {
                // No member!
                /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: isMember()=false');
-               return false;
+               return FALSE;
        } elseif ((!isset($formData['url_id'])) || (!isset($formData['action']))) {
                // Important form elements are missing!
                /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Invalid form data, required field id/action not found');
-               return false;
+               return FALSE;
        } elseif (!isset($urlArray[$formData['url_id']])) {
                // Id not found in cache
                /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Field url_id not found in cache');
-               return false;
+               return FALSE;
        } elseif (!isSurfbarMemberActionStatusValid($formData['action'], $urlArray[$formData['url_id']]['url_status'])) {
                // Action not allowed for current URL status
                /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot add URL: Action not allowed to perform. action=' . $formData['action'] . ',url_status=' . $urlArray[$formData['url_id']]['url_status'] . ',url_id=' . $formData['url_id']);
-               return false;
+               return FALSE;
        }
 
        // Secure action
@@ -251,7 +251,7 @@ function doSurfbarMemberByFormData ($formData, $urlArray) {
        // Has it changed?
        if ($action != $formData['action']) {
                // Invalid data in action found
-               return false;
+               return FALSE;
        } // END - if
 
        // Create the function name for selected action
@@ -320,7 +320,7 @@ function isSurfbarMemberActionStatusValid ($action, $status) {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'action=' . $action . ',status=' . $status . ',isValid=' . intval($isValid));
 
        // Fetch the new status if found
-       if ($isValid === true) {
+       if ($isValid === TRUE) {
                // Load new status
                list($GLOBALS['surfbar_cache']['new_status']) = SQL_FETCHROW($result);
        } // END - if
@@ -425,16 +425,16 @@ function displaySurfbarMemberActionForm ($action, $urlData) {
        } // END - if
 
        // Load the form and display it
-       loadTemplate(sprintf("member_surfbar_%s_action_form", $action), false, $urlData);
+       loadTemplate(sprintf("member_surfbar_%s_action_form", $action), FALSE, $urlData);
 
        // All fine by default ... ;-)
-       return true;
+       return TRUE;
 }
 
 // Execute choosen action
 function executeSurfbarMemberAction ($action, $urlData) {
        // By default nothing is executed
-       $executed = false;
+       $executed = FALSE;
 
        // Is limitation "no" and "limit" is > 0?
        if ((isset($urlData[$action]['limited'])) && ($urlData[$action]['limited'] != 'Y') && ((isset($urlData[$action]['limit'])) && ($urlData[$action]['limit'] > 0)) || (!isset($urlData[$action]['limit']))) {
@@ -448,7 +448,7 @@ function executeSurfbarMemberAction ($action, $urlData) {
        // Is that function there?
        if (function_exists($functionName)) {
                // Execute the function
-               if (call_user_func_array($functionName, array($urlData)) == true) {
+               if (call_user_func_array($functionName, array($urlData)) == TRUE) {
                        // Update status as well
                        $executed = changeSurfbarUrlStatus($urlData['url_id'], $urlData['url_status'], $urlData['new_status'], array($urlData['url_id'] => $urlData));
                } // END - if
@@ -464,10 +464,10 @@ function executeSurfbarMemberAction ($action, $urlData) {
 // "Execute edit" function: Update changed data
 function executeSurfbarMemberEditAction ($urlData) {
        // Default is nothing done
-       $status = false;
+       $status = FALSE;
 
        // Has the URL or limit changed?
-       if (true) {
+       if (TRUE) {
                //if (($urlData['url_views_allowed'] != $urlData['edit']['limit']) || ($url1 != $url2)) {
                // Run the query
                SQL_QUERY_ESC("UPDATE
@@ -489,7 +489,7 @@ LIMIT 1",
                        ), __FUNCTION__, __LINE__);
 
                // All fine
-               $status = true;
+               $status = TRUE;
        } // END - if
 
        // Return status
@@ -499,7 +499,7 @@ LIMIT 1",
 // "Execute delete" function: Does nothing...
 function executeSurfbarMemberDeleteAction ($urlData) {
        // Nothing special to do (see above function for such "special actions" to perform)
-       return true;
+       return TRUE;
 }
 
 //------------------------------------------------------------------------------
@@ -676,7 +676,7 @@ function doSurfbarRegisterUrl ($url, $userid, $status = 'PENDING', $addMode = 'r
        // Is this id valid?
        if ($content['insert_id'] == '0') {
                // INSERT did not insert any data!
-               return false;
+               return FALSE;
        } // END - if
 
        // If in reg-mode we notify admin
@@ -745,7 +745,7 @@ function doSurfbarNotifyAdmin ($messageType, $content) {
 function doSurfbarNotifyMember ($messageType, $content) {
        // Skip notification if userid is zero
        if ($content['url_userid'] == '0') {
-               return false;
+               return FALSE;
        } // END - if
 
        // Prepare template name
@@ -853,14 +853,14 @@ function translateMemberSurfbarActionToSubmit ($action) {
 }
 
 // Determine reward
-function determineSurfbarReward ($onlyMin = false) {
+function determineSurfbarReward ($onlyMin = FALSE) {
        // Static values are default
        $reward = getConfig('surfbar_static_reward');
 
        // Is there static or dynamic?
        if (getSurfbarPaymentModel() == 'DYNAMIC') {
                // "Calculate" dynamic reward
-               if ($onlyMin === true) {
+               if ($onlyMin === TRUE) {
                        $reward += calculateSurfbarDynamicMininumValue();
                } else {
                        $reward += calculateSurfbarDynamicAddValue();
@@ -924,7 +924,7 @@ function determineSurfbarTemplateName() {
 function isSurfbarReloadFull () {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Fixed surf lock is ' . getConfig('surfbar_static_lock') . ' - ENTERED!');
        // Default is full!
-       $isFull = true;
+       $isFull = TRUE;
 
        // Cache static reload lock
        $GLOBALS['surfbar_cache']['surf_lock'] = getConfig('surfbar_static_lock');
@@ -1058,7 +1058,7 @@ function getSurfbarTotalUserUrls ($userid = NULL, $status = '', $exclude = '') {
        }
 
        // Get amount from database
-       $count = countSumTotalData($userid, 'surfbar_urls', 'url_id', 'url_userid', true, $add);
+       $count = countSumTotalData($userid, 'surfbar_urls', 'url_id', 'url_userid', TRUE, $add);
 
        // Return result
        return $count;
@@ -1071,11 +1071,11 @@ function generateSurfbarValidationCode ($urlId, $salt = '') {
        if (empty($salt)) {
                 // Generate random hashed string
                $GLOBALS['surfbar_cache']['salt'] = sha1(generatePassword(mt_rand(200, 255)));
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newSalt='.gerSurfbarSalt().'', false);
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newSalt='.gerSurfbarSalt().'', FALSE);
        } else {
                // Use this as salt!
                $GLOBALS['surfbar_cache']['salt'] = $salt;
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'oldSalt='.gerSurfbarSalt().'', false);
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'oldSalt='.gerSurfbarSalt().'', FALSE);
        }
 
        // Hash it with md5() and salt it with the random string
@@ -1107,7 +1107,7 @@ function isSurfbarValidationCodeValid ($urlId, $check, $salt) {
 function addSurfbarReloadLockById ($urlId) {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',getMemberId()=' . getMemberId() . ' - ENTERED!');
        // Search for an entry
-       $countLock = countSumTotalData(getMemberId(), 'surfbar_locks', 'locks_id', 'locks_userid', true, ' AND `locks_url_id`=' . bigintval($urlId));
+       $countLock = countSumTotalData(getMemberId(), 'surfbar_locks', 'locks_id', 'locks_userid', TRUE, ' AND `locks_url_id`=' . bigintval($urlId));
 
        // Is there no record?
        if ($countLock == 0) {
@@ -1431,7 +1431,7 @@ function changeSurfbarUrlStatus ($urlId, $prevStatus, $newStatus, $data = array(
        // ---------- Comment out for debugging/developing member actions! ---------
        if (SQL_AFFECTEDROWS() != 1) {
                // No, something went wrong
-               return false;
+               return FALSE;
        } // END - if
        // ---------- Comment out for debugging/developing member actions! ---------
 
@@ -1443,7 +1443,7 @@ function changeSurfbarUrlStatus ($urlId, $prevStatus, $newStatus, $data = array(
 
        // All done!
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - EXIT!');
-       return true;
+       return TRUE;
 }
 
 // Calculate minimum value for dynamic payment model
@@ -1807,9 +1807,9 @@ LIMIT 1",
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS());
        if (SQL_NUMROWS($result) == 1) {
                // Load/cache data
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - BEFORE', false);
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - BEFORE', FALSE);
                $GLOBALS['surfbar_cache'] = merge_array($GLOBALS['surfbar_cache'], SQL_FETCHARRAY($result));
-               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - AFTER', false);
+               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - AFTER', FALSE);
 
                // Determine waiting time
                $GLOBALS['surfbar_cache']['time'] = determineSurfbarWaitingTime();
@@ -1817,14 +1817,14 @@ LIMIT 1",
                // Is the last salt there?
                if (is_null($GLOBALS['surfbar_cache']['salts_last_salt'])) {
                        // Then repair it wit the static!
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_salt - FIXED!', false);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_salt - FIXED!', FALSE);
                        $GLOBALS['surfbar_cache']['salts_last_salt'] = '';
                } // END - if
 
                // Fix missing last_surfed
                if ((!isset($GLOBALS['surfbar_cache']['last_surfed'])) || (is_null($GLOBALS['surfbar_cache']['last_surfed']))) {
                        // Fix it here
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_surfed - FIXED!', false);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'last_surfed - FIXED!', FALSE);
                        $GLOBALS['surfbar_cache']['last_surfed'] = '0';
                } // END - if
 
@@ -1922,7 +1922,7 @@ function getSurfbarPaymentModel () {
 //------------------------------------------------------------------------------
 
 // Template helper to generate a selection box for surfbar actions
-function doTemplateSurfbarActionsActionSelectionBox ($templateName, $clear = false, $default = NULL) {
+function doTemplateSurfbarActionsActionSelectionBox ($templateName, $clear = FALSE, $default = NULL) {
        // Init array
        $actionsAction = array(
                0 => array('actions_action' => 'EDIT'),
@@ -1936,14 +1936,14 @@ function doTemplateSurfbarActionsActionSelectionBox ($templateName, $clear = fal
        );
 
        // Handle it over to generateSelectionBoxFromArray()
-       $content = generateSelectionBoxFromArray($actionsAction, 'surfbar_actions_action', 'actions_action', '', '', '', $default, '', false, true);
+       $content = generateSelectionBoxFromArray($actionsAction, 'surfbar_actions_action', 'actions_action', '', '', '', $default, '', FALSE, TRUE);
 
        // Return prepared content
        return $content;
 }
 
 // Template helper to generate a selection box for surfbar status
-function doTemplateSurfbarActionsStatusSelectionBox ($templateName, $clear = false, $default = NULL) {
+function doTemplateSurfbarActionsStatusSelectionBox ($templateName, $clear = FALSE, $default = NULL) {
        // Init array
        $status = array(
                0 => array('actions_status' => 'PENDING'),
@@ -1957,14 +1957,14 @@ function doTemplateSurfbarActionsStatusSelectionBox ($templateName, $clear = fal
        );
 
        // Handle it over to generateSelectionBoxFromArray()
-       $content = generateSelectionBoxFromArray($status, 'surfbar_actions_status', 'actions_status', '', '', '', $default, '', false, true);
+       $content = generateSelectionBoxFromArray($status, 'surfbar_actions_status', 'actions_status', '', '', '', $default, '', FALSE, TRUE);
 
        // Return prepared content
        return $content;
 }
 
 // Template helper to generate a selection box for surfbar status
-function doTemplateSurfbarActionsNewStatusSelectionBox ($templateName, $clear = false, $default = NULL) {
+function doTemplateSurfbarActionsNewStatusSelectionBox ($templateName, $clear = FALSE, $default = NULL) {
        // Init array
        $status = array(
                0 => array('actions_new_status' => 'PENDING'),
@@ -1978,7 +1978,7 @@ function doTemplateSurfbarActionsNewStatusSelectionBox ($templateName, $clear =
        );
 
        // Handle it over to generateSelectionBoxFromArray()
-       $content = generateSelectionBoxFromArray($status, 'surfbar_actions_new_status', 'actions_new_status', '', '', '', $default, '', true, true);
+       $content = generateSelectionBoxFromArray($status, 'surfbar_actions_new_status', 'actions_new_status', '', '', '', $default, '', TRUE, TRUE);
 
        // Return prepared content
        return $content;