Update dependencies, enable temporary PicoFeed debug logs
This commit is contained in:
parent
e09133f004
commit
b0c1f57213
@ -34,6 +34,10 @@ defined('AUTO_UPDATE_BACKUP_DIRECTORY') or define('AUTO_UPDATE_BACKUP_DIRECTORY'
|
|||||||
|
|
||||||
require __DIR__.'/check_setup.php';
|
require __DIR__.'/check_setup.php';
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
PicoFeed\Logging\Logger::enable();
|
||||||
|
}
|
||||||
|
|
||||||
PicoDb\Database::bootstrap('db', function() {
|
PicoDb\Database::bootstrap('db', function() {
|
||||||
|
|
||||||
$db = new PicoDb\Database(array(
|
$db = new PicoDb\Database(array(
|
||||||
|
@ -59,7 +59,7 @@ function get_favicons(array $feed_ids)
|
|||||||
return Database::get('db')
|
return Database::get('db')
|
||||||
->table('favicons')
|
->table('favicons')
|
||||||
->in('feed_id', $feed_ids)
|
->in('feed_id', $feed_ids)
|
||||||
->listing('feed_id', 'icon');
|
->hashmap('feed_id', 'icon');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all favicons for a list of items
|
// Get all favicons for a list of items
|
||||||
@ -83,7 +83,7 @@ function get_all_favicons()
|
|||||||
|
|
||||||
return Database::get('db')
|
return Database::get('db')
|
||||||
->table('favicons')
|
->table('favicons')
|
||||||
->listing('feed_id', 'icon');
|
->hashmap('feed_id', 'icon');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update feed information
|
// Update feed information
|
||||||
@ -290,7 +290,7 @@ function get_ids($limit = LIMIT_ALL)
|
|||||||
$query->limit((int) $limit);
|
$query->limit((int) $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->listing('id', 'id');
|
return $query->hashmap('id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// get number of feeds with errors
|
// get number of feeds with errors
|
||||||
|
@ -71,7 +71,7 @@ function get_all_status()
|
|||||||
->table('items')
|
->table('items')
|
||||||
->in('status', array('read', 'unread'))
|
->in('status', array('read', 'unread'))
|
||||||
->orderBy('updated', 'desc')
|
->orderBy('updated', 'desc')
|
||||||
->listing('id', 'status');
|
->hashmap('id', 'status');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all items by status
|
// Get all items by status
|
||||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb::getLoader();
|
return ComposerAutoloaderInita3275f8a3fafdaf0ccb719369aca304a::getLoader();
|
||||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -36,6 +36,7 @@ return array(
|
|||||||
'PicoFeed\\Filter\\Tag' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php',
|
'PicoFeed\\Filter\\Tag' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php',
|
||||||
'PicoFeed\\Logging\\Logger' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Logging/Logger.php',
|
'PicoFeed\\Logging\\Logger' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Logging/Logger.php',
|
||||||
'PicoFeed\\Parser\\Atom' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php',
|
'PicoFeed\\Parser\\Atom' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php',
|
||||||
|
'PicoFeed\\Parser\\DateParser' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php',
|
||||||
'PicoFeed\\Parser\\Feed' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php',
|
'PicoFeed\\Parser\\Feed' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php',
|
||||||
'PicoFeed\\Parser\\Item' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Parser/Item.php',
|
'PicoFeed\\Parser\\Item' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Parser/Item.php',
|
||||||
'PicoFeed\\Parser\\MalformedXmlException' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php',
|
'PicoFeed\\Parser\\MalformedXmlException' => $vendorDir . '/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php',
|
||||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb
|
class ComposerAutoloaderInita3275f8a3fafdaf0ccb719369aca304a
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
@ -19,9 +19,9 @@ class ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb
|
|||||||
return self::$loader;
|
return self::$loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb', 'loadClassLoader'), true, true);
|
spl_autoload_register(array('ComposerAutoloaderInita3275f8a3fafdaf0ccb719369aca304a', 'loadClassLoader'), true, true);
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb', 'loadClassLoader'));
|
spl_autoload_unregister(array('ComposerAutoloaderInita3275f8a3fafdaf0ccb719369aca304a', 'loadClassLoader'));
|
||||||
|
|
||||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||||
foreach ($map as $namespace => $path) {
|
foreach ($map as $namespace => $path) {
|
||||||
@ -42,14 +42,14 @@ class ComposerAutoloaderInitdd123afa0ab8d569c051c35ab70311cb
|
|||||||
|
|
||||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||||
foreach ($includeFiles as $file) {
|
foreach ($includeFiles as $file) {
|
||||||
composerRequiredd123afa0ab8d569c051c35ab70311cb($file);
|
composerRequirea3275f8a3fafdaf0ccb719369aca304a($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function composerRequiredd123afa0ab8d569c051c35ab70311cb($file)
|
function composerRequirea3275f8a3fafdaf0ccb719369aca304a($file)
|
||||||
{
|
{
|
||||||
require $file;
|
require $file;
|
||||||
}
|
}
|
||||||
|
164
vendor/composer/installed.json
vendored
164
vendor/composer/installed.json
vendored
@ -38,84 +38,6 @@
|
|||||||
"description": "The most easy to use validator library for PHP :)",
|
"description": "The most easy to use validator library for PHP :)",
|
||||||
"homepage": "https://github.com/fguillot/simpleValidator"
|
"homepage": "https://github.com/fguillot/simpleValidator"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "fguillot/json-rpc",
|
|
||||||
"version": "dev-master",
|
|
||||||
"version_normalized": "9999999-dev",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/fguillot/JsonRPC.git",
|
|
||||||
"reference": "86e8339205616ad9b09d581957cc084a99c0ed27"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/fguillot/JsonRPC/zipball/86e8339205616ad9b09d581957cc084a99c0ed27",
|
|
||||||
"reference": "86e8339205616ad9b09d581957cc084a99c0ed27",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.0"
|
|
||||||
},
|
|
||||||
"time": "2014-11-22 20:32:14",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"JsonRPC": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"Unlicense"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Frédéric Guillot",
|
|
||||||
"homepage": "http://fredericguillot.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A simple Json-RPC client/server library that just works",
|
|
||||||
"homepage": "https://github.com/fguillot/JsonRPC"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "fguillot/picodb",
|
|
||||||
"version": "dev-master",
|
|
||||||
"version_normalized": "9999999-dev",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/fguillot/picoDb.git",
|
|
||||||
"reference": "268b3389d2bc3c92ef749a63440d17bd75e2a628"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/268b3389d2bc3c92ef749a63440d17bd75e2a628",
|
|
||||||
"reference": "268b3389d2bc3c92ef749a63440d17bd75e2a628",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.0"
|
|
||||||
},
|
|
||||||
"time": "2015-01-03 00:32:58",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"PicoDb": "lib/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"WTFPL"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Frédéric Guillot",
|
|
||||||
"homepage": "http://fredericguillot.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Minimalist database query builder",
|
|
||||||
"homepage": "https://github.com/fguillot/picoDb"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "fguillot/picofarad",
|
"name": "fguillot/picofarad",
|
||||||
"version": "dev-master",
|
"version": "dev-master",
|
||||||
@ -155,6 +77,45 @@
|
|||||||
"description": "Minimalist micro-framework",
|
"description": "Minimalist micro-framework",
|
||||||
"homepage": "https://github.com/fguillot/picoFarad"
|
"homepage": "https://github.com/fguillot/picoFarad"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "fguillot/json-rpc",
|
||||||
|
"version": "dev-master",
|
||||||
|
"version_normalized": "9999999-dev",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/fguillot/JsonRPC.git",
|
||||||
|
"reference": "f2d92d5a27749e1cfced841f96203f3275a5c16c"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/fguillot/JsonRPC/zipball/f2d92d5a27749e1cfced841f96203f3275a5c16c",
|
||||||
|
"reference": "f2d92d5a27749e1cfced841f96203f3275a5c16c",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"time": "2015-01-19 03:42:02",
|
||||||
|
"type": "library",
|
||||||
|
"installation-source": "dist",
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"JsonRPC": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"Unlicense"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Frédéric Guillot",
|
||||||
|
"homepage": "http://fredericguillot.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A simple Json-RPC client/server library that just works",
|
||||||
|
"homepage": "https://github.com/fguillot/JsonRPC"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "fguillot/picofeed",
|
"name": "fguillot/picofeed",
|
||||||
"version": "dev-master",
|
"version": "dev-master",
|
||||||
@ -162,18 +123,18 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/fguillot/picoFeed.git",
|
"url": "https://github.com/fguillot/picoFeed.git",
|
||||||
"reference": "f3ed9fef18b4cd0d25a1fd389c8a2e2370bcb51b"
|
"reference": "8858f63e5380e8b1df4d8a4bbc5618931cddde7d"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/d3785fc54d0bf9d521fd85e369cc5600f66099cc",
|
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/8858f63e5380e8b1df4d8a4bbc5618931cddde7d",
|
||||||
"reference": "f3ed9fef18b4cd0d25a1fd389c8a2e2370bcb51b",
|
"reference": "8858f63e5380e8b1df4d8a4bbc5618931cddde7d",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.0"
|
"php": ">=5.3.0"
|
||||||
},
|
},
|
||||||
"time": "2015-01-18 00:05:29",
|
"time": "2015-01-18 02:06:19",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -193,5 +154,44 @@
|
|||||||
],
|
],
|
||||||
"description": "Modern library to write or read feeds (RSS/Atom)",
|
"description": "Modern library to write or read feeds (RSS/Atom)",
|
||||||
"homepage": "http://fguillot.github.io/picoFeed"
|
"homepage": "http://fguillot.github.io/picoFeed"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "fguillot/picodb",
|
||||||
|
"version": "dev-master",
|
||||||
|
"version_normalized": "9999999-dev",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/fguillot/picoDb.git",
|
||||||
|
"reference": "9588cf60e74dd6ff63d96f7eb91c4f74b47a11b1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/9588cf60e74dd6ff63d96f7eb91c4f74b47a11b1",
|
||||||
|
"reference": "9588cf60e74dd6ff63d96f7eb91c4f74b47a11b1",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"time": "2015-01-20 00:52:01",
|
||||||
|
"type": "library",
|
||||||
|
"installation-source": "dist",
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"PicoDb": "lib/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"WTFPL"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Frédéric Guillot",
|
||||||
|
"homepage": "http://fredericguillot.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Minimalist database query builder",
|
||||||
|
"homepage": "https://github.com/fguillot/picoDb"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -82,6 +82,12 @@ class Client
|
|||||||
'Content-Type: application/json',
|
'Content-Type: application/json',
|
||||||
'Accept: application/json'
|
'Accept: application/json'
|
||||||
);
|
);
|
||||||
|
/**
|
||||||
|
* SSL certificates verification
|
||||||
|
* @access public
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
public $ssl_verify_peer = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -288,6 +294,7 @@ class Client
|
|||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
||||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
||||||
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->ssl_verify_peer);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
||||||
|
|
||||||
if ($this->username && $this->password) {
|
if ($this->username && $this->password) {
|
||||||
|
24
vendor/fguillot/picodb/lib/PicoDb/Table.php
vendored
24
vendor/fguillot/picodb/lib/PicoDb/Table.php
vendored
@ -21,6 +21,7 @@ class Table
|
|||||||
private $values = array();
|
private $values = array();
|
||||||
private $distinct = false;
|
private $distinct = false;
|
||||||
private $group_by = array();
|
private $group_by = array();
|
||||||
|
private $filter_callback = null;
|
||||||
private $db;
|
private $db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +138,7 @@ class Table
|
|||||||
* @param string $value Column 2
|
* @param string $value Column 2
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function listing($key, $value)
|
public function hashmap($key, $value)
|
||||||
{
|
{
|
||||||
$listing = array();
|
$listing = array();
|
||||||
|
|
||||||
@ -153,6 +154,19 @@ class Table
|
|||||||
return $listing;
|
return $listing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add callback to alter the resultset
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array|callable $callback
|
||||||
|
* @return \PicoDb\Table
|
||||||
|
*/
|
||||||
|
public function filter($callback)
|
||||||
|
{
|
||||||
|
$this->filter_callback = $callback;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all rows
|
* Fetch all rows
|
||||||
*
|
*
|
||||||
@ -162,7 +176,13 @@ class Table
|
|||||||
public function findAll()
|
public function findAll()
|
||||||
{
|
{
|
||||||
$rq = $this->db->execute($this->buildSelectQuery(), $this->values);
|
$rq = $this->db->execute($this->buildSelectQuery(), $this->values);
|
||||||
return $rq->fetchAll(PDO::FETCH_ASSOC);
|
$results = $rq->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (is_callable($this->filter_callback)) {
|
||||||
|
return call_user_func($this->filter_callback, $results);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
18
vendor/fguillot/picofeed/docs/debugging.markdown
vendored
18
vendor/fguillot/picofeed/docs/debugging.markdown
vendored
@ -4,7 +4,23 @@ Debugging
|
|||||||
Logging
|
Logging
|
||||||
-------
|
-------
|
||||||
|
|
||||||
PicoFeed log in memory the execution flow, if a feed doesn't work correctly it's easy to see what is wrong.
|
PicoFeed can log **in memory** the execution flow, if a feed doesn't work correctly it's easy to see what is wrong.
|
||||||
|
|
||||||
|
### Enable/disable logging
|
||||||
|
|
||||||
|
The logging is **disabled by default** to avoid unnecessary memory usage.
|
||||||
|
|
||||||
|
Enable logging:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use PicoFeed\Logging\Logger;
|
||||||
|
|
||||||
|
Logger::enable();
|
||||||
|
|
||||||
|
// or change the flag value
|
||||||
|
|
||||||
|
Logger::$enable = true;
|
||||||
|
```
|
||||||
|
|
||||||
### Reading messages
|
### Reading messages
|
||||||
|
|
||||||
|
@ -335,39 +335,6 @@ abstract class Client
|
|||||||
return isset($response['headers'][$header]) ? $response['headers'][$header] : '';
|
return isset($response['headers'][$header]) ? $response['headers'][$header] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse HTTP headers
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param array $lines List of headers
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function parseHeaders(array $lines)
|
|
||||||
{
|
|
||||||
$status = 200;
|
|
||||||
$headers = array();
|
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
|
||||||
|
|
||||||
if (strpos($line, 'HTTP') === 0) {
|
|
||||||
$status = (int) substr($line, 9, 3);
|
|
||||||
}
|
|
||||||
else if (strpos($line, ':') !== false) {
|
|
||||||
|
|
||||||
@list($name, $value) = explode(': ', $line);
|
|
||||||
if ($value) $headers[trim($name)] = trim($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger::setMessage(get_called_class().' HTTP status code: '.$status);
|
|
||||||
|
|
||||||
foreach ($headers as $name => $value) {
|
|
||||||
Logger::setMessage(get_called_class().' HTTP header: '.$name.' => '.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return array($status, new HttpHeaders($headers));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Last-Modified HTTP header
|
* Set the Last-Modified HTTP header
|
||||||
*
|
*
|
||||||
|
@ -233,7 +233,7 @@ class Curl extends Client
|
|||||||
{
|
{
|
||||||
$this->executeContext();
|
$this->executeContext();
|
||||||
|
|
||||||
list($status, $headers) = $this->parseHeaders(explode("\r\n", $this->headers[$this->headers_counter - 1]));
|
list($status, $headers) = HttpHeaders::parse(explode("\r\n", $this->headers[$this->headers_counter - 1]));
|
||||||
|
|
||||||
// When restricted with open_basedir
|
// When restricted with open_basedir
|
||||||
if ($this->needToHandleRedirection($follow_location, $status)) {
|
if ($this->needToHandleRedirection($follow_location, $status)) {
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
namespace PicoFeed\Client;
|
namespace PicoFeed\Client;
|
||||||
|
|
||||||
use ArrayAccess;
|
use ArrayAccess;
|
||||||
|
use PicoFeed\Logging\Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to handle http headers case insensitivity
|
* Class to handle HTTP headers case insensitivity
|
||||||
*
|
*
|
||||||
* @author Bernhard Posselt
|
* @author Bernhard Posselt
|
||||||
|
* @author Frederic Guillot
|
||||||
* @package Client
|
* @package Client
|
||||||
*/
|
*/
|
||||||
class HttpHeaders implements ArrayAccess
|
class HttpHeaders implements ArrayAccess
|
||||||
@ -40,4 +42,38 @@ class HttpHeaders implements ArrayAccess
|
|||||||
{
|
{
|
||||||
unset($this->headers[strtolower($offset)]);
|
unset($this->headers[strtolower($offset)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse HTTP headers
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @access public
|
||||||
|
* @param array $lines List of headers
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function parse(array $lines)
|
||||||
|
{
|
||||||
|
$status = 200;
|
||||||
|
$headers = array();
|
||||||
|
|
||||||
|
foreach ($lines as $line) {
|
||||||
|
|
||||||
|
if (strpos($line, 'HTTP') === 0) {
|
||||||
|
$status = (int) substr($line, 9, 3);
|
||||||
|
}
|
||||||
|
else if (strpos($line, ':') !== false) {
|
||||||
|
|
||||||
|
@list($name, $value) = explode(': ', $line);
|
||||||
|
if ($value) $headers[trim($name)] = trim($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::setMessage(get_called_class().' HTTP status code: '.$status);
|
||||||
|
|
||||||
|
foreach ($headers as $name => $value) {
|
||||||
|
Logger::setMessage(get_called_class().' HTTP header: '.$name.' => '.$value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($status, new self($headers));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ class Stream extends Client
|
|||||||
throw new TimeoutException('Operation timeout');
|
throw new TimeoutException('Operation timeout');
|
||||||
}
|
}
|
||||||
|
|
||||||
list($status, $headers) = $this->parseHeaders($metadata['wrapper_data']);
|
list($status, $headers) = HttpHeaders::parse($metadata['wrapper_data']);
|
||||||
|
|
||||||
fclose($stream);
|
fclose($stream);
|
||||||
|
|
||||||
|
@ -31,6 +31,26 @@ class Logger
|
|||||||
*/
|
*/
|
||||||
private static $timezone = 'UTC';
|
private static $timezone = 'UTC';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable or disable logging
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @access public
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
public static $enable = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable logging
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public static function enable()
|
||||||
|
{
|
||||||
|
self::$enable = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new message
|
* Add a new message
|
||||||
*
|
*
|
||||||
@ -40,10 +60,11 @@ class Logger
|
|||||||
*/
|
*/
|
||||||
public static function setMessage($message)
|
public static function setMessage($message)
|
||||||
{
|
{
|
||||||
|
if (self::$enable) {
|
||||||
$date = new DateTime('now', new DateTimeZone(self::$timezone));
|
$date = new DateTime('now', new DateTimeZone(self::$timezone));
|
||||||
|
|
||||||
self::$messages[] = '['.$date->format('Y-m-d H:i:s').'] '.$message;
|
self::$messages[] = '['.$date->format('Y-m-d H:i:s').'] '.$message;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all logged messages
|
* Get all logged messages
|
||||||
|
@ -131,7 +131,7 @@ class Atom extends Parser
|
|||||||
*/
|
*/
|
||||||
public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
|
public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
|
||||||
{
|
{
|
||||||
$feed->date = $this->parseDate((string) $xml->updated);
|
$feed->date = $this->date->getTimestamp((string) $xml->updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,8 +143,8 @@ class Atom extends Parser
|
|||||||
*/
|
*/
|
||||||
public function findItemDate(SimpleXMLElement $entry, Item $item)
|
public function findItemDate(SimpleXMLElement $entry, Item $item)
|
||||||
{
|
{
|
||||||
$published = isset($entry->published) ? $this->parseDate((string) $entry->published) : 0;
|
$published = isset($entry->published) ? $this->date->getTimestamp((string) $entry->published) : 0;
|
||||||
$updated = isset($entry->updated) ? $this->parseDate((string) $entry->updated) : 0;
|
$updated = isset($entry->updated) ? $this->date->getTimestamp((string) $entry->updated) : 0;
|
||||||
|
|
||||||
$item->date = max($published, $updated) ?: time();
|
$item->date = max($published, $updated) ?: time();
|
||||||
}
|
}
|
||||||
|
109
vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php
vendored
Normal file
109
vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php
vendored
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PicoFeed\Parser;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use DateTimeZone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date Parser
|
||||||
|
*
|
||||||
|
* @author Frederic Guillot
|
||||||
|
* @package Parser
|
||||||
|
*/
|
||||||
|
class DateParser
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Timezone used to parse feed dates
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $timezone = 'UTC';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supported formats [ 'format' => length ]
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $formats = array(
|
||||||
|
DATE_ATOM => null,
|
||||||
|
DATE_RSS => null,
|
||||||
|
DATE_COOKIE => null,
|
||||||
|
DATE_ISO8601 => null,
|
||||||
|
DATE_RFC822 => null,
|
||||||
|
DATE_RFC850 => null,
|
||||||
|
DATE_RFC1036 => null,
|
||||||
|
DATE_RFC1123 => null,
|
||||||
|
DATE_RFC2822 => null,
|
||||||
|
DATE_RFC3339 => null,
|
||||||
|
'D, d M Y H:i:s' => 25,
|
||||||
|
'D, d M Y h:i:s' => 25,
|
||||||
|
'D M d Y H:i:s' => 24,
|
||||||
|
'j M Y H:i:s' => 20,
|
||||||
|
'Y-m-d H:i:s' => 19,
|
||||||
|
'Y-m-d\TH:i:s' => 19,
|
||||||
|
'd/m/Y H:i:s' => 19,
|
||||||
|
'D, d M Y' => 16,
|
||||||
|
'Y-m-d' => 10,
|
||||||
|
'd-m-Y' => 10,
|
||||||
|
'm-d-Y' => 10,
|
||||||
|
'd.m.Y' => 10,
|
||||||
|
'm.d.Y' => 10,
|
||||||
|
'd/m/Y' => 10,
|
||||||
|
'm/d/Y' => 10,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to parse all date format for broken feeds
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $value Original date format
|
||||||
|
* @return integer Timestamp
|
||||||
|
*/
|
||||||
|
public function getTimestamp($value)
|
||||||
|
{
|
||||||
|
$value = trim($value);
|
||||||
|
|
||||||
|
foreach ($this->formats as $format => $length) {
|
||||||
|
|
||||||
|
$truncated_value = $value;
|
||||||
|
if ($length !== null) {
|
||||||
|
$truncated_value = substr($truncated_value, 0, $length);
|
||||||
|
}
|
||||||
|
|
||||||
|
$timestamp = $this->getValidDate($format, $truncated_value);
|
||||||
|
if ($timestamp > 0) {
|
||||||
|
return $timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$date = new DateTime('now', new DateTimeZone($this->timezone));
|
||||||
|
return $date->getTimestamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a valid date from a given format
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $format Date format
|
||||||
|
* @param string $value Original date value
|
||||||
|
* @return integer Timestamp
|
||||||
|
*/
|
||||||
|
public function getValidDate($format, $value)
|
||||||
|
{
|
||||||
|
$date = DateTime::createFromFormat($format, $value, new DateTimeZone($this->timezone));
|
||||||
|
|
||||||
|
if ($date !== false) {
|
||||||
|
|
||||||
|
$errors = DateTime::getLastErrors();
|
||||||
|
|
||||||
|
if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) {
|
||||||
|
return $date->getTimestamp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@ -3,8 +3,6 @@
|
|||||||
namespace PicoFeed\Parser;
|
namespace PicoFeed\Parser;
|
||||||
|
|
||||||
use SimpleXMLElement;
|
use SimpleXMLElement;
|
||||||
use DateTime;
|
|
||||||
use DateTimeZone;
|
|
||||||
use PicoFeed\Encoding\Encoding;
|
use PicoFeed\Encoding\Encoding;
|
||||||
use PicoFeed\Filter\Filter;
|
use PicoFeed\Filter\Filter;
|
||||||
use PicoFeed\Logging\Logger;
|
use PicoFeed\Logging\Logger;
|
||||||
@ -27,6 +25,14 @@ abstract class Parser
|
|||||||
*/
|
*/
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DateParser object
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
* @var \PicoFeed\Parser\DateParser
|
||||||
|
*/
|
||||||
|
protected $date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash algorithm used to generate item id, any value supported by PHP, see hash_algos()
|
* Hash algorithm used to generate item id, any value supported by PHP, see hash_algos()
|
||||||
*
|
*
|
||||||
@ -35,14 +41,6 @@ abstract class Parser
|
|||||||
*/
|
*/
|
||||||
private $hash_algo = 'sha256';
|
private $hash_algo = 'sha256';
|
||||||
|
|
||||||
/**
|
|
||||||
* Timezone used to parse feed dates
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $timezone = 'UTC';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feed content (XML data)
|
* Feed content (XML data)
|
||||||
*
|
*
|
||||||
@ -101,6 +99,7 @@ abstract class Parser
|
|||||||
*/
|
*/
|
||||||
public function __construct($content, $http_encoding = '', $fallback_url = '')
|
public function __construct($content, $http_encoding = '', $fallback_url = '')
|
||||||
{
|
{
|
||||||
|
$this->date = new DateParser;
|
||||||
$this->fallback_url = $fallback_url;
|
$this->fallback_url = $fallback_url;
|
||||||
$xml_encoding = XmlParser::getEncodingFromXmlTag($content);
|
$xml_encoding = XmlParser::getEncodingFromXmlTag($content);
|
||||||
|
|
||||||
@ -276,87 +275,6 @@ abstract class Parser
|
|||||||
return hash($this->hash_algo, implode(func_get_args()));
|
return hash($this->hash_algo, implode(func_get_args()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to parse all date format for broken feeds
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param string $value Original date format
|
|
||||||
* @return integer Timestamp
|
|
||||||
*/
|
|
||||||
public function parseDate($value)
|
|
||||||
{
|
|
||||||
// Format => truncate to this length if not null
|
|
||||||
$formats = array(
|
|
||||||
DATE_ATOM => null,
|
|
||||||
DATE_RSS => null,
|
|
||||||
DATE_COOKIE => null,
|
|
||||||
DATE_ISO8601 => null,
|
|
||||||
DATE_RFC822 => null,
|
|
||||||
DATE_RFC850 => null,
|
|
||||||
DATE_RFC1036 => null,
|
|
||||||
DATE_RFC1123 => null,
|
|
||||||
DATE_RFC2822 => null,
|
|
||||||
DATE_RFC3339 => null,
|
|
||||||
'D, d M Y H:i:s' => 25,
|
|
||||||
'D, d M Y h:i:s' => 25,
|
|
||||||
'D M d Y H:i:s' => 24,
|
|
||||||
'j M Y H:i:s' => 20,
|
|
||||||
'Y-m-d H:i:s' => 19,
|
|
||||||
'Y-m-d\TH:i:s' => 19,
|
|
||||||
'd/m/Y H:i:s' => 19,
|
|
||||||
'D, d M Y' => 16,
|
|
||||||
'Y-m-d' => 10,
|
|
||||||
'd-m-Y' => 10,
|
|
||||||
'm-d-Y' => 10,
|
|
||||||
'd.m.Y' => 10,
|
|
||||||
'm.d.Y' => 10,
|
|
||||||
'd/m/Y' => 10,
|
|
||||||
'm/d/Y' => 10,
|
|
||||||
);
|
|
||||||
|
|
||||||
$value = trim($value);
|
|
||||||
|
|
||||||
foreach ($formats as $format => $length) {
|
|
||||||
|
|
||||||
$truncated_value = $value;
|
|
||||||
if ($length !== null) {
|
|
||||||
$truncated_value = substr($truncated_value, 0, $length);
|
|
||||||
}
|
|
||||||
|
|
||||||
$timestamp = $this->getValidDate($format, $truncated_value);
|
|
||||||
if ($timestamp > 0) {
|
|
||||||
return $timestamp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$date = new DateTime('now', new DateTimeZone($this->timezone));
|
|
||||||
return $date->getTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a valid date from a given format
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param string $format Date format
|
|
||||||
* @param string $value Original date value
|
|
||||||
* @return integer Timestamp
|
|
||||||
*/
|
|
||||||
public function getValidDate($format, $value)
|
|
||||||
{
|
|
||||||
$date = DateTime::createFromFormat($format, $value, new DateTimeZone($this->timezone));
|
|
||||||
|
|
||||||
if ($date !== false) {
|
|
||||||
|
|
||||||
$errors = DateTime::getLastErrors();
|
|
||||||
|
|
||||||
if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) {
|
|
||||||
return $date->getTimestamp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the given language is "Right to Left"
|
* Return true if the given language is "Right to Left"
|
||||||
*
|
*
|
||||||
@ -412,7 +330,10 @@ abstract class Parser
|
|||||||
*/
|
*/
|
||||||
public function setTimezone($timezone)
|
public function setTimezone($timezone)
|
||||||
{
|
{
|
||||||
$this->timezone = $timezone ?: $this->timezone;
|
if ($timezone) {
|
||||||
|
$this->date->timezone = $timezone;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class Rss10 extends Rss20
|
|||||||
*/
|
*/
|
||||||
public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
|
public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
|
||||||
{
|
{
|
||||||
$feed->date = $this->parseDate(XmlParser::getNamespaceValue($xml->channel, $this->namespaces, 'date'));
|
$feed->date = $this->date->getTimestamp(XmlParser::getNamespaceValue($xml->channel, $this->namespaces, 'date'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,7 +134,7 @@ class Rss20 extends Parser
|
|||||||
public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
|
public function findFeedDate(SimpleXMLElement $xml, Feed $feed)
|
||||||
{
|
{
|
||||||
$date = isset($xml->channel->pubDate) ? $xml->channel->pubDate : $xml->channel->lastBuildDate;
|
$date = isset($xml->channel->pubDate) ? $xml->channel->pubDate : $xml->channel->lastBuildDate;
|
||||||
$feed->date = $this->parseDate((string) $date);
|
$feed->date = $this->date->getTimestamp((string) $date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,7 +156,7 @@ class Rss20 extends Parser
|
|||||||
$date = (string) $entry->pubDate;
|
$date = (string) $entry->pubDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->date = $this->parseDate($date);
|
$item->date = $this->date->getTimestamp($date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
2
vendor/fguillot/picofeed/picofeed
vendored
2
vendor/fguillot/picofeed/picofeed
vendored
@ -8,6 +8,8 @@ use PicoFeed\Reader\Reader;
|
|||||||
use PicoFeed\Logging\Logger;
|
use PicoFeed\Logging\Logger;
|
||||||
use PicoFeed\PicoFeedException;
|
use PicoFeed\PicoFeedException;
|
||||||
|
|
||||||
|
Logger::enable();
|
||||||
|
|
||||||
function get_feed($url, $disable_filtering = false)
|
function get_feed($url, $disable_filtering = false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
48
vendor/fguillot/picofeed/tests/Parser/DateParserTest.php
vendored
Normal file
48
vendor/fguillot/picofeed/tests/Parser/DateParserTest.php
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PicoFeed\Parser;
|
||||||
|
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
|
||||||
|
class DateParserTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testParseDate()
|
||||||
|
{
|
||||||
|
$parser = new DateParser;
|
||||||
|
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
|
$this->assertEquals(1359066183, $parser->getTimestamp('Thu, 24 Jan 2013 22:23:03 +0000'));
|
||||||
|
$this->assertEquals(1362992761, $parser->getTimestamp('2013-03-11T09:06:01+00:00'));
|
||||||
|
$this->assertEquals(1363752990, $parser->getTimestamp('2013-03-20T04:16:30+00:00'));
|
||||||
|
$this->assertEquals(1359066183, $parser->getTimestamp('Thu, 24 Jan 2013 22:23:03 +0000'));
|
||||||
|
$this->assertEquals(1380929699, $parser->getTimestamp('Sat, 04 Oct 2013 02:34:59 +0300'));
|
||||||
|
$this->assertEquals(1054633161, $parser->getTimestamp('Tue, 03 Jun 2003 09:39:21 GMT'));
|
||||||
|
$this->assertEquals(1071340202, $parser->getTimestamp('2003-12-13T18:30:02Z'));
|
||||||
|
$this->assertEquals(1364234797, $parser->getTimestamp('Mon, 25 Mar 2013 19:06:37 +0100'));
|
||||||
|
$this->assertEquals(1360054941, $parser->getTimestamp('2013-02-05T09:02:21.880-08:00'));
|
||||||
|
$this->assertEquals(1286834400, $parser->getTimestamp('Tue, 12 Oct 2010 00:00:00 IST'));
|
||||||
|
$this->assertEquals('2014-12-15 19:49', date('Y-m-d H:i', $parser->getTimestamp('15 Dec 2014 19:49:07 +0100')));
|
||||||
|
$this->assertEquals('2012-05-15', date('Y-m-d', $parser->getTimestamp('Tue, 15 May 2012 24:05:00 UTC')));
|
||||||
|
$this->assertEquals('2013-09-12', date('Y-m-d', $parser->getTimestamp('Thu, 12 Sep 2013 7:00:00 UTC')));
|
||||||
|
$this->assertEquals('2012-01-31', date('Y-m-d', $parser->getTimestamp('01.31.2012')));
|
||||||
|
$this->assertEquals('2012-01-31', date('Y-m-d', $parser->getTimestamp('01/31/2012')));
|
||||||
|
$this->assertEquals('2012-01-31', date('Y-m-d', $parser->getTimestamp('2012-01-31')));
|
||||||
|
$this->assertEquals('2010-02-24', date('Y-m-d', $parser->getTimestamp('2010-02-245T15:27:52Z')));
|
||||||
|
$this->assertEquals('2010-08-20', date('Y-m-d', $parser->getTimestamp('2010-08-20Thh:08:ssZ')));
|
||||||
|
$this->assertEquals(1288648057, $parser->getTimestamp('Mon, 01 Nov 2010 21:47:37 UT'));
|
||||||
|
$this->assertEquals(1346069615, $parser->getTimestamp('Mon Aug 27 2012 12:13:35 GMT-0700 (PDT)'));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp('Tue, 3 Febuary 2010 00:00:00 IST'));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp('############# EST'));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp('Wed, 30 Nov -0001 00:00:00 +0000'));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp('čet, 24 maj 2012 00:00:00'));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp('-0-0T::Z'));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp('Wed, 18 2012'));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp("'2009-09-30 CDT16:09:54"));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp('ary 8 Jan 2013 00:00:00 GMT'));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp('Sat, 11 00:00:01 GMT'));
|
||||||
|
$this->assertEquals(1370631743, $parser->getTimestamp('Fri Jun 07 2013 19:02:23 GMT+0000 (UTC)'));
|
||||||
|
$this->assertEquals(1377412225, $parser->getTimestamp('25/08/2013 06:30:25 م'));
|
||||||
|
$this->assertEquals(time(), $parser->getTimestamp('+0400'));
|
||||||
|
}
|
||||||
|
}
|
@ -6,46 +6,6 @@ use PHPUnit_Framework_TestCase;
|
|||||||
|
|
||||||
class ParserTest extends PHPUnit_Framework_TestCase
|
class ParserTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testParseDate()
|
|
||||||
{
|
|
||||||
$parser = new Rss20('');
|
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$this->assertEquals(1359066183, $parser->parseDate('Thu, 24 Jan 2013 22:23:03 +0000'));
|
|
||||||
$this->assertEquals(1362992761, $parser->parseDate('2013-03-11T09:06:01+00:00'));
|
|
||||||
$this->assertEquals(1363752990, $parser->parseDate('2013-03-20T04:16:30+00:00'));
|
|
||||||
$this->assertEquals(1359066183, $parser->parseDate('Thu, 24 Jan 2013 22:23:03 +0000'));
|
|
||||||
$this->assertEquals(1380929699, $parser->parseDate('Sat, 04 Oct 2013 02:34:59 +0300'));
|
|
||||||
$this->assertEquals(1054633161, $parser->parseDate('Tue, 03 Jun 2003 09:39:21 GMT'));
|
|
||||||
$this->assertEquals(1071340202, $parser->parseDate('2003-12-13T18:30:02Z'));
|
|
||||||
$this->assertEquals(1364234797, $parser->parseDate('Mon, 25 Mar 2013 19:06:37 +0100'));
|
|
||||||
$this->assertEquals(1360054941, $parser->parseDate('2013-02-05T09:02:21.880-08:00'));
|
|
||||||
$this->assertEquals(1286834400, $parser->parseDate('Tue, 12 Oct 2010 00:00:00 IST'));
|
|
||||||
$this->assertEquals('2014-12-15 19:49', date('Y-m-d H:i', $parser->parseDate('15 Dec 2014 19:49:07 +0100')));
|
|
||||||
$this->assertEquals('2012-05-15', date('Y-m-d', $parser->parseDate('Tue, 15 May 2012 24:05:00 UTC')));
|
|
||||||
$this->assertEquals('2013-09-12', date('Y-m-d', $parser->parseDate('Thu, 12 Sep 2013 7:00:00 UTC')));
|
|
||||||
$this->assertEquals('2012-01-31', date('Y-m-d', $parser->parseDate('01.31.2012')));
|
|
||||||
$this->assertEquals('2012-01-31', date('Y-m-d', $parser->parseDate('01/31/2012')));
|
|
||||||
$this->assertEquals('2012-01-31', date('Y-m-d', $parser->parseDate('2012-01-31')));
|
|
||||||
$this->assertEquals('2010-02-24', date('Y-m-d', $parser->parseDate('2010-02-245T15:27:52Z')));
|
|
||||||
$this->assertEquals('2010-08-20', date('Y-m-d', $parser->parseDate('2010-08-20Thh:08:ssZ')));
|
|
||||||
$this->assertEquals(1288648057, $parser->parseDate('Mon, 01 Nov 2010 21:47:37 UT'));
|
|
||||||
$this->assertEquals(1346069615, $parser->parseDate('Mon Aug 27 2012 12:13:35 GMT-0700 (PDT)'));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate('Tue, 3 Febuary 2010 00:00:00 IST'));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate('############# EST'));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate('Wed, 30 Nov -0001 00:00:00 +0000'));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate('čet, 24 maj 2012 00:00:00'));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate('-0-0T::Z'));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate('Wed, 18 2012'));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate("'2009-09-30 CDT16:09:54"));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate('ary 8 Jan 2013 00:00:00 GMT'));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate('Sat, 11 00:00:01 GMT'));
|
|
||||||
$this->assertEquals(1370631743, $parser->parseDate('Fri Jun 07 2013 19:02:23 GMT+0000 (UTC)'));
|
|
||||||
$this->assertEquals(1377412225, $parser->parseDate('25/08/2013 06:30:25 م'));
|
|
||||||
$this->assertEquals(time(), $parser->parseDate('+0400'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testChangeHashAlgo()
|
public function testChangeHashAlgo()
|
||||||
{
|
{
|
||||||
$parser = new Rss20('');
|
$parser = new Rss20('');
|
||||||
|
Loading…
Reference in New Issue
Block a user