X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=ref.php;h=0ee71430c87d7f125de81ccfb82e88168c6bc38f;hp=7adf9ae91a50a7b1339f868042277699a90cdd4e;hb=a28637f0eb7975f2240c42d349e5f08a9722d9bb;hpb=701f5ac005404813e0e546102b5821f2ba2af522 diff --git a/ref.php b/ref.php index 7adf9ae91a..0ee71430c8 100644 --- a/ref.php +++ b/ref.php @@ -1,7 +1,7 @@ 0) { - // Update ref counter - 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 = "index.php"; - } - - // Load the URL - LOAD_URL($URL); -} else { - // You have to install first! - LOAD_URL("install.php"); -} - -// Really all done here... ;-) +require('inc/config-global.php'); + +// Set content type for e.g. search engines +if (isSpider()) setContentType('text/html'); + +// No refid by default +$URL = 'index.php'; + +if (determineReferalId() > 0) { + // Test if nickname or numeric id + if (isExtensionActive('nickname')) { + // Nickname in URL, so load the id + fetchUserData(determineReferalId(), 'nickname'); + + // Do we have an entry? + if (isUserDataValid()) { + // Load userid + $GLOBALS['refid'] = getUserData('userid'); + } else { + // So do we have a userid? + fetchUserData(determineReferalId()); + + // Do we have an entry? + if (!isUserDataValid()) { + // No entry, so no referal id + $GLOBALS['refid'] = getConfig('def_refid'); + } // END - if + } + } // END - if + + // Update session + setSession('refid', determineReferalId()); + + // Is the refid valid? + if (determineReferalId() > 0) { + // Update ref counter + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`=%s LIMIT 1", + array(determineReferalId()), __FILE__, __LINE__); + + // Base URL for redirection + switch (getConfig('refid_target')) { + case 'register': + $URL = 'modules.php?module=index&what=register'; + break; + + case 'index': + $URL = 'index.php'; + break; + } // END - switch + } // END - if +} // END - if + +// Load the URL +redirectToUrl($URL); + +// [EOF] ?>