+// Translates network API configuration status (see function isNetworkApiConfigured()) by given id
+function translateNetworkApiConfiguredStatusById ($networkId) {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__][$networkId])) {
+ // By default it is not configured
+ $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_NOT_CONFIGURED--}';
+
+ // So is it configured?
+ if (!isNetworkActiveById($networkId)) {
+ // Network is not active
+ $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_NOT_ACTIVE--}';
+ } elseif (isNetworkApiConfigured($networkId)) {
+ // Yes, it is
+ $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_CONFIGURED--}';
+ } // END - if
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$networkId];
+}
+
+/**
+ * "Translates" given amount of queries; 0 = unlimited
+ *
+ * @param $amount Amount of free queries
+ * @return $translated "Translated" value; 0 = unlimited
+ */
+function translateNetworkQueryAmount ($amount) {
+ // Default is unlimited (good! ;-) )
+ $translated = '{--UNLIMITED--}';
+
+ // Is the amount larger zero?
+ if ($amount > 0) {
+ // Then translate it
+ $translated = translateComma($amount);
+ } // END - if
+
+ // Return translated value
+ return $translated;
+}
+
+/**
+ * "Translates given status (Y/N) to "de-/activated" but only if expert and
+ * debug mode are enabled.
+ *
+ * @param $status Can be one of Y/N
+ * @return $translated "Translated" status
+ */
+function translateNetworkActivationStatus ($status) {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__][$status])) {
+ // Default is not enabled
+ $GLOBALS[__FUNCTION__][$status] = '';
+
+ // Is expert + debug mode enabled?
+ if ((isAdminsExpertSettingEnabled()) && (isDebugModeEnabled())) {
+ // Then "translate" it
+ $GLOBALS[__FUNCTION__][$status] = translateActivationStatus($status);
+ } // END - if
+ } // END - if
+
+ // Return "translation"
+ return $GLOBALS[__FUNCTION__][$status];
+}
+
+//------------------------------------------------------------------------------
+// Wrapper functions to save data to network tables
+//------------------------------------------------------------------------------
+
+// Updates given network (id) with data from array
+function doNetworkUpdateDataByArray ($networkId, $networkData) {
+ // Ids lower one are not accepted
+ if (!isValidId($networkId)) {
+ // Not good, should be fixed
+ reportBug(__FUNCTION__, __LINE__, 'Network id ' . $networkId . ' is smaller than 1.');
+ } // END - if
+
+ // Just call our inner method
+ return adminSaveSettings($networkData, '_network_data', sprintf("`network_id`=%s", bigintval($networkId)), array(), FALSE, FALSE);
+}
+
+// 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 -----------------------
+