From ed2e4260898a75477dd0bffad49732fdf702717e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 11 Aug 2011 13:25:58 +0000 Subject: [PATCH] More fixes for ext-yoomedia (didn't handle non-error responses correctly) --- inc/config-functions.php | 2 + inc/extensions-functions.php | 4 +- inc/extensions/ext-doubler.php | 12 ++- inc/extensions/ext-network.php | 2 +- inc/http-functions.php | 1 + inc/language/yoomedia_de.php | 10 +-- inc/libs/yoomedia_functions.php | 78 ++++++++++++------- inc/modules/admin/overview-inc.php | 8 +- .../de/html/admin/admin_config_yoomedia.tpl | 2 +- 9 files changed, 74 insertions(+), 45 deletions(-) diff --git a/inc/config-functions.php b/inc/config-functions.php index c85f60ada1..189d4c448b 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -97,6 +97,8 @@ function isConfigEntrySet ($configEntry) { // Merges $GLOBALS['config'] with data in given array function mergeConfig ($newConfig) { $GLOBALS['config'] = merge_array(getConfigArray(), $newConfig); + + // Remove all cached entries } // Increment or init with given value or 1 as default the given config entry diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 847fcf18f8..12de2776d3 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -155,7 +155,7 @@ function loadExtension ($ext_name, $ext_mode, $ext_ver = '0.0.0', $dry_run = fal loadCurrentExtensionInclude(); // Is this extension deprecated? - if ((isExtensionDeprecated()) && (getExtensionMode() != 'test')) { + if ((isExtensionDeprecated()) && (!in_array(getExtensionMode(), array('test', 'update')))) { // Deactivate the extension doDeactivateExtension($ext_name); @@ -947,7 +947,7 @@ function doDeactivateExtension ($ext_name) { // Is the extension installed? if (!isExtensionInstalled($ext_name)) { // Non-installed extensions cannot be activated - debug_report_bug(__FUNCTION__, __LINE__, 'Tried to deactivate non-installed extension ' . $ext_name); + debug_report_bug(__FUNCTION__, __LINE__, 'Tried to deactivate non-installed extension ' . $ext_name . ',getExtensionMode()=' . getExtensionMode()); } // END - if // Activate the extension diff --git a/inc/extensions/ext-doubler.php b/inc/extensions/ext-doubler.php index 76fb81982d..46d31abd98 100644 --- a/inc/extensions/ext-doubler.php +++ b/inc/extensions/ext-doubler.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.1.8'); +setThisExtensionVersion('0.1.9'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8')); +setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9')); switch (getExtensionMode()) { case 'register': // Do stuff when installation is running @@ -248,6 +248,14 @@ INDEX (`userid`)", // Update notes setExtensionUpdateNotes("Doppler-Gutschriften werden nun über die Tabelle {OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data verwaltet."); break; + + case '0.1.9': // SQL queries for v0.1.9 + // Total payed out points from your doublers + addConfigAddSql('doubler_used', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000'); + + // Update notes + setExtensionUpdateNotes("Fehlender Konfigurationseintrag doubler_used hinzgefügt."); + break; } // END - switch break; diff --git a/inc/extensions/ext-network.php b/inc/extensions/ext-network.php index 1543bdbe3e..56d029710b 100644 --- a/inc/extensions/ext-network.php +++ b/inc/extensions/ext-network.php @@ -302,7 +302,7 @@ UNIQUE INDEX `provider_type` (`network_id`,`network_type_id`)", ('homeads', 'homeADS', 'http://www.homeads.de/?ref=1540', '|', '|', 'GET', 'WINDOWS-1252','N'), ('fucoexsponsor', 'FuCoExSponsor.net', 'http://fucoexsponsor.net/index.php?seite=anmeldung&ref=Quix0r', '|', '|', 'GET', 'ISO-8859-1','N'), ('adconvention', 'AdConvention', 'http://www.adconvention.de?ref=233', '|', '|', 'GET', 'WINDOWS-1252','N'), -('ad-hit', 'Ad-Hit.de', 'http://www.ad-hit.de?ref=41', '|', '|', 'GET', 'WINDOWS-1252', 'N'"); +('ad-hit', 'Ad-Hit.de', 'http://www.ad-hit.de?ref=41', '|', '|', 'GET', 'WINDOWS-1252', 'N')"); // Network type handlers - A3H addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_types` (`network_type_id`,`network_id`,`network_type_handle`,`network_type_api_url`,`network_type_click_url`,`network_type_banner_url`) VALUES diff --git a/inc/http-functions.php b/inc/http-functions.php index d049a7b75d..0dfce733ea 100644 --- a/inc/http-functions.php +++ b/inc/http-functions.php @@ -342,6 +342,7 @@ function sendRawRequest ($host, $request) { } // END - if // Add it to response + //* DEBUG: */ print 'line='.$line.'
'; $response[] = $line; } // END - while diff --git a/inc/language/yoomedia_de.php b/inc/language/yoomedia_de.php index 5129b6e9a0..7df8ff995b 100644 --- a/inc/language/yoomedia_de.php +++ b/inc/language/yoomedia_de.php @@ -47,7 +47,7 @@ addMessages(array( 'ADMIN_CONFIG_YOOMEDIA_SID' => "Seiten-Id:", 'ADMIN_CONFIG_YOOMEDIA_PASSWD' => "Interface-Passwort:", 'ADMIN_CONFIG_YOOMEDIA_TM_MAX_RELOAD' => "Maximale Reloadzeit der Kampagnen in Stunden:", - 'ADMIN_CONFIG_YOOMEDIA_TM_MIN_WAIT' => "Mindestaufenthalt in Sekunden:", + 'ADMIN_CONFIG_YOOMEDIA_TM_MIN_WAIT' => "Maximaler Mindestaufenthalt in Sekunden:", 'ADMIN_CONFIG_YOOMEDIA_TM_CLICKS_REMAIN' => "Mindestanzahl der restlichen Klicks:", 'ADMIN_CONFIG_YOOMEDIA_TM_MIN_PAY' => "Mindestvergütung der Kampagne:", 'ADMIN_CONFIG_YOOMEDIA_EROTIC_ALLOWED' => "Kampagnen mit erotischen Inhalt anzeigen?", @@ -57,7 +57,7 @@ addMessages(array( 'ADMIN_CONFIG_YOOMEDIA_EROTIC_NOTE' => "Hinweise: Sollten Sie Erotik in Ihrem {?mt_word?} anzeigen wollen, so sollten Sie einen Jugendschutzbeauftragten haben und diesen im Impressum nennen. Das gesamte Entwicklerteam weisst darauf hin, dass niemand aus dem Team Ihnen hierzu rechtsberatende Hinweise geben kann. Auch im Community-Forum erfolgt keine Rechtsberatung! Etwaige Postings werden entweder kommentarlos gelöscht oder gesperrt.", 'ADMIN_CONFIG_YOOMEDIA_TEST_FAILED' => "Konfigurationsdaten stimmen nicht überein. Details entnehmen Sie bitte der Datei {?CACHE_PATH?}debug.log.", -// Generic admin strings + // Generic admin strings 'ADMIN_YOOMEDIA_REQUESTS_DEPLETED' => "Ihr Abfragekonto der API ist erschöpft. Bitte surfen Sie auf www.YooMedia.de und loggen Sie sich ein, um manuell Mails zu versenden.", 'ADMIN_YOOMEDIA_INVALID_RESULT' => "Ungültige Antwort von der API erhalten. Ist www.yoomedia.de erreichbar?", 'ADMIN_YOOMEDIA_PREPARE_MAIL' => "Bonusmail vorbereiten", @@ -71,11 +71,11 @@ addMessages(array( 'ADMIN_YOOMEDIA_SEND_MAIL_TITLE' => "Textmail aus Yoo!Media API 2.0 versenden", 'ADMIN_YOOMEDIA_RECEIVER_ARE_ALL_NOTE' => "Es werden in der jeweiligen Kategorie alle verfügbaren Empfänger ausgewählt.", -// Subject lines + // Subject lines 'ADMIN_YOOMEDIA_SUBJECT_PREFIX' => "Admin-Paidmail:", 'ADMIN_YOOMEDIA_ENTER_URL_NOTE' => "Die URL wird automatisch für Sie konstruiert.", -// Admin header lines + // Admin header lines 'ADMIN_YOOMEDIA_TM_ID' => "Id", 'ADMIN_YOOMEDIA_TM_NAME' => "Betreff", 'ADMIN_YOOMEDIA_TM_RELOAD' => "Reloadzeit", @@ -84,7 +84,7 @@ addMessages(array( 'ADMIN_YOOMEDIA_TM_PAY' => "Vergütung", 'ADMIN_YOOMEDIA_TM_ACTIONS' => "Aktionen", -// Error messages for admin + // Error messages for admin 'ADMIN_YOOMEDIA_ERROR_UNKNOWN_ERROR' => "Unbekannter/leerer Fehler von API erhalten. Möglicherweise keine API-Daten angegeben.", 'ADMIN_YOOMEDIA_ERROR_FAILED' => "Allgemeiner Fehler von API, nicht weiter spezifiziert.", 'ADMIN_YOOMEDIA_ERROR_TITLE' => "Fehler bei Abfrage der Yoo!Media API 2.0", diff --git a/inc/libs/yoomedia_functions.php b/inc/libs/yoomedia_functions.php index b153bd6f50..8a9889d3ea 100644 --- a/inc/libs/yoomedia_functions.php +++ b/inc/libs/yoomedia_functions.php @@ -90,15 +90,18 @@ function YOOMEDIA_TEST_CONFIG ($data) { return false; } // END - if - // Transfer config data + // Remove 'ok' + unset($data['ok']); + + // Merge config mergeConfig($data); // Temporary allow maximum - setConfigEntry('yoomedia_tm_max_reload' , 100000); - setConfigEntry('yoomedia_tm_min_wait' , 0); - setConfigEntry('yoomedia_tm_clicks_remain', 10); - setConfigEntry('yoomedia_tm_min_pay' , 0); - setConfigEntry('yoomedia_erotic_allowed' , 1); + setConfigEntry('yoomedia_tm_max_reload' , '100000'); + setConfigEntry('yoomedia_tm_min_wait' , '1000'); + setConfigEntry('yoomedia_tm_clicks_remain', '10'); + setConfigEntry('yoomedia_tm_min_pay' , '0.00001'); + setConfigEntry('yoomedia_erotic_allowed' , '1'); // Query the API with a test request without couting it // If zero reply comes back the data is invalid! @@ -110,14 +113,14 @@ function YOOMEDIA_TEST_CONFIG ($data) { // Log the response if failed if ((count($response) == 0) && ($errorCode > 0)) { // Queries depleted (as we count here!) - logDebugMessage(__FUNCTION__, __LINE__, 'Requested depleted. Maxmimum was: ' . getConfig('yoomedia_requests_total')); + logDebugMessage(__FUNCTION__, __LINE__, 'Requested depleted. Maxmimum was: ' . getConfig('yoomedia_requests_total') . ',errorCode=' . $errorCode); $errorCode = -1; } elseif ((($errorCode <= 4) && ($errorCode > 0)) || ($errorCode >= 8)) { // An error has returned from the account logDebugMessage(__FUNCTION__, __LINE__, 'Unexpected error code ' . $errorCode . ' received.'); } elseif ((count($response) > 0) && ($errorCode != 0)) { // Log serialized raw response - logDebugMessage(__FUNCTION__, __LINE__, 'Raw response=' . base64_encode(serialize($response))); + logDebugMessage(__FUNCTION__, __LINE__, 'errorCode=' . $errorCode . ',response=' . base64_encode(serialize($response))); $errorCode = -1; } else { // This is fine, because the result array is okay and the response code on element 8 is fine @@ -134,8 +137,13 @@ function YOOMEDIA_GET_PARSED_RESULT_TEXTMAILS () { // Get the raw response $response = YOOMEDIA_QUERY_API('out_textmail.php'); + // By default an empty result is returned + $result = array(); + // Parse the response - $result = YOOMEDIA_PARSE_RESPONSE($response, 'textmail'); + if (count($response) > 0) { + $result = YOOMEDIA_PARSE_RESPONSE($response, 'textmail'); + } // END - if // Return result return $result; @@ -152,7 +160,7 @@ function YOOMEDIA_PARSE_RESPONSE ($response, $type) { // If we have no result, abort here if (count($dummy) == 0) { // Empty response from API - logDebugMessage(__FUNCTION__, __LINE__, 'Empy result from API received.'); + debug_report_bug(__FUNCTION__, __LINE__, 'Empty result from API received. response()=' . count($response) . ',type=' . $type); return array(); } // END - if @@ -385,33 +393,43 @@ function YOOMEDIA_GET_ERRORCODE_FROM_RESULT ($response) { // Use only the first element $code = bigintval($codeArray[0]); } elseif (!empty($response[0])) { - // Begin with extraction - $codeArray = explode(' ', $response[0]['id']); - $code = $codeArray[0]; - $codeArray = explode('
', $code); - $code = $codeArray[0]; - $codeArray = explode('
', $code); - $code = $codeArray[0]; - - // Remove all new-line characters - $codeArray = explode("\n", $code); - $code = $codeArray[0]; - - // Remove carrige-return - $code = str_replace("\n", '', $code); + // Merge response together + $parts = explode('|', implode('', $response)); + + // If we have only one part, we got an error + if (count($parts) > 1) { + // All fine + $code = '0'; + } else { + // Begin with extraction of error code + $codeArray = explode(' ', $response[0]); + $code = $codeArray[0]; + $codeArray = explode('
', $code); + $code = $codeArray[0]; + $codeArray = explode('
', $code); + $code = $codeArray[0]; + + // Remove all new-line characters + $codeArray = explode("\n", $code); + $code = $codeArray[0]; + + // Remove carrige-return + $code = trim(str_replace("\n", '', $code)); + + // Is it still empty? + if (empty($code)) { + // Then fix it + $code = -999; + } // END - if + } } elseif (count($response) == 0) { // All fine, but empty result - $code = 0; + $code = '0'; } else { // Should not happen! debug_report_bug(__FUNCTION__, __LINE__, 'Cannot parse response. Raw response:
' . print_r($response, true) . '
'); } - // Fix empty code to bad - if (empty($code)) { - $code = -999; - } // END - if - // Return error code return $code; } diff --git a/inc/modules/admin/overview-inc.php b/inc/modules/admin/overview-inc.php index f330994e93..72007a445f 100644 --- a/inc/modules/admin/overview-inc.php +++ b/inc/modules/admin/overview-inc.php @@ -75,7 +75,7 @@ function outputStandardOverview (&$result_tasks) { createNewExtensionTask($ext_name); } // END - if } else { - // Test-drive extension in update mode + // Test-drive extension loadExtension($ext_name, 'test'); // Get extension version @@ -264,7 +264,7 @@ LIMIT 1", 'subject' => $taskData['subject'], 'add' => $add, 'text' => $taskData['text'], - 'task_created' => generateDateTime($taskData['task_created'], 1), + 'task_created' => generateDateTime($taskData['task_created'], '1'), 'extension' => $ext_name ); @@ -287,7 +287,7 @@ LIMIT 1", $OUT .= '
{--ADMIN_EXTENSION_ALREADY_REGISTERED--}
'; // Close task but not already closed, solved, deleted or update tasks - if ((!in_array($taskData['status'], array('CLOSED','DELETED','SOLVED'))) && ($taskData['task_type'] != 'EXTENSION_UPDATE')) { + if ((!in_array($taskData['status'], array('CLOSED', 'DELETED', 'SOLVED'))) && ($taskData['task_type'] != 'EXTENSION_UPDATE')) { // Solve the task runFilterChain('solve_task', $taskData['id']); } // END - if @@ -298,7 +298,7 @@ LIMIT 1", // Extension updates are installed automatically $OUT .= '
{--ADMIN_EXTENSION_UPDATED--}
'; - // Close task + // Close task if not closed or deleted if (!in_array($taskData['status'], array('CLOSED', 'DELETED'))) { // Solve the task runFilterChain('solve_task', $taskData['id']); diff --git a/templates/de/html/admin/admin_config_yoomedia.tpl b/templates/de/html/admin/admin_config_yoomedia.tpl index e7b67bcb38..5908ec3414 100644 --- a/templates/de/html/admin/admin_config_yoomedia.tpl +++ b/templates/de/html/admin/admin_config_yoomedia.tpl @@ -59,7 +59,7 @@ {--ADMIN_CONFIG_YOOMEDIA_TM_MIN_PAY--} - + -- 2.39.5