2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/19/2003 *
4 * =================== Last change: 07/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-refbanner.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Manage all referral banner *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle Banner fuer die Ref-Links verwalten *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
47 if ((!isPostRequestElementSet('url')) || (!isPostRequestElementSet('alternate'))) {
48 unsetPostRequestElement('ok');
52 // Fix older calls from add-new-banner-form
53 if (!isGetRequestElementSet('mode')) setGetRequestElement('mode', 'add');
55 switch (getRequestElement('mode')) {
57 // Check if banner is already added
58 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `url`='%s' LIMIT 1",
59 array(postRequestElement('url')), __FILE__, __LINE__);
61 // Was the banner found?
62 if (SQL_HASZERONUMS($result)) {
64 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refbanner` (`url`,`alternate`,`visible`)
65 VALUES ('%s','%s','%s')",
67 postRequestElement('url'),
68 postRequestElement('alternate'),
69 postRequestElement('visible')
70 ), __FILE__, __LINE__);
74 SQL_FREERESULT($result);
77 case 'edit': // Update banner
78 foreach (postRequestElement('sel') as $id => $sel) {
83 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `url`='%s',`alternate`='%s',`visible`='%s' WHERE `id`=%s LIMIT 1",
85 postRequestElement('url', $id),
86 postRequestElement('alternate', $id),
87 postRequestElement('visible'),
89 ), __FILE__, __LINE__);
94 // Check if we have saved (updated)
95 if (!SQL_HASZEROAFFECTED()) {
97 $content = '{--SETTINGS_SAVED--}';
99 // Nothing has been updated
100 $content = '<span class="notice">{--SETTINGS_NOT_SAVED--}</span>';
104 displayMessage($content);
105 } elseif ((ifPostContainsSelections()) && (isFormSent('edit'))) {
108 foreach (postRequestElement('sel') as $id => $sel) {
110 $result = SQL_QUERY_ESC("SELECT `id`,`url`,`alternate`,`visible` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
111 array(bigintval($id)), __FILE__, __LINE__);
112 $content = SQL_FETCHARRAY($result);
113 SQL_FREERESULT($result);
115 // Preapre data for the row
116 $content['visible'] = addSelectionBox('yn', $content['visible'], 'visible');
118 // Load row template and switch color
119 $OUT .= loadTemplate('admin_edit_refbanner_row', true, $content);
122 // Load main template
123 loadTemplate('admin_edit_refbanner', false, $OUT);
125 if ((ifPostContainsSelections()) && (isFormSent('delete'))) {
127 foreach (postRequestElement('sel') as $id => $sel) {
128 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
129 array(bigintval($id)), __FILE__, __LINE__);
134 $result = SQL_QUERY('SELECT `id`,`url`,`alternate`,`visible`,`counter`,`clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `url` ASC', __FILE__, __LINE__);
137 if (!SQL_HASZERONUMS($result)) {
138 // Make referral banner editable and deletable
140 while ($content = SQL_FETCHARRAY($result)) {
141 // Load row template and switch color
142 $OUT .= loadTemplate('admin_list_refbanner_row', true, $content);
146 SQL_FREERESULT($result);
148 // Load main template
149 loadTemplate('admin_list_refbanner', false, $OUT);
152 // Form for adding new referral levels
153 loadTemplate('admin_add_refbanner');