X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=ref.php;h=a475c51acea62bfee71d163502ec7bc87677bcae;hp=6e639520a2dd2137663d1c5042a1ffb4554ccbfd;hb=8fc1c99d323e7599dd91071a5a772261b5d079a7;hpb=5071030af40e69ca4284642f44758964e18f5be8 diff --git a/ref.php b/ref.php index 6e639520a2..a475c51ace 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 - redirectToUrl($URL); -} else { - // You have to install first! - redirectToUrl('install.php'); -} - -// Really all done here... ;-) -shutdown(); - -// +// 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] ?>