2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 08/13/2011 *
4 * =================== Last change: 08/13/2011 *
6 * -------------------------------------------------------------------- *
7 * File : what-config_network_types.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Handler types configuration *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Werbe-Handler-Konfiguration *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2013 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__);
46 // By default we should display list/add new forms
47 $GLOBALS['network_display'] = TRUE;
50 doNetworkHandleForm();
53 if ($GLOBALS['network_display'] === FALSE) {
58 // Is there a network selected?
59 if (isGetRequestElementSet('network_id')) {
60 // Set current network id
61 setCurrentNetworkId(getRequestElement('network_id'));
63 // Is a network type handler selected?
64 if (isGetRequestElementSet('network_type_id')) {
65 // Load data for given network
66 $result = SQL_QUERY_ESC('SELECT
68 `t`.`network_type_id`,
69 `t`.`network_type_handler`,
70 `t`.`network_type_reload_time_unit`,
72 NULL AS `network_data_id`,
73 NULL AS `network_max_reload_time`,
74 NULL AS `network_min_waiting_time`,
75 NULL AS `network_max_waiting_time`,
76 NULL AS `network_min_remain_budget`,
77 NULL AS `network_min_remain_clicks`,
78 NULL AS `network_min_payment`,
79 NULL AS `network_allow_erotic`,
80 NULL AS `network_media_size`,
81 NULL AS `network_media_output`
83 `{?_MYSQL_PREFIX?}_network_types` AS `t`
85 `{?_MYSQL_PREFIX?}_network_data` AS `d`
87 d.network_id=t.network_id
89 `t`.`network_id`=%s AND
90 `t`.`network_type_id`=%s
93 bigintval(getRequestElement('network_id')),
94 bigintval(getRequestElement('network_type_id'))
95 ), __FUNCTION__, __LINE__);
98 if (SQL_NUMROWS($result) == 1) {
100 $content = SQL_FETCHARRAY($result);
102 // Is the network active?
103 if (($content['network_active'] == 'N') && (!isAdminsExpertWarningEnabled()) && (!isDebugModeEnabled())) {
105 displayMessage('{--ADMIN_NETWORK_NOT_ACTIVE--}');
109 // Check for network type configuration
110 $result_config = SQL_QUERY_ESC('SELECT
112 `network_max_reload_time`,
113 `network_min_waiting_time`,
114 `network_max_waiting_time`,
115 `network_min_remain_budget`,
116 `network_min_remain_clicks`,
117 `network_min_payment`,
118 `network_allow_erotic`,
119 `network_media_size`,
120 `network_media_output`
122 `{?_MYSQL_PREFIX?}_network_handler_config`
128 bigintval(getRequestElement('network_id')),
129 bigintval($content['network_type_id'])
130 ), __FUNCTION__, __LINE__);
132 // Use template for adding
133 $templateName = 'admin_add_config_network_type_form';
135 // Do we also have configuration?
136 if (SQL_NUMROWS($result_config) == 1) {
137 // Load as well and merge it
138 $content = merge_array($content, SQL_FETCHARRAY($result_config));
140 // Use template for editing
141 $templateName = 'admin_edit_config_network_type_form';
145 SQL_FREERESULT($result_config);
147 // "Translate" some values
148 $content['network_max_reload_time'] = createTimeSelections($content['network_max_reload_time'], 'network_max_reload_time', 'WDhms');
151 loadTemplate($templateName, FALSE, $content);
157 displayMessage('{%message,ADMIN_ADD_CONFIG_NETWORK_HANDLER_TYPE_404=' . bigintval(getRequestElement('network_id')) . '/' . bigintval(getRequestElement('network_type_id')) . '%}');
161 SQL_FREERESULT($result);
164 // Get all type handlers
165 $result = SQL_QUERY_ESC('SELECT
168 `network_type_handler`,
169 `network_type_reload_time_unit`
171 `{?_MYSQL_PREFIX?}_network_types`
175 `network_type_handler` ASC',
177 bigintval(getRequestElement('network_id'))
178 ), __FUNCTION__, __LINE__);
180 // Are there entries left?
181 if (!SQL_HASZERONUMS($result)) {
186 while ($content = SQL_FETCHARRAY($result)) {
187 // Check if config entry is there
188 $result_config = SQL_QUERY_ESC('SELECT
190 `network_max_reload_time`,
191 `network_min_waiting_time`,
192 `network_max_waiting_time`,
193 `network_min_remain_budget`,
194 `network_min_remain_clicks`,
195 `network_min_payment`,
196 `network_allow_erotic`,
197 `network_media_size`,
198 `network_media_output`
200 `{?_MYSQL_PREFIX?}_network_handler_config`
206 bigintval(getRequestElement('network_id')),
207 bigintval($content['network_type_id'])
208 ), __FUNCTION__, __LINE__);
210 // Is there an entry?
211 if (SQL_NUMROWS($result_config) == 1) {
212 // Load this data as well
213 $content = merge_array($content, SQL_FETCHARRAY($result_config));
215 // Add it with extra template
216 $content['network_type_config_content'] = loadTemplate('admin_show_config_network_type', TRUE, $content);
218 // No configuration found, so display form
219 $content['network_type_config_content'] = loadTemplate('admin_add_config_network_type', TRUE, $content);
223 SQL_FREERESULT($result_config);
226 $OUT .= loadTemplate('admin_config_network_types_row', TRUE, $content);
229 // Prepare array for main template
231 'network_id' => bigintval(getRequestElement('network_id')),
235 // Load main template
236 loadTemplate('admin_config_network_types', FALSE, $content);
239 displayMessage('{%message,ADMIN_CONFIG_NETWORK_HANDLER_TYPES_404=' . bigintval(getRequestElement('network_id')) . '%}');
243 SQL_FREERESULT($result);
245 // Generate network list for this script
246 $OUT = generateAdminNetworkList(FALSE, TRUE, FALSE);
253 // Nothing configured yet
254 displayMessage('{--ADMIN_NETWORK_QUERY_API_404--}');