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 - 2012 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');
53 switch (getRequestElement('do')) {
55 // Check if banner is already added
56 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `url`='%s' LIMIT 1",
57 array(postRequestElement('url')), __FILE__, __LINE__);
59 // Was the banner found?
60 if (SQL_HASZERONUMS($result)) {
62 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_refbanner` (`url`, `alternate`, `visible`)
63 VALUES ('%s','%s','%s')",
65 postRequestElement('url'),
66 postRequestElement('alternate'),
67 postRequestElement('visible')
68 ), __FILE__, __LINE__);
72 SQL_FREERESULT($result);
75 case 'edit': // Update banner
76 foreach (postRequestElement('sel') as $id => $sel) {
81 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_refbanner` SET `url`='%s',`alternate`='%s',`visible`='%s' WHERE `id`=%s LIMIT 1",
83 postRequestElement('url', $id),
84 postRequestElement('alternate', $id),
85 postRequestElement('visible'),
87 ), __FILE__, __LINE__);
92 // Check if we have saved (updated)
93 if (!SQL_HASZEROAFFECTED()) {
95 $content = '{--SETTINGS_SAVED--}';
97 // Nothing has been updated
98 $content = '<span class="bad">{--SETTINGS_NOT_SAVED--}</span>';
102 displayMessage($content);
103 } elseif ((ifPostContainsSelections()) && (isFormSent('edit'))) {
106 foreach (postRequestElement('sel') as $id => $sel) {
108 $result = SQL_QUERY_ESC("SELECT `id`, `url`, `alternate`, `visible` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
109 array(bigintval($id)), __FILE__, __LINE__);
110 $content = SQL_FETCHARRAY($result);
111 SQL_FREERESULT($result);
113 // Preapre data for the row
114 $content['visible'] = addSelectionBox('yn', $content['visible'], 'visible');
116 // Load row template and switch color
117 $OUT .= loadTemplate('admin_edit_refbanner_row', TRUE, $content);
120 // Load main template
121 loadTemplate('admin_edit_refbanner', FALSE, $OUT);
123 if ((ifPostContainsSelections()) && (isFormSent('delete'))) {
125 foreach (postRequestElement('sel') as $id => $sel) {
126 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `id`=%s LIMIT 1",
127 array(bigintval($id)), __FILE__, __LINE__);
132 $result = SQL_QUERY('SELECT `id`, `url`, `alternate`, `visible`, `counter`, `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` ORDER BY `url` ASC', __FILE__, __LINE__);
135 if (!SQL_HASZERONUMS($result)) {
136 // Make referral banner editable and deletable
138 while ($content = SQL_FETCHARRAY($result)) {
139 // Load row template and switch color
140 $OUT .= loadTemplate('admin_list_refbanner_row', TRUE, $content);
144 SQL_FREERESULT($result);
146 // Load main template
147 loadTemplate('admin_list_refbanner', FALSE, $OUT);
150 // Form for adding new referral levels
151 loadTemplate('admin_add_refbanner');