getHttpData() публичный статический Метод

public static getHttpData ( $url, array $paramsGet = [], array $paramsPost = [] ) : boolean | string
$url
$paramsGet array
$paramsPost array
Результат boolean | string
Пример #1
0
 /**
  * @param $imagePath
  * @param array $options
  * @return $this|bool|self
  */
 public function load($imagePath, $options = [])
 {
     // support image URLs
     if (preg_match("@^https?://@", $imagePath)) {
         $tmpFilename = "imagick_auto_download_" . md5($imagePath) . "." . File::getFileExtension($imagePath);
         $tmpFilePath = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/" . $tmpFilename;
         $this->tmpFiles[] = $tmpFilePath;
         File::put($tmpFilePath, \Pimcore\Tool::getHttpData($imagePath));
         $imagePath = $tmpFilePath;
     }
     if ($this->resource) {
         unset($this->resource);
         $this->resource = null;
     }
     try {
         $i = new \Imagick();
         $this->imagePath = $imagePath;
         if (method_exists($i, "setcolorspace")) {
             $i->setcolorspace(\Imagick::COLORSPACE_SRGB);
         }
         $i->setBackgroundColor(new \ImagickPixel('transparent'));
         //set .png transparent (print)
         if (isset($options["resolution"])) {
             // set the resolution to 2000x2000 for known vector formats
             // otherwise this will cause problems with eg. cropPercent in the image editable (select specific area)
             // maybe there's a better solution but for now this fixes the problem
             $i->setResolution($options["resolution"]["x"], $options["resolution"]["y"]);
         }
         $imagePathLoad = $imagePath;
         if (!defined("HHVM_VERSION")) {
             $imagePathLoad .= "[0]";
             // not supported by HHVM implementation - selects the first layer/page in layered/pages file formats
         }
         if (!$i->readImage($imagePathLoad) || !filesize($imagePath)) {
             return false;
         }
         $this->resource = $i;
         // this is because of HHVM which has problems with $this->resource->readImage();
         // set dimensions
         $dimensions = $this->getDimensions();
         $this->setWidth($dimensions["width"]);
         $this->setHeight($dimensions["height"]);
         // check if image can have alpha channel
         if (!$this->reinitializing) {
             $alphaChannel = $i->getImageAlphaChannel();
             if ($alphaChannel) {
                 $this->setIsAlphaPossible(true);
             }
         }
         $this->setColorspaceToRGB();
     } catch (\Exception $e) {
         \Logger::error("Unable to load image: " . $imagePath);
         \Logger::error($e);
         return false;
     }
     $this->setModified(false);
     return $this;
 }
Пример #2
0
 /**
  * @param $domain
  */
 public function __construct($domain)
 {
     $this->_domain = $domain;
     try {
         $robotsUrl = $domain . '/robots.txt';
         $cacheKey = "robots_" . crc32($robotsUrl);
         if (!($robotsTxt = Cache::load($cacheKey))) {
             $robotsTxt = \Pimcore\Tool::getHttpData($robotsUrl);
             Cache::save($robotsTxt, $cacheKey, array("system"), 3600, 999, true);
         }
         $this->_rules = $this->_makeRules($robotsTxt);
     } catch (\Exception $e) {
     }
 }
Пример #3
0
 /**
  * loads the image by the specified path
  *
  * @param $imagePath
  * @param array $options
  * @return ImageMagick
  */
 public function load($imagePath, $options = [])
 {
     // support image URLs
     if (preg_match("@^https?://@", $imagePath)) {
         $tmpFilename = "imagick_auto_download_" . md5($imagePath) . "." . File::getFileExtension($imagePath);
         $tmpFilePath = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/" . $tmpFilename;
         $this->tmpFiles[] = $tmpFilePath;
         File::put($tmpFilePath, \Pimcore\Tool::getHttpData($imagePath));
         $imagePath = $tmpFilePath;
     }
     if (!stream_is_local($imagePath)) {
         // imagick is only able to deal with local files
         // if your're using custom stream wrappers this wouldn't work, so we create a temp. local copy
         $tmpFilePath = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/imagick-tmp-" . uniqid() . "." . File::getFileExtension($imagePath);
         copy($imagePath, $tmpFilePath);
         $imagePath = $tmpFilePath;
         $this->tmpFiles[] = $imagePath;
     }
     $this->imagePath = $imagePath;
     $this->initResource();
     $this->setModified(false);
     return $this;
 }
Пример #4
0
 /**
  * @throws \Zend_Json_Exception
  */
 public function translateAction()
 {
     $conf = Config::getSystemConfig();
     $key = $conf->services->translate->apikey;
     $locale = new \Zend_Locale($this->getParam("language"));
     $language = $locale->getLanguage();
     $supportedTypes = array("input", "textarea", "wysiwyg");
     $data = \Zend_Json::decode($this->getParam("data"));
     foreach ($data as &$d) {
         if (in_array($d["type"], $supportedTypes)) {
             $response = Tool::getHttpData("https://www.googleapis.com/language/translate/v2?key=" . $key . "&q=" . urlencode($d["data"]) . "&target=" . $language);
             $tData = \Zend_Json::decode($response);
             if ($tData["data"]["translations"][0]["translatedText"]) {
                 $d["data"] = $tData["data"]["translations"][0]["translatedText"];
             }
         }
     }
     $this->getRequest()->setParam("data", \Zend_Json::encode($data));
     $this->saveToSessionAction();
 }
Пример #5
0
 /**
  *
  */
 public function usageStatistics()
 {
     if (Config::getSystemConfig()->general->disableusagestatistics) {
         return;
     }
     $logFile = PIMCORE_LOG_DIRECTORY . "/usagelog.log";
     if (is_file($logFile) && filesize($logFile) > 200000) {
         $data = gzencode(file_get_contents($logFile));
         $response = Tool::getHttpData("https://www.pimcore.org/usage-statistics/", array(), array("data" => $data));
         if (strpos($response, "true") !== false) {
             @unlink($logFile);
             \Logger::debug("Usage statistics are transmitted and logfile was cleaned");
         } else {
             \Logger::debug("Unable to send usage statistics");
         }
     }
 }
 public function importUrlAction()
 {
     $success = true;
     $data = Tool::getHttpData($this->getParam("url"));
     $filename = basename($this->getParam("url"));
     $parentId = $this->getParam("id");
     $parentAsset = Asset::getById(intval($parentId));
     $filename = File::getValidFilename($filename);
     $filename = $this->getSafeFilename($parentAsset->getFullPath(), $filename);
     if (empty($filename)) {
         throw new \Exception("The filename of the asset is empty");
     }
     // check for duplicate filename
     $filename = $this->getSafeFilename($parentAsset->getFullPath(), $filename);
     if ($parentAsset->isAllowed("create")) {
         $asset = Asset::create($parentId, array("filename" => $filename, "data" => $data, "userOwner" => $this->user->getId(), "userModification" => $this->user->getId()));
         $success = true;
     } else {
         \Logger::debug("prevented creating asset because of missing permissions");
     }
     $this->_helper->json(array("success" => $success));
 }
Пример #7
0
 /**
  * @param $string
  * @param null $document
  * @return mixed
  * @throws \Exception
  */
 public static function embedAndModifyCss($string, $document = null)
 {
     if ($document && $document instanceof Model\Document == false) {
         throw new \Exception('$document has to be an instance of Document');
     }
     //matches all <link> Tags
     preg_match_all("@<link.*?href\\s*=\\s*[\"'](.*?)[\"'].*?(/?>|</\\s*link>)@is", $string, $matches);
     if (!empty($matches[0])) {
         $css = "";
         foreach ($matches[0] as $key => $value) {
             $fullMatch = $matches[0][$key];
             $path = $matches[1][$key];
             $fileContent = "";
             $fileInfo = [];
             if (stream_is_local($path)) {
                 $fileInfo = self::getNormalizedFileInfo($path, $document);
                 if (in_array($fileInfo['fileExtension'], ['css', 'less'])) {
                     if (is_readable($fileInfo['filePathNormalized'])) {
                         if ($fileInfo['fileExtension'] == 'css') {
                             $fileContent = file_get_contents($fileInfo['filePathNormalized']);
                         } else {
                             $fileContent = \Pimcore\Tool\Less::compile($fileInfo['filePathNormalized']);
                             $fileContent = str_replace('/**** compiled with lessphp ****/', '', $fileContent);
                         }
                     }
                 }
             } elseif (strpos($path, "http") === 0) {
                 $fileContent = \Pimcore\Tool::getHttpData($path);
                 $fileInfo = ["fileUrlNormalized" => $path];
             }
             if ($fileContent) {
                 $fileContent = self::normalizeCssContent($fileContent, $fileInfo);
                 $css .= "\n\n\n";
                 $css .= $fileContent;
                 // remove <link> tag
                 $string = str_replace($fullMatch, '', $string);
             }
         }
         $cssToInlineStyles = new CssToInlineStyles();
         $cssToInlineStyles->setHTML($string);
         $cssToInlineStyles->setCSS($css);
         $string = $cssToInlineStyles->convert();
     }
     return $string;
 }
Пример #8
0
 public function seopanelTreeAction()
 {
     $this->checkPermission("seo_document_editor");
     $document = Document::getById($this->getParam("node"));
     $documents = array();
     if ($document->hasChilds()) {
         $list = new Document\Listing();
         $list->setCondition("parentId = ?", $document->getId());
         $list->setOrderKey("index");
         $list->setOrder("asc");
         $childsList = $list->load();
         foreach ($childsList as $childDocument) {
             // only display document if listing is allowed for the current user
             if ($childDocument->isAllowed("list")) {
                 $list = new Document\Listing();
                 $list->setCondition("path LIKE ? and type = ?", array($childDocument->getFullPath() . "/%", "page"));
                 if ($childDocument instanceof Document\Page || $list->getTotalCount() > 0) {
                     $nodeConfig = $this->getTreeNodeConfig($childDocument);
                     if (method_exists($childDocument, "getTitle") && method_exists($childDocument, "getDescription")) {
                         // anaylze content
                         $nodeConfig["links"] = 0;
                         $nodeConfig["externallinks"] = 0;
                         $nodeConfig["h1"] = 0;
                         $nodeConfig["h1_text"] = "";
                         $nodeConfig["hx"] = 0;
                         $nodeConfig["imgwithalt"] = 0;
                         $nodeConfig["imgwithoutalt"] = 0;
                         $title = null;
                         $description = null;
                         try {
                             // cannot use the rendering service from Document\Service::render() because of singleton's ...
                             // $content = Document\Service::render($childDocument, array("pimcore_admin" => true, "pimcore_preview" => true), true);
                             $request = $this->getRequest();
                             $contentUrl = $request->getScheme() . "://" . $request->getHttpHost() . $childDocument->getFullPath();
                             $content = Tool::getHttpData($contentUrl, array("pimcore_preview" => true, "pimcore_admin" => true, "_dc" => time()));
                             if ($content) {
                                 include_once "simple_html_dom.php";
                                 $html = str_get_html($content);
                                 if ($html) {
                                     $nodeConfig["links"] = count($html->find("a"));
                                     $nodeConfig["externallinks"] = count($html->find("a[href^=http]"));
                                     $nodeConfig["h1"] = count($html->find("h1"));
                                     $h1 = $html->find("h1", 0);
                                     if ($h1) {
                                         $nodeConfig["h1_text"] = strip_tags($h1->innertext);
                                     }
                                     $title = $html->find("title", 0);
                                     if ($title) {
                                         $title = html_entity_decode(trim(strip_tags($title->innertext)), null, "UTF-8");
                                     }
                                     $description = $html->find("meta[name=description]", 0);
                                     if ($description) {
                                         $description = html_entity_decode(trim(strip_tags($description->content)), null, "UTF-8");
                                     }
                                     $nodeConfig["hx"] = count($html->find("h2,h2,h4,h5"));
                                     $images = $html->find("img");
                                     if ($images) {
                                         foreach ($images as $image) {
                                             $alt = $image->alt;
                                             if (empty($alt)) {
                                                 $nodeConfig["imgwithoutalt"]++;
                                             } else {
                                                 $nodeConfig["imgwithalt"]++;
                                             }
                                         }
                                     }
                                     $html->clear();
                                     unset($html);
                                 }
                             }
                         } catch (\Exception $e) {
                             \Logger::debug($e);
                         }
                         if (!$title) {
                             $title = $childDocument->getTitle();
                         }
                         if (!$description) {
                             $description = $childDocument->getDescription();
                         }
                         $nodeConfig["title"] = $title;
                         $nodeConfig["description"] = $description;
                         $nodeConfig["title_length"] = mb_strlen($title);
                         $nodeConfig["description_length"] = mb_strlen($description);
                         if (mb_strlen($title) > 80 || mb_strlen($title) < 5 || mb_strlen($description) > 180 || mb_strlen($description) < 20 || $nodeConfig["h1"] != 1 || $nodeConfig["hx"] < 1) {
                             $nodeConfig["cls"] = "pimcore_document_seo_warning";
                         }
                     }
                     $documents[] = $nodeConfig;
                 }
             }
         }
     }
     $this->_helper->json($documents);
 }
Пример #9
0
<?php

// update .htaccess to the latest version if not changed manually
$htaccessFile = PIMCORE_DOCUMENT_ROOT . "/.htaccess";
$currentFileMd5 = md5_file($htaccessFile);
// old standard md5's
$defaultMd5s = ["64fcf5d7266000f01ed7c64e4793b407", "bdf1652ff1c76d0251d8f4afe73d1e0f", "e769830d7e4f2d7b79481237052df0ec", "cc05bacbc951d4afc1224ec3a4191bbd", "6375537320664103ff1d9b1f22852b63", "254fc7e808732c5bd3008b92ebce8cae", "42c4974dff95764f3cf0e5b7a6e8df0d", "18fede900eb01b921a522b7e80a61bfd", "2716d910eef4ff1e887b4fc8bc865f7d", "e173dc2b9c278baa8e6bb3fca4676e23", "1dc23f9666512f20743e718b7e54fed9", "5f8d678fdc15a4552d8d3c99d657b844", "5c5a899c5c5b190300764b75f2492aef", "9c22252dc36769323ab15c036c055afa", "1c656a396801827236a3af3c63638070", "0bdde18a3484599a9b9ae4a42ee6d1f8"];
if (in_array($currentFileMd5, $defaultMd5s)) {
    // this instance is using a default .htaccess, so we can update it
    $oldData = file_get_contents($htaccessFile);
    $data = \Pimcore\Tool::getHttpData("https://raw.githubusercontent.com/pimcore/pimcore/1bf36b865bc47cf88ead0fc401161f3782f5de07/.htaccess");
    if (strpos($data, "RewriteEngine On")) {
        // check for a certain string in the content, that has to be in the file
        file_put_contents($htaccessFile, $data);
        if (md5_file($htaccessFile) != "93c9ae0d2211a46db278bdfe5011fff2") {
            // something went wrong, write back the old contents
            file_put_contents($htaccessFile, $oldData);
        }
    }
}
Пример #10
0
 public function getLanguagesAction()
 {
     $languagesJson = \Pimcore\Tool::getHttpData("http://www.pimcore.org/?controller=translation&action=json");
     echo $languagesJson;
     exit;
     $languagesData = \Zend_Json_Decoder::decode($languagesJson);
     $languages = $languagesData["languages"];
     if (is_array($languages)) {
         for ($i = 0; $i < count($languages); $i++) {
             if (is_file($filesDir = PIMCORE_CONFIGURATION_DIRECTORY . "/texts/" . $languages[$i]['key'] . ".csv")) {
                 $languages[$i]["exists"] = true;
             } else {
                 $languages[$i]["exists"] = false;
             }
         }
     }
     $this->_helper->json(array("languages" => $languages));
 }
Пример #11
0
 /**
  *
  */
 public static function updateMaxmindDb()
 {
     $downloadUrl = "http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz";
     $geoDbFile = PIMCORE_CONFIGURATION_DIRECTORY . "/GeoLite2-City.mmdb";
     $geoDbFileGz = $geoDbFile . ".gz";
     $firstTuesdayOfMonth = strtotime(date("F") . " 2013 tuesday");
     $filemtime = 0;
     if (file_exists($geoDbFile)) {
         $filemtime = filemtime($geoDbFile);
     }
     // update if file is older than 30 days, or if it is the first tuesday of the month
     if ($filemtime < time() - 30 * 86400 || date("m/d/Y") == date("m/d/Y", $firstTuesdayOfMonth) && $filemtime < time() - 86400) {
         $data = Tool::getHttpData($downloadUrl);
         if (strlen($data) > 1000000) {
             File::put($geoDbFileGz, $data);
             @unlink($geoDbFile);
             $sfp = gzopen($geoDbFileGz, "rb");
             $fp = fopen($geoDbFile, "w");
             while ($string = gzread($sfp, 4096)) {
                 fwrite($fp, $string, strlen($string));
             }
             gzclose($sfp);
             fclose($fp);
             unlink($geoDbFileGz);
             \Logger::info("Updated MaxMind GeoIP2 Database in: " . $geoDbFile);
         } else {
             \Logger::err("Failed to update MaxMind GeoIP2, size is under about 1M");
         }
     } else {
         \Logger::debug("MayMind GeoIP2 Download skipped, everything up to date, last update: " . date("m/d/Y H:i", $filemtime));
     }
 }
Пример #12
0
<?php

// update .htaccess to the latest version if not changed manually
$htaccessFile = PIMCORE_DOCUMENT_ROOT . "/.htaccess";
$currentFileMd5 = md5_file($htaccessFile);
// old standard md5's
$defaultMd5s = ["64fcf5d7266000f01ed7c64e4793b407", "bdf1652ff1c76d0251d8f4afe73d1e0f", "e769830d7e4f2d7b79481237052df0ec", "cc05bacbc951d4afc1224ec3a4191bbd", "6375537320664103ff1d9b1f22852b63", "254fc7e808732c5bd3008b92ebce8cae", "42c4974dff95764f3cf0e5b7a6e8df0d", "18fede900eb01b921a522b7e80a61bfd", "2716d910eef4ff1e887b4fc8bc865f7d", "e173dc2b9c278baa8e6bb3fca4676e23", "1dc23f9666512f20743e718b7e54fed9", "5f8d678fdc15a4552d8d3c99d657b844", "5c5a899c5c5b190300764b75f2492aef", "9c22252dc36769323ab15c036c055afa"];
if (in_array($currentFileMd5, $defaultMd5s)) {
    // this instance is using a default .htaccess, so we can update it
    $oldData = file_get_contents($htaccessFile);
    $data = \Pimcore\Tool::getHttpData("https://raw.githubusercontent.com/pimcore/pimcore/4286080f649c79c97357e0c63cbb759224b20497/.htaccess");
    if (strpos($data, "RewriteEngine On")) {
        // check for a certain string in the content, that has to be in the file
        file_put_contents($htaccessFile, $data);
        if (md5_file($htaccessFile) != "1c656a396801827236a3af3c63638070") {
            // something went wrong, write back the old contents
            file_put_contents($htaccessFile, $oldData);
        }
    }
}
Пример #13
0
 /**
  * @param $imagePath
  * @param array $options
  * @return $this|bool|self
  */
 public function load($imagePath, $options = [])
 {
     // support image URLs
     if (preg_match("@^https?://@", $imagePath)) {
         $tmpFilename = "imagick_auto_download_" . md5($imagePath) . "." . File::getFileExtension($imagePath);
         $tmpFilePath = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/" . $tmpFilename;
         $this->tmpFiles[] = $tmpFilePath;
         File::put($tmpFilePath, \Pimcore\Tool::getHttpData($imagePath));
         $imagePath = $tmpFilePath;
     }
     if (!stream_is_local($imagePath)) {
         // imagick is only able to deal with local files
         // if your're using custom stream wrappers this wouldn't work, so we create a temp. local copy
         $tmpFilePath = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/imagick-tmp-" . uniqid() . "." . File::getFileExtension($imagePath);
         copy($imagePath, $tmpFilePath);
         $imagePath = $tmpFilePath;
         $this->tmpFiles[] = $imagePath;
     }
     if ($this->resource) {
         unset($this->resource);
         $this->resource = null;
     }
     try {
         $i = new \Imagick();
         $this->imagePath = $imagePath;
         if (!$this->isPreserveColor() && method_exists($i, "setcolorspace")) {
             $i->setcolorspace(\Imagick::COLORSPACE_SRGB);
         }
         if (!$this->isPreserveColor() && $this->isVectorGraphic($imagePath)) {
             // only for vector graphics
             // the below causes problems with PSDs when target format is PNG32 (nobody knows why ;-))
             $i->setBackgroundColor(new \ImagickPixel('transparent'));
         }
         if (isset($options["resolution"])) {
             // set the resolution to 2000x2000 for known vector formats
             // otherwise this will cause problems with eg. cropPercent in the image editable (select specific area)
             // maybe there's a better solution but for now this fixes the problem
             $i->setResolution($options["resolution"]["x"], $options["resolution"]["y"]);
         }
         $imagePathLoad = $imagePath;
         if (!defined("HHVM_VERSION")) {
             $imagePathLoad .= "[0]";
             // not supported by HHVM implementation - selects the first layer/page in layered/pages file formats
         }
         if (!$i->readImage($imagePathLoad) || !filesize($imagePath)) {
             return false;
         }
         $this->resource = $i;
         // this is because of HHVM which has problems with $this->resource->readImage();
         // set dimensions
         $dimensions = $this->getDimensions();
         $this->setWidth($dimensions["width"]);
         $this->setHeight($dimensions["height"]);
         // check if image can have alpha channel
         if (!$this->reinitializing) {
             $alphaChannel = $i->getImageAlphaChannel();
             if ($alphaChannel) {
                 $this->setIsAlphaPossible(true);
             }
         }
         if (!$this->isPreserveColor()) {
             $this->setColorspaceToRGB();
         }
     } catch (\Exception $e) {
         Logger::error("Unable to load image: " . $imagePath);
         Logger::error($e);
         return false;
     }
     $this->setModified(false);
     return $this;
 }
Пример #14
0
<?php

// update .htaccess to the latest version if not changed manually
$htaccessFile = PIMCORE_DOCUMENT_ROOT . "/.htaccess";
$currentFileMd5 = md5_file($htaccessFile);
// old standard md5's
$defaultMd5s = ["64fcf5d7266000f01ed7c64e4793b407", "bdf1652ff1c76d0251d8f4afe73d1e0f", "e769830d7e4f2d7b79481237052df0ec", "cc05bacbc951d4afc1224ec3a4191bbd", "6375537320664103ff1d9b1f22852b63", "254fc7e808732c5bd3008b92ebce8cae", "42c4974dff95764f3cf0e5b7a6e8df0d", "18fede900eb01b921a522b7e80a61bfd", "2716d910eef4ff1e887b4fc8bc865f7d", "e173dc2b9c278baa8e6bb3fca4676e23", "1dc23f9666512f20743e718b7e54fed9", "5f8d678fdc15a4552d8d3c99d657b844", "5c5a899c5c5b190300764b75f2492aef", "9c22252dc36769323ab15c036c055afa", "1c656a396801827236a3af3c63638070"];
if (in_array($currentFileMd5, $defaultMd5s)) {
    // this instance is using a default .htaccess, so we can update it
    $oldData = file_get_contents($htaccessFile);
    $data = \Pimcore\Tool::getHttpData("https://raw.githubusercontent.com/pimcore/pimcore/b4affb659ff07a95ebf72308e05becffc24afc60/.htaccess");
    if (strpos($data, "RewriteEngine On")) {
        // check for a certain string in the content, that has to be in the file
        file_put_contents($htaccessFile, $data);
        if (md5_file($htaccessFile) != "0bdde18a3484599a9b9ae4a42ee6d1f8") {
            // something went wrong, write back the old contents
            file_put_contents($htaccessFile, $oldData);
        }
    }
}
Пример #15
0
 private function getSeoNodeConfig($document)
 {
     $nodeConfig = $this->getTreeNodeConfig($document);
     if (method_exists($document, "getTitle") && method_exists($document, "getDescription")) {
         // anaylze content
         $nodeConfig["links"] = 0;
         $nodeConfig["externallinks"] = 0;
         $nodeConfig["h1"] = 0;
         $nodeConfig["h1_text"] = "";
         $nodeConfig["hx"] = 0;
         $nodeConfig["imgwithalt"] = 0;
         $nodeConfig["imgwithoutalt"] = 0;
         $title = null;
         $description = null;
         try {
             // cannot use the rendering service from Document\Service::render() because of singleton's ...
             // $content = Document\Service::render($childDocument, array("pimcore_admin" => true, "pimcore_preview" => true), true);
             $request = $this->getRequest();
             $contentUrl = $request->getScheme() . "://" . $request->getHttpHost() . $document->getFullPath();
             $content = Tool::getHttpData($contentUrl, ["pimcore_preview" => true, "pimcore_admin" => true, "_dc" => time()]);
             if ($content) {
                 include_once "simple_html_dom.php";
                 $html = str_get_html($content);
                 if ($html) {
                     $nodeConfig["links"] = count($html->find("a"));
                     $nodeConfig["externallinks"] = count($html->find("a[href^=http]"));
                     $nodeConfig["h1"] = count($html->find("h1"));
                     $h1 = $html->find("h1", 0);
                     if ($h1) {
                         $nodeConfig["h1_text"] = strip_tags($h1->innertext);
                     }
                     $title = $html->find("title", 0);
                     if ($title) {
                         $title = html_entity_decode(trim(strip_tags($title->innertext)), null, "UTF-8");
                     }
                     $description = $html->find("meta[name=description]", 0);
                     if ($description) {
                         $description = html_entity_decode(trim(strip_tags($description->content)), null, "UTF-8");
                     }
                     $nodeConfig["hx"] = count($html->find("h2,h2,h4,h5"));
                     $images = $html->find("img");
                     if ($images) {
                         foreach ($images as $image) {
                             $alt = $image->alt;
                             if (empty($alt)) {
                                 $nodeConfig["imgwithoutalt"]++;
                             } else {
                                 $nodeConfig["imgwithalt"]++;
                             }
                         }
                     }
                     $html->clear();
                     unset($html);
                 }
             }
         } catch (\Exception $e) {
             Logger::debug($e);
         }
         if (!$title) {
             $title = $document->getTitle();
         }
         if (!$description) {
             $description = $document->getDescription();
         }
         $nodeConfig["title"] = $title;
         $nodeConfig["description"] = $description;
         $nodeConfig["title_length"] = mb_strlen($title);
         $nodeConfig["description_length"] = mb_strlen($description);
         $qtip = "";
         /** @var \Zend_Translate_Adapter $t */
         $t = \Zend_Registry::get("Zend_Translate");
         if (mb_strlen($title) > 80) {
             $nodeConfig["cls"] = "pimcore_document_seo_warning";
             $qtip .= $t->translate("The title is too long, it should have 5 to 80 characters.<br>");
         }
         if (mb_strlen($title) < 5) {
             $nodeConfig["cls"] = "pimcore_document_seo_warning";
             $qtip .= $t->translate("The title is too short, it should have 5 to 80 characters.<br>");
         }
         if (mb_strlen($description) > 180) {
             $nodeConfig["cls"] = "pimcore_document_seo_warning";
             $qtip .= $t->translate("The description is too long, it should have 20 to 180 characters.<br>");
         }
         if (mb_strlen($description) < 20) {
             $nodeConfig["cls"] = "pimcore_document_seo_warning";
             $qtip .= $t->translate("The description is too short, it should have 20 to 180 characters.<br>");
         }
         if ($nodeConfig["h1"] != 1) {
             $nodeConfig["cls"] = "pimcore_document_seo_warning";
             $qtip .= sprintf($t->translate("The document should have one h1, but has %s.<br>"), $nodeConfig["h1"]);
         }
         if ($nodeConfig["hx"] < 1) {
             $nodeConfig["cls"] = "pimcore_document_seo_warning";
             $qtip .= $t->translate("The document should some headlines other than h1, but has none.<br>");
         }
         if ($qtip) {
             $nodeConfig["qtip"] = $qtip;
         }
     }
     return $nodeConfig;
 }