Copyright updated
[mailer.git] / 0.2.1 / inc / modules / member / what-reflinks.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 10/19/2003 *\r
4  * ===============                              Last change: 09/10/2004 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : what-reflinks.php                                *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : Referral links                                   *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Referral-Links                                   *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Some security stuff...\r
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))\r
36 {\r
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
38         require($INC);\r
39 }\r
40  elseif (!IS_LOGGED_IN())\r
41 {\r
42         LOAD_URL(URL."/modules.php?module=index");\r
43 }\r
44 \r
45 // Add description as navigation point\r
46 ADD_DESCR("member", basename(__FILE__));\r
47 \r
48 OPEN_TABLE("90%", "member_table member_content_align", "");\r
49 \r
50 // Load current referral clicks\r
51 $result = SQL_QUERY_ESC("SELECT ref_clicks FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",\r
52  array($GLOBALS['userid']), __FILE__, __LINE__);\r
53 \r
54 list($c) = SQL_FETCHROW($result);\r
55 SQL_FREERESULT($result);\r
56 \r
57 OUTPUT_HTML ("<FONT class=\"tiny\">".YOUR_PERSONAL_REFLINK.":<BR>\r
58 <STRONG><A href=\"".URL."/ref.php?ref=".$GLOBALS['userid']."\" target=\"_blank\">".URL."/ref.php?ref=".$GLOBALS['userid']."</A></STRONG><BR>\r
59 <BR>");\r
60 \r
61 if (EXT_IS_ACTIVE("nickname"))\r
62 {\r
63         // Add nickname link when nickname is entered\r
64         $nick = NICKNAME_GET_NICK($GLOBALS['userid']);\r
65 \r
66         if (!empty($nick))\r
67         {\r
68                 // Display nickname link\r
69                 OUTPUT_HTML (NICKNAME_YOUR_REFLINK.":<BR>\r
70 <STRONG><A href=\"".URL."/ref.php?ref=".$nick."\" target=\"_blank\">".URL."/ref.php?ref=".$nick."</A></STRONG><BR>\r
71 <BR>");\r
72         }\r
73          else\r
74         {\r
75                 // Display link to nickname form\r
76                 OUTPUT_HTML ("<STRONG class=\"guest_note\">".NO_NICKNAME_SET."</STRONG><BR>\r
77 <A class=\"tiny\" href=\"".URL."/modules.php?module=login&amp;what=nickname\">".PLEASE_CLICK_NICKNAME_FORM."</A>");\r
78         }\r
79 }\r
80 \r
81 // Clicks on your reflink\r
82 OUTPUT_HTML (YOUR_REFCLICKS.": <STRONG>".$c."</STRONG> ".CLICKS."</FONT><BR><BR>");\r
83 $WHERE = " WHERE visible='Y'";\r
84 if (IS_ADMIN()) $WHERE = "";\r
85 $result = SQL_QUERY("SELECT id, url, alternate, counter, clicks FROM "._MYSQL_PREFIX."_refbanner", __FILE__, __LINE__);\r
86 \r
87 if (SQL_NUMROWS($result) > 0)\r
88 {\r
89         // List available ref banners\r
90         $SW = 2; $OUT = "";\r
91         while (list($id, $url, $alt, $count, $clks) = SQL_FETCHROW($result))\r
92         {\r
93                 $test = str_replace(URL, PATH, $url); $size = 0;\r
94                 if ($test == $url)\r
95                 {\r
96                         // Download banner (I hope you keep the banner on same server???)\r
97                         $fp = @file($url); $file = "";\r
98                         if ((!empty($fp)) && (is_array($fp)) && (count($fp) > 0))\r
99                         {\r
100                                 // Loads only found banner, when there is a 404 error this foreach() command\r
101                                 // will cause an "Invalid argument supplied for foreach()" error\r
102                                 foreach ($fp as $f)\r
103                                 {\r
104                                         $file .= $f;\r
105                                 }\r
106                         }\r
107                         $size = strlen($file);\r
108                 }\r
109                  elseif (file_exists($test))\r
110                 {\r
111                         $size = filesize($test);\r
112                 }\r
113                 if ($size > 0) $alt .= " (".TRANSLATE_COMMA(round($size/102.4)/10)." ".KBYTES.")";\r
114 \r
115                 // Load banner data\r
116                 $content = array(\r
117                         'sw'  => $SW,\r
118                         'url' => $url,\r
119                         'alt' => $alt,\r
120                         'cnt' => $count,\r
121                         'cks' => $clks,\r
122                         'uid' => $GLOBALS['userid'],\r
123                         'id'  => $id,\r
124                 );\r
125 \r
126                 // Add row\r
127                 $OUT .= LOAD_TEMPLATE("member_reflinks_row", true, $content);\r
128 \r
129                 // Switchcolors\r
130                 $SW = 3 - $SW;\r
131         }\r
132 \r
133         define('__REFLINKS_ROWS', $OUT);\r
134 \r
135         // Load final template\r
136         LOAD_TEMPLATE("member_reflinks_table", false, $GLOBALS['userid']);\r
137 }\r
138 \r
139 // Free result\r
140 SQL_FREERESULT($result);\r
141 \r
142 CLOSE_TABLE();\r
143 //\r
144 ?>\r