HTTP/1.1 does allow chunked content, but our script does not support it (yet)
[mailer.git] / ref.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/13/2003 *
4  * ===================                          Last change: 09/04/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ref.php                                          *
8  * -------------------------------------------------------------------- *
9  * Short description : Redirection for the referal link                 *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Weiterleitungsscript fuer die Referal-Links      *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Load security stuff here
41 require('inc/libs/security_functions.php');
42
43 // Set module
44 $GLOBALS['module'] = 'ref';
45 $GLOBALS['output_mode'] = -1;
46
47 // Load the required file(s)
48 require('inc/config-global.php');
49
50 // Set content type for e.g. search engines
51 setContentType('text/html');
52
53 // No refid by default
54 $URL = 'modules.php?module=index';
55
56 if (determineReferalId() > 0) {
57         // Test if nickname or numeric id
58         if (isExtensionActive('nickname')) {
59                 // Nickname in URL, so load the id
60                 fetchUserData(determineReferalId(), 'nickname');
61
62                 // Do we have an entry?
63                 if (isUserDataValid()) {
64                         // Load userid
65                         $GLOBALS['refid'] = getUserData('userid');
66                 } else {
67                         // So do we have a userid?
68                         fetchUserData(determineReferalId());
69
70                         // Do we have an entry?
71                         if (!isUserDataValid()) {
72                                 // No entry, so no referal id
73                                 $GLOBALS['refid'] = getConfig('def_refid');
74                         } // END - if
75                 }
76         } // END - if
77
78         // Update session
79         setSession('refid', determineReferalId());
80
81         // Is the refid valid?
82         if (determineReferalId() > 0) {
83                 // Update ref counter
84                 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`=%s LIMIT 1",
85                         array(determineReferalId()), __FILE__, __LINE__);
86
87                 // Base URL for redirection
88                 switch (getConfig('refid_target')) {
89                         case 'register':
90                                 $URL = 'modules.php?module=index&amp;what=register';
91                                 break;
92
93                         case 'index':
94                                 $URL = 'modules.php?module=index';
95                                 break;
96                 } // END - switch
97         } // END - if
98 } // END - if
99
100 // Load the URL
101 redirectToUrl($URL);
102
103 // [EOF]
104 ?>