X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=ref.php;h=a475c51acea62bfee71d163502ec7bc87677bcae;hp=783aab194c3b04928a3627c62d6f3da17cb55d9b;hb=01f61fde8c4a4e040dc089ccb274441859487e1d;hpb=524c58a61b0a074fed8d7c9dc2f9ddab7f653595 diff --git a/ref.php b/ref.php index 783aab194c..a475c51ace 100644 --- a/ref.php +++ b/ref.php @@ -1,18 +1,23 @@ 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"; - } - - // Load the URL - LOAD_URL($URL); -} else { - // You have to configure first! - LOAD_URL("install.php"); -} - -// Really all done here... ;-) +require('inc/config-global.php'); + +// Set content type for e.g. search engines +setContentType('text/html'); + +// No refid by default +$URL = 'modules.php?module=index'; + +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 = 'modules.php?module=index'; + break; + } // END - switch + } // END - if +} // END - if + +// Load the URL +redirectToUrl($URL); + +// [EOF] ?>