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