]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/yoomedia_functions.php
Workaround for WINDOWS-1252 encoded data :(
[mailer.git] / inc / libs / yoomedia_functions.php
index 6bd9c4e52538561111639bb350eccbe8f7992d59..19f8a773f5bd22e92419d2a34e11c56bb56722ed 100644 (file)
@@ -116,7 +116,15 @@ function YOOMEDIA_QUERY_API ($script, $countQuery = true) {
 
                // Convert from ISO to UTF-8
                foreach ($response as $k => $v) {
 
                // Convert from ISO to UTF-8
                foreach ($response as $k => $v) {
-                       $response[$k] = iconv('ISO-8859-1', 'UTF-8//TRANSLIT',$v);
+                       $response[$k] = iconv('windows-1252', 'UTF-8//TRANSLIT', $v);
+                       /*
+                       // iconv()-less ISO-8859-1 -> UTF-8
+                       $response[$k] = preg_replace(
+                               "/([\x80-\xFF])/e",
+                               "chr(0xC0|ord('\\1')>>6).chr(0x80|ord('\\1')&0x3F)",
+                               $v
+                       );
+                       */
                } // END - if
 
                // Shall we count the query as used?
                } // END - if
 
                // Shall we count the query as used?
@@ -221,7 +229,7 @@ function YOOMEDIA_PREPARE_MAIL_DELIVERY ($data) {
        $data['categories'] = generateCategoryOptionsList('normal');
 
        // Decode entities
        $data['categories'] = generateCategoryOptionsList('normal');
 
        // Decode entities
-       $data['text'] = (decodeEntities($data['text']));
+       $data['text'] = decodeEntities($data['text']);
 
        // Load template
        loadTemplate('admin_send_yoomedia', false, $data);
 
        // Load template
        loadTemplate('admin_send_yoomedia', false, $data);
@@ -315,10 +323,7 @@ function translateYooMediaError ($errorCode) {
                $return = $GLOBALS['translation_tables']['yoomedia']['error_codes'][$errorCode];
        } else {
                // Log missing entries
                $return = $GLOBALS['translation_tables']['yoomedia']['error_codes'][$errorCode];
        } else {
                // Log missing entries
-               logDebugMessage(__FUNCTION__, __LINE__, "errorCode={$errorCode}");
-               print('<pre>');
-               debug_print_backtrace();
-               die('</pre>');
+               debug_report_bug(sprintf("Unknown error code <strong>%s</strong> detected.", $errorCode));
        }
 
        // Return value
        }
 
        // Return value
@@ -388,18 +393,18 @@ function YOOMEDIA_CONVERT_MODE ($mode) {
 }
 
 // Extract code from response
 }
 
 // Extract code from response
-function YOOMEDIA_GET_ERRORCODE_FROM_RESULT (array $response) {
+function YOOMEDIA_GET_ERRORCODE_FROM_RESULT ($response) {
        // Bad code as default
        $code = -999;
 
        // Which response should we parse?
        // Bad code as default
        $code = -999;
 
        // Which response should we parse?
-       if (isset($response[8])) {
+       if ((isset($response[8])) && (count($response) == 9)) {
                // Use error code from element 8 (mostly API errors)
                $codeArray = explode("<br>", $response[8]);
 
                // Use only the first element
                $code = bigintval($codeArray[0]);
                // Use error code from element 8 (mostly API errors)
                $codeArray = explode("<br>", $response[8]);
 
                // Use only the first element
                $code = bigintval($codeArray[0]);
-       } elseif (isset($response[0]['id'])) {
+       } elseif ((is_array($response[0])) && (isset($response[0]['id']))) {
                // Begin with extraction
                $codeArray = explode(" ", $response[0]['id']);
                $code = $codeArray[0];
                // Begin with extraction
                $codeArray = explode(" ", $response[0]['id']);
                $code = $codeArray[0];