X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=ref.php;h=0ee71430c87d7f125de81ccfb82e88168c6bc38f;hp=d733f53f890d8728273b27f436b060d88761f03d;hb=27d3ef2b2af55933a48294ff9bc9750fdbe050eb;hpb=daefa5dc8ffd7773e0c2556a5dcf33fa52196180 diff --git a/ref.php b/ref.php index d733f53f89..0ee71430c8 100644 --- a/ref.php +++ b/ref.php @@ -1,18 +1,23 @@ 0) { + // Test if nickname or numeric id + if (isExtensionActive('nickname')) { + // Nickname in URL, so load the id + fetchUserData(determineReferalId(), 'nickname'); - if (!empty($ref)) { - // Test if nickname or numeric id - if ((EXT_IS_ACTIVE("nickname")) && ($ref != "".bigintval($ref)."")) { - // Nickname in URL, so load the ID - $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE nickname='%s' LIMIT 1", - array($ref), __FILE__, __LINE__); - list($ref) = SQL_FETCHROW($result); - SQL_FREERESULT($result); - } // END - if + // Do we have an entry? + if (isUserDataValid()) { + // Load userid + $GLOBALS['refid'] = getUserData('userid'); + } else { + // So do we have a userid? + fetchUserData(determineReferalId()); - // Also edit this 0 ! - if (empty($ref)) $ref = "0"; + // Do we have an entry? + if (!isUserDataValid()) { + // No entry, so no referal id + $GLOBALS['refid'] = getConfig('def_refid'); + } // END - if + } + } // END - if - // We have an refid here. So we simply add it - $URL .= bigintval($ref); + // Update session + setSession('refid', determineReferalId()); + // Is the refid valid? + if (determineReferalId() > 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__); - } else { - // No refid and we add our refid (don't forget to set $def_refid!) - $URL = URL."/index.php"; - } + 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 - LOAD_URL($URL); -} else { - // You have to configure first! - LOAD_URL("install.php"); -} +// Load the URL +redirectToUrl($URL); -// Really all done here... ;-) +// [EOF] ?>