A lot templates rewritten, TODOs.txt updated, XHTML fixes:
[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 // Prepare some data
50 $content['userid']           = getMemberId();
51 $content['nickname_content'] = '';
52
53 // @TODO Move this into a filter
54 if (isExtensionActive('nickname')) {
55         // Add nickname link when nickname is entered
56         $nick = getNickname(getMemberId());
57
58         if (!empty($nick)) {
59                 // Display nickname link
60                 $content['nickname_content'] = loadTemplate('member_reflink_nickname', true, $nick);
61         } else {
62                 // Display link to nickname form
63                 $content['nickname_content'] = loadTemplate('member_reflink_no_nickname', true);
64         }
65 } // END - if
66
67 $whereStatement = " WHERE `visible`='Y'";
68 if (isAdmin()) $whereStatement = '';
69 $result = SQL_QUERY("SELECT `id`, `url`, `alternate`, `counter`, `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner`", __FILE__, __LINE__);
70
71 if (SQL_NUMROWS($result) > 0) {
72         // List available ref banners
73         $OUT = ''; $SW = 2;
74         while ($row = SQL_FETCHARRAY($result)) {
75                 $test = str_replace(getConfig('URL'), getConfig('PATH'), $row['url']); $size = '0';
76                 if ($test == $row['url']) {
77                         // Download banner (I hope you keep the banner on same server???)
78                         $fp = sendGetRequest($row['url']); $bannerContent = '';
79                         if ((!empty($fp)) && (is_array($fp)) && (count($fp) > 0)) {
80                                 // Loads only found banner, when there is a 404 error this foreach() command
81                                 // will cause an "Invalid argument supplied for foreach()" error
82                                 foreach ($fp as $f) {
83                                         $bannerContent .= $f;
84                                 } // END - foreach
85                         } // END - if
86                         $size = strlen($bannerContent);
87                 } elseif (isFileReadable($test)) {
88                         $size = filesize($test);
89                 }
90
91                 // Empty alternative text?
92                 if (empty($row['alternate'])) {
93                         // Then set default
94                         $row['alternate'] = '{?MAIN_TITLE?} - {?SLOGAN?}';
95                 } // END - if
96
97                 if ($size > 0) $row['alternate'] .= ' ('  .translateComma(round($size / 102.4) / 10) . ' {--KBYTES--})';
98
99                 // Add some more data
100                 $row['sw']     = $SW;
101                 $row['userid'] = getMemberId();
102
103                 // Add row
104                 $OUT .= loadTemplate('member_reflinks_row', true, $row);
105
106                 // Switchcolors
107                 $SW = 3 - $SW;
108         } // END - while
109
110         // Load final template
111         $content['refbanner_content'] = loadTemplate('member_reflinks_table', true, $OUT);
112 } else {
113         // No refbanner found!
114         $content['refbanner_content'] = loadTemplate('admin_settings_saved', true, getMessage('MEMBER_NO_REFBANNER_FOUND'));
115 }
116
117 // Free result
118 SQL_FREERESULT($result);
119
120 // Load main template
121 loadTemplate('member_reflink', false, $content);
122
123 // [EOF]
124 ?>