2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 11/04/2009 *
4 * =================== Last change: 11/04/2009 *
6 * -------------------------------------------------------------------- *
7 * File : network_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for ext-network *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen fuer ext-network *
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')) {
43 // Private setter for current network id
44 function setCurrentNetworkId ($networkId) {
45 $GLOBALS['current_network_id'] = bigintval($networkId);
48 // Private getter for current network id
49 function getCurrentNetworkId () {
50 return $GLOBALS['current_network_id'];
53 // Detects if a supported form has been sent
54 function detectNetworkProcessForm () {
55 // 'do' must be provided in URL
56 if (!isGetRequestElementSet('do')) {
58 debug_report_bug(__FUNCTION__, __LINE__, 'No "do" has been provided. Please fix your templates.');
62 $GLOBALS['network_form_name'] = 'invalid';
64 // Now search all valid
65 foreach (array('ok', 'edit', 'delete', 'do_edit', 'do_delete') as $form) {
67 if (isFormSent($form)) {
69 $GLOBALS['network_form_name'] = $form;
76 // Has the form being detected?
77 if ($GLOBALS['network_form_name'] == 'invalid') {
79 debug_report_bug(__FUNCTION__, __LINE__, 'POST form could not be detected.');
83 // Handle a (maybe) sent form here
84 function doNetworkHandleForm () {
85 // Do we have a form sent?
86 if (countRequestPost() > 0) {
87 // Detect sent POST form
88 detectNetworkProcessForm();
89 } elseif (!isGetRequestElementSet('do')) {
90 // Skip any further requests
94 // Process the request
95 doAdminNetworkProcessForm();
98 // Processes an admin form
99 function doAdminNetworkProcessForm () {
100 // Create function name
101 $functionName = sprintf("doAdminNetworkProcess%s", capitalizeUnderscoreString(getRequestElement('do')));
103 // Is the function valid?
104 if (!function_exists($functionName)) {
105 // Invalid function name
106 debug_report_bug(__FUNCTION__, __LINE__, 'Invalid do ' . getRequestElement('do') . ', function ' . $functionName .' does not exist.', false);
109 // Call-back the method handling our request
110 call_user_func($functionName);
113 // Checks wether the (short) network name is already used (valid)
114 function isNetworkNameValid ($name) {
116 $result = SQL_QUERY_ESC("SELECT `network_id` FROM `{?_MYSQL_PREFIX?}_network_data` WHERE `network_short_name`='%s' LIMIT 1",
117 array($name), __FUNCTION__, __LINE__);
120 $isValid = (SQL_NUMROWS($result) == 1);
123 SQL_FREERESULT($result);
129 // Checks wether the given network type is already used (valid)
130 function isNetworkTypeHandleValid ($type, $networkId) {
132 $result = SQL_QUERY_ESC("SELECT `network_type_id` FROM `{?_MYSQL_PREFIX?}_network_types` WHERE `network_id`=%s AND `network_type_handle`='%s' LIMIT 1",
136 ), __FUNCTION__, __LINE__);
139 $isValid = (SQL_NUMROWS($result) == 1);
142 SQL_FREERESULT($result);
148 // Checks wether the given network request parameter is already used (valid)
149 function isNetworkRequestElementValid ($key, $type, $networkId) {
151 $result = SQL_QUERY_ESC("SELECT `network_request_param_id` FROM `{?_MYSQL_PREFIX?}_network_request_params` WHERE `network_id`=%s AND `network_type_id`=%s AND `network_request_param_key`='%s' LIMIT 1",
156 ), __FUNCTION__, __LINE__);
159 $isValid = (SQL_NUMROWS($result) == 1);
162 SQL_FREERESULT($result);
168 // Checks wether the given network API array translation
169 function isNetworkArrayTranslationValid ($key, $type, $networkId) {
171 $result = SQL_QUERY_ESC("SELECT `network_array_id` FROM `{?_MYSQL_PREFIX?}_network_array_translation` WHERE `network_id`=%s AND `network_type_id`=%s AND `network_array_index`='%s' LIMIT 1",
176 ), __FUNCTION__, __LINE__);
179 $isValid = (SQL_NUMROWS($result) == 1);
182 SQL_FREERESULT($result);
188 // "Getter" for a network's data by provided id number
189 function getNetworkDataById ($networkId, $column = '') {
190 // Ids lower one are not accepted
191 if ($networkId < 1) {
192 // Not good, should be fixed
193 debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $networkId . ' is smaller than 1.');
196 // Set current network id
197 setCurrentNetworkId($networkId);
200 if (!isset($GLOBALS['network_data'][$networkId])) {
201 // By default we have no data
202 $GLOBALS['network_data'][$networkId] = array();
204 // Query for the network data
205 $result = SQL_QUERY_ESC('SELECT
207 `network_short_name`,
210 `network_data_separator`,
211 `network_row_separator`,
212 `network_request_type`,
214 `network_require_id_card`,
215 `network_query_amount`
217 `{?_MYSQL_PREFIX?}_network_data`
221 array(bigintval($networkId)), __FUNCTION__, __LINE__);
223 // Do we have an entry?
224 if (SQL_NUMROWS($result) == 1) {
226 $GLOBALS['network_data'][$networkId] = SQL_FETCHARRAY($result);
230 SQL_FREERESULT($result);
234 if (empty($column)) {
236 return $GLOBALS['network_data'][$networkId];
239 return $GLOBALS['network_data'][$networkId][$column];
243 // "Getter" for a network's data by provided type id number
244 function getNetworkDataByTypeId ($networkId, $column = '') {
245 // Ids lower one are not accepted
246 if ($networkId < 1) {
247 // Not good, should be fixed
248 debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $networkId . ' is smaller than 1.');
251 // Set current network id
252 setCurrentNetworkId($networkId);
255 if (!isset($GLOBALS['network_data'][$networkId])) {
256 // By default we have no data
257 $GLOBALS['network_data'][$networkId] = array();
259 // Query for the network data
260 $result = SQL_QUERY_ESC('SELECT
262 d.`network_short_name`,
265 d.`network_data_separator`,
266 d.`network_row_separator`,
267 d.`network_request_type`,
269 d.`network_require_id_card`,
270 d.`network_query_amount`,
271 t.`network_type_handle`,
272 t.`network_type_api_url`,
273 t.`network_type_click_url`,
274 t.`network_type_banner_url`
276 `{?_MYSQL_PREFIX?}_network_data` AS d
278 `{?_MYSQL_PREFIX?}_network_types` AS t
280 d.`network_id`=t.`network_id`
282 t.`network_type_id`=%s
284 array(bigintval($networkId)), __FUNCTION__, __LINE__);
286 // Do we have an entry?
287 if (SQL_NUMROWS($result) == 1) {
289 $GLOBALS['network_data'][$networkId] = SQL_FETCHARRAY($result);
293 SQL_FREERESULT($result);
297 if (empty($column)) {
299 return $GLOBALS['network_data'][$networkId];
302 return $GLOBALS['network_data'][$networkId][$column];
306 // "Getter" for a network type data by provided id number
307 function getNetworkTypeDataById ($networkId) {
308 // Ids lower one are not accepted
309 if ($networkId < 1) {
310 // Not good, should be fixed
311 debug_report_bug(__FUNCTION__, __LINE__, 'Network type id ' . $networkId . ' is smaller than 1.');
314 // By default we have no data
315 $GLOBALS['network_type_data'][$networkId] = array();
317 // Query for the network data
318 $result = SQL_QUERY_ESC('SELECT
321 `network_type_handle`,
322 `network_type_api_url`,
323 `network_type_click_url`,
324 `network_type_banner_url`
326 `{?_MYSQL_PREFIX?}_network_types`
330 array(bigintval($networkId)), __FUNCTION__, __LINE__);
332 // Do we have an entry?
333 if (SQL_NUMROWS($result) == 1) {
335 $GLOBALS['network_type_data'][$networkId] = SQL_FETCHARRAY($result);
339 SQL_FREERESULT($result);
342 return $GLOBALS['network_type_data'][$networkId];
345 // "Getter" for a network request parameter data by provided id number
346 function getNetworkRequestParamsDataById ($networkId) {
347 // Ids lower one are not accepted
348 if ($networkId < 1) {
349 // Not good, should be fixed
350 debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $networkId . ' is smaller than 1.');
353 // By default we have no data
354 $networkRequestData = array();
356 // Query for the network data
357 $result = SQL_QUERY_ESC('SELECT
358 `network_request_param_id`,
361 `network_request_param_key`,
362 `network_request_param_value`,
363 `network_request_param_default`
365 `{?_MYSQL_PREFIX?}_network_request_params`
367 `network_request_param_id`=%s
369 array(bigintval($networkId)), __FUNCTION__, __LINE__);
371 // Do we have an entry?
372 if (SQL_NUMROWS($result) == 1) {
374 $networkRequestData = SQL_FETCHARRAY($result);
378 SQL_FREERESULT($result);
381 return $networkRequestData;
384 // Updates given network (id) with data from array
385 function doNetworkUpdateDataByArray ($networkId, $networkData) {
386 // Ids lower one are not accepted
387 if ($networkId < 1) {
388 // Not good, should be fixed
389 debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $networkId . ' is smaller than 1.');
392 // Just call our inner method
393 return adminSaveSettings($networkData, '_network_data', sprintf("`network_id`=%s", bigintval($networkId)), array(), false, false);
396 // Updates given network type handler (id) with data from array
397 function doNetworkUpdateTypeByArray ($networkId, $networkTypeData) {
398 // Ids lower one are not accepted
399 if ($networkId < 1) {
400 // Not good, should be fixed
401 debug_report_bug(__FUNCTION__, __LINE__, 'Network type handler id ' . $networkId . ' is smaller than 1.');
404 // Just call our inner method
405 return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($networkId)), array(), false, false);
408 // Updates given network request parameters (id) with data from array
409 function doNetworkUpdateParamsByArray ($networkId, $networkParamData) {
410 // Ids lower one are not accepted
411 if ($networkId < 1) {
412 // Not good, should be fixed
413 debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $networkId . ' is smaller than 1.');
416 // Just call our inner method
417 return adminSaveSettings($networkParamData, '_network_request_params', sprintf("`network_request_param_id`=%s", bigintval($networkId)), array(), false, false);
420 // Removes given network entry
421 function doAdminRemoveNetworkEntry ($table, $column, $networkId, $limit = 1) {
423 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_network_%s` WHERE `%s`=%s LIMIT %s",
429 ), __FUNCTION__, __LINE__);
431 // Return affected rows
432 return SQL_AFFECTEDROWS();
435 // Generates a list of networks for given script and returns it
436 function generateAdminNetworkList () {
440 // Query for all networks
441 $result = SQL_QUERY('SELECT
443 `network_short_name`,
446 `{?_MYSQL_PREFIX?}_network_data`
448 `network_short_name` ASC', __FUNCTION__, __LINE__);
450 // Do we have entries?
451 if (!SQL_HASZERONUMS($result)) {
454 while ($row = SQL_FETCHARRAY($result)) {
455 // Is this valid, then add it
456 if ((is_array($row)) && (isset($row['network_id']))) {
458 $rows[$row['network_id']] = $row;
462 // Generate the selection box
463 $content = generateSelectionBoxFromArray($rows, 'network_id', 'network_id', '', '', 'network');
466 $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
470 SQL_FREERESULT($result);
476 // Generator (somewhat getter) for a list of network types for given network id
477 function generateAdminNetworkTypeList ($networkId) {
481 // Query all types of this network
482 $result = SQL_QUERY_ESC('SELECT
484 `network_type_handle`
486 `{?_MYSQL_PREFIX?}_network_types`
490 `network_type_handle` ASC',
492 bigintval($networkId)
493 ), __FUNCTION__, __LINE__);
495 // Do we have entries?
496 if (!SQL_HASZERONUMS($result)) {
499 while ($row = SQL_FETCHARRAY($result)) {
500 // Is this valid, then add it
501 if ((is_array($row)) && (isset($row['network_type_id']))) {
503 $rows[$row['network_type_id']] = $row;
507 // Generate the selection box
508 $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id');
511 $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
515 SQL_FREERESULT($result);
521 // Generator (somewhat getter) for a list of network types for all types
522 function generateAdminDistinctNetworkTypeList () {
526 // Query all types of this network
527 $result = SQL_QUERY('SELECT
528 t.`network_type_id`, t.`network_type_handle`, d.`network_title`
530 `{?_MYSQL_PREFIX?}_network_types` AS t
532 `{?_MYSQL_PREFIX?}_network_data` AS d
534 t.`network_id`=d.`network_id`
536 d.`network_short_name` ASC,
537 t.`network_type_handle` ASC', __FUNCTION__, __LINE__);
539 // Do we have entries?
540 if (!SQL_HASZERONUMS($result)) {
543 while ($row = SQL_FETCHARRAY($result)) {
544 // Is this valid, then add it
545 if ((is_array($row)) && (isset($row['network_type_id']))) {
547 $rows[$row['network_type_id']] = $row;
551 // Generate the selection box
552 $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id', '', '_title');
555 $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
559 SQL_FREERESULT($result);
560 //* DEBUG: */ die('<pre>'.encodeEntities($content).'</pre>');
566 // Generator (somewhat getter) for network type options
567 function generateNetworkTypeOptions ($networkId) {
568 // Is this an array, then we just came back from edit/delete actions
569 if (is_array($networkId)) {
574 if (!isset($GLOBALS[__FUNCTION__][$networkId])) {
575 // Generate output and cache it
576 $GLOBALS[__FUNCTION__][$networkId] = generateOptionList(
579 'network_type_handle',
583 "WHERE `network_id`=%s",
584 bigintval(getRequestElement('network_id'))
587 'translateNetworkTypeHandler'
592 return $GLOBALS[__FUNCTION__][$networkId];
595 // Generates an options list of all available (hard-coded) handlers
596 function generateNetworkTypesAvailableOptions () {
598 if (!isset($GLOBALS[__FUNCTION__])) {
600 $GLOBALS[__FUNCTION__] = generateOptionList(
636 $GLOBALS['network_types_disabled'],
637 'translateNetworkTypeHandler'
642 return $GLOBALS[__FUNCTION__];
645 // Generates an options list (somewhat getter) ofr request keys
646 function generateNetworkRequestKeyOptions () {
648 if (!isset($GLOBALS[__FUNCTION__])) {
649 // Generate and cache it
650 $GLOBALS[__FUNCTION__] = generateOptionList(
672 $GLOBALS['network_params_disabled'],
673 'translateNetworkRequestElement'
678 return $GLOBALS[__FUNCTION__];
681 // Generator (somewhat getter) for (return) array translation
682 function generateNetworkTranslationOptions ($default = '') {
684 if (!isset($GLOBALS[__FUNCTION__][$default])) {
685 // Generate and cache it
686 $GLOBALS[__FUNCTION__][$default] = generateOptionList(
687 'network_translations',
688 'network_translation_id',
689 'network_translation_name',
693 $GLOBALS['network_translation_disabled'],
694 'translateNetworkTranslationName'
699 return $GLOBALS[__FUNCTION__][$default];
702 // Generates an option list of request types
703 function generateNetworkRequestTypeOptions ($default = '') {
705 if (!isset($GLOBALS[__FUNCTION__][$default])) {
707 $GLOBALS[__FUNCTION__][$default] = generateOptionList(
714 '{--ADMIN_NETWORK_REQUEST_TYPE_GET--}',
715 '{--ADMIN_NETWORK_REQUEST_TYPE_POST--}'
722 return $GLOBALS[__FUNCTION__][$default];
725 // Generates an option list of network_api_active
726 function generateNetworkApiActiveOptions ($default = '') {
728 if (!isset($GLOBALS[__FUNCTION__][$default])) {
730 $GLOBALS[__FUNCTION__][$default] = generateYesNoOptionList($default);
734 return $GLOBALS[__FUNCTION__][$default];
737 // Translates 'translate_name' for e.g. templates
738 function translateNetworkTranslationName ($name) {
739 // Get the message id
740 return '{--ADMIN_NETWORK_TRANSLATE_' . strtoupper($name) . '_NAME--}';
743 // Translates the network type handler (e.g. banner, paidmail) for templates
744 function translateNetworkTypeHandler ($type) {
745 // Get the message id
746 return '{--ADMIN_NETWORK_TYPES_' . strtoupper($type) . '--}';
749 // Translates request type
750 function translateNetworkRequestType ($type) {
751 // Get the message id
752 return '{--ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($type) . '--}';
755 // Translates request parameter
756 function translateNetworkRequestElement ($param) {
757 // Get the message id
758 return '{--ADMIN_NETWORK_REQUEST_PARAMETER_' . strtoupper($param) . '--}';
761 // Translates API index
762 function translateNetworkApiIndex ($index) {
764 if (!isset($GLOBALS['network_array_index'])) {
765 // Get an array of all API array indexes
766 $GLOBALS['network_array_index'] = array();
769 $result = SQL_QUERY('SELECT
771 `network_array_index`,
772 `network_translation_name`
774 `{?_MYSQL_PREFIX?}_network_array_translation`
776 `{?_MYSQL_PREFIX?}_network_translations`
778 `network_array_index`=`network_translation_id`
780 `sort` ASC', __FUNCTION__, __LINE__);
782 // Do we have entries?
783 if (!SQL_HASZERONUMS($result)) {
785 while ($row = SQL_FETCHARRAY($result)) {
786 // Add it to our global array
787 $GLOBALS['network_array_index'][$row['network_array_index']] = $row;
792 SQL_FREERESULT($result);
795 // Default name is unknown
798 // Is the entry there?
799 if (isset($GLOBALS['network_array_index'][$index])) {
801 $name = $GLOBALS['network_array_index'][$index]['network_translation_name'];
804 // Return translation
805 return translateNetworkTranslationName($name);
808 // Translates network API configuration status (see function isNetworkApiConfigured()) by given id
809 function translateNetworkApiConfiguredStatusById ($networkId) {
811 if (!isset($GLOBALS[__FUNCTION__][$networkId])) {
812 // By default it is not configured
813 $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_NOT_CONFIGURED--}';
815 // So is it configured?
816 if (isNetworkApiConfigured($networkId)) {
818 $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_CONFIGURED--}';
823 return $GLOBALS[__FUNCTION__][$networkId];
826 // Checks if the given network is configured by looking its API configuration entry up
827 function isNetworkApiConfigured ($networkId) {
829 if (!isset($GLOBALS[__FUNCTION__][$networkId])) {
830 // Check for an entry in network_api_config
831 $GLOBALS[__FUNCTION__][$networkId] = (countSumTotalData(
832 bigintval($networkId),
833 'network_api_config',
841 return $GLOBALS[__FUNCTION__][$networkId];
844 // Checks wether the given network type handler is configured
845 function isNetworkTypeHandlerConfigured ($networkId, $networkTypeId) {
847 if (!isset($GLOBALS[__FUNCTION__][$networkId][$networkTypeId])) {
849 $GLOBALS[__FUNCTION__][$networkId][$networkTypeId] = (countSumTotalData(
850 bigintval($networkTypeId),
851 'network_types_config',
855 sprintf(' AND `network_id`=%s', bigintval($networkId))
860 return $GLOBALS[__FUNCTION__][$networkId][$networkTypeId];
863 //------------------------------------------------------------------------------
864 // Call-back functions
865 //------------------------------------------------------------------------------
867 // Callback function to add new network
868 function doAdminNetworkProcessAddNetwork () {
869 // We can say here, the form is sent, so check if the network is already added
870 if (isNetworkNameValid(postRequestElement('network_short_name'))) {
872 loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_ALREADY_ADDED=' . postRequestElement('network_short_name') . '%}');
876 // Remove the 'ok' part
877 unsetPostRequestElement('ok');
879 // Add the whole request to database
880 SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_data'), __FUNCTION__, __LINE__);
882 // Add the id for output only
883 setPostRequestElement('network_id', SQL_INSERTID());
886 if (!SQL_HASZEROAFFECTED()) {
887 // Successfully added
888 loadTemplate('admin_network_added', false, postRequestArray());
891 loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_DATA_NOT_ADDED=' . postRequestElement('network_short_name') . '%}');
895 // Displays selected networks for editing
896 function doAdminNetworkProcessHandleNetwork () {
897 // Do we have selections?
898 if (ifPostContainsSelections()) {
899 // Something has been selected, so start displaying one by one
901 foreach (postRequestElement('sel') as $networkId => $sel) {
904 // Load this network's data
905 $networkData = getNetworkDataById($networkId);
907 // Do we have found the network?
908 if (count($networkData) > 0) {
909 // Add row template with given form name
910 $OUT .= loadTemplate('admin_' . $GLOBALS['network_form_name'] . '_networks_row', true, $networkData);
915 // If we have no rows, we don't need to display the edit form
917 // Output main template
918 loadTemplate('admin_' . $GLOBALS['network_form_name'] . '_networks', false, $OUT);
920 // Don't display the list/add new form
921 $GLOBALS['network_display'] = false;
923 // Nothing selected/found
924 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_FOUND--}');
929 // Handle network type form
930 function doAdminNetworkProcessHandleNetworkType () {
931 // Do we have selections?
932 if (ifPostContainsSelections()) {
934 $networkData = getNetworkDataById(getRequestElement('network_id'));
936 // Something has been selected, so start displaying one by one
938 foreach (postRequestElement('sel') as $networkId => $sel) {
941 // Load this network's data
942 $networkTypeData = getNetworkTypeDataById($networkId);
944 // Do we have found the network?
945 if (count($networkTypeData) > 0) {
946 if (isFormSent('edit')) {
947 // Add row template for deleting
948 $OUT .= loadTemplate('admin_edit_network_types_row', true, $networkTypeData);
949 } elseif (isFormSent('delete')) {
950 // Add row template for deleting
951 $OUT .= loadTemplate('admin_delete_network_types_row', true, $networkTypeData);
954 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
960 // If we have no rows, we don't need to display the edit form
962 // Output main template
963 if (isFormSent('edit')) {
964 loadTemplate('admin_edit_network_types', false, $OUT);
965 } elseif (isFormSent('delete')) {
966 loadTemplate('admin_delete_network_types', false, $OUT);
969 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
972 // Don't display the list/add new form
973 $GLOBALS['network_display'] = false;
975 // Nothing selected/found
976 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_FOUND--}');
981 // Handle network request parameter form
982 function doAdminNetworkProcessHandleRequestParams () {
983 // Do we have selections?
984 if (ifPostContainsSelections()) {
986 $GLOBALS['network_params_disabled'] = array();
989 $networkData = getNetworkDataById(getRequestElement('network_id'));
991 // Something has been selected, so start displaying one by one
993 foreach (postRequestElement('sel') as $networkId => $sel) {
996 // Load this network's data
997 $networkRequestData = getNetworkRequestParamsDataById($networkId);
999 // Do we have found the network?
1000 if (count($networkRequestData) > 0) {
1001 if (isFormSent('edit')) {
1002 // Add row template for deleting
1003 $OUT .= loadTemplate('admin_edit_network_params_row', true, $networkRequestData);
1004 } elseif (isFormSent('delete')) {
1006 $networkRequestData['network_type_data'] = getNetworkTypeDataById($networkRequestData['network_type_id']);
1008 // Add row template for deleting
1009 $OUT .= loadTemplate('admin_delete_network_params_row', true, $networkRequestData);
1012 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
1018 // If we have no rows, we don't need to display the edit form
1020 // Output main template
1021 if (isFormSent('edit')) {
1022 loadTemplate('admin_edit_network_params', false, $OUT);
1023 } elseif (isFormSent('delete')) {
1024 loadTemplate('admin_delete_network_params', false, $OUT);
1027 debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
1030 // Don't display the list/add new form
1031 $GLOBALS['network_display'] = false;
1033 // Nothing selected/found
1034 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_FOUND--}');
1039 // Changes given networks
1040 function doAdminNetworkProcessChangeNetwork () {
1041 // Do we have selections?
1042 if (ifPostContainsSelections()) {
1043 // By default nothing is updated
1046 // Something has been selected, so start updating them
1047 foreach (postRequestElement('sel') as $networkId => $sel) {
1048 // Update this entry?
1051 $networkData = array();
1053 // Transfer whole array, except 'sel'
1054 foreach (postRequestArray() as $key => $entry) {
1055 // Skip 'sel' and submit button
1056 if (in_array($key, array('sel', 'do_edit'))) {
1060 // Do we have this enty?
1061 if (!isset($entry[$networkId])) {
1062 // Not found, needs fixing
1063 debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $networkId . ' found.');
1067 $networkData[$key] = $entry[$networkId];
1070 // Update the network data
1071 $updated += doNetworkUpdateDataByArray($networkId, $networkData);
1075 // Do we have updates?
1078 displayMessage('{%message,ADMIN_NETWORK_UPDATED=' . $updated . '%}');
1081 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_CHANGED--}');
1086 // Removes given networks
1087 function doAdminNetworkProcessRemoveNetwork () {
1088 // Do we have selections?
1089 if (ifPostContainsSelections()) {
1090 // By default nothing is removed
1093 // Something has been selected, so start updating them
1094 foreach (postRequestElement('sel') as $networkId => $sel) {
1095 // Update this entry?
1097 // Remove this entry
1098 $removed += doAdminRemoveNetworkEntry('data', 'network_id', $networkId);
1102 // Do we have removes?
1105 displayMessage('{%message,ADMIN_NETWORK_REMOVED=' . $removed . '%}');
1108 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_NOTHING_REMOVED--}');
1113 // Add a network type handler if not yet found
1114 function doAdminNetworkProcessAddNetworkType () {
1115 // Is the network type handle already used with given network?
1116 if (isNetworkTypeHandleValid(postRequestElement('network_type_handle'), getRequestElement('network_id'))) {
1118 loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_TYPES_HANDLE_ALREADY_ADDED=' . postRequestElement('network_type_handle') . '%}');
1120 // ... so abort here
1124 // Remove the 'ok' part
1125 unsetPostRequestElement('ok');
1128 setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
1130 // Is network_type_banner_url set?
1131 if (postRequestElement('network_type_banner_url') == '') {
1132 // Remove empty value to get a NULL for an optional entry
1133 unsetPostRequestElement('network_type_banner_url');
1136 // Add the whole request to database
1137 SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_types'), __FUNCTION__, __LINE__);
1140 if (!SQL_HASZEROAFFECTED()) {
1141 // Successfully added
1142 loadTemplate('admin_network_type_added', false, postRequestArray());
1145 loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_TYPES_NOT_ADDED=' . postRequestElement('network_type_handle') . '%}');
1149 // Changes given network type handlers
1150 function doAdminNetworkProcessChangeNetworkType () {
1151 // Do we have selections?
1152 if (ifPostContainsSelections()) {
1153 // By default nothing is updated
1156 // Something has been selected, so start updating them
1157 foreach (postRequestElement('sel') as $networkId => $sel) {
1158 // Update this entry?
1161 $networkTypeData = array();
1163 // Transfer whole array, except 'sel'
1164 foreach (postRequestArray() as $key => $entry) {
1165 // Skip 'sel' and submit button
1166 if (in_array($key, array('sel', 'do_edit'))) {
1170 // Do we have this enty?
1171 if (!isset($entry[$networkId])) {
1172 // Not found, needs fixing
1173 debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $networkId . ' found.');
1176 // Fix empty network_type_banner_url to NULL
1177 if (($key == 'network_type_banner_url') && (trim($entry[$networkId]) == '')) {
1179 $entry[$networkId] = NULL;
1183 $networkTypeData[$key] = $entry[$networkId];
1186 // Update the network data
1187 $updated += doNetworkUpdateTypeByArray($networkId, $networkTypeData);
1191 // Do we have updates?
1194 displayMessage('{%message,ADMIN_NETWORK_TYPES_UPDATED=' . $updated . '%}');
1197 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_CHANGED--}');
1202 // Changes given network request parameters
1203 function doAdminNetworkProcessChangeNetworkParam () {
1204 // Do we have selections?
1205 if (ifPostContainsSelections()) {
1206 // By default nothing is updated
1209 // Something has been selected, so start updating them
1210 foreach (postRequestElement('sel') as $networkId => $sel) {
1211 // Update this entry?
1214 $networkParamsData = array();
1216 // Transfer whole array, except 'sel'
1217 foreach (postRequestArray() as $key => $entry) {
1218 // Skip 'sel' and submit button
1219 if (in_array($key, array('sel', 'do_edit'))) {
1223 // Do we have this enty?
1224 if (!isset($entry[$networkId])) {
1225 // Not found, needs fixing
1226 debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $networkId . ' found.');
1229 // Fix empty network_request_param_default to NULL
1230 if (($key == 'network_request_param_default') && (trim($entry[$networkId]) == '')) {
1232 $entry[$networkId] = NULL;
1236 $networkParamsData[$key] = $entry[$networkId];
1239 // Update the network data
1240 $updated += doNetworkUpdateParamsByArray($networkId, $networkParamsData);
1244 // Do we have updates?
1247 displayMessage('{%message,ADMIN_NETWORK_REQUEST_PARAMETER_UPDATED=' . $updated . '%}');
1250 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_CHANGED--}');
1255 // Removes given network type handlers
1256 function doAdminNetworkProcessRemoveNetworkType () {
1257 // Do we have selections?
1258 if (ifPostContainsSelections()) {
1259 // By default nothing is removed
1262 // Something has been selected, so start updating them
1263 foreach (postRequestElement('sel') as $networkId => $sel) {
1264 // Update this entry?
1266 // Remove this entry
1267 $removed += doAdminRemoveNetworkEntry('types', 'network_type_id', $networkId);
1271 // Do we have removes?
1274 displayMessage('{%message,ADMIN_NETWORK_TYPES_REMOVED=' . $removed . '%}');
1277 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPES_NOTHING_REMOVED--}');
1282 // Removes given network request parameters
1283 function doAdminNetworkProcessRemoveNetworkParam () {
1284 // Do we have selections?
1285 if (ifPostContainsSelections()) {
1286 // By default nothing is removed
1289 // Something has been selected, so start updating them
1290 foreach (postRequestElement('sel') as $networkId => $sel) {
1291 // Update this entry?
1293 // Remove this entry
1294 $removed += doAdminRemoveNetworkEntry('request_params', 'network_request_param_id', $networkId);
1298 // Do we have removes?
1301 displayMessage('{%message,ADMIN_NETWORK_REQUEST_PARAMETER_REMOVED=' . $removed . '%}');
1304 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_REMOVED--}');
1309 // Adds a request parameter to given network and type
1310 function doAdminNetworkProcessAddNetworkParam () {
1311 // Is the request parameter already used with given network?
1312 if (isNetworkRequestElementValid(postRequestElement('network_request_param_key'), postRequestElement('network_type_id'), getRequestElement('network_id'))) {
1314 loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_REQUEST_PARAMETER_ALREADY_ADDED=' . postRequestElement('network_request_param_key') . '%}');
1316 // ... so abort here
1320 // Remove the 'ok' part
1321 unsetPostRequestElement('ok');
1324 setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
1326 // Is network_request_param_default set?
1327 if (postRequestElement('network_request_param_default') == '') {
1328 // Remove empty value to get a NULL for an optional entry
1329 unsetPostRequestElement('network_request_param_default');
1332 // Add the whole request to database
1333 SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_request_params'), __FUNCTION__, __LINE__);
1336 if (!SQL_HASZEROAFFECTED()) {
1337 // Successfully added
1338 loadTemplate('admin_network_request_param_added', false, postRequestArray());
1341 loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_REQUEST_PARAMETER_NOT_ADDED=' . postRequestElement('network_request_param_key') . '%}');
1345 // Adds a API response array entry
1346 function doAdminNetworkProcessAddNetworkArrayTranslation () {
1347 // Is the request parameter already used with given network?
1348 if (isNetworkArrayTranslationValid(postRequestElement('network_array_index'), postRequestElement('network_type_id'), getRequestElement('network_id'))) {
1350 loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_ARRAY_TRANSLATION_ALREADY_ADDED=' . postRequestElement('network_array_index') . '%}');
1352 // ... so abort here
1356 // Remove the 'ok' part
1357 unsetPostRequestElement('ok');
1360 setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
1363 setPostRequestElement('sort', (countSumTotalData(
1364 bigintval(postRequestElement('network_id')),
1365 'network_array_translation',
1369 sprintf(" AND `network_type_id`=%s", bigintval(postRequestElement('network_type_id')))
1372 // Add the whole request to database
1373 SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_array_translation'), __FUNCTION__, __LINE__);
1376 if (!SQL_HASZEROAFFECTED()) {
1377 // Successfully added
1378 loadTemplate('admin_network_array_translation_added', false, postRequestArray());
1381 loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_ARRAY_TRANSLATION_NOT_ADDED=' . postRequestElement('network_array_index') . '%}');
1385 // Adds/update network API configuration
1386 function doAdminNetworkProcessNetworkApiConfig () {
1387 // Remove the 'ok' part
1388 unsetPostRequestElement('ok');
1391 setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
1393 // Is network_api_referral_button set?
1394 if (postRequestElement('network_api_referral_button') == '') {
1395 // Remove empty value to get a NULL for an optional entry
1396 unsetPostRequestElement('network_api_referral_button');
1399 // Is there already an entry?
1400 if (isNetworkApiConfigured(getRequestElement('network_id'))) {
1401 // Generate SQL query
1402 $SQL = getUpdateSqlFromArray(postRequestArray(), 'network_api_config', 'network_id', postRequestElement('network_id'), array('network_id'));
1405 $SQL = getInsertSqlFromArray(postRequestArray(), 'network_api_config');
1409 SQL_QUERY($SQL, __FUNCTION__, __LINE__);
1412 if (!SQL_HASZEROAFFECTED()) {
1413 // Successfully added
1414 displayMessage('{--ADMIN_CONFIG_NETWORK_API_SAVED--}');
1417 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_API_NOT_SAVED--}');
1421 // Only adds network type configuration if not yet present
1422 function doAdminNetworkProcessAddNetworkTypesConfig () {
1423 // Remove the 'ok' part
1424 unsetPostRequestElement('ok');
1427 setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
1428 setPostRequestElement('network_type_id', bigintval(getRequestElement('network_type_id')));
1431 * Some parameters are optional, at least one must be given so check a bunch
1434 foreach (array('network_min_waiting_time', 'network_min_remain_clicks', 'network_min_payment', 'network_allow_erotic') as $element) {
1435 // Is this element empty?
1436 if (postRequestElement($element) == '') {
1437 // Then unset it to get a NULL for optional parameter
1438 unsetPostRequestElement($element);
1442 // Initialize variables
1444 $id = 'network_max_reload_time_ye';
1446 $postData = postRequestArray();
1448 // Convert "reload time selections"
1449 convertSelectionsToEpocheTime($postData, $content, $id, $skip);
1451 // Set the POST array back
1452 setPostRequestArray($postData);
1454 // Is there already an entry?
1455 if (isNetworkTypeHandlerConfigured(getRequestElement('network_id'), getRequestElement('network_type_id'))) {
1456 // This network type handler is already configured
1457 displayMessage('{--ADMIN_NETWORK_TYPE_HANDLER_ALREADY_CONFIGURED--}');
1461 // Get SQL query for new entry
1462 $SQL = getInsertSqlFromArray(postRequestArray(), 'network_types_config');
1465 SQL_QUERY($SQL, __FUNCTION__, __LINE__);
1468 if (!SQL_HASZEROAFFECTED()) {
1469 // Successfully added
1470 displayMessage('{--ADMIN_CONFIG_NETWORK_TYPE_HANDLER_SAVED--}');
1473 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_TYPE_HANDLER_NOT_SAVED--}');
1477 // Only changes network type configuration if not yet present
1478 function doAdminNetworkProcessEditNetworkTypesConfig () {
1479 // Remove the 'ok' part
1480 unsetPostRequestElement('ok');
1483 setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
1484 setPostRequestElement('network_type_id', bigintval(getRequestElement('network_type_id')));
1487 * Some parameters are optional, at least one must be given so check a bunch
1490 foreach (array('network_min_waiting_time', 'network_min_remain_clicks', 'network_min_payment', 'network_allow_erotic') as $element) {
1491 // Is this element empty?
1492 if (postRequestElement($element) == '') {
1493 // Then unset it to get a NULL for optional parameter
1494 unsetPostRequestElement($element);
1498 // Initialize variables
1500 $id = 'network_max_reload_time_ye';
1502 $postData = postRequestArray();
1504 // Convert "reload time selections"
1505 convertSelectionsToEpocheTime($postData, $content, $id, $skip);
1507 // Set the POST array back
1508 setPostRequestArray($postData);
1510 // Is there already an entry?
1511 if (!isNetworkTypeHandlerConfigured(getRequestElement('network_id'), getRequestElement('network_type_id'))) {
1512 // This network type handler is not configured
1513 displayMessage('{--ADMIN_NETWORK_TYPE_HANDLER_NOT_CONFIGURED--}');
1517 // Get SQL query for new entry
1518 $SQL = getUpdateSqlFromArray(postRequestArray(), 'network_types_config', 'network_data_id', postRequestElement('network_data_id'), array('network_data_id'));
1521 SQL_QUERY($SQL, __FUNCTION__, __LINE__);
1524 if (!SQL_HASZEROAFFECTED()) {
1525 // Successfully added
1526 displayMessage('{--ADMIN_CONFIG_NETWORK_TYPE_HANDLER_SAVED--}');
1529 loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_TYPE_HANDLER_NOT_CHANGED--}');
1533 // Do expression code for this extension
1534 function doExpressionNetwork ($data) {
1535 // Construct replacer
1536 $replacer = sprintf(
1537 "{DQUOTE} . %s(%s, '%s') . {DQUOTE}",
1539 $data['matches'][4][$data['key']],
1543 // Replace %network_id% with the current network id
1544 $replacer = str_replace('%network_id%', getCurrentNetworkId(), $replacer);
1547 $code = replaceExpressionCode($data, $replacer);
1553 // ----------------------------------------------------------------------------
1554 // Call-back functions for exporting data
1555 // ----------------------------------------------------------------------------
1557 // Callback function to export network tables
1558 function doAdminNetworkProcessExport () {
1559 // Init table with all valid what->table entries
1560 $validExports = array(
1561 // General network data
1562 'list_networks' => 'network_data',
1563 // Network type handler
1564 'list_network_types' => 'network_types',
1565 // Network request parameter
1566 'list_network_params' => 'network_request_params',
1567 // Network API response array index translation
1568 'list_network_array_translation' => 'network_array_translation',
1571 // Is the 'what' key valid?
1572 if (!isset($validExports[getWhat()])) {
1574 debug_report_bug(__FUNCTION__, __LINE__, 'what=' . getWhat() . ' - not supported');
1577 // Generate call-back, some tables require to export not all columns
1578 $callbackName = 'doAdminNetworkExport' . capitalizeUnderscoreString($validExports[getWhat()]);
1580 // Is the call-back function there?
1581 if (!function_exists($callbackName)) {
1582 // No, this is really bad
1583 debug_report_bug(__FUNCTION__, __LINE__, 'Invalid call-back function ' . $callbackName . ' detected.');
1584 } elseif (isset($GLOBALS[__FUNCTION__][$callbackName])) {
1586 debug_report_bug(__FUNCTION__, __LINE__, 'Double-call of export function ' . $callbackName . ' detected.');
1589 // Call the function
1590 call_user_func($callbackName);
1592 // Mark it as called
1593 $GLOBALS[__FUNCTION__][$callbackName] = true;
1595 // Don't display the list/add new form
1596 $GLOBALS['network_display'] = false;
1599 // Exports (and displays) the table 'network_data'
1600 function doAdminNetworkExportNetworkData () {
1601 // Query for all networks
1602 $result = SQL_QUERY('SELECT
1603 `network_short_name`,
1606 `network_data_separator`,
1607 `network_row_separator`,
1608 `network_request_type`,
1610 `network_require_id_card`,
1611 `network_query_amount`
1613 `{?_MYSQL_PREFIX?}_network_data`
1616 __FUNCTION__, __LINE__);
1618 // Start an empty SQL query
1622 while ($content = SQL_FETCHARRAY($result)) {
1625 $content['network_short_name'] . "', '" .
1626 $content['network_title'] . "', '" .
1627 $content['network_reflink'] . "', '" .
1628 $content['network_data_separator'] . "', '" .
1629 $content['network_row_separator'] . "', '" .
1630 $content['network_request_type'] . "', '" .
1631 $content['network_charset'] . "', '" .
1632 $content['network_require_id_card'] . "', " .
1633 $content['network_query_amount'] . '),</pre>';
1636 // Remove last commata and close braces
1637 $SQL = substr($SQL, 0, -7) . '</pre>';
1640 SQL_FREERESULT($result);
1642 // Output the SQL query
1643 loadTemplate('admin_export_network_data', false, $SQL);
1646 // Exports (and displays) the table 'network_types'
1647 function doAdminNetworkExportNetworkTypes () {
1648 // 'network_id' must be set
1649 if (!isGetRequestElementSet('network_id')) {
1650 // Only network handlers of one network will be exported per time
1651 debug_report_bug(__FUNCTION__, __LINE__, 'network_id not provided, please fix your links.');
1654 // Get all network types of given network
1655 $result = SQL_QUERY_ESC('SELECT
1658 `network_type_handle`,
1659 `network_type_api_url`,
1660 `network_type_click_url`,
1661 `network_type_banner_url`
1663 `{?_MYSQL_PREFIX?}_network_types`
1667 `network_type_id` ASC',
1669 bigintval(getRequestElement('network_id'))
1670 ), __FUNCTION__, __LINE__);
1672 // Start an empty SQL query
1673 $SQL = "<pre>INSERT INTO `{?_MYSQL_PREFIX?}_network_types` (`network_type_id`,`network_id`,`network_type_handle`,`network_type_api_url`,`network_type_click_url`,`network_type_banner_url`) VALUES\n";
1676 while ($content = SQL_FETCHARRAY($result)) {
1679 $content['network_type_id'] . ', ' .
1680 $content['network_id'] . ", '" .
1681 $content['network_type_handle'] . "', '" .
1682 $content['network_type_api_url'] . "', '" .
1683 $content['network_type_click_url'] . "', ";
1685 // Is the column NULL?
1686 if (is_null($content['network_type_banner_url'])) {
1691 $SQL .= $content['network_type_banner_url'] . "'),\n";
1695 // Remove last commata and close braces
1696 $SQL = substr($SQL, 0, -1) . '</pre>';
1699 SQL_FREERESULT($result);
1701 // Output the SQL query
1702 loadTemplate('admin_export_network_types', false, $SQL);
1705 // Exports (and displays) the table 'network_request_params'
1706 function doAdminNetworkExportNetworkRequestParams () {
1707 // 'network_id' must be set
1708 if (!isGetRequestElementSet('network_id')) {
1709 // Only network request parameters of one network will be exported per time
1710 debug_report_bug(__FUNCTION__, __LINE__, 'network_id not provided, please fix your links.');
1713 // Get all network types of given network
1714 $result = SQL_QUERY_ESC('SELECT
1717 `network_request_param_key`,
1718 `network_request_param_value`,
1719 `network_request_param_default`
1721 `{?_MYSQL_PREFIX?}_network_request_params`
1725 `network_type_id` ASC ,
1726 `network_request_param_id` ASC',
1728 bigintval(getRequestElement('network_id'))
1729 ), __FUNCTION__, __LINE__);
1731 // Start an empty SQL query
1732 $SQL = "<pre>INSERT INTO `{?_MYSQL_PREFIX?}_network_request_params` (`network_id`,`network_type_id`,`network_request_param_key`,`network_request_param_value`,`network_request_param_default`) VALUES\n";
1735 while ($content = SQL_FETCHARRAY($result)) {
1738 $content['network_id'] . ', ' .
1739 $content['network_type_id'] . ", '" .
1740 $content['network_request_param_key'] . "', '" .
1741 $content['network_request_param_value'] . "', '";
1743 // Is the column NULL?
1744 if (is_null($content['network_request_param_default'])) {
1749 $SQL .= $content['network_request_param_default'] . "'),\n";
1753 // Remove last commata and close braces
1754 $SQL = substr($SQL, 0, -2) . '</pre>';
1757 SQL_FREERESULT($result);
1759 // Output the SQL query
1760 loadTemplate('admin_export_network_request_params', false, $SQL);
1763 // Exports (and displays) the table 'network_array_translation'
1764 function doAdminNetworkExportNetworkArrayTranslation () {
1765 // 'network_id' must be set
1766 if (!isGetRequestElementSet('network_id')) {
1767 // Only network API array index translations of one network will be exported per time
1768 debug_report_bug(__FUNCTION__, __LINE__, 'network_id not provided, please fix your links.');
1771 // Get all network types of given network
1772 $result = SQL_QUERY_ESC('SELECT
1775 `network_array_index`,
1778 `{?_MYSQL_PREFIX?}_network_array_translation`
1782 `network_type_id` ASC,
1785 bigintval(getRequestElement('network_id'))
1786 ), __FUNCTION__, __LINE__);
1788 // Start an empty SQL query
1789 $SQL = "<pre>INSERT INTO `{?_MYSQL_PREFIX?}_network_array_translation` (`network_id`,`network_type_id`,`network_array_index`,`sort`) VALUES\n";
1792 while ($content = SQL_FETCHARRAY($result)) {
1795 $content['network_id'] . ', ' .
1796 $content['network_type_id'] . ', ' .
1797 $content['network_array_index'] . ', ' .
1798 $content['sort'] . "),\n";
1801 // Remove last commata and close braces
1802 $SQL = substr($SQL, 0, -2) . '</pre>';
1805 SQL_FREERESULT($result);
1807 // Output the SQL query
1808 loadTemplate('admin_export_network_array_translation', false, $SQL);