+ return $networkRequestData;
+}
+
+// Updates given network (id) with data from array
+function doNetworkUpdateDataByArray ($id, $networkData) {
+ // Ids lower one are not accepted
+ if ($id < 1) {
+ // Not good, should be fixed
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network id ' . $id . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkData, '_network_data', sprintf("`network_id`=%s", bigintval($id)), array(), false, false);
+}
+
+// Updates given network type handler (id) with data from array
+function doNetworkUpdateTypeByArray ($id, $networkTypeData) {
+ // Ids lower one are not accepted
+ if ($id < 1) {
+ // Not good, should be fixed
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network type handler id ' . $id . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($id)), array(), false, false);
+}
+
+// Updates given network request parameters (id) with data from array
+function doNetworkUpdateParamsByArray ($id, $networkParamData) {
+ // Ids lower one are not accepted
+ if ($id < 1) {
+ // Not good, should be fixed
+ debug_report_bug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $id . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkParamData, '_network_request_params', sprintf("`network_param_id`=%s", bigintval($id)), array(), false, false);
+}
+
+// Removes given network entry
+function doAdminRemoveNetworkEntry ($table, $column, $id, $limit = 1) {
+ // Remove the entry
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_network_%s` WHERE `%s`=%s LIMIT %s",
+ array($table, $column, $id, $limit), __FUNCTION__, __LINE__);
+
+ // Return affected rows
+ return SQL_AFFECTEDROWS();
+}
+
+// Generates a list of networks for given script and returns it
+function generateAdminNetworkList () {
+ // Init output
+ $content = '';
+
+ // Query for all networks
+ $result = SQL_QUERY('SELECT
+ `network_id`, `network_short_name`, `network_title`
+FROM
+ `{?_MYSQL_PREFIX?}_network_data`
+ORDER BY
+ `network_short_name` ASC', __FUNCTION__, __LINE__);
+
+ // Do we have entries?
+ if (!SQL_HASZERONUMS($result)) {
+ // List all entries
+ $rows = array();
+ while ($row = SQL_FETCHARRAY($result)) {
+ // Is this valid, then add it
+ if ((is_array($row)) && (isset($row['network_id']))) {
+ // Add entry
+ $rows[$row['network_id']] = $row;
+ } // END - if
+ } // END - while
+
+ // Generate the selection box
+ $content = generateSelectionBoxFromArray($rows, 'network', 'network_id');
+ } else {
+ // Nothing selected
+ $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
+ }
+
+ // Free the result
+ SQL_FREERESULT($result);
+
+ // Return the list
+ return $content;
+}
+
+// Generator (somewhat getter) for a list of network types for given network id
+function generateAdminNetworkTypeList ($networkId) {
+ // Init content
+ $content = '';
+
+ // Query all types of this network
+ $result = SQL_QUERY_ESC("SELECT
+ `network_type_id`, `network_type_handle`
+FROM
+ `{?_MYSQL_PREFIX?}_network_types`
+WHERE
+ `network_id`=%s
+ORDER BY
+ `network_type_handle` ASC",
+ array(
+ bigintval($networkId)
+ ), __FUNCTION__, __LINE__);
+
+ // Do we have entries?
+ if (!SQL_HASZERONUMS($result)) {
+ // List all entries
+ $rows = array();
+ while ($row = SQL_FETCHARRAY($result)) {
+ // Is this valid, then add it
+ if ((is_array($row)) && (isset($row['network_type_id']))) {
+ // Add entry
+ $rows[$row['network_type_id']] = $row;
+ } // END - if
+ } // END - while
+
+ // Generate the selection box
+ $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id');
+ } else {
+ // Nothing selected
+ $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
+ }
+
+ // Free the result
+ SQL_FREERESULT($result);
+
+ // Return content
+ return $content;
+}
+
+// Generator (somewhat getter) for a list of network types for all types
+function generateAdminDistinctNetworkTypeList () {
+ // Init content
+ $content = '';
+
+ // Query all types of this network
+ $result = SQL_QUERY('SELECT
+ t.`network_type_id`, t.`network_type_handle`, d.`network_title`
+FROM
+ `{?_MYSQL_PREFIX?}_network_types` AS t
+LEFT JOIN
+ `{?_MYSQL_PREFIX?}_network_data` AS d
+ON
+ t.`network_id`=d.`network_id`
+ORDER BY
+ d.`network_short_name` ASC,
+ t.`network_type_handle` ASC', __FUNCTION__, __LINE__);
+
+ // Do we have entries?
+ if (!SQL_HASZERONUMS($result)) {
+ // List all entries
+ $rows = array();
+ while ($row = SQL_FETCHARRAY($result)) {
+ // Is this valid, then add it
+ if ((is_array($row)) && (isset($row['network_type_id']))) {
+ // Add entry
+ $rows[$row['network_type_id']] = $row;
+ } // END - if
+ } // END - while
+
+ // Generate the selection box
+ $content = generateSelectionBoxFromArray($rows, 'network_type', 'network_type_id', '', '_title');
+ } else {
+ // Nothing selected
+ $content = loadTemplate('admin_settings_unsaved', false, '{--ADMIN_ENTRIES_404--}');
+ }
+
+ // Free the result
+ SQL_FREERESULT($result);
+ //* DEBUG: */ die('<pre>'.encodeEntities($content).'</pre>');
+
+ // Return content
+ return $content;
+}
+
+// Generator (somewhat getter) for network type options
+function generateNetworkTypeOptions ($id) {
+ // Is this an array, then we just came back from edit/delete actions
+ if (is_array($id)) $id = '';
+
+ // Is this cached?
+ if (!isset($GLOBALS[__FUNCTION__][$id])) {
+ // Generate output and cache it
+ $GLOBALS[__FUNCTION__][$id] = generateOptionList(
+ 'network_types',
+ 'network_type_id',
+ 'network_type_handle',
+ $id,
+ '',
+ sprintf(
+ "WHERE `network_id`=%s",
+ bigintval(getRequestParameter('network'))
+ ),
+ '',
+ 'translateNetworkTypeHandler'
+ );
+ } // END - if
+
+ // Return content
+ return $GLOBALS[__FUNCTION__][$id];
+}
+
+// Generates an options list of all available (hard-coded) handlers
+function generateNetworkTypesAvailableOptions () {
+ // Is it cached?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Generate list
+ $GLOBALS[__FUNCTION__] = generateOptionList(
+ '/ARRAY/',
+ array(
+ 'banner',
+ 'banner_click',
+ 'banner_view',
+ 'button',
+ 'button_click',
+ 'button_view',
+ 'surfbar',
+ 'surfbar_click',
+ 'surfbar_view',
+ 'forcedbanner',
+ 'forcedtextlink',
+ 'textlink',
+ 'textlink_click',
+ 'textlink_view',
+ 'skybanner',
+ 'skybanner_click',
+ 'skybanner_view',
+ 'layer',
+ 'layer_click',
+ 'layer_view',
+ 'popup',
+ 'popdown',
+ 'textmail',
+ 'htmlmail',
+ 'lead',
+ 'sale',
+ 'payperactive',
+ 'pagepeel',
+ 'traffic'
+ ),
+ array(),
+ '',
+ '', '',
+ $GLOBALS['network_types_disabled'],
+ 'translateNetworkTypeHandler'
+ );
+ } // END - if
+
+ // Return content
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Generates an options list (somewhat getter) ofr request keys
+function generateNetworkRequestKeyOptions () {
+ // Is it cached?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Generate and cache it
+ $GLOBALS[__FUNCTION__] = generateOptionList(
+ '/ARRAY/',
+ array(
+ 'id',
+ 'sid',
+ 'hash',
+ 'password',
+ 'reload',
+ 'maximum_stay',
+ 'minimum_stay',
+ 'currency',
+ 'type',
+ 'remain',
+ 'reward',
+ 'size',
+ 'erotic',
+ 'extra',
+ 'country'
+ ),
+ array(),
+ '',
+ '', '',
+ $GLOBALS['network_params_disabled'],
+ 'translateNetworkRequestParameter'
+ );
+ } // END - if
+
+ // Return content
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Generator (somewhat getter) for (return) array translation
+function generateNetworkTranslationOptions ($default = '') {
+ // Is it cached?
+ if (!isset($GLOBALS[__FUNCTION__][$default])) {
+ // Generate and cache it
+ $GLOBALS[__FUNCTION__][$default] = generateOptionList(
+ 'network_translations',
+ 'network_translation_id',
+ 'network_translation_name',
+ $default,
+ '',
+ '',
+ $GLOBALS['network_translation_disabled'],
+ 'translateNetworkTranslationName'
+ );
+ } // END - if
+
+ // Return content
+ return $GLOBALS[__FUNCTION__][$default];
+}
+
+// Generates an option list of request types
+function generateNetworkRequestTypeOptions ($default = '') {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$default])) {
+ // Generate the list
+ $GLOBALS[__FUNCTION__][$default] = generateOptionList(
+ '/ARRAY/',
+ array(
+ 'GET',
+ 'POST'
+ ),
+ array(
+ '{--ADMIN_NETWORK_REQUEST_TYPE_GET--}',
+ '{--ADMIN_NETWORK_REQUEST_TYPE_POST--}'
+ ),
+ $default
+ );
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$default];
+}
+
+// Generates an option list of network_active
+function generateNetworkActiveOptions ($default = '') {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$default])) {
+ // Generate the list
+ $GLOBALS[__FUNCTION__][$default] = generateOptionList(
+ '/ARRAY/',
+ array(
+ 'Y',
+ 'N'
+ ),
+ array(
+ '{--YES--}',
+ '{--NO--}'
+ ),
+ $default
+ );
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$default];
+}
+
+// Translates 'translate_name' for e.g. templates
+function translateNetworkTranslationName ($name) {
+ // Get the message id
+ return getMessage('ADMIN_NETWORK_TRANSLATE_' . strtoupper($name) . '_NAME');
+}
+
+// Translates the network type handler (e.g. banner, paidmail) for templates
+function translateNetworkTypeHandler ($type) {
+ // Get the message id
+ return getMessage('ADMIN_NETWORK_TYPES_' . strtoupper($type) . '');
+}
+
+// Translates request type
+function translateNetworkRequestType ($type) {
+ // Get the message id
+ return getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($type) . '');
+}
+
+// Translates request parameter
+function translateNetworkRequestParameter ($param) {
+ // Get the message id
+ return getMessage('ADMIN_NETWORK_REQUEST_PARAMETER_' . strtoupper($param) . '');
+}
+
+// Translates API index
+function translateNetworkApiIndex ($index) {
+ // Do we have cache?
+ if (!isset($GLOBALS['network_api_index'])) {
+ // Get an array of all API array indexes
+ $GLOBALS['network_api_index'] = array();
+
+ // Get all entries
+ $result = SQL_QUERY('SELECT
+ `network_api_id`, `network_api_index`, `network_translation_name`
+FROM
+ `{?_MYSQL_PREFIX?}_network_api_translation`
+INNER JOIN
+ `{?_MYSQL_PREFIX?}_network_translations`
+ON
+ `network_api_index`=`network_translation_id`
+ORDER BY
+ `sort` ASC', __FUNCTION__, __LINE__);
+
+ // Do we have entries?
+ if (SQL_NUMROWS($result) > 0) {
+ // Get all entries
+ while ($row = SQL_FETCHARRAY($result)) {
+ // Add it to our global array
+ $GLOBALS['network_api_index'][$row['network_api_index']] = $row;
+ } // END - while
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+ } // END - if
+
+ // Default name is unknown
+ $name = 'unknown';
+
+ // Is the entry there?
+ if (isset($GLOBALS['network_api_index'][$index])) {
+ // Then get the name
+ $name = $GLOBALS['network_api_index'][$index]['network_translation_name'];
+ } // END - if
+
+ // Return translation
+ return translateNetworkTranslationName($name);