Viewing 2 replies - 1 through 2 (of 2 total)
  • Can you explain in detail?

    Where are you seeing this characters?

    most often this is due to wrong encoding. Please define it as UTF8

    Thread Starter hispanico87

    (@hispanico87)

    I solved the problem creating conf/bootstrap.before.php file:

    <?php if (!defined('APPLICATION')) exit();
       function FetchPageInfo($Url, $Timeout = 0) {
          $PageInfo = array(
             'Url' => $Url,
             'Title' => '',
             'Description' => '',
             'Images' => array(),
             'Exception' => FALSE
          );
          try {
             $PageHtml = ProxyRequest($Url, $Timeout, TRUE);
             $Dom = new DOMDocument();
             @$Dom->loadHTML('<?xml encoding="UTF-8">'.$PageHtml);
             // Page Title
             $TitleNodes = $Dom->getElementsByTagName('title');
             $PageInfo['Title'] = $TitleNodes->length > 0 ? $TitleNodes->item(0)->nodeValue : '';
             // Page Description
             $MetaNodes = $Dom->getElementsByTagName('meta');
             foreach($MetaNodes as $MetaNode) {
                if (strtolower($MetaNode->getAttribute('name')) == 'description')
                   $PageInfo['Description'] = $MetaNode->getAttribute('content');
             }
             // Keep looking for page description?
             if ($PageInfo['Description'] == '') {
                $PNodes = $Dom->getElementsByTagName('p');
                foreach($PNodes as $PNode) {
                   $PVal = $PNode->nodeValue;
                   if (strlen($PVal) > 90) {
                      $PageInfo['Description'] = $PVal;
                      break;
                   }
                }
             }
             if (strlen($PageInfo['Description']) > 400)
                $PageInfo['Description'] = SliceString($PageInfo['Description'], 400);
             // Page Images (retrieve first 3 if bigger than 100w x 300h)
             $Images = array();
             $ImageNodes = $Dom->getElementsByTagName('img');
             $i = 0;
             foreach ($ImageNodes as $ImageNode) {
                $Images[] = AbsoluteSource($ImageNode->getAttribute('src'), $Url);
             }
             // Sort by size, biggest one first
             $ImageSort = array();
             // Only look at first 10 images (speed!)
             $i = 0;
             foreach ($Images as $Image) {
                $i++;
                if ($i > 10)
                   break;
                list($Width, $Height, $Type, $Attributes) = getimagesize($Image);
                $Diag = (int)floor(sqrt(($Width*$Width) + ($Height*$Height)));
                if (!array_key_exists($Diag, $ImageSort))
                   $ImageSort[$Diag] = $Image;
             }
             krsort($ImageSort);
             $PageInfo['Images'] = array_values($ImageSort);
          } catch (Exception $ex) {
             $PageInfo['Exception'] = $ex;
          }
          return $PageInfo;
       }

    Thanks to VanillaForum community.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Comments, problem with character encoding’ is closed to new replies.