Function loadLanguageFile() does now support extensions
[mailer.git] / beg.php
diff --git a/beg.php b/beg.php
index 3de49a3a9b251cefbecc9cd68393089d5934cafc..27bb97df84504d8646f695e3fd77282a31bc6029 100644 (file)
--- a/beg.php
+++ b/beg.php
 // Load security stuff here
 require('inc/libs/security_functions.php');
 
-// Init "action" and "what"
+// Init start time
 $GLOBALS['startTime'] = microtime(true);
-$GLOBALS['what'] = '';
-$GLOBALS['action'] = '';
 
 // Set module
 $GLOBALS['module'] = 'beg';
 $GLOBALS['refid']  = 0;
 $GLOBALS['output_mode'] = -1;
-$msg = null;
+$errorCode = null;
 
 // Load the required file(s)
 require('inc/config-global.php');
@@ -76,17 +74,17 @@ if (REQUEST_ISSET_GET('uid')) {
        if (''.(REQUEST_GET('uid') + 0).'' !== ''.REQUEST_GET('uid').'') {
                if (EXT_IS_ACTIVE('nickname')) {
                        // Maybe we have found a nickname?
-                       $result = SQL_QUERY_ESC("SELECT userid, beg_clicks, ref_payout, status, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' LIMIT 1",
-                       array(REQUEST_GET('uid')), __FILE__, __LINE__);
+                       $result = SQL_QUERY_ESC("SELECT `userid`, `beg_clicks`, `ref_payout`, `status`, `last_online` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `nickname`='%s' LIMIT 1",
+                               array(REQUEST_GET('uid')), __FILE__, __LINE__);
                } else {
                        // Nickname entered but nickname is not active
-                       $msg = getCode('EXTENSION_PROBLEM');
+                       $errorCode = getCode('EXTENSION_PROBLEM');
                        $uid = -1;
                }
        } else {
                // Direct userid
-               $result = SQL_QUERY_ESC("SELECT userid, beg_clicks, ref_payout, status, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-               array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
+               $result = SQL_QUERY_ESC("SELECT `userid`, `beg_clicks`, `ref_payout`, `status`, `last_online` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+                       array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
        }
 
        // Check if locked in so don't pay points
@@ -124,8 +122,8 @@ if (REQUEST_ISSET_GET('uid')) {
        // User id valid and not webmaster's id?
        if (($uid > 0) && (getConfig('beg_uid') != $uid)) {
                // Update counter
-               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET beg_clicks=beg_clicks+1 WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1",
-               array($uid), __FILE__, __LINE__);
+               SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `beg_clicks`=`beg_clicks`+1 WHERE `userid`=%s AND `status`='CONFIRMED' LIMIT 1",
+                       array($uid), __FILE__, __LINE__);
 
                // Check for last entry for userid w/o IP number
                $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_beg_ips` WHERE (timeout > (UNIX_TIMESTAMP() - ".getConfig('beg_timeout').") OR (timeout > (UNIX_TIMESTAMP() - ".getConfig('beg_uid_timeout').") AND `userid`=%s)) AND (remote_ip='%s' OR sid='%s') LIMIT 1",
@@ -139,8 +137,8 @@ if (REQUEST_ISSET_GET('uid')) {
                                // Remember remote address, userid and timestamp for next click
                                // but only when there is no admin begging.
                                // Admins shall be able to test it!
-                               SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_beg_ips` (userid, remote_ip,sid, timeout) VALUES ('%s','%s','%s', UNIX_TIMESTAMP())",
-                               array($uid, detectRemoteAddr(), session_id()), __FILE__, __LINE__);
+                               SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_beg_ips` (`userid`, `remote_ip`,`sid`, `timeout`) VALUES ('%s','%s','%s', UNIX_TIMESTAMP())",
+                                       array($uid, detectRemoteAddr(), session_id()), __FILE__, __LINE__);
 
                                // Was is successfull?
                                $pay (SQL_AFFECTEDROWS() == 1);
@@ -209,28 +207,28 @@ if (REQUEST_ISSET_GET('uid')) {
                loadIncludeOnce('inc/footer.php');
        } elseif (($status != 'CONFIRMED') && ($status != 'failed')) {
                // Maybe locked/unconfirmed account?
-               $msg = generateErrorCodeFromUserStatus($status);
+               $errorCode = generateErrorCodeFromUserStatus($status);
        } elseif (($uid == '0') || ($status == 'failed')) {
                // Inalid or locked account, so let's find out
                $result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE nickname='%s' LIMIT 1",
-               array(REQUEST_GET('uid')), __FILE__, __LINE__);
+                       array(REQUEST_GET('uid')), __FILE__, __LINE__);
                if (SQL_NUMROWS($result) == 1) {
                        // Locked account
-                       $msg = getCode('ACCOUNT_LOCKED');
+                       $errorCode = getCode('ACCOUNT_LOCKED');
                } else {
                        // Invalid nickname! (404)
-                       $msg = getCode('USER_404');
+                       $errorCode = getCode('USER_404');
                }
 
                // Free memory
                SQL_FREERESULT($result);
        } elseif ($uid == getConfig('beg_uid')) {
                // Webmaster's ID cannot beg for points!
-               $msg = getCode('BEG_SAME_AS_OWN');
+               $errorCode = getCode('BEG_SAME_AS_OWN');
        }
 
        // Reload to index module
-       if ((!empty($msg)) && (!empty($msg))) redirectToUrl('modules.php?module=index&msg='.$msg.'&ext=beg');
+       if ((!empty($errorCode)) && (!empty($errorCode))) redirectToUrl('modules.php?module=index&msg=' . $errorCode . '&ext=beg');
 } else {
        // No userid entered
        redirectToUrl('modules.php?module=index');