2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/19/2003 *
4 * =============== Last change: 09/10/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-reflinks.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Referal links *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Referal-Links *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
42 } elseif (!isMember()) {
43 redirectToIndexMemberOnlyModule();
46 // Add description as navigation point
47 addMenuDescription('member', __FILE__);
49 // Load current referal clicks
50 if (!fetchUserData(getMemberId())) {
51 // Something really bad happened
52 debug_report_bug('No user account ' . getMemberId() . ' found.');
56 $content['ref_clicks'] = getUserData('ref_clicks');
57 $content['userid'] = getMemberId();
59 // @TODO Move this into a filter
60 if (isExtensionActive('nickname')) {
61 // Add nickname link when nickname is entered
62 $nick = getNickname(getMemberId());
65 // Display nickname link
66 $content['nickname_content'] = loadTemplate('member_reflink_nickname', true, $nick);
68 // Display link to nickname form
69 $content['nickname_content'] = loadTemplate('member_reflink_no_nickname', true);
73 $whereStatement = " WHERE `visible`='Y'";
74 if (isAdmin()) $whereStatement = '';
75 $result = SQL_QUERY("SELECT `id`, `url`, `alternate`, `counter`, `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner`", __FILE__, __LINE__);
77 if (SQL_NUMROWS($result) > 0) {
78 // List available ref banners
80 while ($row = SQL_FETCHARRAY($result)) {
81 $test = str_replace(getConfig('URL'), getConfig('PATH'), $row['url']); $size = '0';
82 if ($test == $row['url']) {
83 // Download banner (I hope you keep the banner on same server???)
84 $fp = sendGetRequest($row['url']); $bannerContent = '';
85 if ((!empty($fp)) && (is_array($fp)) && (count($fp) > 0)) {
86 // Loads only found banner, when there is a 404 error this foreach() command
87 // will cause an "Invalid argument supplied for foreach()" error
92 $size = strlen($bannerContent);
93 } elseif (isFileReadable($test)) {
94 $size = filesize($test);
97 // Empty alternative text?
98 if (empty($row['alternate'])) {
100 $row['alternate'] = '{?MAIN_TITLE?} - {?SLOGAN?}';
103 if ($size > 0) $row['alternate'] .= ' (' .translateComma(round($size / 102.4) / 10) . ' {--KBYTES--})';
105 // Add some more data
107 $row['userid'] = getMemberId();
110 $OUT .= loadTemplate('member_reflinks_row', true, $row);
116 // Load final template
117 $content['refbanner_content'] = loadTemplate('member_reflinks_table', true, $OUT);
119 // No refbanner found!
120 $content['refbanner_content'] = loadTemplate('admin_settings_saved', true, getMessage('MEMBER_NO_REFBANNER_FOUND'));
124 SQL_FREERESULT($result);
126 // Load main template
127 loadTemplate('member_reflink', false, $content);