]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/surfbar_functions.php
Renamed all SQL-related functions to camel-case notation
[mailer.git] / inc / libs / surfbar_functions.php
index 55af52e3dae1845591f2ce7003254dbf9dc67944..9dbc62b9986a475ce749de1e3d3dc7295493fd11 100644 (file)
@@ -292,20 +292,20 @@ function getSurfbarActionsDataFromId ($columnName, $id) {
                $GLOBALS[__FUNCTION__][$id][$columnName] = '*INVALID*';
 
                // Search for it
-               $result = SQL_QUERY_ESC("SELECT `%s` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_id`=%s LIMIT 1",
+               $result = sqlQueryEscaped("SELECT `%s` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_id`=%s LIMIT 1",
                        array(
                                $columnName,
                                bigintval($id)
                        ), __FUNCTION__, __LINE__);
 
                // Is there an entry?
-               if (SQL_NUMROWS($result) == 1) {
+               if (sqlNumRows($result) == 1) {
                        // Load it
-                       list($GLOBALS[__FUNCTION__][$id][$columnName]) = SQL_FETCHROW($result);
+                       list($GLOBALS[__FUNCTION__][$id][$columnName]) = sqlFetchRow($result);
                } // END - if
 
                // Free result
-               SQL_FREERESULT($result);
+               sqlFreeResult($result);
        } // END - if
 
        // Return value
@@ -315,14 +315,14 @@ function getSurfbarActionsDataFromId ($columnName, $id) {
 // Validate if the requested action can be performed on current URL status
 function isSurfbarMemberActionStatusValid ($action, $status) {
        // Search for the requested action/status combination in database
-       $result = SQL_QUERY_ESC("SELECT `actions_new_status` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_action`='%s' AND `actions_status`='%s' LIMIT 1",
+       $result = sqlQueryEscaped("SELECT `actions_new_status` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_action`='%s' AND `actions_status`='%s' LIMIT 1",
                array(
                        strtoupper($action),
                        strtoupper($status)
                ), __FUNCTION__, __LINE__);
 
        // Is the entry there?
-       $isValid = (SQL_NUMROWS($result) == 1);
+       $isValid = (sqlNumRows($result) == 1);
 
        // Debug message
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'action=' . $action . ',status=' . $status . ',isValid=' . intval($isValid));
@@ -330,11 +330,11 @@ function isSurfbarMemberActionStatusValid ($action, $status) {
        // Fetch the new status if found
        if ($isValid === TRUE) {
                // Load new status
-               list($GLOBALS['surfbar_cache']['new_status']) = SQL_FETCHROW($result);
+               list($GLOBALS['surfbar_cache']['new_status']) = sqlFetchRow($result);
        } // END - if
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return status
        return $isValid;
@@ -478,7 +478,7 @@ function executeSurfbarMemberEditAction ($urlData) {
        if (TRUE) {
                // @TODO if (($urlData['url_views_allowed'] != $urlData['edit']['limit']) || ($url1 != $url2)) {
                // Run the query
-               SQL_QUERY_ESC("UPDATE
+               sqlQueryEscaped("UPDATE
        `{?_MYSQL_PREFIX?}_surfbar_urls`
 SET
        `url`='%s',
@@ -566,7 +566,7 @@ function doHandleSurfbarLowPoints () {
                        doSurfbarNotifyMember('low_points', $content);
 
                        // Update last notified
-                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `surfbar_low_notified`=NOW() WHERE `userid`=%s LIMIT 1",
+                       sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `surfbar_low_notified`=NOW() WHERE `userid`=%s LIMIT 1",
                                array($userid), __FUNCTION__, __LINE__);
                } // END - if
        } // END - foreach
@@ -605,7 +605,7 @@ function getSurfbarUrlData ($searchTerm, $column = 'url_id', $order = 'url_id',
        } // END - if
 
        // Look up the record
-       $result = SQL_QUERY_ESC("SELECT
+       $result = sqlQueryEscaped("SELECT
        `url_id`,
        `url_userid`,
        `url_package_id`,
@@ -637,9 +637,9 @@ ORDER BY
                ), __FUNCTION__, __LINE__);
 
        // Is there at least one record?
-       if (!SQL_HASZERONUMS($result)) {
+       if (!ifSqlHasZeroNums($result)) {
                // Then load all!
-               while ($dataRow = SQL_FETCHARRAY($result)) {
+               while ($dataRow = sqlFetchArray($result)) {
                        // Shall we group these results?
                        if ($group == 'url_id') {
                                // Add the row by id as index
@@ -652,7 +652,7 @@ ORDER BY
        } // END - if
 
        // Free the result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return the result
        return $GLOBALS['last_url_data'];
@@ -716,7 +716,7 @@ function insertSurfbarUrlByArray ($urlData) {
        } // 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`, `url_fixed_waiting`) VALUES (%s, '%s', '%s', %s, %s, %s, %s)",
+       sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_urls` (`url_userid`, `url`, `url_status`, `url_views_max`, `url_views_allowed`, `url_fixed_reload`, `url_fixed_waiting`) VALUES (%s, '%s', '%s', %s, %s, %s, %s)",
                array(
                        $userid,
                        $urlData['url'],
@@ -729,7 +729,7 @@ function insertSurfbarUrlByArray ($urlData) {
        );
 
        // Return secured insert id
-       return SQL_INSERT_ID();
+       return getSqlInsertId();
 }
 
 // Notify admin(s) with a selected message and content
@@ -952,7 +952,7 @@ function isSurfbarReloadFull () {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'surf_lock=' . $GLOBALS['surfbar_cache']['surf_lock'] . ' - AFTER');
 
        // Ask the database
-       $result = SQL_QUERY_ESC("SELECT
+       $result = sqlQueryEscaped("SELECT
        COUNT(`l`.`locks_id`) AS `cnt`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_locks` AS `l`
@@ -972,7 +972,7 @@ LIMIT 1",
        );
 
        // Fetch row
-       list($GLOBALS['surfbar_cache']['user_locks']) = SQL_FETCHROW($result);
+       list($GLOBALS['surfbar_cache']['user_locks']) = sqlFetchRow($result);
 
        // Is it null?
        if (is_null($GLOBALS['surfbar_cache']['user_locks'])) {
@@ -981,7 +981,7 @@ LIMIT 1",
        } // END - if
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Get total URLs
        $total = getSurfbarTotalUrls();
@@ -1012,7 +1012,7 @@ function getSurfbarTotalUrls ($status = 'ACTIVE', $excludeUserId = NULL) {
        } // END - if
 
        // Get amount from database
-       $result = SQL_QUERY_ESC("SELECT
+       $result = sqlQueryEscaped("SELECT
        COUNT(`url_id`) AS `cnt`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_urls`
@@ -1024,10 +1024,10 @@ LIMIT 1",
        );
 
        // Fetch row
-       list($count) = SQL_FETCHROW($result);
+       list($count) = sqlFetchRow($result);
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Debug message
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cnt=' . $count . ' - EXIT!');
@@ -1126,7 +1126,7 @@ function addSurfbarReloadLockById ($urlId) {
        // Is there 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)',
+               sqlQueryEscaped('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)',
                        array(
                                getMemberId(),
                                bigintval($urlId)
@@ -1134,7 +1134,7 @@ function addSurfbarReloadLockById ($urlId) {
        } // END - if
 
        // Remove the salt from database
-       SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_surfbar_salts` WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1',
+       sqlQueryEscaped('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_surfbar_salts` WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1',
                array(
                        bigintval($urlId),
                        getMemberId()
@@ -1176,20 +1176,20 @@ function updateInsertSurfbarStatisticsRecord () {
        } // END - if
 
        // Update URL stats
-       SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `url_views_total`=`url_views_total`+1' . $add . ' WHERE `url_id`=%s LIMIT 1',
+       sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `url_views_total`=`url_views_total`+1' . $add . ' WHERE `url_id`=%s LIMIT 1',
                array(getSurfbarId()), __FUNCTION__, __LINE__);
 
        // Update the stats entry
-       SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_surfbar_stats` SET `stats_count`=`stats_count`+1 WHERE `stats_userid`=%s AND `stats_url_id`=%s LIMIT 1',
+       sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_surfbar_stats` SET `stats_count`=`stats_count`+1 WHERE `stats_userid`=%s AND `stats_url_id`=%s LIMIT 1',
                array(
                        getMemberId(),
                        getSurfbarId()
                ), __FUNCTION__, __LINE__);
 
        // Was that update okay?
-       if (SQL_HASZEROAFFECTED()) {
+       if (ifSqlHasZeroAffectedRows()) {
                // No, then insert entry
-               SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`, `stats_url_id`, `stats_count`) VALUES (%s,%s,1)',
+               sqlQueryEscaped('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`, `stats_url_id`, `stats_count`) VALUES (%s,%s,1)',
                        array(
                                getMemberId(),
                                getSurfbarId()
@@ -1221,7 +1221,7 @@ function updateSurfbarSaltStatistics () {
        updateInsertSurfbarStatisticsRecord();
 
        // Simply store the salt from cache away in database...
-       SQL_QUERY("UPDATE
+       sqlQuery("UPDATE
        `{?_MYSQL_PREFIX?}_surfbar_salts`
 SET
        `salts_last_salt`='{%pipe,getSurfbarSalt%}'
@@ -1234,9 +1234,9 @@ LIMIT 1", __FUNCTION__, __LINE__);
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'salt=' . getSurfbarSalt() . ',id=' . getSurfbarId() . ',userid=' . getMemberId() . ',SQL_AFFECTEDROWS()=' . SQL_AFFECTEDROWS() . ' - UPDATE!');
 
        // Was that okay?
-       if (SQL_HASZEROAFFECTED()) {
+       if (ifSqlHasZeroAffectedRows()) {
                // Insert missing entry!
-               SQL_QUERY("INSERT INTO
+               sqlQuery("INSERT INTO
        `{?_MYSQL_PREFIX?}_surfbar_salts`
 (
        `salts_url_id`,
@@ -1253,14 +1253,14 @@ LIMIT 1", __FUNCTION__, __LINE__);
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'affectedRows=' . SQL_AFFECTEDROWS() . ' - EXIT!');
 
        // Return if the update was okay
-       return (!SQL_HASZEROAFFECTED());
+       return (!ifSqlHasZeroAffectedRows());
 }
 
 // Check if the reload lock is active for given id
 function ifSurfbarReloadLock ($urlId) {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $urlId . ' -  ENTERED!');
        // Ask the database
-       $result = SQL_QUERY_ESC('SELECT COUNT(`locks_id`) AS `cnt`
+       $result = sqlQueryEscaped('SELECT COUNT(`locks_id`) AS `cnt`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_locks`
 WHERE
@@ -1274,10 +1274,10 @@ LIMIT 1',
        );
 
        // Fetch counter
-       list($count) = SQL_FETCHROW($result);
+       list($count) = sqlFetchRow($result);
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return check
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',count=' . $count . ',getSurfbarSurfLock()=' . getSurfbarSurfLock() . ' - EXIT!');
@@ -1301,7 +1301,7 @@ function determineSurfbarDepletedUserids ($limit=0) {
                $userids['notified'][getMemberId()]   = '0';
 
                // Get all userid except logged in one
-               $result = SQL_QUERY_ESC("SELECT
+               $result = sqlQueryEscaped("SELECT
        `u`.`url_userid`,
        UNIX_TIMESTAMP(`d`.`surfbar_low_notified`) AS `notified`
 FROM
@@ -1321,7 +1321,7 @@ ORDER BY
                        array(getMemberId()), __FUNCTION__, __LINE__);
        } else {
                // Get all userid
-               $result = SQL_QUERY("SELECT
+               $result = sqlQuery("SELECT
        `u`.`url_userid`,
        UNIX_TIMESTAMP(`d`.`surfbar_low_notified`) AS `notified`
 FROM
@@ -1340,7 +1340,7 @@ ORDER BY
        }
 
        // Load all userid
-       while ($content = SQL_FETCHARRAY($result)) {
+       while ($content = sqlFetchArray($result)) {
                // Get total points
                $points = getTotalPoints($content['url_userid']);
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $content['url_userid'] . ',points=' . $points);
@@ -1356,7 +1356,7 @@ ORDER BY
        } // END - while
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Debug message
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UIDs::count=' . count($userids) . ' (with own userid=' . getMemberId() . ')');
@@ -1368,7 +1368,7 @@ ORDER BY
 // Determine how many users are Online in surfbar
 function determineSurfbarTotalOnline () {
        // Count all users in surfbar modue and return the value
-       $result = SQL_QUERY('SELECT
+       $result = sqlQuery('SELECT
        `stats_id`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_stats`
@@ -1378,10 +1378,10 @@ GROUP BY
        `stats_userid` ASC', __FUNCTION__, __LINE__);
 
        // Fetch count
-       $count = SQL_NUMROWS($result);
+       $count = sqlNumRows($result);
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return result
        return $count;
@@ -1443,7 +1443,7 @@ function changeSurfbarUrlStatus ($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 `url_status`='%s' WHERE `url_id`=%s LIMIT 1",
+       sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `url_status`='%s' WHERE `url_id`=%s LIMIT 1",
                array(
                        $newStatus,
                        bigintval($urlId)
@@ -1452,7 +1452,7 @@ function changeSurfbarUrlStatus ($urlId, $prevStatus, $newStatus, $data = array(
 
        // Was that fine?
        // ---------- Comment out for debugging/developing member actions! ---------
-       if (SQL_AFFECTEDROWS() != 1) {
+       if (sqlAffectedRows() != 1) {
                // No, something went wrong
                return FALSE;
        } // END - if
@@ -1553,7 +1553,7 @@ function getSurfbarLockIdsArray () {
        $ignored = array();
 
        // Get all id from locks within the timestamp
-       $result = SQL_QUERY_ESC("SELECT
+       $result = sqlQueryEscaped("SELECT
        `locks_id`,
        `locks_url_id`,
        UNIX_TIMESTAMP(`locks_last_surfed`) AS `last_surfed`
@@ -1566,7 +1566,7 @@ ORDER BY
        __FUNCTION__, __LINE__);
 
        // Load all entries
-       while ($content = SQL_FETCHARRAY($result)) {
+       while ($content = sqlFetchArray($result)) {
                // Debug message
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'next - lid='.$content['locks_id'].',url='.$content['locks_url_id'].',rest='.(time() - $content['last_surfed']).'/'.getSurfbarSurfLock());
 
@@ -1596,7 +1596,7 @@ ORDER BY
        } // END - while
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return array
        return $USE;
@@ -1605,7 +1605,7 @@ ORDER BY
 // "Getter" for maximum random number
 function getSurfbarMaximumRandom ($userids, $add) {
        // Count max availabe entries
-       $result = SQL_QUERY("SELECT
+       $result = sqlQuery("SELECT
        `sbu`.`url_id` AS `cnt`
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_urls` AS `sbu`
@@ -1629,10 +1629,10 @@ GROUP BY
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS());
 
        // Fetch max rand
-       $maxRand = SQL_NUMROWS($result);
+       $maxRand = sqlNumRows($result);
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return value
        return $maxRand;
@@ -1644,7 +1644,7 @@ function getSurfbarUserUrls () {
        $urlArray = array();
 
        // Begin the query
-       $result = SQL_QUERY_ESC("SELECT
+       $result = sqlQueryEscaped("SELECT
        `u`.`url_id`,
        `u`.`url_userid`,
        `u`.`url_package_id`,
@@ -1666,16 +1666,16 @@ ORDER BY
                array(getMemberId()), __FUNCTION__, __LINE__);
 
        // Are there entries?
-       if (!SQL_HASZERONUMS($result)) {
+       if (!ifSqlHasZeroNums($result)) {
                // Load all rows
-               while ($row = SQL_FETCHARRAY($result)) {
+               while ($row = sqlFetchArray($result)) {
                        // Add the row
                        $urlArray[$row['url_id']] = $row;
                } // END - while
        } // END - if
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return the array
        return $urlArray;
@@ -1687,20 +1687,20 @@ function getSurfbarArrayFromStatus ($status) {
        $returnArray = array();
 
        // Get all assigned actions
-       $result = SQL_QUERY_ESC("SELECT `actions_action` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_status`='%s' ORDER BY `actions_id` ASC",
+       $result = sqlQueryEscaped("SELECT `actions_action` FROM `{?_MYSQL_PREFIX?}_surfbar_actions` WHERE `actions_status`='%s' ORDER BY `actions_id` ASC",
                array($status), __FUNCTION__, __LINE__);
 
        // Some entries there?
-       if (!SQL_HASZERONUMS($result)) {
+       if (!ifSqlHasZeroNums($result)) {
                // Load all actions
                // @TODO This can be somehow rewritten
-               while ($content = SQL_FETCHARRAY($result)) {
+               while ($content = sqlFetchArray($result)) {
                        array_push($returnArray, $content['actions_action']);
                } // END - if
        } // END - if
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return result
        return $returnArray;
@@ -1762,7 +1762,7 @@ function determineSurfbarNextId ($urlId = NULL) {
 
                // And query the database
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'randNum='.$randNum.',maxRand='.$maxRand.',surfLock='.getSurfbarSurfLock());
-               $result = SQL_QUERY_ESC("SELECT
+               $result = sqlQueryEscaped("SELECT
        `sbu`.`url_id`,
        `sbu`.`url_userid`,
        `sbu`.`url_package_id`,
@@ -1798,7 +1798,7 @@ LIMIT %s,1",
                );
        } else {
                // Get data from specified id number
-               $result = SQL_QUERY_ESC("SELECT
+               $result = sqlQueryEscaped("SELECT
        `sbu`.`url_id`,
        `sbu`.`url_userid`,
        `sbu`.`url_package_id`,
@@ -1831,10 +1831,10 @@ LIMIT 1",
 
        // Is there an id number?
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'lastQuery='.getConfig('db_last_query').'|numRows='.SQL_NUMROWS($result).'|Affected='.SQL_AFFECTEDROWS());
-       if (SQL_NUMROWS($result) == 1) {
+       if (sqlNumRows($result) == 1) {
                // Load/cache data
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - BEFORE', FALSE);
-               $GLOBALS['surfbar_cache'] = merge_array($GLOBALS['surfbar_cache'], SQL_FETCHARRAY($result));
+               $GLOBALS['surfbar_cache'] = merge_array($GLOBALS['surfbar_cache'], sqlFetchArray($result));
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count('.count($GLOBALS['surfbar_cache']).') - AFTER', FALSE);
 
                // Determine waiting time
@@ -1872,7 +1872,7 @@ LIMIT 1",
        } // END - if
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return result
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',nextId=' . $nextId . ' - EXIT!');