Continued a bit:
[mailer.git] / ref.php
diff --git a/ref.php b/ref.php
index a36ed18..80850e2 100644 (file)
--- a/ref.php
+++ b/ref.php
@@ -6,19 +6,13 @@
  * -------------------------------------------------------------------- *
  * File              : ref.php                                          *
  * -------------------------------------------------------------------- *
- * Short description : Redirection for the referal link                 *
+ * Short description : Redirection for the referral link                *
  * -------------------------------------------------------------------- *
- * Kurzbeschreibung  : Weiterleitungsscript fuer die Referal-Links      *
- * -------------------------------------------------------------------- *
- * $Revision::                                                        $ *
- * $Date::                                                            $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
+ * Kurzbeschreibung  : Weiterleitungsscript fuer die Referral-Links     *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2016 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
 // Load security stuff here
 require('inc/libs/security_functions.php');
 
-// Set module
-$GLOBALS['module'] = 'ref';
-$GLOBALS['output_mode'] = -1;
-
-// Load the required file(s)
-require('inc/config-global.php');
+// Init start time
+$GLOBALS['__start_time'] = microtime(TRUE);
 
-// No refid by default
-$URL = 'index.php';
+// Set module
+$GLOBALS['__module']      = 'ref';
+$GLOBALS['__output_mode'] = -1;
 
-if (determineReferalId() > 0) {
-       // Test if nickname or numeric id
-       if (isExtensionActive('nickname')) {
-               // Nickname in URL, so load the id
-               fetchUserData(determineReferalId(), 'nickname');
+// Initialize application
+require('inc/init.php');
 
-               // Do we have an entry?
-               if (isUserDataValid()) {
-                       // Load userid
-                       $GLOBALS['refid'] = getUserData('userid');
-               } else {
-                       // So do we have a userid?
-                       fetchUserData(determineReferalId());
+// Set content type for e.g. search engines
+setContentType('text/html');
 
-                       // Do we have an entry?
-                       if (!isUserDataValid()) {
-                               // No entry, so no referal id
-                               $GLOBALS['refid'] = getConfig('def_refid');
-                       } // END - if
-               }
-       } // END - if
+// No refid by default
+$url = 'modules.php?module=index';
 
-       // Update session
-       setSession('refid', determineReferalId());
+// Check for determined referral id
+if ((isExtensionActive('user')) && (isValidReferralId()) && (isValidId(determineReferralId()))) {
+       // Run filter chain for updating referral data
+       runFilterChain('update_referral_data');
 
-       // 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;
 
-               // 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;
 
-                       case 'index':
-                               $URL = 'index.php';
-                               break;
-               } // END - switch
-       } // END - if
+               default: // Is not valid
+                       reportBug(__FILE__, __LINE__, 'Invalid refid target ' . getConfig('refid_target') . ' detected.');
+                       break;
+       } // END - switch
 } // END - if
 
 // Load the URL
-redirectToUrl($URL);
+redirectToUrl($url);
 
 // [EOF]
 ?>