+// Updates given network type handler (id) with data from array
+function doNetworkUpdateTypeByArray ($networkTypeId, $networkTypeData) {
+ // Ids lower one are not accepted
+ if (!isValidId($networkTypeId)) {
+ // Not good, should be fixed
+ reportBug(__FUNCTION__, __LINE__, 'Network type handler id ' . $networkTypeId . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkTypeData, '_network_types', sprintf("`network_type_id`=%s", bigintval($networkTypeId)), array(), FALSE, FALSE);
+}
+
+// Updates given network request parameters (id) with data from array
+function doNetworkUpdateParamsByArray ($networkParamsId, $networkParamsData) {
+ // Ids lower one are not accepted
+ if (!isValidId($networkParamsId)) {
+ // Not good, should be fixed
+ reportBug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $networkParamsId . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkParamsData, '_network_request_params', sprintf("`network_request_param_id`=%s", bigintval($networkParamsId)), array(), FALSE, FALSE);
+}
+
+// Updates given network array translations (id) with data from array
+function doNetworkUpdateArrayTranslationsByArray ($networkTranslationsId, $networkTranslationsData) {
+ // Ids lower one are not accepted
+ if (!isValidId($networkTranslationsId)) {
+ // Not good, should be fixed
+ reportBug(__FUNCTION__, __LINE__, 'Network request parameter id ' . $networkTranslationsId . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkTranslationsData, '_network_array_translation', sprintf("`network_array_id`=%s", bigintval($networkTranslationsId)), array(), FALSE, FALSE);
+}
+
+//------------------------------------------------------------------------------
+// Call-back functions for request parameter keys
+//------------------------------------------------------------------------------
+
+// ----------------------- Table: network_api_config -----------------------
+
+// Handles affiliate id
+function doHandleNetworkRequestAffiliateIdKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ } elseif (empty($configData['network_api_affiliate_id'])) {
+ // Required element is not set
+ reportBug(__FUNCTION__, __LINE__, 'network_api_affiliate_id for network_id=' . $configData['network_id'] . ',networkTypeId=' . $networkTypeId . ' is not set.');
+ }
+
+ // Return configured value
+ return $configData['network_api_affiliate_id'];
+}
+
+// Handles site id
+function doHandleNetworkRequestSiteIdKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ } elseif (empty($configData['network_api_site_id'])) {
+ // Required element is not set
+ reportBug(__FUNCTION__, __LINE__, 'network_api_site_id for network_id=' . $configData['network_id'] . ',networkTypeId=' . $networkTypeId . ' is not set.');
+ }
+
+ // Return configured value
+ return $configData['network_api_site_id'];
+}
+
+// Handles interface password
+function doHandleNetworkRequestPasswordKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ } elseif (empty($configData['network_api_password'])) {
+ // Required element is not set
+ reportBug(__FUNCTION__, __LINE__, 'network_api_password for network_id=' . $configData['network_id'] . ',networkTypeId=' . $networkTypeId . ' is not set.');
+ }
+
+ // Return configured value
+ return $configData['network_api_password'];
+}
+
+// ----------------------- Table: network_handler_config -----------------------
+
+// Handles reload lock
+function doHandleNetworkRequestReloadKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ }
+
+ // Return configured value
+ return caluculateTimeUnitValue($configData['network_max_reload_time'], $configData['network_type_reload_time_unit']);
+}
+
+// Handles minimum stay
+function doHandleNetworkRequestMinimumStayKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ }
+
+ // Return configured value
+ return $configData['network_min_waiting_time'];
+}
+
+// Handles maximum stay
+function doHandleNetworkRequestMaximumStayKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ }
+
+ // Return configured value
+ return $configData['network_max_waiting_time'];
+}
+
+// Handles remaining clicks
+function doHandleNetworkRequestRemainClicksKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ }
+
+ // Return configured value
+ return $configData['network_min_remain_clicks'];
+}
+
+// Handles remaining budget
+function doHandleNetworkRequestRemainBudgetKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ }
+
+ // Return configured value
+ return $configData['network_min_remain_budget'];
+}
+
+// Handles reward (payment)
+function doHandleNetworkRequestRewardKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ } elseif (empty($configData['network_min_payment'])) {
+ // Required element is not set
+ reportBug(__FUNCTION__, __LINE__, 'network_min_payment for network_id=' . $configData['network_id'] . ',networkTypeId=' . $networkTypeId . ' is not set.');
+ }
+
+ // Return configured value
+ return $configData['network_min_payment'];
+}
+
+// Handles media size
+function doHandleNetworkRequestSizeKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ } elseif (empty($configData['network_media_size'])) {
+ // Required element is not set
+ reportBug(__FUNCTION__, __LINE__, 'network_media_size for network_id=' . $configData['network_id'] . ',networkTypeId=' . $networkTypeId . ' is not set.');
+ }
+
+ // Return configured value
+ return $configData['network_media_size'];
+}
+
+// Handles media output (type)
+function doHandleNetworkRequestTypeKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ }
+
+ // Return configured value
+ return $configData['network_media_output'];
+}
+
+// Handles erotic
+function doHandleNetworkRequestEroticKey ($networkTypeId) {
+ // It is assumed that the network + type handler are both configured
+ // Load full config data (this will be "cached"!)
+ $configData = getFullNetworkConfigurationByTypeId($networkTypeId);
+
+ // Is the network activated?
+ if (!isset($configData['network_api_active'])) {
+ // Configuration could not be loaded
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for networkTypeId=' . $networkTypeId . ' could not be loaded.');
+ } elseif (($configData['network_api_active'] == 'N') && (!isDebugModeEnabled())) {
+ // Is not activated, so don't handle it in non-debug mode
+ reportBug(__FUNCTION__, __LINE__, 'Configuration for network_id ' . $configData['network_id'] .',networkTypeId=' . $networkTypeId . ' is not activated.');
+ } elseif (empty($configData['network_allow_erotic'])) {
+ // Required element is not set
+ reportBug(__FUNCTION__, __LINE__, 'network_allow_erotic for network_id=' . $configData['network_id'] . ',networkTypeId=' . $networkTypeId . ' is not set.');
+ }
+
+ // Return configured value
+ return $configData['network_allow_erotic'];
+}
+
+// ----------------------- Table: network_request_params -----------------------
+
+//------------------------------------------------------------------------------
+// Call-back functions for admin area
+//------------------------------------------------------------------------------
+
+// Callback function to add new network
+function doAdminNetworkProcessAddNetwork () {
+ // We can say here, the form is sent, so check if the network is already added
+ if (isNetworkNameValid(postRequestElement('network_short_name'))) {
+ // Already there
+ loadTemplate('admin_settings_unsaved', FALSE, '{%message,ADMIN_NETWORK_ALREADY_ADDED=' . postRequestElement('network_short_name') . '%}');
+ return FALSE;
+ } // END - if
+
+ // Add the whole request to database
+ SQL_QUERY(getInsertSqlFromArray(postRequestArray(), 'network_data'), __FUNCTION__, __LINE__);
+
+ // Add the id for output only
+ setPostRequestElement('network_id', SQL_INSERTID());
+
+ // Output message
+ if (!SQL_HASZEROAFFECTED()) {
+ // Successfully added
+ loadTemplate('admin_network_added', FALSE, postRequestArray());
+ } else {
+ // Not added
+ loadTemplate('admin_settings_unsaved', FALSE, '{%message,ADMIN_NETWORK_DATA_NOT_ADDED=' . postRequestElement('network_short_name') . '%}');
+ }
+}
+
+// Displays selected networks for editing
+function doAdminNetworkProcessHandleNetworks () {
+ // Is there selections?
+ if (ifPostContainsSelections()) {
+ // Something has been selected, so start displaying one by one
+ $OUT = '';
+ foreach (postRequestElement('sel') as $networkId => $sel) {
+ // Is this selected?
+ if ($sel == 1) {
+ // Load this network's data
+ $networkData = getNetworkDataById($networkId);
+
+ // Is there found the network?
+ if (count($networkData) > 0) {
+ // Add row template with given form name
+ $OUT .= loadTemplate('admin_' . getNetworkFormName() . '_networks_row', TRUE, $networkData);