More fixes for ext-yoomedia (didn't handle non-error responses correctly)
authorRoland Häder <roland@mxchange.org>
Thu, 11 Aug 2011 13:25:58 +0000 (13:25 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 11 Aug 2011 13:25:58 +0000 (13:25 +0000)
inc/config-functions.php
inc/extensions-functions.php
inc/extensions/ext-doubler.php
inc/extensions/ext-network.php
inc/http-functions.php
inc/language/yoomedia_de.php
inc/libs/yoomedia_functions.php
inc/modules/admin/overview-inc.php
templates/de/html/admin/admin_config_yoomedia.tpl

index c85f60ada1a43b71030df9df3ae5d03048622adb..189d4c448b5d59d7b45b9f851db785b6ef13246b 100644 (file)
@@ -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
index 847fcf18f818218096494400f032b2220209922c..12de2776d313d95576d943b2a203c572ca4cefe6 100644 (file)
@@ -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
index 76fb81982dc0628cd6f7cb16aae9844fc000a84a..46d31abd98e9578e883b8d84497f119905ae5065 100644 (file)
@@ -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 &uuml;ber die Tabelle <strong>{OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data</strong> 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 <strong>doubler_used</strong> hinzgef&uuml;gt.");
+                               break;
                } // END - switch
                break;
 
index 1543bdbe3e890dbd15d3db8ddc5da1d0ac18fea6..56d029710ba08e192d3ec5cf7ae55b07ac167fe1 100644 (file)
@@ -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
index d049a7b75d4323b43c0cae0566063ef6b1e7dcd5..0dfce733ea63bbf75b3346ab8efa3b986aa85436 100644 (file)
@@ -342,6 +342,7 @@ function sendRawRequest ($host, $request) {
                } // END - if
 
                // Add it to response
+               //* DEBUG: */ print 'line='.$line.'<br />';
                $response[] = $line;
        } // END - while
 
index 5129b6e9a084e5aacc22bd7a80a93d0de6808d54..7df8ff995b2e3dac635410b6f353caf67b50046a 100644 (file)
@@ -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&uuml;tung der Kampagne:",
        'ADMIN_CONFIG_YOOMEDIA_EROTIC_ALLOWED' => "Kampagnen mit erotischen Inhalt anzeigen?",
@@ -57,7 +57,7 @@ addMessages(array(
        'ADMIN_CONFIG_YOOMEDIA_EROTIC_NOTE' => "<strong>Hinweise:</strong> 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&ouml;scht oder gesperrt.",
        'ADMIN_CONFIG_YOOMEDIA_TEST_FAILED' => "Konfigurationsdaten stimmen nicht &uuml;berein. Details entnehmen Sie bitte der Datei <u>{?CACHE_PATH?}debug.log</u>.",
 
-// Generic admin strings
+       // Generic admin strings
        'ADMIN_YOOMEDIA_REQUESTS_DEPLETED' => "Ihr Abfragekonto der API ist ersch&ouml;pft. Bitte surfen Sie auf <a href=\"http://www.yoomedia.de?ref=1715\" target=\"_blank\">www.YooMedia.de</a> und loggen Sie sich ein, um manuell Mails zu versenden.",
        'ADMIN_YOOMEDIA_INVALID_RESULT' => "Ung&uuml;ltige Antwort von der API erhalten. Ist <a href=\"http://www.yoomedia.de?ref=1715\" target=\"_blank\">www.yoomedia.de</a> 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&uuml;gbaren Empf&auml;nger ausgew&auml;hlt.",
 
-// Subject lines
+       // Subject lines
        'ADMIN_YOOMEDIA_SUBJECT_PREFIX' => "Admin-Paidmail:",
        'ADMIN_YOOMEDIA_ENTER_URL_NOTE' => "Die URL wird automatisch f&uuml;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&uuml;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&ouml;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",
index b153bd6f50037c01cfa13e0fb99db3484672994e..8a9889d3ead598d0fffc4223276c617cc6890625 100644 (file)
@@ -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('<br />', $code);
-               $code = $codeArray[0];
-               $codeArray = explode('<br>', $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('<br />', $code);
+                       $code = $codeArray[0];
+                       $codeArray = explode('<br>', $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:<pre>' . print_r($response, true) . '</pre>');
        }
 
-       // Fix empty code to bad
-       if (empty($code)) {
-               $code = -999;
-       } // END - if
-
        // Return error code
        return $code;
 }
index f330994e938f64af9423e6ca82844a0c7563b5a8..72007a445f240a54290ee710454226e89fca82f6 100644 (file)
@@ -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 .= '<div class="notice">{--ADMIN_EXTENSION_ALREADY_REGISTERED--}</div>';
 
                                                        // 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 .= '<div class="notice medium">{--ADMIN_EXTENSION_UPDATED--}</div>';
 
-                                               // 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']);
index e7b67bcb380f903df9876c1c39f1057ff756ccc3..5908ec3414ca78592da7caa1169b06bdf770e6e7 100644 (file)
@@ -59,7 +59,7 @@
                {--ADMIN_CONFIG_YOOMEDIA_TM_MIN_PAY--}
        </td>
        <td style="padding-left: 10px">
-               <input type="text" class="form_field" name="yoomedia_tm_min_pay" size="3" maxlength="6" value="{?yoomedia_tm_min_pay?}" />
+               <input type="text" class="form_field" name="yoomedia_tm_min_pay" size="5" maxlength="20" value="{?yoomedia_tm_min_pay?}" />
        </td>
 </tr>
 <tr>