]> git.mxchange.org Git - mailer.git/commitdiff
More fixes for reflink and rallye extension
authorRoland Häder <roland@mxchange.org>
Sat, 27 Sep 2008 18:22:02 +0000 (18:22 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 27 Sep 2008 18:22:02 +0000 (18:22 +0000)
16 files changed:
inc/config.php
inc/databases.php
inc/extensions/ext-sql_patches.php
inc/functions.php
inc/libs/rallye_functions.php
inc/modules/admin.php
inc/modules/admin/admin-inc.php
inc/modules/guest/what-confirm.php
inc/modules/guest/what-register.php
inc/modules/guest/what-wernis_portal.php
inc/mysql-manager.php
inc/session.php
lead-confirm.php
ref.php
templates/de/html/guest/guest_register_refid.tpl
templates/de/html/guest/guest_register_refid_hide.tpl

index 08df3c6eff4c7819df66338e25bad8a1b425b0a0..4f90620e1ac09472b7664d0907cc0a3773a5718c 100644 (file)
@@ -106,6 +106,9 @@ define('admin_registered', false);
 // CFG: DEBUG-MODE (if enabled all mails will be *displayed* and *not* send!)
 define('DEBUG_MODE', false);
 
+// CFG: DEBUG-MAIL (turn this on if you need to debug mails, only affects if DEBUG_MODE is true)
+//define('DEBUG_MAIL', true);
+
 // When we are not installing
 if (!defined('mxchange_installing')) define('mxchange_installing', false);
 
index 1ee3935f7d04d726efa1683300e6e0d1ac4e9e2d..16d8b8cdaf95bb3c69ba6bbe4cc80b1efdac0963 100644 (file)
@@ -113,7 +113,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "397");
+define('CURR_SVN_REVISION', "399");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index 2efdb59de6e0a6d6ab189b899415bb9001993f44..7e99c8bfa41e23f59f7ca55c0a6608d9c055e665 100644 (file)
@@ -38,13 +38,13 @@ if (!defined('__SECURITY')) {
 }
 
 // Version number
-$EXT_VERSION = "0.4.8";
+$EXT_VERSION = "0.4.9";
 
 // Auto-set extension version
 if (!isset($EXT_VER)) $EXT_VER = $EXT_VERSION;
 
 // Version history array (add more with , "0.1" and so on)
-$EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6", "0.1.7", "0.1.8", "0.1.9", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.3.6", "0.3.7", "0.3.8", "0.3.9", "0.4.0", "0.4.1", "0.4.2", "0.4.3", "0.4.4", "0.4.5", "0.4.6", "0.4.7", "0.4.8");
+$EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6", "0.1.7", "0.1.8", "0.1.9", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.3.6", "0.3.7", "0.3.8", "0.3.9", "0.4.0", "0.4.1", "0.4.2", "0.4.3", "0.4.4", "0.4.5", "0.4.6", "0.4.7", "0.4.8", "0.4.9");
 
 switch ($EXT_LOAD_MODE)
 {
@@ -623,6 +623,15 @@ PRIMARY KEY (id)
                // Update notes (these will be set as task text!)
                $UPDATE_NOTES = "Index f&uuml;r Betreff eingef&uuml;gt.";
                break;
+
+       case "0.4.9": // SQL queries for v0.4.9
+               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data CHANGE `user_hash` `user_hash` VARCHAR(255) NULL DEFAULT NULL";
+               $SQLs[] = "UPDATE "._MYSQL_PREFIX."_user_data SET user_hash=NULL WHERE user_hash IS NOT NULL AND status='CONFIRMED'";
+               $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_user_data` ADD UNIQUE (`user_hash`)";
+
+               // Update notes (these will be set as task text!)
+               $UPDATE_NOTES = "User-Hash zum Best&auml;tigen wird auf NULL gesetzt, wenn Account best&auml;tigt wird.";
+               break;
        }
        break;
 
index 9a7b1fc6f1fb23c6758cf81baf23b15a7d45cf5b..3dcee7a5cce4ea43680c3ae67ac6ee7f27ff18a3 100644 (file)
@@ -134,7 +134,7 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) {
                ob_end_clean();
 
                // Extension "rewrite" installed?
-               if ((EXT_IS_ACTIVE("rewrite", true)) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) {
+               if ((EXT_IS_ACTIVE("rewrite")) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) {
                        $OUTPUT = REWRITE_LINKS($OUTPUT);
                } // END - if
 
@@ -157,7 +157,7 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) {
                OUTPUT_RAW($OUTPUT);
        } elseif ((OUTPUT_MODE == "render") && (!empty($OUTPUT))) {
                // Rewrite links when rewrite extension is active
-               if ((EXT_IS_ACTIVE("rewrite", true)) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) {
+               if ((EXT_IS_ACTIVE("rewrite")) && (function_exists('REWRITE_LINKS')) && ($CSS != "1") && ($CSS != "-1")) {
                        $OUTPUT = REWRITE_LINKS($OUTPUT);
                } // END - if
 
@@ -420,7 +420,10 @@ To      : ".$TO."
 Subject : ".$SUBJECT."
 Message : ".$MSG."
 </pre>\n";
-       } elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail", true))) {
+
+               // Log the mail away
+               if (defined('DEBUG_MAIL')) DEBUG_LOG(__FUNCTION__.":to={$TO},subject={$SUBJECT},msg={$MSG}");
+       } elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail"))) {
                // Send mail as HTML away
                SEND_HTML_EMAIL($TO, $SUBJECT, $MSG, $FROM);
        } elseif (!empty($TO)) {
@@ -898,6 +901,15 @@ function LOAD_URL($URL, $addUrlData=true) {
 //
 function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) {
        global $SEC_CHARS, $URL_CHARS;
+       // Is the code a string?
+       if (!is_string($code)) {
+               // Abort here with backtrace
+               DEBUG_LOG(__FUNCTION__.": code is not string!");
+               print "<pre>";
+               debug_print_backtrace();
+               die("</pre>");
+       } // END - if
+
        $ARRAY = $SEC_CHARS;
 
        // Select smaller set of chars to replace when we e.g. want to compile URLs
@@ -1908,7 +1920,7 @@ function CREATE_EMAIL_LINK($email, $table="admins") {
        if ((EXT_IS_ACTIVE("admins")) && ($table == "admins")) {
                // Create email link for contacting admin in guest area
                $EMAIL = ADMINS_CREATE_EMAIL_LINK($email);
-       } elseif ((EXT_IS_ACTIVE("user", true)) && (GET_EXT_VERSION("user") >= "0.3.3") && ($table == "user_data")) {
+       } elseif ((EXT_IS_ACTIVE("user")) && (GET_EXT_VERSION("user") >= "0.3.3") && ($table == "user_data")) {
                // Create email link for contacting a member within admin area (or later in other areas, too?)
                $EMAIL = USER_CREATE_EMAIL_LINK($email);
        } elseif ((EXT_IS_ACTIVE("sponsor")) && ($table == "sponsor_data")) {
@@ -1927,7 +1939,7 @@ function generateHash ($plainText, $salt = "") {
        global $_CONFIG, $_SERVER;
 
        // Is the required extension "sql_patches" there and a salt is not given?
-       if (((EXT_VERSION_IS_OLDER("sql_patches", "0.3.6")) || (EXT_IS_ACTIVE("sql_patches"))) && (empty($salt))) {
+       if (((EXT_VERSION_IS_OLDER("sql_patches", "0.3.6")) || (!EXT_IS_ACTIVE("sql_patches"))) && (empty($salt))) {
                // Extension sql_patches is missing/outdated so we return the plain text
                return $plainText;
        } // END - if
@@ -2333,7 +2345,7 @@ function GET_DIR_AS_ARRAY ($baseDir, $prefix) {
 
                // Is this a valid reset file?
                //* DEBUG: */ echo __FUNCTION__.":baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}<br />\n";
-               if ((is_file($file)) && (is_readable($file)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) {
+               if ((FILE_READABLE($file)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) {
                        // Remove both for extension name
                        $extName = substr($baseFile, strlen($prefix), -4);
 
@@ -2529,8 +2541,17 @@ function REBUILD_CACHE ($cache, $inc="") {
 
                        // Include file given?
                        if (!empty($inc)) {
-                               // And rebuild it from scratch
-                               require_once(PATH."inc/loader/load_cache-".$inc.".php");
+                               // Construct FQFN
+                               $fqfn = sprintf("%sinc/loader/load_cache-%s.php", PATH, $inc);
+
+                               // Is the include there?
+                               if (FILE_READABLE($fqfn)) {
+                                       // And rebuild it from scratch
+                                       require_once($fqfn);
+                               } else {
+                                       // Include not found!
+                                       DEBUG_LOG(__FUNCTION__.":Include {$inc} not found. cache={$cache}");
+                               }
                        } // END - if
                } // END - if
        } // END - if
index 796356caca854116dba09c067d42782580e5ed4c..36e85f6c076078699c6468cbd70664f3f98cdedd 100644 (file)
@@ -280,32 +280,44 @@ LIMIT 1", array(bigintval($uid), $_CONFIG['ref_payout'], $since), __FILE__, __LI
 function RALLYE_AUTOADD_USER($uid)
 {
        global $DATA;
+       $ADD = "";
+
+       // Updated extension?
+       if (GET_EXT_VERSION("rallye") >= "0.2.0") {
+               $ADD .= ", min_users, min_prices";
+       } // END - if
+
        // Check for an auto-add rallye
-       $result = SQL_QUERY("SELECT id, title, start_time, end_time, send_notify FROM "._MYSQL_PREFIX."_rallye_data WHERE is_active='Y' AND notified='Y' AND auto_add_new_user='Y' AND expired='N' LIMIT 1", __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) == 1)
-       {
+       $result = SQL_QUERY("SELECT id, title, start_time, end_time, send_notify".$ADD." FROM "._MYSQL_PREFIX."_rallye_data WHERE is_active='Y' AND notified='Y' AND auto_add_new_user='Y' AND expired='N' LIMIT 1", __FILE__, __LINE__);
+       if (SQL_NUMROWS($result) == 1) {
+               // Init variables
+               $min_users = 0; $min_prices = 0;
                // Load data
-               list($id, $title, $start, $end, $notify) = SQL_FETCHROW($result);
+               if (GET_EXT_VERSION("rallye") >= "0.2.0") {
+                       list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result);
+               } else {
+                       list($id, $title, $start, $end, $notify) = SQL_FETCHROW($result);
+               }
+
+               // Free result
                SQL_FREERESULT($result);
 
                // Check if line is already included...
                $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_users WHERE rallye_id=%s AND userid=%s LIMIT 1",
-                array(bigintval($id), bigintval($uid)), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 0)
-               {
+                       array(bigintval($id), bigintval($uid)), __FILE__, __LINE__);
+
+               // Is this user added?
+               if (SQL_NUMROWS($result) == 0) {
                        // Add userid and his ref count to table
                        $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_rallye_users (rallye_id, userid, refs)
 VALUES ('%s','%s','0')",
  array(bigintval($id), bigintval($uid)), __FILE__, __LINE__);
-               }
-                else
-               {
+               } else {
                        // Free memory
                        SQL_FREERESULT($result);
                }
 
-               if ($notify == "Y")
-               {
+               if ($notify == "Y") {
                        // Transfer all neccessary data to the global $DATA array
                        $DATA['start'] = MAKE_DATETIME($start, "2");
                        $DATA['end']   = MAKE_DATETIME($end  , "2");
@@ -313,15 +325,32 @@ VALUES ('%s','%s','0')",
                        $DATA['title'] = $title;
                        $DATA['id']    = $id;  // ID for the rallye details link
                        $DATA['ref']   = 0;
+                       $DATA['refs']  = GET_TOTAL_DATA($uid, "user_data", "userid", "refid", true);
 
                        // Load prices
                        $prices = RALLYE_ADD_PRICES($id);
 
+                       if ($min_users == 0) {
+                               // Rallye ends without user limitation
+                               $DATA['min_users'] = RALLYE_END_NO_USER_LIMITATION;
+                       } else {
+                               // Rallye ends when X members are totally in your exchange
+                               $DATA['min_users'] = RALLYE_END_USERS_1." ".$min_users." ".RALLYE_END_USERS_2;
+                       }
+
+                       if ($min_prices == 0) {
+                               // Rallye ends without user limitation
+                               $DATA['min_prices'] = RALLYE_END_NO_PRICE_LIMITATION;
+                       } else {
+                               // Rallye ends when X members are totally in your exchange
+                               $DATA['min_prices'] = RALLYE_END_PRICES_1." ".$min_prices." ".RALLYE_END_PRICES_2;
+                       }
+
                        // Send notification to member
                        $msg = LOAD_EMAIL_TEMPLATE("member_rallye_notify", array('prices' => $prices), $uid);
                        SEND_EMAIL($uid, RALLYE_MEMBER_NOTIFY.$title, $msg);
-               }
-       }
+               } // END - if
+       } // END - if
 }
 //
 function RALLYE_EXPIRE_RALLYES($result)
index d1a728404623e9749c220cc68a2cd073c92bbe8b..06823fef116a420c0528e4b03a86950f61b3332a 100644 (file)
@@ -203,6 +203,8 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
        if ((isset($_POST['ok'])) && ($_POST['ok'] != "***")) {
                // All required data was entered so we check his account
                $ret = CHECK_ADMIN_LOGIN($_POST['login'], $_POST['pass']);
+
+               // Which status do we have?
                switch ($ret)
                {
                case "done": // Admin and password are okay, so we log in now
index f391b42a8c16bf03071cd51cab8f69b7ebaa0276..74ba0ce258a39acad47cd8aa6d384cbe224d6128 100644 (file)
@@ -67,7 +67,7 @@ function CHECK_ADMIN_LOGIN ($admin_login, $password)
        $data = array();
 
        // Is the cache valid?
-       if (!empty($cacheArray['admins']['aid'][$admin_login])) {
+       if (!empty($cacheArray['admins']['password'][$admin_login])) {
                // Get password from cache
                $data['password'] = $cacheArray['admins']['password'][$admin_login];
                $ret = "pass";
@@ -79,7 +79,7 @@ function CHECK_ADMIN_LOGIN ($admin_login, $password)
                        $data['login_failtures'] = $cacheArray['admins']['login_failtures'][$admin_login];
                        $data['last_failture']   = $cacheArray['admins']['last_failture'][$admin_login];
                } // END - if
-       } elseif (GET_EXT_VERSION("cache") == "") {
+       } elseif (EXT_IS_ACTIVE("cache")) {
                $ADD = "";
                if (GET_EXT_VERSION("admins") >= "0.7.0") {
                        // Load them here
@@ -122,7 +122,7 @@ function CHECK_ADMIN_LOGIN ($admin_login, $password)
 
        // Check if password is same
        //* DEBUG: */ echo "*".$ret.",".$data['password'].",".$password.",".$salt."*<br >\n";
-       if (($ret == "pass") && ($data['password'] == generateHash($password, $salt)) && (!empty($salt))) {
+       if (($ret == "pass") && ($data['password'] == generateHash($password, $salt)) && ((!empty($salt))) || ($data['password'] == $password)) {
                // Re-hash the plain passord with new random salt
                $data['password'] = generateHash($password);
 
index 7d554b5f3daf2a1c0549981e6799791138ff5bb7..22acf14e50f137206fba410d4117ddcf32e67645 100644 (file)
@@ -40,37 +40,32 @@ if (!defined('__SECURITY')) {
 // Add description as navigation point
 ADD_DESCR("guest", basename(__FILE__));
 
-if (!empty($_GET['hash']))
-{
+if (!empty($_GET['hash'])) {
        // Initialize the user ID
        $uid = 0;
 
        // Search for an unconfirmed or confirmed account
        $result = SQL_QUERY_ESC("SELECT userid, email, refid FROM "._MYSQL_PREFIX."_user_data WHERE user_hash='%s' AND (status='UNCONFIRMED' OR status='CONFIRMED') LIMIT 1",
-        array($_GET['hash']), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) == 1)
-       {
+               array($_GET['hash']), __FILE__, __LINE__);
+       if (SQL_NUMROWS($result) == 1) {
                // Ok, he want's to confirm now so we load some data
                list ($uid, $email, $rid) = SQL_FETCHROW($result);
 
                // Unlock his account (but only when it is on UNCONFIRMED!)
-               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED', ref_payout='%s' WHERE user_hash='%s' AND status='UNCONFIRMED' LIMIT 1",
-                array($_CONFIG['ref_payout'], $_GET['hash']), __FILE__, __LINE__);
-               if (SQL_AFFECTEDROWS() == 1)
-               {
+               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED', ref_payout=%s, user_hash=NULL WHERE user_hash='%s' AND status='UNCONFIRMED' LIMIT 1",
+                       array($_CONFIG['ref_payout'], $_GET['hash']), __FILE__, __LINE__);
+               if (SQL_AFFECTEDROWS() == 1) {
                        $msg = LOAD_EMAIL_TEMPLATE("confirm-member", array('points' => $_CONFIG['points_register']), bigintval($uid));
 
                        // And send him right away the confirmation mail
                        SEND_EMAIL($email, GUEST_THANX_CONFIRM, $msg);
 
                        // Maybe he got "referraled"?
-                       if (($rid > 0) && ($rid != $uid))
-                       {
+                       if (($rid > 0) && ($rid != $uid)) {
                                // Select the referral userid
                                $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
                                 array(bigintval($rid)), __FILE__, __LINE__);
-                               if (SQL_NUMROWS($result) == 1)
-                               {
+                               if (SQL_NUMROWS($result) == 1) {
                                        // Update ref counter...
                                        UPDATE_REF_COUNTER($rid);
 
@@ -78,38 +73,34 @@ if (!empty($_GET['hash']))
                                        unset($DEPTH);
 
                                        // Shall I "pay" the referral points imidiately?
-                                       if ($_CONFIG['ref_payout'] == "0")
-                                       {
+                                       if ($_CONFIG['ref_payout'] == "0") {
                                                // Yes, "pay" it now
                                                $locked = false;
-                                       }
-                                        else
-                                       {
+                                       } else {
                                                // No, "pay" it later
                                                $locked = true;
                                        }
 
                                        // If version matches add ref bonus to refid's account
-                                       if ((GET_EXT_VERSION("bonus") >= "0.4.4") && ($_CONFIG['bonus_active'] == "Y"))
-                                       {
+                                       if ((GET_EXT_VERSION("bonus") >= "0.4.4") && ($_CONFIG['bonus_active'] == "Y")) {
                                                // Add points (directly only!)
                                                $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET bonus_ref=bonus_ref+%s WHERE userid=%s LIMIT 1",
                                                 array($_CONFIG['bonus_ref'], bigintval($rid)), __FILE__, __LINE__);
 
                                                // Subtract points from system
                                                BONUS_POINTS_HANDLER($_CONFIG['bonus_ref']);
-                                       }
+                                       } // END - if
 
                                        // Add one-time referral bonus over referral system or directly
                                        $DEPTH = 0;
                                        ADD_POINTS_REFSYSTEM($rid, $_CONFIG['points_ref'], true, bigintval($uid), $locked, $_CONFIG['reg_points_mode']);
-                               }
-                       }
+                               } // END - if
+                       } // END - if
 
                        if (EXT_IS_ACTIVE("rallye")) {
                                // Add user to rallye (or not?)
                                RALLYE_AUTOADD_USER(bigintval($uid));
-                       }
+                       } // END - if
 
                        // Account confirmed!
                        if (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
index 71f2c4443984099982cbea6686b98a58a0aa66e0..b020a6d4e26017d01af5040efa916513fb9210c2 100644 (file)
@@ -68,8 +68,23 @@ if (empty($_POST['city']))         $_POST['city']         = "";
 if (empty($_POST['cntry']))        $_POST['cntry']        = "";
 if (empty($_POST['country_code'])) $_POST['country_code'] = "1";
 
-if (isset($_POST['ok']))
-{
+// Default refid is zero
+$_POST['refid'] = 0;
+if ($GLOBALS['refid'] > 0) {
+       // Test if the refid is valid
+       $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
+               array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
+       if (SQL_NUMROWS($result) == 0) {
+               // Not found so we set your refid!
+               $_POST['refid'] = $_CONFIG['def_refid'];
+               set_session('refid', $_CONFIG['def_refid']);
+       } else {
+               // Use the refid here
+               $_POST['refid'] = $GLOBALS['refid'];
+       }
+} // END - if
+
+if (isset($_POST['ok'])) {
        // First we only check the submitted data then we continue... :)
        //
        // Did he agree to our Terms Of Usage?
@@ -155,19 +170,6 @@ if (isset($_POST['ok']))
                $FAILED = true;
        }
 
-       // Default refid is zero
-       $_POST['refid'] = 0;
-       if ($GLOBALS['refid'] > 0) {
-               // Test if the refid is valid
-               $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
-                       array(bigintval($GLOBALS['refid'])), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 0) {
-                       // Not found so we set your refid!
-                       $_POST['refid'] = $_CONFIG['def_refid'];
-                       set_session("refid", $_CONFIG['def_refid']);
-               } // END - if
-       } // END - if
-
        // Free memory
        SQL_FREERESULT($result);
 }
@@ -183,25 +185,22 @@ if ((isset($_POST['ok'])) && (!$FAILED))
 
        // Add design when extension sql_patches is v0.2.7 or greater
        $ADD1 = ""; $ADD2 = "";
-       if (GET_EXT_VERSION("sql_patches") >= "0.2.7")
-       {
+       if (GET_EXT_VERSION("sql_patches") >= "0.2.7") {
                // Okay, add design here
                $ADD1 = ", curr_theme";
                $ADD2 = ", '".GET_CURR_THEME()."'";
-       }
+       } // END - if
 
        // Check if I shall disable sending mail to newly registered members out about active/begging rallye
        //
        // First comes first: begging rallye
-       if (GET_EXT_VERSION("beg") >= "0.1.7")
-       {
+       if (GET_EXT_VERSION("beg") >= "0.1.7") {
                // Okay, shall I disable now?
-               if ($_CONFIG['beg_new_mem_notify'] == "N")
-               {
+               if ($_CONFIG['beg_new_mem_notify'] == "N") {
                        $ADD1 .= ", beg_ral_notify, beg_ral_en_notify";
                        $ADD2 .= ", UNIX_TIMESTAMP(), UNIX_TIMESTAMP()";
-               }
-       }
+               } // END - if
+       } // END - if
 
        // Second: active rallye
        if (GET_EXT_VERSION("bonus") >= "0.7.7") {
@@ -396,28 +395,12 @@ VALUES ('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONF
        // Adds maximum receiveable mails list... :)
        define('MAX_RECEIVE_LIST', ADD_MAX_RECEIVE_LIST("guest", "", true));
 
-       // Check if nickname extension is active and get state if nickname is selected or userid
-       $nick = false;
-       if (EXT_IS_ACTIVE("nickname")) $nick = NICKNAME_IS_ACTIVE($GLOBALS['refid']);
-
-       // Is the nickname valid?
-       if (!$nick) {
-               // Nope, disable it
-               if (GET_EXT_VERSION("sql_patches") != '') {
-                       // Use default refid
-                       $GLOBALS['refid'] = $_CONFIG['def_refid'];
-               } else {
-                       // Set zero
-                       $GLOBALS['refid'] = 0;
-               }
-       } // END - if
-
        // Shall I display the refid or shall I make it editable?
        if ($_CONFIG['display_refid'] == "Y") {
-               // Load template to enter it
+               // Load "hide" form template
                define('REFID_CONTENT', LOAD_TEMPLATE("guest_register_refid_hide", true, $GLOBALS['refid']));
        } else {
-               // Load "hide" form template
+               // Load template to enter it
                define('REFID_CONTENT', LOAD_TEMPLATE("guest_register_refid", true, $GLOBALS['refid']));
        }
 
@@ -437,8 +420,7 @@ VALUES ('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONF
        define('__ADDY',    SQL_ESCAPE($_POST['addy']));
 
        // Shall I add a counrty selection box or the old input box?
-       if (EXT_IS_ACTIVE("country"))
-       {
+       if (EXT_IS_ACTIVE("country")) {
                // New variant, good!
                $OUT  = "<SELECT name=\"country_code\" class=\"guest_select\" size=\"1\">\n";
                $whereStatement = "WHERE is_active='Y'";
@@ -446,9 +428,7 @@ VALUES ('%s','%s','%s','%s','%s',%s,'%s','%s',%s, %s,%s,'%s',%s, %s,'%s','UNCONF
                $OUT .= ADD_OPTION_LINES("countries", "id", "descr", $_POST['country_code'], "code", $whereStatement);
                $OUT .= "</SELECT>";
                define('__COUNTRY_CONTENT', $OUT);
-       }
-        else
-       {
+       } else {
                // Old out-dated variant
                define('__COUNTRY_CONTENT', "<INPUT type=\"text\" name=\"cntry\" class=\"guest_normal\" size=\"2\" maxlength=\"3\" value=\"".__COUNTRY."\">");
        }
index 5c82e8d187af1c96ea7ae85479e5111d14d7a22a..c747674116abbb1b0f7ed60e54a37751ef1cb25b 100644 (file)
@@ -51,10 +51,10 @@ $rdf->set_salt(SITE_KEY);
 $rdf->set_max_item(10);
 $rdf->set_Options(
        array(
-               "textinput" => "hidden",
-               "sitelink"  => "http://www.wds66.com",
-               "refid"     => bigintval($_CONFIG['wernis_refid']),
-               "reflink"   => "/ref.php?refid=",
+               'textinput' => "hidden",
+               'sitelink'  => "http://www.wds66.com",
+               'refid'     => bigintval($_CONFIG['wernis_refid']),
+               'reflink'   => "/ref.php?refid=",
        )
 );
 
index 717865cbaaec5e2767ff6afeb1b349cff605c481..83677bd75b389c1e8665beb7dfaf5a19f0acca78 100644 (file)
@@ -1060,8 +1060,7 @@ function REMOVE_RECEIVER(&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=fal
        return $ret;
 }
 //
-function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false)
-{
+function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid", $onlyRows=false) {
        $ret = 0;
        if ($onlyRows) {
                // Count rows
@@ -1075,15 +1074,16 @@ function GET_TOTAL_DATA($search, $tableName, $lookFor, $whereStatement="userid",
 
        // Load row
        list($ret) = SQL_FETCHROW($result);
-       //* DEBUG: */ echo __LINE__."*".$DATA."/".$search."/".$tableName."/".$ret."*<br />\n";
+
+       // Free result
        SQL_FREERESULT($result);
-       if (empty($ret)) {
-               if (($lookFor == "counter") || ($lookFor == "id")) {
-                       $ret = 0;
-               } else {
-                       $ret = "0.00000";
-               }
-       }
+
+       // Fix empty values
+       if ((empty($ret)) && ($lookFor != "counter") && ($lookFor != "id") && ($lookFor != "userid")) {
+               $ret = "0.00000";
+       } // END - if
+
+       // Return value
        return $ret;
 }
 /**
index 2c7ab4488d4d59ca92eef7bf279a9ccf2469027b..4c93c2267c51fb210b80a6e9a8b34b8a4596b7f9 100644 (file)
@@ -57,7 +57,7 @@ set_session("mx_lang", $mx_lang);
 require_once(PATH."inc/load_extensions.php");
 
 // Check if refid is set
-if ((!empty($_GET['user'])) && ($CLICK == 1) && ($_SERVER['PHP_SELF'] == "click.php")) {
+if ((!empty($_GET['user'])) && ($CLICK == 1) && (basename($_SERVER['PHP_SELF']) == "click.php")) {
        // The variable user comes from the click-counter script click.php and we only accept this here
        $GLOBALS['refid'] = bigintval($_GET['user']);
 } elseif (!empty($_POST['refid'])) {
@@ -83,8 +83,8 @@ if ((!empty($_GET['user'])) && ($CLICK == 1) && ($_SERVER['PHP_SELF'] == "click.
 // Set cookie when default refid > 0
 if (!isSessionVariableSet('refid') || (!empty($GLOBALS['refid'])) || ((get_session('refid') == "0") && ($_CONFIG['def_refid'] > 0))) {
        // Set cookie
-       set_session("refid", $GLOBALS['refid']);
-}
+       set_session('refid', $GLOBALS['refid']);
+} // END - if
 
 // Transfer userid from session and validate it
 if (isset($_SESSION['userid'])) {
index 0f62cef8d79b88088c43a879977cb3383e25d572..d9724b76969187bf92cc7e7ccc3dc63a71d19147 100644 (file)
@@ -66,7 +66,10 @@ if (isBooleanConstantAndTrue('mxchange_installed')) {
                        $content['lead_uid'] = bigintval(get_session('lead_uid'));
 
                        // Load the email address
-                       list($content['lead_email']) = COMPILE_CODE(SQL_FETCHROW($result));
+                       list($email) = SQL_FETCHROW($result);
+
+                       // Compile email
+                       $content['lead_email'] = COMPILE_CODE($email);
                } else {
                        // Not found!
                        $content['lead_uid'] = 0;
diff --git a/ref.php b/ref.php
index e6e51d7b83f32eb87eb95da143a01c512d6ed557..905abf7122db965a1c657283365f881151d8f2b3 100644 (file)
--- a/ref.php
+++ b/ref.php
@@ -75,12 +75,18 @@ if (isBooleanConstantAndTrue('mxchange_installed')) {
                // Also edit this 0 !
                if (empty($ref)) $ref = 0;
 
+               // Update session
+               set_session('refid', $ref);
+
                // We have an refid here. So we simply add it
                $URL .= bigintval($ref);
 
-               // Update ref counter
-               $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ref_clicks=ref_clicks+1 WHERE userid=%s LIMIT 1",
-                       array(bigintval($ref)), __FILE__, __LINE__);
+               // Is the refid valid?
+               if ($ref > 0) {
+                       // Update ref counter
+                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ref_clicks=ref_clicks+1 WHERE userid=%s LIMIT 1",
+                               array(bigintval($ref)), __FILE__, __LINE__);
+               } // END - if
        } else {
                // No refid and we add our refid (don't forget to set $def_refid!)
                $URL = URL."/index.php";
index 55fa291a844ca5be0c0386ec5ff8f450f08c7a18..ca630b76ab163ffc5fc352b4f588faf93b0cf9fb 100644 (file)
@@ -1,7 +1,7 @@
 <TR>
        <TD align="right" width="50%" class="register_left">
-       {--REFID_BY--}:&nbsp;&nbsp;</TD>
-       <TD width="50%" class="register_right"><INPUT type="text"
-               name="refid" class="register_normal" size="5" maxlength="10"
-               value="$content" /></TD>
+               {--REFID_BY--}:&nbsp;&nbsp;</TD>
+       <TD width="50%" class="register_right">
+               <INPUT type="text" name="refid" class="register_normal" size="5" maxlength="10" value="$content" />
+       </TD>
 </TR>
index dd3e841ef8d30d2ae34d4c58050bb2d1200cb768..dd219f69b6b9fa803271c1369197bc5ab2ca02d8 100644 (file)
@@ -1,6 +1,8 @@
 <TR>
        <TD align="right" width="50%" class="register_left">
-       {--REFID_BY--}:&nbsp;&nbsp;</TD>
-       <TD width="50%" class="register_right"><STRONG>$content</STRONG> <INPUT
-               type="hidden" name="refid" value="$content" /></TD>
+               {--REFID_BY--}:&nbsp;&nbsp;</TD>
+       <TD width="50%" class="register_right">
+               <STRONG>$content</STRONG>
+               <INPUT type="hidden" name="refid" value="$content" />
+       </TD>
 </TR>