agustin Posted February 13, 2010 Share Posted February 13, 2010 Hello Everyone, I open this thread to ask for your help: I use WHMCS and import emails to create a ticket using POP3. The problem is that when the email I import has a character like this: á,é, í, ó, ú or ñ, WHMCS shows this: � My WHMCS System Charset is utf-8 and I import emails from Google Apps (the same than Gmail, but for business). Could you help me with this? Thanks! Regards, 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 27, 2010 Share Posted April 27, 2010 Hi, agustin. Did you find any clue? I have the same issue 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted April 27, 2010 Share Posted April 27, 2010 maybe try out http://de.php.net/manual/de/function.utf8-encode.php or http://de.php.net/manual/de/function.imap-utf8.php 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 27, 2010 Share Posted April 27, 2010 Can do nothing about php as import script is coded, as you know. From firefox, if I change the charset view from utf8 to iso8859, I can read it perfectly, even if the admin header contains: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> So, the presentation is utf-8 and the database storage is utf-8. The problem must be inside the import script 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted April 27, 2010 Share Posted April 27, 2010 mmh right. there was a params problem with umlauts in my plesk module, too. the whmcs "gettheparamsorsomething" function does not handle it correct. you have always to mysql select by self. but its still encrpyted the importer script (where is the script in backendnavigation?) ... 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 27, 2010 Share Posted April 27, 2010 I run script "whmcs/pipe/pop.php" every 5 minutes from root's crontab. So I think pop.php should be the one checking and converting different charset (at least it should) I already opened a ticket, still waiting for the anser. I'll let you know ;-) 0 Quote Link to comment Share on other sites More sharing options...
hypertoast Posted April 27, 2010 Share Posted April 27, 2010 (edited) sorry, wrong post. Edited April 27, 2010 by hypertoast wrong post 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 27, 2010 Share Posted April 27, 2010 Thanks, hypertoast, but we werew talking about the script which imports tickets via POP protocol. I can't find the relation between this and jwhmcs/viewcart template 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted April 28, 2010 Share Posted April 28, 2010 you could fix the ticket in DB by using the hook "TicketOpen". i think. 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 28, 2010 Share Posted April 28, 2010 That's exactly what I asked Matt, I was wondering if there was any hook I can use. Maybe I can make use of php's mb_detect_encoding function with data already stored on mysql. Gonna check it! 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted April 28, 2010 Share Posted April 28, 2010 i tested it and i can confirm this bug! maybe i look into this next time. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted April 28, 2010 Share Posted April 28, 2010 Could a couple of you guys here in this post contact me (via ticket) to test a file that I wipped up to remove accents. If it works ok then I'll make it available (free). 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 28, 2010 Share Posted April 28, 2010 I've made a simple php script to read from tickets table and just shows imported messages. It uses mb_detect_encoding() to detect possible utf8 content, and when found, it uses utf8_encode() to force utf8 and shows message again with ferfect characters Would you like to try it out? This is the first step for on-the-fly charset fix <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Encode testing</title> </head> <body> <?php // Encode testing mysql_connect('localhost', 'root', ''); mysql_select_db('whmcs'); // Read first 5 tickets $sql = "SELECT id, tid, title, message FROM tbltickets LIMIT 5"; $res = mysql_query($sql); // For each ticket while(list($id, $tid, $title, $message) = mysql_fetch_array($res)) { // Shows generic info for this ticket echo "[$id] "; echo "<strong>$title</strong><br />\n"; echo "<p><strong>Before</strong><br />$message</p>\n"; // Check if encoding is utf8 $enc = mb_detect_encoding($message, 'auto'); if($enc=="UTF-8") { // If so, force charset $message = utf8_encode($message); // and print fixed message echo "<p><strong>After</strong><br />$message</p>\n"; } echo "<br />\n"; } ?> </body> </html> 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 28, 2010 Share Posted April 28, 2010 And this could be a hook <?php function convert_utf8($vars) { $ticket_id = $vars['id']; $message = $vars['message']; $is_utf8 = mb_detect_encoding($message, 'UTF-8, ISO-8859-1'); if($is_utf8=="ISO-8859-1") { $message = utf8_encode($message); $upd = "UPDATE tbltickets SET message='$message' WHERE id='$ticket_id'"; $res = mysql_query($upd); } add_hook("TicketOpen", 1, "convert_utf8"); ?> 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted April 28, 2010 Share Posted April 28, 2010 (edited) thx, but i can't confirm that ISO-8859-1 emails get in correct with this hook Hook: function init_TicketOpen($vars) { $ticket_id = $vars['id']; $message = $vars['message']; $is_utf8 = mb_detect_encoding($message, 'UTF-8, ISO-8859-1'); if ($is_utf8 == "ISO-8859-1") { $message = utf8_encode($message); $res = mysql_query("UPDATE tbltickets SET message='$message' WHERE id='$ticket_id' LIMIT 1"); } } add_hook("TicketOpen",1,"init_TicketOpen",""); i think the hook is not called. trying $message = "huhuhuhuhu " . utf8_encode($message); has no effect. Edited April 28, 2010 by HerrZ 0 Quote Link to comment Share on other sites More sharing options...
ditto Posted April 28, 2010 Share Posted April 28, 2010 What can we do now? Change the WHMCS charset to ISO-8859-1? What may be affected by this change? My WHMCS installation is using iso-8859-1, and I also have problems with displaying characters correct. All email sent from Gmail accounts with æ, ø or å is not displayed correct. I am using email piping/forwarders. So it seems there is problems both for us that use iso-8859-1, and for those using utf-8 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted April 28, 2010 Share Posted April 28, 2010 i think the hook TicketOpen is not called in piping progress. anyway the correct function params for a hook are: $ticket_id = $vars['ticketid']; $subject = $vars['subject']; $message = $vars['message']; not like above. 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 28, 2010 Share Posted April 28, 2010 Yes, I was wrong with the $vars parameters: TicketOpen - ticketid, userid, deptid, deptname, subject, message, priority Anyway there seems to be no way of "hooking" the import funcions. Must edit pop.php, but it's encrypted :-( I have no more ideas 0 Quote Link to comment Share on other sites More sharing options...
Gitex Posted April 28, 2010 Share Posted April 28, 2010 please check this in upper case : UTF-8 maybe help/ 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted April 29, 2010 Share Posted April 29, 2010 please check this in upper case : UTF-8 maybe help/ i still tried this out 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted April 29, 2010 Share Posted April 29, 2010 This should convert the accents to normal charactors from any form posted in whmcs or any file that includes dbfunctions.php (which is pretty well all of them) Create a file called remove_accents.php in your includes/hooks directory and insert this code into the file. <?php function removeaccents($string) { $UTF8_UPPER_ACCENTS = array( 'À' => 'A', 'Ô' => 'O', 'ÄŽ' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Å ' => 'S', 'Æ ' => 'O', 'Ä‚' => 'A', 'Ř' => 'R', 'Èš' => 'T', 'Ň' => 'N', 'Ä€' => 'A', 'Ķ' => 'K', 'Åœ' => 'S', 'Ỳ' => 'Y', 'Å…' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'á¹–' => 'P', 'Ó' => 'O', 'Ú' => 'U', 'Äš' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'ÄŠ' => 'C', 'Õ' => 'O', 'á¹ ' => 'S', 'Ø' => 'O', 'Ä¢' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ä–' => 'E', 'Ĉ' => 'C', 'Åš' => 'S', 'ÃŽ' => 'I', 'Å°' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Å´' => 'W', 'Ṫ' => 'T', 'Ū' => 'U', 'ÄŒ' => 'C', 'Ö' => 'Oe', 'È' => 'E', 'Ŷ' => 'Y', 'Ä„' => 'A', 'Å' => 'L', 'Ų' => 'U', 'Å®' => 'U', 'Åž' => 'S', 'Äž' => 'G', 'Ä»' => 'L', 'Æ‘' => 'F', 'Ž' => 'Z', 'Ẃ' => 'W', 'Ḃ' => 'B', 'Ã…' => 'A', 'ÃŒ' => 'I', 'Ã' => 'I', 'Ḋ' => 'D', 'Ť' => 'T', 'Å–' => 'R', 'Ä' => 'Ae', 'Ã' => 'I', 'Å”' => 'R', 'Ê' => 'E', 'Ãœ' => 'Ue', 'Ã’' => 'O', 'Ä’' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Äœ' => 'G', 'Ä' => 'D', 'Ä´' => 'J', 'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Å¢' => 'T', 'Ã' => 'Y', 'Å' => 'O', 'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Å»' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ä ' => 'G', 'á¹€' => 'M', 'ÅŒ' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Ä®' => 'I', 'Ź' => 'Z', 'Ã' => 'A', 'Û' => 'U', 'Þ' => 'Th', 'Ã' => 'Dh', 'Æ' => 'Ae', 'Ä”' => 'E', ); $UTF8_LOWER_ACCENTS = array( 'à ' => 'a', 'ô' => 'o', 'Ä' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'Å¡' => 's', 'Æ¡' => 'o', 'ß' => 'ss', 'ă' => 'a', 'Å™' => 'r', 'È›' => 't', 'ň' => 'n', 'Ä' => 'a', 'Ä·' => 'k', 'Å' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'á¹—' => 'p', 'ó' => 'o', 'ú' => 'u', 'Ä›' => 'e', 'é' => 'e', 'ç' => 'c', 'áº' => 'w', 'Ä‹' => 'c', 'õ' => 'o', 'ṡ' => 's', 'ø' => 'o', 'Ä£' => 'g', 'ŧ' => 't', 'È™' => 's', 'Ä—' => 'e', 'ĉ' => 'c', 'Å›' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'Ä™' => 'e', 'ŵ' => 'w', 'ṫ' => 't', 'Å«' => 'u', 'Ä' => 'c', 'ö' => 'oe', 'è' => 'e', 'Å·' => 'y', 'Ä…' => 'a', 'Å‚' => 'l', 'ų' => 'u', 'ů' => 'u', 'ÅŸ' => 's', 'ÄŸ' => 'g', 'ļ' => 'l', 'Æ’' => 'f', 'ž' => 'z', 'ẃ' => 'w', 'ḃ' => 'b', 'Ã¥' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'Å¥' => 't', 'Å—' => 'r', 'ä' => 'ae', 'Ã*' => 'i', 'Å•' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o', 'Ä“' => 'e', 'ñ' => 'n', 'Å„' => 'n', 'Ä¥' => 'h', 'Ä' => 'g', 'Ä‘' => 'd', 'ĵ' => 'j', 'ÿ' => 'y', 'Å©' => 'u', 'Å*' => 'u', 'Æ°' => 'u', 'Å£' => 't', 'ý' => 'y', 'Å‘' => 'o', 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'Ä«' => 'i', 'ã' => 'a', 'Ä¡' => 'g', 'á¹' => 'm', 'Å' => 'o', 'Ä©' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a', 'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', 'Ä•' => 'e', ); $accents = array_merge($UTF8_UPPER_ACCENTS, $UTF8_LOWER_ACCENTS); $convertedstring = array(); if (is_array($string)){ foreach ($string AS $key=>$value) { if (is_array($value)) { $convertedstring[$key] = removeaccents($value); } else { $encoding = mb_detect_encoding($value, 'auto'); if($encoding != "UTF-8") $value = utf8_encode($string); $convertedstring[$key] = strtr($value,$accents); } } } else { $encoding = mb_detect_encoding($string, 'auto'); if($encoding != "UTF-8") $string = utf8_encode($string); $convertedstring = strtr($string,$accents); } return utf8_encode($convertedstring); } foreach ($_REQUEST as $key=>$value) { $_REQUEST[$key] = removeaccents($value); } unset($key,$value); foreach ($_POST as $key=>$value) { $_POST[$key] = removeaccents($value); } unset($key,$value); foreach ($_GET as $key=>$value) { $_GET[$key] = removeaccents($value); } unset($key,$value); foreach ($_REQUEST AS $key=>$value) { $$key = $value; } unset($key,$value); ?> 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 29, 2010 Share Posted April 29, 2010 That would work, but that's not the way. Different letters make different words, and you shouldn't modify customer's email, letter by letter. It's not a good practice and it's not an elegant solution. I won't change España into Espana, won't chage "tú" (your) into "tu" (yours) There is a bug and should be fixed ASAP, in a professional way. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted April 29, 2010 Share Posted April 29, 2010 It was meant to be for a charactor replacement... see post #1 At least if the charactor is converted to something that is partly readable instead of �������� Maybe you can tell me what the above says? What your asking for know is a complete dictionary replacement. You could always try google translate. 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted April 29, 2010 Share Posted April 29, 2010 Hi, sparky I'm not asking for a replacement, but for a charset conversion, a very common feature used in email readers. Post #1 is pointing a bug and a fix is needed. You can try to replace every string, but it's not an adecuated solution, as you may be changing some strings that shouldn't be translated, like passwords or any other field in any custom module. You cannot replace every letter in every module, that's not the problem. The problem is a charset conversion, not a character replacement. There is a bug, and should be fixed by whmcs team. I want to use whmcs in spanish, with spanish letters, spanish words and multilingual support. This can not be done as long as import scripts don't care about charsets. Relax ;-) 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted April 30, 2010 Share Posted April 30, 2010 This should convert the accents to normal charactors from any form posted in whmcs or any file that includes dbfunctions.php (which is pretty well all of them) Create a file called remove_accents.php in your includes/hooks directory and insert this code into the file. <?php function removeaccents($string) { $UTF8_UPPER_ACCENTS = array( 'À' => 'A', 'Ô' => 'O', 'ÄŽ' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Å ' => 'S', 'Æ ' => 'O', 'Ä‚' => 'A', 'Ř' => 'R', 'Èš' => 'T', 'Ň' => 'N', 'Ä€' => 'A', 'Ķ' => 'K', 'Åœ' => 'S', 'Ỳ' => 'Y', 'Å…' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'á¹–' => 'P', 'Ó' => 'O', 'Ú' => 'U', 'Äš' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'ÄŠ' => 'C', 'Õ' => 'O', 'á¹ ' => 'S', 'Ø' => 'O', 'Ä¢' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ä–' => 'E', 'Ĉ' => 'C', 'Åš' => 'S', 'ÃŽ' => 'I', 'Å°' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Å´' => 'W', 'Ṫ' => 'T', 'Ū' => 'U', 'ÄŒ' => 'C', 'Ö' => 'Oe', 'È' => 'E', 'Ŷ' => 'Y', 'Ä„' => 'A', 'Å' => 'L', 'Ų' => 'U', 'Å®' => 'U', 'Åž' => 'S', 'Äž' => 'G', 'Ä»' => 'L', 'Æ‘' => 'F', 'Ž' => 'Z', 'Ẃ' => 'W', 'Ḃ' => 'B', 'Ã…' => 'A', 'ÃŒ' => 'I', 'Ã' => 'I', 'Ḋ' => 'D', 'Ť' => 'T', 'Å–' => 'R', 'Ä' => 'Ae', 'Ã' => 'I', 'Å”' => 'R', 'Ê' => 'E', 'Ãœ' => 'Ue', 'Ã’' => 'O', 'Ä’' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Äœ' => 'G', 'Ä' => 'D', 'Ä´' => 'J', 'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Å¢' => 'T', 'Ã' => 'Y', 'Å' => 'O', 'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Å»' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ä ' => 'G', 'á¹€' => 'M', 'ÅŒ' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Ä®' => 'I', 'Ź' => 'Z', 'Ã' => 'A', 'Û' => 'U', 'Þ' => 'Th', 'Ã' => 'Dh', 'Æ' => 'Ae', 'Ä”' => 'E', ); $UTF8_LOWER_ACCENTS = array( 'à ' => 'a', 'ô' => 'o', 'Ä' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'Å¡' => 's', 'Æ¡' => 'o', 'ß' => 'ss', 'ă' => 'a', 'Å™' => 'r', 'È›' => 't', 'ň' => 'n', 'Ä' => 'a', 'Ä·' => 'k', 'Å' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'á¹—' => 'p', 'ó' => 'o', 'ú' => 'u', 'Ä›' => 'e', 'é' => 'e', 'ç' => 'c', 'áº' => 'w', 'Ä‹' => 'c', 'õ' => 'o', 'ṡ' => 's', 'ø' => 'o', 'Ä£' => 'g', 'ŧ' => 't', 'È™' => 's', 'Ä—' => 'e', 'ĉ' => 'c', 'Å›' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'Ä™' => 'e', 'ŵ' => 'w', 'ṫ' => 't', 'Å«' => 'u', 'Ä' => 'c', 'ö' => 'oe', 'è' => 'e', 'Å·' => 'y', 'Ä…' => 'a', 'Å‚' => 'l', 'ų' => 'u', 'ů' => 'u', 'ÅŸ' => 's', 'ÄŸ' => 'g', 'ļ' => 'l', 'Æ’' => 'f', 'ž' => 'z', 'ẃ' => 'w', 'ḃ' => 'b', 'Ã¥' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'Å¥' => 't', 'Å—' => 'r', 'ä' => 'ae', 'Ã*' => 'i', 'Å•' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o', 'Ä“' => 'e', 'ñ' => 'n', 'Å„' => 'n', 'Ä¥' => 'h', 'Ä' => 'g', 'Ä‘' => 'd', 'ĵ' => 'j', 'ÿ' => 'y', 'Å©' => 'u', 'Å*' => 'u', 'Æ°' => 'u', 'Å£' => 't', 'ý' => 'y', 'Å‘' => 'o', 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'Ä«' => 'i', 'ã' => 'a', 'Ä¡' => 'g', 'á¹' => 'm', 'Å' => 'o', 'Ä©' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a', 'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', 'Ä•' => 'e', ); $accents = array_merge($UTF8_UPPER_ACCENTS, $UTF8_LOWER_ACCENTS); $convertedstring = array(); if (is_array($string)){ foreach ($string AS $key=>$value) { if (is_array($value)) { $convertedstring[$key] = removeaccents($value); } else { $encoding = mb_detect_encoding($value, 'auto'); if($encoding != "UTF-8") $value = utf8_encode($string); $convertedstring[$key] = strtr($value,$accents); } } } else { $encoding = mb_detect_encoding($string, 'auto'); if($encoding != "UTF-8") $string = utf8_encode($string); $convertedstring = strtr($string,$accents); } return utf8_encode($convertedstring); } foreach ($_REQUEST as $key=>$value) { $_REQUEST[$key] = removeaccents($value); } unset($key,$value); foreach ($_POST as $key=>$value) { $_POST[$key] = removeaccents($value); } unset($key,$value); foreach ($_GET as $key=>$value) { $_GET[$key] = removeaccents($value); } unset($key,$value); foreach ($_REQUEST AS $key=>$value) { $$key = $value; } unset($key,$value); ?> uuhhh, on each pagecall! foreach $_REQUEST and $_POST (actually $_POST is in $_REQUEST this is an very unperformant solution. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.