]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/surfbar_functions.php
Language id renamed, some network query amounts added
[mailer.git] / inc / libs / surfbar_functions.php
index 9a8edbbb8d2bb5726215a8c4302bcdc7bf9f594b..7b555fc471c6139910b5d6acb8ae5bd0e8416cce 100644 (file)
@@ -17,7 +17,7 @@
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -654,11 +654,11 @@ function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) {
 
        // Is the id set?
        if (empty($userid)) {
-               $userid = NULL;
+               $userid = 'NULL';
        } // END - if
 
        // Just run the insert query for now
-       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_urls` (`url_userid`, `url`, `url_status`, `url_views_max`, `url_views_allowed`, `url_fixed_reload`) VALUES (%s,'%s','%s',%s,%s,%s)",
+       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_urls` (`url_userid`,`url`,`url_status`,`url_views_max`,`url_views_allowed`,`url_fixed_reload`) VALUES (%s,'%s','%s',%s,%s,%s)",
                array(
                        $userid,
                        $urlData['url'],
@@ -861,10 +861,10 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() {
        $templateName = 'surfbar_frameset';
 
        // Any frame set? ;-)
-       if (isGetRequestParameterSet('frame')) {
+       if (isGetRequestElementSet('frame')) {
                // Use the frame as a template name part... ;-)
                $templateName = sprintf("surfbar_frame_%s",
-                       getRequestParameter('frame')
+                       getRequestElement('frame')
                );
        } // END - if
 
@@ -934,7 +934,7 @@ LIMIT 1",
 }
 
 // Get total amount of URLs of given status for current user or of ACTIVE URLs by default
-function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = '0') {
+function SURFBAR_GET_TOTAL_URLS ($status = 'ACTIVE', $excludeUserId = NULL) {
        // Determine depleted user account
        $userids = SURFBAR_DETERMINE_DEPLETED_USERIDS();
 
@@ -978,16 +978,16 @@ LIMIT 1",
 // Check wether the user is allowed to book more URLs
 function SURFBAR_IF_USER_BOOK_MORE_URLS ($userid = NULL) {
        // Is this admin and userid is zero or does the user has some URLs left to book?
-       return ((($userid == '0') && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array('REJECTED')) < getSurfbarMaxOrder()));
+       return (((is_null($userid)) && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array('REJECTED')) < getSurfbarMaxOrder()));
 }
 
 // Get total amount of URLs of given status for current user
 function SURFBAR_GET_TOTAL_USER_URLS ($userid = NULL, $status = '', $exclude = '') {
        // Is the user 0 and user is logged in?
-       if (($userid == '0') && (isMember())) {
+       if ((is_null($userid)) && (isMember())) {
                // Then use this userid
                $userid = getMemberId();
-       } elseif ($userid == '0') {
+       } elseif (is_null($userid)) {
                // Error!
                return (getSurfbarMaxOrder() + 1);
        }
@@ -998,16 +998,16 @@ function SURFBAR_GET_TOTAL_USER_URLS ($userid = NULL, $status = '', $exclude = '
        // Is the status set?
        if (is_array($status)) {
                // Only URLs with these status
-               $add = sprintf(" AND `url_status` IN('%s')", implode("','", $status));
+               $add = sprintf(" WHERE `url_status` IN('%s')", implode("','", $status));
        } elseif (!empty($status)) {
                // Only URLs with this status
-               $add = sprintf(" AND `url_status`='%s'", $status);
+               $add = sprintf(" WHERE `url_status`='%s'", $status);
        } elseif (is_array($exclude)) {
                // Exclude URLs with these status
-               $add = sprintf(" AND `url_status` NOT IN('%s')", implode("','", $exclude));
+               $add = sprintf(" WHERE `url_status` NOT IN('%s')", implode("','", $exclude));
        } elseif (!empty($exclude)) {
                // Exclude URLs with this status
-               $add = sprintf(" AND `url_status` != '%s'", $exclude);
+               $add = sprintf(" WHERE `url_status` != '%s'", $exclude);
        }
 
        // Get amount from database
@@ -1032,7 +1032,7 @@ function SURFBAR_GENERATE_VALIDATION_CODE ($urlId, $salt = '') {
        }
 
        // Hash it with md5() and salt it with the random string
-       $hashedCode = generateHash(md5($urlId . getEncryptSeperator() . getMemberId()), SURFBAR_GET_SALT());
+       $hashedCode = generateHash(md5($urlId . getEncryptSeparator() . getMemberId()), SURFBAR_GET_SALT());
 
        // Finally encrypt it PGP-like and return it
        $valHashedCode = encodeHashForCookie($hashedCode);
@@ -1065,7 +1065,7 @@ function SURFBAR_LOCKDOWN_ID ($urlId) {
        // Do we have no record?
        if ($countLock == 0) {
                // Just add it to the database
-               SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)',
+               SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`,`locks_url_id`) VALUES (%s, %s)',
                        array(
                                getMemberId(),
                                bigintval($urlId)
@@ -1087,6 +1087,7 @@ function SURFBAR_PAY_POINTS () {
        // Remove it from the URL owner
        /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS() . ' - ENTERED!');
        if (isValidUserId(SURFBAR_GET_USERID())) {
+               // Subtract points and ignore return status
                subtractPoints(sprintf("surfbar_%s", getSurfbarPaymentModel()), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS());
        } // END - if
 
@@ -1094,7 +1095,7 @@ function SURFBAR_PAY_POINTS () {
        // Init referal system here
        initReferalSystem();
 
-       // Book it to the user
+       // Book it to the user and ignore return status
        addPointsThroughReferalSystem(sprintf("surfbar:%s", getSurfbarPaymentModel()), getMemberId(), SURFBAR_GET_REWARD());
        /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS() . ' - EXIT!');
 }
@@ -1127,7 +1128,7 @@ function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
        // Was that update okay?
        if (SQL_HASZEROAFFECTED()) {
                // No, then insert entry
-               SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`, `stats_url_id`, `stats_count`) VALUES (%s,%s,1)',
+               SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`,`stats_url_id`,`stats_count`) VALUES (%s,%s,1)',
                        array(
                                getMemberId(),
                                SURFBAR_GET_ID()
@@ -1172,7 +1173,7 @@ function SURFBAR_UPDATE_SALT_STATS () {
        // Was that okay?
        if (SQL_HASZEROAFFECTED()) {
                // Insert missing entry!
-               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_salts` (`salts_url_id`, `salts_userid`, `salts_last_salt`) VALUES (%s, %s, '%s')",
+               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_salts` (`salts_url_id`,`salts_userid`,`salts_last_salt`) VALUES (%s, %s, '%s')",
                        array(
                                SURFBAR_GET_ID(),
                                getMemberId(),
@@ -1340,7 +1341,7 @@ function SURFBAR_DETERMINE_WAIT_TIME () {
 }
 
 // Changes the status of an URL from given to other
-function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) {
+function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data = array()) {
        /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - ENTERED!');
        // Make new status always lower-case
        $newStatus = strtolower($newStatus);
@@ -1648,14 +1649,14 @@ function SURFBAR_RELOAD_TO_STOP_PAGE ($page = 'stop') {
 
 // Determine next id for surfbar or get data for given id, always call this before you call other
 // getters below this function!
-function SURFBAR_DETERMINE_NEXT_ID ($urlId = '0') {
+function SURFBAR_DETERMINE_NEXT_ID ($urlId = NULL) {
        /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ' - ENTERED!');
        // Default is no id and no random number
        $nextId = '0';
        $randNum = '0';
 
        // Is the id set?
-       if ($urlId == '0') {
+       if (is_null($urlId)) {
                // Get array with lock ids
                $USE = SURFBAR_GET_LOCK_IDS();
 
@@ -1882,7 +1883,7 @@ function SURFBAR_GET_DATA ($element) {
        /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ' - ENTERED!');
 
        // Default is null
-       $data = null;
+       $data = NULL;
 
        // Is the entry there?
        if (isset($GLOBALS['surfbar_cache'][$element])) {