]> git.mxchange.org Git - mailer.git/blob - inc/modules/member/what-reflinks.php
Fix for #138 and some 'empty version' fixed
[mailer.git] / inc / modules / member / what-reflinks.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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::                                                        $ *
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  * 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         die();
42 } elseif (!isMember()) {
43         redirectToIndexMemberOnlyModule();
44 }
45
46 // Add description as navigation point
47 addMenuDescription('member', __FILE__);
48
49 // Load current referal clicks
50 if (!fetchUserData(getMemberId())) {
51         // Something really bad happened
52         debug_report_bug('No user account ' . getMemberId() . ' found.');
53 } // END - if
54
55 // Prepare some data
56 $content['ref_clicks']       = getUserData('ref_clicks');
57 $content['userid']           = getMemberId();
58 $content['nickname_content'] = '';
59
60 // @TODO Move this into a filter
61 if (isExtensionActive('nickname')) {
62         // Add nickname link when nickname is entered
63         $nick = getNickname(getMemberId());
64
65         if (!empty($nick)) {
66                 // Display nickname link
67                 $content['nickname_content'] = loadTemplate('member_reflink_nickname', true, $nick);
68         } else {
69                 // Display link to nickname form
70                 $content['nickname_content'] = loadTemplate('member_reflink_no_nickname', true);
71         }
72 } // END - if
73
74 $whereStatement = " WHERE `visible`='Y'";
75 if (isAdmin()) $whereStatement = '';
76 $result = SQL_QUERY("SELECT `id`, `url`, `alternate`, `counter`, `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner`", __FILE__, __LINE__);
77
78 if (SQL_NUMROWS($result) > 0) {
79         // List available ref banners
80         $OUT = ''; $SW = 2;
81         while ($row = SQL_FETCHARRAY($result)) {
82                 $test = str_replace(getConfig('URL'), getConfig('PATH'), $row['url']); $size = '0';
83                 if ($test == $row['url']) {
84                         // Download banner (I hope you keep the banner on same server???)
85                         $fp = sendGetRequest($row['url']); $bannerContent = '';
86                         if ((!empty($fp)) && (is_array($fp)) && (count($fp) > 0)) {
87                                 // Loads only found banner, when there is a 404 error this foreach() command
88                                 // will cause an "Invalid argument supplied for foreach()" error
89                                 foreach ($fp as $f) {
90                                         $bannerContent .= $f;
91                                 } // END - foreach
92                         } // END - if
93                         $size = strlen($bannerContent);
94                 } elseif (isFileReadable($test)) {
95                         $size = filesize($test);
96                 }
97
98                 // Empty alternative text?
99                 if (empty($row['alternate'])) {
100                         // Then set default
101                         $row['alternate'] = '{?MAIN_TITLE?} - {?SLOGAN?}';
102                 } // END - if
103
104                 if ($size > 0) $row['alternate'] .= ' ('  .translateComma(round($size / 102.4) / 10) . ' {--KBYTES--})';
105
106                 // Add some more data
107                 $row['sw']     = $SW;
108                 $row['userid'] = getMemberId();
109
110                 // Add row
111                 $OUT .= loadTemplate('member_reflinks_row', true, $row);
112
113                 // Switchcolors
114                 $SW = 3 - $SW;
115         } // END - while
116
117         // Load final template
118         $content['refbanner_content'] = loadTemplate('member_reflinks_table', true, $OUT);
119 } else {
120         // No refbanner found!
121         $content['refbanner_content'] = loadTemplate('admin_settings_saved', true, getMessage('MEMBER_NO_REFBANNER_FOUND'));
122 }
123
124 // Free result
125 SQL_FREERESULT($result);
126
127 // Load main template
128 loadTemplate('member_reflink', false, $content);
129
130 // [EOF]
131 ?>