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