fooRequestElementBar() functions renamed, adding of request parameters added:
[mailer.git] / inc / libs / network_functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/04/2009 *
4  * ===================                          Last change: 11/04/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : network_functions.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Functions for ext-network                        *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Funktionen fuer ext-network                      *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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                  *
22  *                                                                      *
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.                                  *
27  *                                                                      *
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.                         *
32  *                                                                      *
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,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 } // END - if
43
44 // Handle a (maybe) sent form here
45 function doNetworkHandleForm () {
46         // Was the form sent?
47         if ((isFormSent()) || (isPostRequestParameterSet('edit')) || (isPostRequestParameterSet('del')) || (isPostRequestParameterSet('change')) || (isPostRequestParameterSet('remove'))) {
48                 // Do we have a 'do'?
49                 if (isGetRequestParameterSet('do')) {
50                         // Process the request
51                         doAdminNetworkProcessForm();
52                 } else {
53                         // No 'do' found
54                         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_DO_404'));
55                 }
56         } // END - if
57 }
58
59 // Processes an admin form
60 function doAdminNetworkProcessForm () {
61         // Form really sent?
62         if ((!isFormSent()) && (!isPostRequestParameterSet('edit')) && (!isPostRequestParameterSet('del')) && (!isPostRequestParameterSet('change')) && (!isPostRequestParameterSet('remove'))) {
63                 // Abort here
64                 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_FORM_NOT_SENT'));
65                 return;
66         } elseif (!isGetRequestParameterSet('do')) {
67                 // No 'do' found
68                 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_DO_404'));
69                 return;
70         }
71
72         // Create function name
73         $functionName = sprintf("doAdminNetworkProcess%sForm", ucfirst(strtolower(getRequestParameter('do'))));
74
75         // Is the function valid?
76         if (!function_exists($functionName)) {
77                 // Invalid function name
78                 debug_report_bug('Invalid do ' . getRequestParameter('do') . ', function ' . $functionName .' does not exist.', false);
79         } // END - if
80
81         // Call-back the method handling our request
82         call_user_func($functionName);
83 }
84
85 // Checks wether the (short) network name is already used (valid)
86 function isNetworkNameValid ($name) {
87         // Query for it
88         $result = SQL_QUERY_ESC("SELECT `network_id` FROM `{?_MYSQL_PREFIX?}_network_data` WHERE `network_short_name`='%s' LIMIT 1",
89                 array($name), __FUNCTION__, __LINE__);
90
91         // Does it exist?
92         $isValid = (SQL_NUMROWS($result) == 1);
93
94         // Free result
95         SQL_FREERESULT($result);
96
97         // Return result
98         return $isValid;
99 }
100
101 // Checks wether the given network type is already used (valid)
102 function isNetworkTypeHandleValid ($type, $networkId) {
103         // Query for it
104         $result = SQL_QUERY_ESC("SELECT `network_type_id` FROM `{?_MYSQL_PREFIX?}_network_types` WHERE `network_id`=%s AND `network_type_handle`='%s' LIMIT 1",
105                 array($networkId, $type), __FUNCTION__, __LINE__);
106
107         // Does it exist?
108         $isValid = (SQL_NUMROWS($result) == 1);
109
110         // Free result
111         SQL_FREERESULT($result);
112
113         // Return result
114         return $isValid;
115 }
116
117 // Checks wether the given network request parameter is already used (valid)
118 function isNetworkRequestParameterValid ($key, $type, $networkId) {
119         // Query for it
120         $result = SQL_QUERY_ESC("SELECT `network_param_id` FROM `{?_MYSQL_PREFIX?}_network_request_params` WHERE `network_id`=%s AND `network_type_id`=%s AND `request_param_key`='%s' LIMIT 1",
121                 array($networkId, $type, $key), __FUNCTION__, __LINE__);
122
123         // Does it exist?
124         $isValid = (SQL_NUMROWS($result) == 1);
125
126         // Free result
127         SQL_FREERESULT($result);
128
129         // Return result
130         return $isValid;
131 }
132
133 // "Getter" for a network's data by provided id number
134 function getNetworkDataById ($id) {
135         // Ids lower one are not accepted
136         if ($id < 1) {
137                 // Not good, should be fixed
138                 debug_report_bug('Network id ' . $id . ' is smaller than 1.');
139         } // END - if
140
141         // By default we have no data
142         $networkData = array();
143
144         // Query for the network data
145         $result = SQL_QUERY_ESC("SELECT
146         `network_id`, `network_short_name`, `network_title`, `network_reflink`, `network_data_seperator`, `network_row_seperator`, `network_request_type`, `network_charset`
147 FROM
148         `{?_MYSQL_PREFIX?}_network_data`
149 WHERE
150         `network_id`=%s
151 LIMIT 1",
152                 array(bigintval($id)), __FUNCTION__, __LINE__);
153
154         // Do we have an entry?
155         if (SQL_NUMROWS($result) == 1) {
156                 // Then get it
157                 $networkData = SQL_FETCHARRAY($result);
158         } // END - if
159
160         // Free result
161         SQL_FREERESULT($result);
162
163         // Return result
164         return $networkData;
165 }
166
167 // "Getter" for a network type data by provided id number
168 function getNetworkTypeDataById ($id) {
169         // Ids lower one are not accepted
170         if ($id < 1) {
171                 // Not good, should be fixed
172                 debug_report_bug('Network type id ' . $id . ' is smaller than 1.');
173         } // END - if
174
175         // By default we have no data
176         $networkTypeData = array();
177
178         // Query for the network data
179         $result = SQL_QUERY_ESC("SELECT
180         `network_type_id`, `network_id`, `network_type_handle`, `network_type_api_url`, `network_type_click_url`, `network_type_banner_url`
181 FROM
182         `{?_MYSQL_PREFIX?}_network_types`
183 WHERE
184         `network_type_id`=%s
185 LIMIT 1",
186                 array(bigintval($id)), __FUNCTION__, __LINE__);
187
188         // Do we have an entry?
189         if (SQL_NUMROWS($result) == 1) {
190                 // Then get it
191                 $networkTypeData = SQL_FETCHARRAY($result);
192         } // END - if
193
194         // Free result
195         SQL_FREERESULT($result);
196
197         // Return result
198         return $networkTypeData;
199 }
200
201 // Updates given network (id) with data from array
202 function doNetworkUpdateDataByArray ($id, $networkData) {
203         // Ids lower one are not accepted
204         if ($id < 1) {
205                 // Not good, should be fixed
206                 debug_report_bug('Network id ' . $id . ' is smaller than 1.');
207         } // END - if
208
209         // Just call our inner method
210         return adminSaveSettings($networkData, '_network_data', sprintf("`network_id`=%s", bigintval($id)), array(), false, false);
211 }
212
213 // Updates given network type handler (id) with data from array
214 function doNetworkUpdateTypeByArray ($id, $networkTypeData) {
215         // Ids lower one are not accepted
216         if ($id < 1) {
217                 // Not good, should be fixed
218                 debug_report_bug('Network type handler id ' . $id . ' is smaller than 1.');
219         } // END - if
220
221         // Just call our inner method
222         return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($id)), array(), false, false);
223 }
224
225 // Removes given network entry
226 function doAdminRemoveNetworkEntry ($table, $column, $id, $limit = 1) {
227         // Remove the entry
228         SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_network_%s` WHERE `%s`=%s LIMIT %s",
229                 array($table, $column, $id, $limit), __FILE__, __LINE__);
230
231         // Return affected rows
232         return SQL_AFFECTEDROWS();
233 }
234
235 // Generates a list of networks for given script and returns it
236 function generateAdminNetworkList () {
237         // Init output
238         $content = '';
239
240         // Query for all networks
241         $result = SQL_QUERY("SELECT
242         `network_id`, `network_title`
243 FROM
244         `{?_MYSQL_PREFIX?}_network_data`
245 ORDER BY
246         `network_title` ASC", __FILE__, __LINE__);
247
248         // Do we have entries?
249         if (SQL_NUMROWS($result) > 0) {
250                 // List all entries
251                 $rows = array();
252                 while ($row = SQL_FETCHARRAY($result)) {
253                         // Is this valid, then add it
254                         if ((is_array($row)) && (isset($row['network_id']))) $rows[] = $row;
255                 } // END - while
256
257                 // Generate the selection box
258                 $content = generateSelectionBoxFromArray($rows, 'network', 'network_id', 'network_title');
259         } else {
260                 // Nothing selected
261                 $content = loadTemplate('admin_settings_saved', false, getMessage('ADMIN_ENTRIES_404'));
262         }
263
264         // Free the result
265         SQL_FREERESULT($result);
266
267         // Return the list
268         return $content;
269 }
270
271 //------------------------------------------------------------------------------
272 //                             Call-back functions
273 //------------------------------------------------------------------------------
274
275 // Callback function to add new network
276 function doAdminNetworkProcessAddnetworkForm () {
277         // We can say here, the form is sent, so check if the network is already added
278         if (isNetworkNameValid(postRequestParameter('network_short_name'))) {
279                 // Already there
280                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_ALREADY_ADDED', postRequestParameter('network_short_name')));
281                 return false;
282         } // END - if
283
284         // Remove the 'ok' part
285         unsetPostRequestParameter('ok');
286
287         // Add the whole request to database
288         SQL_QUERY("INSERT INTO
289         `{?_MYSQL_PREFIX?}_network_data`
290 (
291         `" . implode('`,`', array_keys(postRequestArray())) . "`
292 ) VALUES (
293         '" . implode("','", array_values(postRequestArray())) . "'
294 )", __FUNCTION__, __LINE__);
295
296         // Add the id for output only
297         setPostRequestParameter('network_id', SQL_INSERTID());
298
299         // Output message
300         if (SQL_AFFECTEDROWS() == 1) {
301                 // Successfully added
302                 loadTemplate('admin_network_added', false, postRequestArray());
303         } else {
304                 // Not added
305                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_DATA_NOT_ADDED', postRequestParameter('network_short_name')));
306         }
307 }
308
309 // Displays selected networks for editing
310 function doAdminNetworkProcessHandlenetworkForm () {
311         // Do we have selections?
312         if (countPostSelection() > 0) {
313                 // Something has been selected, so start displaying one by one
314                 $SW = 2; $OUT = '';
315                 foreach (postRequestParameter('sel') as $id => $sel) {
316                         // Is this selected?
317                         if ($sel == 1) {
318                                 // Load this network's data
319                                 $networkData = getNetworkDataById($id);
320
321                                 // Do we have found the network?
322                                 if (count($networkData) > 0) {
323                                         // Add color
324                                         $networkData['sw'] = $SW;
325
326                                         if (isPostRequestParameterSet('edit')) {
327                                                 // Make selection box for network_request_type
328                                                 $networkData['network_request_type'] = generateOptionList(
329                                                         '/ARRAY/',
330                                                         array('GET','POST'),
331                                                         array(
332                                                                 getMessage('ADMIN_NETWORK_REQUEST_TYPE_GET'),
333                                                                 getMessage('ADMIN_NETWORK_REQUEST_TYPE_POST')
334                                                         ),
335                                                         $networkData['network_request_type']
336                                                 );
337
338                                                 // Add row template for editing
339                                                 $OUT .= loadTemplate('admin_edit_networks_row', true, $networkData);
340                                         } elseif (isPostRequestParameterSet('del')) {
341                                                 // Translate the request type
342                                                 $networkData['network_request_type'] = getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . $networkData['network_request_type']);
343
344                                                 // Add row template for deleting
345                                                 $OUT .= loadTemplate('admin_del_networks_row', true, $networkData);
346                                         } else {
347                                                 // Problem!
348                                                 debug_report_bug('Cannot detect edit/del.');
349                                         }
350
351                                         // Switch colors
352                                         $SW = 3 - $SW;
353                                 } // END - if
354                         } // END - if
355                 } // END - foreach
356
357                 // If we have no rows, we don't need to display the edit form
358                 if (!empty($OUT)) {
359                         // Output main template
360                         if (isPostRequestParameterSet('edit')) {
361                                 loadTemplate('admin_edit_networks', false, $OUT);
362                         } elseif (isPostRequestParameterSet('del')) {
363                                 loadTemplate('admin_del_networks', false, $OUT);
364                         } else {
365                                 // Problem!
366                                 debug_report_bug('Cannot detect edit/del.');
367                         }
368
369                         // Don't display the list/add new form
370                         $GLOBALS['network_display'] = false;
371                 } else {
372                         // Nothing selected/found
373                         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_NOTHING_FOUND'));
374                 }
375         } // END - if
376 }
377
378 // Handle network type form
379 function doAdminNetworkProcessHandlenetworktypeForm () {
380         // Do we have selections?
381         if (countPostSelection() > 0) {
382                 // Load network data
383                 $networkData = getNetworkDataById(getRequestParameter('network'));
384
385                 // Something has been selected, so start displaying one by one
386                 $SW = 2; $OUT = '';
387                 foreach (postRequestParameter('sel') as $id => $sel) {
388                         // Is this selected?
389                         if ($sel == 1) {
390                                 // Load this network's data
391                                 $networkTypeData = getNetworkTypeDataById($id);
392
393                                 // Do we have found the network?
394                                 if (count($networkTypeData) > 0) {
395                                         // Add color
396                                         $networkTypeData['sw'] = $SW;
397
398                                         if (isPostRequestParameterSet('edit')) {
399                                                 // Add row template for deleting
400                                                 $OUT .= loadTemplate('admin_edit_network_types_row', true, $networkTypeData);
401                                         } elseif (isPostRequestParameterSet('del')) {
402                                                 // Fix empty banner URL
403                                                 if (trim($networkTypeData['network_type_banner_url']) == '') $networkTypeData['network_type_banner_url'] = '---';
404
405                                                 // Add row template for deleting
406                                                 $OUT .= loadTemplate('admin_del_network_types_row', true, $networkTypeData);
407                                         } else {
408                                                 // Problem!
409                                                 debug_report_bug('Cannot detect edit/del.');
410                                         }
411
412                                         // Switch colors
413                                         $SW = 3 - $SW;
414                                 } // END - if
415                         } // END - if
416                 } // END - foreach
417
418                 // If we have no rows, we don't need to display the edit form
419                 if (!empty($OUT)) {
420                         // Prepare content for template
421                         $content = array(
422                                 'rows' => $OUT,
423                                 'network_data' => getNetworkDataById(getRequestParameter('network'))
424                         );
425
426                         // Output main template
427                         if (isPostRequestParameterSet('edit')) {
428                                 loadTemplate('admin_edit_network_types', false, $content);
429                         } elseif (isPostRequestParameterSet('del')) {
430                                 loadTemplate('admin_del_network_types', false, $content);
431                         } else {
432                                 // Problem!
433                                 debug_report_bug('Cannot detect edit/del.');
434                         }
435
436                         // Don't display the list/add new form
437                         $GLOBALS['network_display'] = false;
438                 } else {
439                         // Nothing selected/found
440                         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_TYPES_NOTHING_FOUND'));
441                 }
442         } // END - if
443 }
444
445 // Changes given networks
446 function doAdminNetworkProcessChangenetworkForm () {
447         // Do we have selections?
448         if (countPostSelection() > 0) {
449                 // By default nothing is updated
450                 $updated = 0;
451
452                 // Something has been selected, so start updating them
453                 foreach (postRequestParameter('sel') as $id => $sel) {
454                         // Update this entry?
455                         if ($sel == 1) {
456                                 // Init data array
457                                 $networkData = array();
458
459                                 // Transfer whole array, except 'sel'
460                                 foreach (postRequestArray() as $key => $entry) {
461                                         // Skip 'sel' and submit button
462                                         if (in_array($key, array('sel', 'change'))) continue;
463
464                                         // Do we have this enty?
465                                         if (!isset($entry[$id])) {
466                                                 // Not found, needs fixing
467                                                 debug_report_bug('No entry in key=' . $key . ', id=' . $id . ' found.');
468                                         } // END - if
469
470                                         // Add this entry
471                                         $networkData[$key] = $entry[$id];
472                                 } // END - foreach
473
474                                 // Update the network data
475                                 $updated += doNetworkUpdateDataByArray($id, $networkData);
476                         } // END - if
477                 } // END - foreach
478
479                 // Do we have updates?
480                 if ($updated > 0) {
481                         // Updates done
482                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_UPDATED', $updated));
483                 } else {
484                         // Nothing changed
485                         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_NOTHING_CHANGED'));
486                 }
487         } // END - if
488 }
489
490 // Removes given networks
491 function doAdminNetworkProcessRemovenetworkForm () {
492         // Do we have selections?
493         if (countPostSelection() > 0) {
494                 // By default nothing is removed
495                 $removed = 0;
496
497                 // Something has been selected, so start updating them
498                 foreach (postRequestParameter('sel') as $id => $sel) {
499                         // Update this entry?
500                         if ($sel == 1) {
501                                 // Remove this entry
502                                 $removed += doAdminRemoveNetworkEntry('data', 'network_id', $id);
503                         } // END - if
504                 } // END - foreach
505
506                 // Do we have removes?
507                 if ($removed > 0) {
508                         // Removals done
509                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REMOVED', $removed));
510                 } else {
511                         // Nothing removed
512                         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_NOTHING_REMOVED'));
513                 }
514         } // END - if
515 }
516
517 // Add a network type handler if not yet found
518 function doAdminNetworkProcessAddnetworktypeForm () {
519         // Is the network type handle already used with given network?
520         if (isNetworkTypeHandleValid(postRequestParameter('network_type_handle'), getRequestParameter('network'))) {
521                 // Already added
522                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_HANDLE_ALREADY_ADDED', postRequestParameter('network_type_handle')));
523
524                 // ... so abort here
525                 return false;
526         } // END - if
527
528         // Remove the 'ok' part
529         unsetPostRequestParameter('ok');
530
531         // Add id
532         setPostRequestParameter('network_id', getRequestParameter('network'));
533
534         // Add the whole request to database
535         SQL_QUERY("INSERT INTO
536         `{?_MYSQL_PREFIX?}_network_types`
537 (
538         `" . implode('`,`', array_keys(postRequestArray())) . "`
539 ) VALUES (
540         '" . implode("','", array_values(postRequestArray())) . "'
541 )", __FUNCTION__, __LINE__);
542
543         // Output message
544         if (SQL_AFFECTEDROWS() == 1) {
545                 // Successfully added
546                 loadTemplate('admin_network_type_added', false, postRequestArray());
547         } else {
548                 // Not added
549                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_NOT_ADDED', postRequestParameter('network_type_handle')));
550         }
551 }
552
553 // Changes given network type handlers
554 function doAdminNetworkProcessChangenetworktypeForm () {
555         // Do we have selections?
556         if (countPostSelection() > 0) {
557                 // By default nothing is updated
558                 $updated = 0;
559
560                 // Something has been selected, so start updating them
561                 foreach (postRequestParameter('sel') as $id => $sel) {
562                         // Update this entry?
563                         if ($sel == 1) {
564                                 // Init data array
565                                 $networkTypeData = array();
566
567                                 // Transfer whole array, except 'sel'
568                                 foreach (postRequestArray() as $key => $entry) {
569                                         // Skip 'sel' and submit button
570                                         if (in_array($key, array('sel', 'change'))) continue;
571
572                                         // Do we have this enty?
573                                         if (!isset($entry[$id])) {
574                                                 // Not found, needs fixing
575                                                 debug_report_bug('No entry in key=' . $key . ', id=' . $id . ' found.');
576                                         } // END - if
577
578                                         // Add this entry
579                                         $networkTypeData[$key] = $entry[$id];
580                                 } // END - foreach
581
582                                 // Update the network data
583                                 $updated += doNetworkUpdateTypeByArray($id, $networkTypeData);
584                         } // END - if
585                 } // END - foreach
586
587                 // Do we have updates?
588                 if ($updated > 0) {
589                         // Updates done
590                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_UPDATED', $updated));
591                 } else {
592                         // Nothing changed
593                         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_TYPES_NOTHING_CHANGED'));
594                 }
595         } // END - if
596 }
597
598 // Removes given network type handlers
599 function doAdminNetworkProcessRemovenetworktypeForm () {
600         // Do we have selections?
601         if (countPostSelection() > 0) {
602                 // By default nothing is removed
603                 $removed = 0;
604
605                 // Something has been selected, so start updating them
606                 foreach (postRequestParameter('sel') as $id => $sel) {
607                         // Update this entry?
608                         if ($sel == 1) {
609                                 // Remove this entry
610                                 $removed += doAdminRemoveNetworkEntry('types', 'network_type_id', $id);
611                         } // END - if
612                 } // END - foreach
613
614                 // Do we have removes?
615                 if ($removed > 0) {
616                         // Removals done
617                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_TYPES_REMOVED', $removed));
618                 } else {
619                         // Nothing removed
620                         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NETWORK_TYPES_NOTHING_REMOVED'));
621                 }
622         } // END - if
623 }
624
625 // Adds a request parameter to given network and type
626 function doAdminNetworkProcessAddnetworkparamForm () {
627         // Is the request parameter already used with given network?
628         if (isNetworkRequestParameterValid(postRequestParameter('request_param_key'), postRequestParameter('network_type_id'), getRequestParameter('network'))) {
629                 // Already added
630                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_ALREADY_ADDED', postRequestParameter('request_param_key')));
631
632                 // ... so abort here
633                 return false;
634         } // END - if
635
636         // Remove the 'ok' part
637         unsetPostRequestParameter('ok');
638
639         // Add id
640         setPostRequestParameter('network_id', getRequestParameter('network'));
641
642         // Add the whole request to database
643         SQL_QUERY("INSERT INTO
644         `{?_MYSQL_PREFIX?}_network_request_params`
645 (
646         `" . implode('`,`', array_keys(postRequestArray())) . "`
647 ) VALUES (
648         '" . implode("','", array_values(postRequestArray())) . "'
649 )", __FUNCTION__, __LINE__);
650
651         // Output message
652         if (SQL_AFFECTEDROWS() == 1) {
653                 // Successfully added
654                 loadTemplate('admin_network_request_param_added', false, postRequestArray());
655         } else {
656                 // Not added
657                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_NETWORK_REQUEST_PARAMETER_NOT_ADDED', postRequestParameter('request_param_key')));
658         }
659 }
660
661 // [EOF]
662 ?>