diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-02 13:49:17 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-06-12 19:22:26 +0200 |
| commit | c3d7d830b4989c9ec4d56ec49b6b3ca3c44a9d20 (patch) | |
| tree | e781a127493b13f5f767f6a615c4a9dcce3d0f85 /tests | |
| parent | 402bc3ff2889cd19dd8373e68e90caf5ff0e2ab9 (diff) | |
| download | yafpp-c3d7d830b4989c9ec4d56ec49b6b3ca3c44a9d20.tar.gz yafpp-c3d7d830b4989c9ec4d56ec49b6b3ca3c44a9d20.zip | |
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/charset.php | 60 | ||||
| -rw-r--r-- | tests/charsetcurl.php | 11 | ||||
| -rw-r--r-- | tests/showmods.php | 9 | ||||
| -rw-r--r-- | tests/xpath.php | 33 |
4 files changed, 0 insertions, 113 deletions
diff --git a/tests/charset.php b/tests/charset.php deleted file mode 100644 index f429241..0000000 --- a/tests/charset.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -$config = array( - 'type' => 'xpath', - 'xpath' => 'div[@class="meldung_wrapper"]', -); - -// http://www.heise.de/newsticker/heise-atom.xml - -$article = array( - 'link' => 'http://www.heise.de/newsticker/meldung/Fruehjahrspatches-Microsoft-9-Adobe-3-1838175.html/from/atom10', - 'content' => 'This is the feed content', - 'plugin_data' => '', -); - -$doc = new DOMDocument(); - -$html = file_get_contents($article['link']); - -// BEGIN --- New code -$headers = $http_response_header; -$content_type = false; -foreach ($headers as $h) { - if (substr(strtolower($h), 0, 13) == 'content-type:') { - $content_type = substr($h, 14); - // don't break here to find LATEST (if redirected) entry - } -} - -$charset = false; -if ($content_type) { - preg_match('/charset=(\S+)/', $content_type, $matches); - if (isset($matches[1]) && !empty($matches[1])) $charset = $matches[1]; -} - -// END --- New code - -echo 'CHARSET: ' . $charset . PHP_EOL; - - -$doc->loadHTML('<?xml encoding="' . $charset . '">' . $html); - -echo 'ENCODING: ' . $doc->encoding . PHP_EOL; - -if ($doc) { - $basenode = false; - $xpath = new DOMXPath($doc); - $entries = $xpath->query('(//'.$config['xpath'].')'); // find main DIV according to config - - var_dump($entries); - - if ($entries->length > 0) $basenode = $entries->item(0); - - if ($basenode) { - $article['content'] = $doc->saveXML($basenode); - $article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data']; - } -} - -print_r($article); diff --git a/tests/charsetcurl.php b/tests/charsetcurl.php deleted file mode 100644 index 9db93e8..0000000 --- a/tests/charsetcurl.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -$ch = curl_init('http://www.heise.de/newsticker/meldung/Fruehjahrspatches-Microsoft-9-Adobe-3-1838175.html/from/atom10'); -#curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); -#curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -#curl_setopt($ch, CURLINFO_HEADER_OUT, true); - -curl_exec($ch); - -var_dump(curl_getinfo($ch,CURLINFO_CONTENT_TYPE)); - diff --git a/tests/showmods.php b/tests/showmods.php deleted file mode 100644 index 3408435..0000000 --- a/tests/showmods.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -$mods = glob('../mods/*.json'); - -foreach ($mods as $mod) { - $json = file_get_contents($mod); - $data = json_decode($json, true); - echo $mod . ': ' . $data['name'] . PHP_EOL; -} diff --git a/tests/xpath.php b/tests/xpath.php deleted file mode 100644 index 4e422ad..0000000 --- a/tests/xpath.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -$config = array( - 'type' => 'xpath', - 'xpath' => 'div[@itemprop="articleBody"]', -); - -$article = array( - 'link' => 'http://www.der-postillon.com/2013/04/nordkoreas-armee-nach-wochenlangem.html', - 'content' => 'This is the feed content', - 'plugin_data' => '', -); - -$doc = new DOMDocument(); -$html = file_get_contents($article['link']); -$doc->loadHTML($html); - -if ($doc) { - $basenode = false; - $xpath = new DOMXPath($doc); - $entries = $xpath->query('(//'.$config['xpath'].')'); // find main DIV according to config - - var_dump($entries); - - if ($entries->length > 0) $basenode = $entries->item(0); - - if ($basenode) { - $article['content'] = $doc->saveXML($basenode); - $article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data']; - } -} - -print_r($article);
\ No newline at end of file |
