+// Changes given network type handlers
+function doAdminNetworkProcessChangeHandlerTypes () {
+ // Do we have selections?
+ if (ifPostContainsSelections()) {
+ // By default nothing is updated
+ $updated = 0;
+
+ // Something has been selected, so start updating them
+ foreach (postRequestElement('sel') as $networkId => $sel) {
+ // Update this entry?
+ if ($sel == 1) {
+ // Init data array
+ $networkTypeData = array();
+
+ // Transfer whole array, except 'sel'
+ foreach (postRequestArray() as $key => $entry) {
+ // Skip 'sel' and submit button
+ if (in_array($key, array('sel', 'do_edit'))) {
+ continue;
+ } // END - if
+
+ // Do we have this enty?
+ if (!isset($entry[$networkId])) {
+ // Not found, needs fixing
+ debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $networkId . ' found.');
+ } // END - if
+
+ // Fix empty network_type_banner_url to NULL
+ if (($key == 'network_type_banner_url') && (trim($entry[$networkId]) == '')) {
+ // Set it to NULL
+ $entry[$networkId] = NULL;
+ } // END - if
+
+ // Add this entry
+ $networkTypeData[$key] = $entry[$networkId];
+ } // END - foreach
+
+ // Update the network data
+ $updated += doNetworkUpdateTypeByArray($networkId, $networkTypeData);
+ } // END - if
+ } // END - foreach
+
+ // Do we have updates?
+ if ($updated > 0) {
+ // Updates done
+ displayMessage('{%message,ADMIN_NETWORK_TYPE_HANDLER_UPDATED=' . $updated . '%}');
+ } else {
+ // Nothing changed
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPE_HANDLER_NOTHING_CHANGED--}');
+ }
+ } // END - if
+}
+
+// Changes given network request parameters
+function doAdminNetworkProcessChangeRequestParams () {
+ // Do we have selections?
+ if (ifPostContainsSelections()) {
+ // By default nothing is updated
+ $updated = 0;
+
+ // Something has been selected, so start updating them
+ foreach (postRequestElement('sel') as $networkId => $sel) {
+ // Update this entry?
+ if ($sel == 1) {
+ // Init data array
+ $networkParamsData = array();
+
+ // Transfer whole array, except 'sel'
+ foreach (postRequestArray() as $key => $entry) {
+ // Skip 'sel' and submit button
+ if (in_array($key, array('sel', 'do_edit'))) {
+ continue;
+ } // END - if
+
+ // Do we have this enty?
+ if (!isset($entry[$networkId])) {
+ // Not found, needs fixing
+ debug_report_bug(__FUNCTION__, __LINE__, 'No entry in key=' . $key . ', id=' . $networkId . ' found.');
+ } // END - if
+
+ // Fix empty network_request_param_default to NULL
+ if (($key == 'network_request_param_default') && (trim($entry[$networkId]) == '')) {
+ // Set it to NULL
+ $entry[$networkId] = NULL;
+ } // END - if
+
+ // Add this entry
+ $networkParamsData[$key] = $entry[$networkId];
+ } // END - foreach
+
+ // Update the network data
+ $updated += doNetworkUpdateParamsByArray($networkId, $networkParamsData);
+ } // END - if
+ } // END - foreach
+
+ // Do we have updates?
+ if ($updated > 0) {
+ // Updates done
+ displayMessage('{%message,ADMIN_NETWORK_REQUEST_PARAMETER_UPDATED=' . $updated . '%}');
+ } else {
+ // Nothing changed
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_CHANGED--}');
+ }
+ } // END - if
+}
+
+// Removes given network type handlers
+function doAdminNetworkProcessRemoveNetworkTypes () {
+ // Do we have selections?
+ if (ifPostContainsSelections()) {
+ // By default nothing is removed
+ $removed = 0;
+
+ // Something has been selected, so start updating them
+ foreach (postRequestElement('sel') as $networkId => $sel) {
+ // Update this entry?
+ if ($sel == 1) {
+ // Remove this entry
+ $removed += doAdminRemoveNetworkEntry('types', 'network_type_id', $networkId);
+ } // END - if
+ } // END - foreach
+
+ // Do we have removes?
+ if ($removed > 0) {
+ // Removals done
+ displayMessage('{%message,ADMIN_NETWORK_TYPE_HANDLER_REMOVED=' . $removed . '%}');
+ } else {
+ // Nothing removed
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_TYPE_HANDLER_NOTHING_REMOVED--}');
+ }
+ } // END - if
+}
+
+// Removes given network request parameters
+function doAdminNetworkProcessRemoveNetworkRequestParams () {
+ // Do we have selections?
+ if (ifPostContainsSelections()) {
+ // By default nothing is removed
+ $removed = 0;
+
+ // Something has been selected, so start updating them
+ foreach (postRequestElement('sel') as $networkId => $sel) {
+ // Update this entry?
+ if ($sel == 1) {
+ // Remove this entry
+ $removed += doAdminRemoveNetworkEntry('request_params', 'network_request_param_id', $networkId);
+ } // END - if
+ } // END - foreach
+
+ // Do we have removes?
+ if ($removed > 0) {
+ // Removals done
+ displayMessage('{%message,ADMIN_NETWORK_REQUEST_PARAMETER_REMOVED=' . $removed . '%}');
+ } else {
+ // Nothing removed
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_NETWORK_REQUEST_PARAMETER_NOTHING_REMOVED--}');
+ }
+ } // END - if
+}
+
+// Adds a request parameter to given network and type
+function doAdminNetworkProcessAddRequestParam () {
+ // Is the request parameter already used with given network?
+ if (isNetworkRequestElementValid(postRequestElement('network_request_param_key'), postRequestElement('network_type_id'), getRequestElement('network_id'))) {
+ // Already added
+ loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_REQUEST_PARAMETER_ALREADY_ADDED=' . postRequestElement('network_request_param_key') . '%}');
+
+ // ... so abort here
+ return false;
+ } // END - if
+
+ // Remove the 'ok' part
+ unsetPostRequestElement('ok');
+
+ // Add id
+ setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
+
+ // Is network_request_param_default set?
+ if (postRequestElement('network_request_param_default') == '') {
+ // Remove empty value to get a NULL for an optional entry
+ unsetPostRequestElement('network_request_param_default');
+ } // END - if
+
+ // Add the whole request to database
+ SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_request_params'), __FUNCTION__, __LINE__);
+
+ // Output message
+ if (!SQL_HASZEROAFFECTED()) {
+ // Successfully added
+ loadTemplate('admin_network_request_param_added', false, postRequestArray());
+ } else {
+ // Not added
+ loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_REQUEST_PARAMETER_NOT_ADDED=' . postRequestElement('network_request_param_key') . '%}');
+ }
+}
+
+// Adds a API response array entry
+function doAdminNetworkProcessAddNetworkArrayTranslation () {
+ // Is the request parameter already used with given network?
+ if (isNetworkArrayTranslationValid(postRequestElement('network_array_index'), postRequestElement('network_type_id'), getRequestElement('network_id'))) {
+ // Already added
+ loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_ARRAY_TRANSLATION_ALREADY_ADDED=' . postRequestElement('network_array_index') . '%}');
+
+ // ... so abort here
+ return false;
+ } // END - if
+
+ // Remove the 'ok' part
+ unsetPostRequestElement('ok');
+
+ // Add id
+ setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
+
+ // Add sorting
+ setPostRequestElement('sort', (countSumTotalData(
+ bigintval(postRequestElement('network_id')),
+ 'network_array_translation',
+ 'network_array_id',
+ 'network_id',
+ true,
+ sprintf(" AND `network_type_id`=%s", bigintval(postRequestElement('network_type_id')))
+ ) + 1));
+
+ // Add the whole request to database
+ SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_array_translation'), __FUNCTION__, __LINE__);
+
+ // Output message
+ if (!SQL_HASZEROAFFECTED()) {
+ // Successfully added
+ loadTemplate('admin_network_array_translation_added', false, postRequestArray());
+ } else {
+ // Not added
+ loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_ARRAY_TRANSLATION_NOT_ADDED=' . postRequestElement('network_array_index') . '%}');
+ }
+}
+
+// Adds/update network API configuration
+function doAdminNetworkProcessNetworkApiConfig () {
+ // Remove the 'ok' part
+ unsetPostRequestElement('ok');
+
+ // Add id
+ setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
+
+ // Is network_api_referral_button set?
+ if (postRequestElement('network_api_referral_button') == '') {
+ // Remove empty value to get a NULL for an optional entry
+ unsetPostRequestElement('network_api_referral_button');
+ } // END - if
+
+ // Is there already an entry?
+ if (isNetworkApiConfigured(getRequestElement('network_id'))) {
+ // Generate SQL query
+ $SQL = getUpdateSqlFromArray(postRequestArray(), 'network_api_config', 'network_id', postRequestElement('network_id'), array('network_id'));
+ } else {
+ // Insert new entry
+ $SQL = getInsertSqlFromArray(postRequestArray(), 'network_api_config');
+ }
+
+ // Run the query
+ SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+
+ // Output message
+ if (!SQL_HASZEROAFFECTED()) {
+ // Successfully added
+ displayMessage('{--ADMIN_CONFIG_NETWORK_API_SAVED--}');
+ } else {
+ // Not added
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_API_NOT_SAVED--}');
+ }
+}
+
+// Only adds network type configuration if not yet present
+function doAdminNetworkProcessAddHandlerTypesConfig ($displayMessage = true) {
+ // Remove the 'ok' part
+ unsetPostRequestElement('ok');
+
+ // Add both ids
+ setPostRequestElement('network_id', bigintval(getRequestElement('network_id')));
+ setPostRequestElement('network_type_id', bigintval(getRequestElement('network_type_id')));
+
+ /*
+ * Some parameters are optional, at least one must be given so check a bunch
+ * of parameters.
+ */
+ foreach (array('network_min_waiting_time', 'network_min_remain_clicks', 'network_min_payment', 'network_allow_erotic') as $element) {
+ // Is this element empty?
+ if (postRequestElement($element) == '') {
+ // Then unset it to get a NULL for optional parameter
+ unsetPostRequestElement($element);
+ } // END - if
+ } // END - foreach
+
+ // Initialize variables
+ $content = array();
+ $id = 'network_max_reload_time_ye';
+ $skip = false;
+
+ // Get all POST data
+ $postData = postRequestArray();
+
+ // Convert "reload time selections"
+ convertSelectionsToEpocheTime($postData, $content, $id, $skip);
+
+ // Set the POST array back
+ setPostRequestArray($postData);
+
+ // Is there already an entry?
+ if (isNetworkTypeHandlerConfigured(getRequestElement('network_id'), getRequestElement('network_type_id'))) {
+ // This network type handler is already configured
+ displayMessage('{--ADMIN_NETWORK_HANDLER_TYPE_HANDLER_ALREADY_CONFIGURED--}');
+ return;
+ } // END - if
+
+ // Copy 'set all' and remove it from POST data
+ $setAll = (postRequestElement('set_all') === 'Y');
+ unsetPostRequestElement('set_all');
+
+ // Shall we set for all?
+ if ($setAll === true) {
+ // Get all handlers
+ $result = SQL_QUERY_ESC('SELECT `network_type_id` FROM `{?_MYSQL_PREFIX?}_network_types` WHERE `network_id`=%s ORDER BY `network_type_id` ASC',
+ array(bigintval(getRequestElement('network_id'))), __FUNCTION__, __LINE__);
+
+ // Do we have entries?
+ if (SQL_HASZERONUMS($result)) {
+ // No, then abort here
+ displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL_404--}');
+ return;
+ } // END - if
+
+ // Init number of rows
+ $numRows = 0;
+
+ // Fetch all ids
+ while (list($typeId) = SQL_FETCHROW($result)) {
+ // Set it in GET data
+ setGetRequestElement('network_type_id', $typeId);
+
+ // Call this function again
+ $numRows += doAdminNetworkProcessAddHandlerTypesConfig(false);
+ } // END - while
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output message
+ if ($numRows > 0) {
+ // Something has been updated
+ displayMessage('{%message,ADMIN_CONFIG_NETWORK_HANDLER_TYPE_ALL_HANDLER_SAVED=' . bigintval($numRows) . '%}');
+ } else {
+ // Nothing has been saved
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_CHANGED--}');
+ }
+ } else {
+ // Get SQL query for new entry
+ $SQL = getInsertSqlFromArray(postRequestArray(), 'network_types_config');
+
+ // Run the query
+ SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+
+ // Shall we display the message?
+ if ($displayMessage === true) {
+ // Output message
+ if (!SQL_HASZEROAFFECTED()) {
+ // Successfully added
+ displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_SAVED--}');
+ } else {
+ // Not added
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_SAVED--}');
+ }
+ } else {
+ // Return amount of affected rows (1 or 2)
+ return SQL_AFFECTEDROWS();
+ }
+ }
+}
+
+// Only changes network type configuration if not yet present
+function doAdminNetworkProcessEditHandlerTypesConfig ($displayMessage = true) {
+ // Remove the 'ok' part
+ unsetPostRequestElement('ok');
+
+ /*
+ * Some parameters are optional, at least one must be given so check a bunch
+ * of parameters.
+ */
+ foreach (array('network_min_waiting_time', 'network_min_remain_clicks', 'network_min_payment', 'network_allow_erotic') as $element) {
+ // Is this element empty?
+ if (postRequestElement($element) == '') {
+ // Then unset it to get a NULL for optional parameter
+ unsetPostRequestElement($element);
+ } // END - if
+ } // END - foreach
+
+ // Initialize variables
+ $content = array();
+ $id = 'network_max_reload_time_ye';
+ $skip = false;
+ $postData = postRequestArray();
+
+ // Convert "reload time selections"
+ convertSelectionsToEpocheTime($postData, $content, $id, $skip);
+
+ // Set the POST array back
+ setPostRequestArray($postData);
+
+ // Is there already an entry?
+ if (!isNetworkTypeHandlerConfigured(getRequestElement('network_id'), getRequestElement('network_type_id'))) {
+ // This network type handler is not configured
+ displayMessage('{--ADMIN_NETWORK_HANDLER_TYPE_HANDLER_NOT_CONFIGURED--}');
+ return;
+ } // END - if
+
+ // Copy 'set all' and remove it from POST data
+ $setAll = (postRequestElement('set_all') === 'Y');
+ unsetPostRequestElement('set_all');
+
+ // Shall we set for all?
+ if ($setAll === true) {
+ // Get all data entries
+ $result = SQL_QUERY_ESC('SELECT `network_data_id` FROM `{?_MYSQL_PREFIX?}_network_types_config` WHERE `network_id`=%s ORDER BY `network_type_id` ASC',
+ array(bigintval(getRequestElement('network_id'))), __FUNCTION__, __LINE__);
+
+ // Do we have entries?
+ if (SQL_HASZERONUMS($result)) {
+ // No, then abort here
+ displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_SET_ALL_404--}');
+ return;
+ } // END - if
+
+ // Init number of rows
+ $numRows = 0;
+
+ // Fetch all ids
+ while (list($dataId) = SQL_FETCHROW($result)) {
+ // Set it in GET data
+ setPostRequestElement('network_data_id', $dataId);
+
+ // Call this function again
+ $numRows += doAdminNetworkProcessEditHandlerTypesConfig(false);
+ } // END - while
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output message
+ if ($numRows > 0) {
+ // Something has been updated
+ displayMessage('{%message,ADMIN_CONFIG_NETWORK_HANDLER_TYPE_ALL_HANDLER_SAVED=' . bigintval($numRows) . '%}');
+ } else {
+ // Nothing has been saved
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_CHANGED--}');
+ }
+ } else {
+ // Get SQL query for new entry
+ $SQL = getUpdateSqlFromArray(postRequestArray(), 'network_types_config', 'network_data_id', postRequestElement('network_data_id'), array('network_data_id'));
+
+ // Run the query
+ SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+
+ // Shall we display the message?
+ if ($displayMessage === true) {
+ // Output message
+ if (!SQL_HASZEROAFFECTED()) {
+ // Successfully added
+ displayMessage('{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_SAVED--}');
+ } else {
+ // Not added
+ loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CONFIG_NETWORK_HANDLER_TYPE_HANDLER_NOT_CHANGED--}');
+ }
+ } else {
+ // Return amount of affected rows (1 or 2)
+ return SQL_AFFECTEDROWS();
+ }
+ }
+}
+
+// Do expression code for this extension
+function doExpressionNetwork ($data) {
+ // Construct replacer
+ $replacer = sprintf(
+ "{DQUOTE} . %s(%s, '%s') . {DQUOTE}",
+ $data['callback'],
+ $data['matches'][4][$data['key']],
+ $data['extra_func']
+ );
+
+ // Replace %network_id% with the current network id
+ $replacer = str_replace('%network_id%', getCurrentNetworkId(), $replacer);
+
+ // Replace the code
+ $code = replaceExpressionCode($data, $replacer);
+
+ // Return it
+ return $code;
+}
+
+// ----------------------------------------------------------------------------
+// Call-back functions for exporting data
+// ----------------------------------------------------------------------------
+
+// Callback function to export network tables
+function doAdminNetworkProcessExport () {
+ // Init table with all valid what->table entries
+ $validExports = array(
+ // General network data
+ 'list_networks' => 'network_data',
+ // Network type handler
+ 'list_network_types' => 'network_types',
+ // Network request parameter
+ 'list_network_request_params' => 'network_request_params',
+ // Network API response array index translation
+ 'list_network_array_translation' => 'network_array_translation',
+ );
+
+ // Is the 'what' key valid?
+ if (!isset($validExports[getWhat()])) {
+ // Not valid
+ debug_report_bug(__FUNCTION__, __LINE__, 'what=' . getWhat() . ' - not supported');
+ } // END - if
+
+ // Generate call-back, some tables require to export not all columns
+ $callbackName = 'doAdminNetworkExport' . capitalizeUnderscoreString($validExports[getWhat()]);
+
+ // Is the call-back function there?
+ if (!function_exists($callbackName)) {
+ // No, this is really bad
+ debug_report_bug(__FUNCTION__, __LINE__, 'Invalid call-back function ' . $callbackName . ' detected.');
+ } elseif (isset($GLOBALS[__FUNCTION__][$callbackName])) {
+ // Already called!
+ debug_report_bug(__FUNCTION__, __LINE__, 'Double-call of export function ' . $callbackName . ' detected.');
+ }
+
+ // Call the function
+ call_user_func($callbackName);
+
+ // Mark it as called
+ $GLOBALS[__FUNCTION__][$callbackName] = true;
+
+ // Don't display the list/add new form
+ $GLOBALS['network_display'] = false;
+}
+
+// Exports (and displays) the table 'network_data'
+function doAdminNetworkExportNetworkData () {
+ // Query for all networks
+ $result = SQL_QUERY('SELECT
+ `network_short_name`,
+ `network_title`,
+ `network_reflink`,
+ `network_data_separator`,
+ `network_row_separator`,
+ `network_request_type`,
+ `network_charset`,
+ `network_require_id_card`,
+ `network_query_amount`
+FROM
+ `{?_MYSQL_PREFIX?}_network_data`
+ORDER BY
+ `network_id` ASC',
+ __FUNCTION__, __LINE__);
+
+ // Start an empty SQL query
+ $SQL = "<pre>INSERT INTO `{?_MYSQL_PREFIX?}_network_data` (`network_short_name`,`network_title`,`network_reflink`,`network_data_separator`,`network_row_separator`,`network_request_type`,`network_charset`,`network_require_id_card`,`network_query_amount`) VALUES\n";
+
+ // Load all entries
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Add row
+ $SQL .= "('" .
+ $content['network_short_name'] . "', '" .
+ $content['network_title'] . "', '" .
+ $content['network_reflink'] . "', '" .
+ $content['network_data_separator'] . "', '" .
+ $content['network_row_separator'] . "', '" .
+ $content['network_request_type'] . "', '" .
+ $content['network_charset'] . "', '" .
+ $content['network_require_id_card'] . "', " .
+ $content['network_query_amount'] . "),\n";
+ } // END - while
+
+ // Remove last commata and close braces
+ $SQL = substr($SQL, 0, -2) . '</pre>';
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output the SQL query
+ loadTemplate('admin_export_network_data', false, $SQL);
+}
+
+// Exports (and displays) the table 'network_types'
+function doAdminNetworkExportNetworkTypes () {
+ // 'network_id' must be set
+ if (!isGetRequestElementSet('network_id')) {
+ // Only network handlers of one network will be exported per time
+ debug_report_bug(__FUNCTION__, __LINE__, 'network_id not provided, please fix your links.');
+ } // END - if
+
+ // Get all network types of given network
+ $result = SQL_QUERY_ESC('SELECT
+ `network_type_id`,
+ `network_id`,
+ `network_type_handler`,
+ `network_type_api_url`,
+ `network_type_click_url`,
+ `network_type_banner_url`,
+ `network_type_reload_time_unit`
+FROM
+ `{?_MYSQL_PREFIX?}_network_types`
+WHERE
+ `network_id`=%s
+ORDER BY
+ `network_type_id` ASC',
+ array(
+ bigintval(getRequestElement('network_id'))
+ ), __FUNCTION__, __LINE__);
+
+ // Start an empty SQL query
+ $SQL = "<pre>INSERT INTO `{?_MYSQL_PREFIX?}_network_types` (`network_type_id`,`network_id`,`network_type_handler`,`network_type_api_url`,`network_type_click_url`,`network_type_banner_url`) VALUES\n";
+
+ // Load all entries
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Add row
+ $SQL .= '(' .
+ $content['network_type_id'] . ', ' .
+ $content['network_id'] . ", '" .
+ $content['network_type_handler'] . "', '" .
+ $content['network_type_api_url'] . "', '" .
+ $content['network_type_click_url'] . "', ";
+
+ // Is the column NULL?
+ if (is_null($content['network_type_banner_url'])) {
+ // Column is NULL
+ $SQL .= 'NULL';
+ } else {
+ // Column is set
+ $SQL .= "'" . $content['network_type_banner_url'] . "'";
+ }
+
+ // Add more
+ $SQL .= $content['network_type_reload_time_unit'] . "')\n";
+ } // END - while
+
+ // Remove last commata and close braces
+ $SQL = substr($SQL, 0, -2) . '</pre>';
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output the SQL query
+ loadTemplate('admin_export_network_types', false, $SQL);
+}
+
+// Exports (and displays) the table 'network_request_params'
+function doAdminNetworkExportNetworkRequestParams () {
+ // 'network_id' must be set
+ if (!isGetRequestElementSet('network_id')) {
+ // Only network request parameters of one network will be exported per time
+ debug_report_bug(__FUNCTION__, __LINE__, 'network_id not provided, please fix your links.');
+ } // END - if
+
+ // Get all network types of given network
+ $result = SQL_QUERY_ESC('SELECT
+ `network_id`,
+ `network_type_id`,
+ `network_request_param_key`,
+ `network_request_param_value`,
+ `network_request_param_default`
+FROM
+ `{?_MYSQL_PREFIX?}_network_request_params`
+WHERE
+ `network_id`=%s
+ORDER BY
+ `network_type_id` ASC ,
+ `network_request_param_id` ASC',
+ array(
+ bigintval(getRequestElement('network_id'))
+ ), __FUNCTION__, __LINE__);
+
+ // Start an empty SQL query
+ $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";
+
+ // Load all entries
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Add row
+ $SQL .= '(' .
+ $content['network_id'] . ', ' .
+ $content['network_type_id'] . ", '" .
+ $content['network_request_param_key'] . "', '" .
+ $content['network_request_param_value'] . "', ";
+
+ // Is the column NULL?
+ if (is_null($content['network_request_param_default'])) {
+ // Column is NULL
+ $SQL .= "NULL),\n";
+ } else {
+ // Column is set
+ $SQL .= "'" . $content['network_request_param_default'] . "'),\n";
+ }
+ } // END - while
+
+ // Remove last commata and close braces
+ $SQL = substr($SQL, 0, -2) . '</pre>';
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output the SQL query
+ loadTemplate('admin_export_network_request_params', false, $SQL);
+}
+
+// Exports (and displays) the table 'network_array_translation'
+function doAdminNetworkExportNetworkArrayTranslation () {
+ // 'network_id' must be set
+ if (!isGetRequestElementSet('network_id')) {
+ // Only network API array index translations of one network will be exported per time
+ debug_report_bug(__FUNCTION__, __LINE__, 'network_id not provided, please fix your links.');
+ } // END - if
+
+ // Get all network types of given network
+ $result = SQL_QUERY_ESC('SELECT
+ `network_id`,
+ `network_type_id`,
+ `network_array_index`,
+ `sort`
+FROM
+ `{?_MYSQL_PREFIX?}_network_array_translation`
+WHERE
+ `network_id`=%s
+ORDER BY
+ `network_type_id` ASC,
+ `sort` ASC',
+ array(
+ bigintval(getRequestElement('network_id'))
+ ), __FUNCTION__, __LINE__);
+
+ // Start an empty SQL query
+ $SQL = "<pre>INSERT INTO `{?_MYSQL_PREFIX?}_network_array_translation` (`network_id`,`network_type_id`,`network_array_index`,`sort`) VALUES\n";
+
+ // Load all entries
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Add row
+ $SQL .= '(' .
+ $content['network_id'] . ', ' .
+ $content['network_type_id'] . ', ' .
+ $content['network_array_index'] . ', ' .
+ $content['sort'] . "),\n";
+ } // END - while
+
+ // Remove last commata and close braces
+ $SQL = substr($SQL, 0, -2) . '</pre>';
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output the SQL query
+ loadTemplate('admin_export_network_array_translation', false, $SQL);
+}
+