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 - 2008 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')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
43 } elseif (!IS_MEMBER()) {
44 redirectToUrl('modules.php?module=index');
47 // Add description as navigation point
48 ADD_DESCR('member', __FILE__);
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(getUserId()), __FILE__, __LINE__);
53 list($c) = SQL_FETCHROW($result);
54 SQL_FREERESULT($result);
56 OUTPUT_HTML("<div class=\"tiny\">{--YOUR_PERSONAL_REFLINK--}:<br />
57 <strong><a href=\"{!URL!}/ref.php?refid=".getUserId()."\" target=\"_blank\">{!URL!}/ref.php?ref=".getUserId()."</a></strong><br />
60 if (EXT_IS_ACTIVE('nickname')) {
61 // Add nickname link when nickname is entered
62 $nick = NICKNAME_GET_NICK(getUserId());
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 />
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&what=nickname\">{--PLEASE_CLICK_NICKNAME_FORM--}</a>");
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__);
82 if (SQL_NUMROWS($result) > 0) {
83 // List available ref banners
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 = sendGetRequest($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
97 $size = strlen($bannerContent);
98 } elseif (isFileReadable($test)) {
99 $size = filesize($test);
102 if ($size > 0) $content['alternate'] .= " (".translateComma(round($size/102.4)/10)." {--KBYTES--})";
105 // @TODO Rewritings: alt->alternate,cnt->counter,cks->clicks,uid->userid in template
108 'url' => $content['url'],
109 'alt' => $content['alternate'],
110 'cnt' => $content['counter'],
111 'cks' => $content['clicks'],
112 'uid' => getUserId(),
113 'id' => $content['id'],
117 $OUT .= LOAD_TEMPLATE("member_reflinks_row", true, $content);
123 define('__REFLINKS_ROWS', $OUT);
125 // Load final template
126 LOAD_TEMPLATE("member_reflinks_table", false, getUserId());
128 // No refbanner found!
129 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_NO_REFBANNER_FOUND'));
133 SQL_FREERESULT($result);