+// ----------------------------------------------------------------------------
+// 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' => 'data',
+ // Network type handler
+ 'list_network_types' => 'types',
+ // Network request parameter
+ 'list_network_request_params' => 'request_params',
+ // Vcheck request parameter
+ 'list_network_vcheck_params' => 'vcheck_params',
+ // Network API response array index translation
+ 'list_network_array_translation' => 'array_translation',
+ );
+
+ // Is the 'what' key valid?
+ if (!isset($validExports[getWhat()])) {
+ // Not valid
+ reportBug(__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
+ reportBug(__FUNCTION__, __LINE__, 'Invalid call-back function ' . $callbackName . ' detected.');
+ } elseif (isset($GLOBALS[__FUNCTION__][$callbackName])) {
+ // Already called!
+ reportBug(__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 doAdminNetworkExportData () {
+ // 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`,
+ `network_active`
+FROM
+ `{?_MYSQL_PREFIX?}_network_data`
+ORDER BY
+ `network_id` ASC',
+ __FUNCTION__, __LINE__);
+
+ // Start an empty SQL query
+ $SQL = "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`,`network_active`) 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'] . ", '" .
+ $content['network_active'] . "'),\n";
+ } // END - while
+
+ // Remove last commata and close braces
+ $SQL = substr($SQL, 0, -2);
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output the SQL query
+ loadTemplate('admin_export_network_data', false, $SQL);
+}
+
+// Exports (and displays) the table 'network_types'
+function doAdminNetworkExportTypes () {
+ // 'network_id' must be set
+ if (!isGetRequestElementSet('network_id')) {
+ // Only network handlers of one network will be exported per time
+ reportBug(__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 = "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`,`network_type_reload_time_unit`) 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 .= chr(39) . $content['network_type_banner_url'] . chr(39);
+ }
+
+ // Add more
+ $SQL .= ",'" . $content['network_type_reload_time_unit'] . "'),\n";
+ } // END - while
+
+ // Remove last commata and close braces
+ $SQL = substr($SQL, 0, -2);
+
+ // 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 doAdminNetworkExportRequestParams () {
+ // 'network_id' must be set
+ if (!isGetRequestElementSet('network_id')) {
+ // Only network request parameters of one network will be exported per time
+ reportBug(__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 = "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 .= chr(39) . $content['network_request_param_default'] . "'),\n";
+ }
+ } // END - while
+
+ // Remove last commata and close braces
+ $SQL = substr($SQL, 0, -2);
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output the SQL query
+ loadTemplate('admin_export_network_request_params', false, $SQL);
+}
+
+// Exports (and displays) the table 'network_vcheck_params'
+function doAdminNetworkExportVcheckParams () {
+ // 'network_id' must be set
+ if (!isGetRequestElementSet('network_id')) {
+ // Only network vcheck parameters of one network will be exported per time
+ reportBug(__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_vcheck_param_key`,
+ `network_vcheck_param_value`,
+ `network_vcheck_param_default`
+FROM
+ `{?_MYSQL_PREFIX?}_network_vcheck_params`
+WHERE
+ `network_id`=%s
+ORDER BY
+ `network_vcheck_param_id` ASC',
+ array(
+ bigintval(getRequestElement('network_id'))
+ ), __FUNCTION__, __LINE__);
+
+ // Start an empty SQL query
+ $SQL = "INSERT INTO `{?_MYSQL_PREFIX?}_network_vcheck_params` (`network_id`,`network_vcheck_param_key`,`network_vcheck_param_value`,`network_vcheck_param_default`) VALUES\n";
+
+ // Load all entries
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Add row
+ $SQL .= '(' .
+ $content['network_id'] . ", '" .
+ $content['network_vcheck_param_key'] . "', '" .
+ $content['network_vcheck_param_value'] . "', ";
+
+ // Is the column NULL?
+ if (is_null($content['network_vcheck_param_default'])) {
+ // Column is NULL
+ $SQL .= "NULL),\n";
+ } else {
+ // Column is set
+ $SQL .= chr(39) . $content['network_vcheck_param_default'] . "'),\n";
+ }
+ } // END - while
+
+ // Remove last commata and close braces
+ $SQL = substr($SQL, 0, -2);
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output the SQL query
+ loadTemplate('admin_export_network_vcheck_params', false, $SQL);
+}
+
+// Exports (and displays) the table 'network_array_translation'
+function doAdminNetworkExportArrayTranslation () {
+ // 'network_id' must be set
+ if (!isGetRequestElementSet('network_id')) {
+ // Only network API array index translations of one network will be exported per time
+ reportBug(__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 = "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);
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Output the SQL query
+ loadTemplate('admin_export_network_array_translation', false, $SQL);
+}
+