Improve remember me + update vendor

This commit is contained in:
Frederic Guillot 2015-03-30 20:13:07 -04:00
parent c795d46669
commit 401a60c7a7
10 changed files with 81 additions and 32 deletions

View File

@ -60,7 +60,7 @@ function authenticate()
// Update the sequence
write_cookie(
$record['token'],
update($record['token'], $record['sequence']),
update($record['token']),
$record['expiration']
);
@ -92,7 +92,7 @@ function refresh()
// Update the sequence
write_cookie(
$record['token'],
update($record['token'], $record['sequence']),
update($record['token']),
$record['expiration']
);
}
@ -191,17 +191,15 @@ function cleanup()
*
* @access public
* @param string $token Session token
* @param string $sequence Sequence token
* @return string
*/
function update($token, $sequence)
function update($token)
{
$new_sequence = Config\generate_token();
Database::get('db')
->table(TABLE)
->eq('token', $token)
->eq('sequence', $sequence)
->update(array('sequence' => $new_sequence));
return $new_sequence;
@ -268,7 +266,7 @@ function write_cookie($token, $sequence, $expiration)
$expiration,
BASE_URL_DIRECTORY,
null,
! empty($_SERVER['HTTPS']),
\Helper\isSecureConnection(),
true
);
}
@ -301,7 +299,7 @@ function delete_cookie()
time() - 3600,
BASE_URL_DIRECTORY,
null,
! empty($_SERVER['HTTPS']),
\Helper\isSecureConnection(),
true
);
}

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit8ccf24e95a95febb275803014c1c9a9a::getLoader();
return ComposerAutoloaderInit177dcd3c68ed52652977fcc464bd77bd::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit8ccf24e95a95febb275803014c1c9a9a
class ComposerAutoloaderInit177dcd3c68ed52652977fcc464bd77bd
{
private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInit8ccf24e95a95febb275803014c1c9a9a
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit8ccf24e95a95febb275803014c1c9a9a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit177dcd3c68ed52652977fcc464bd77bd', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit8ccf24e95a95febb275803014c1c9a9a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit177dcd3c68ed52652977fcc464bd77bd', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -42,14 +42,14 @@ class ComposerAutoloaderInit8ccf24e95a95febb275803014c1c9a9a
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
composerRequire8ccf24e95a95febb275803014c1c9a9a($file);
composerRequire177dcd3c68ed52652977fcc464bd77bd($file);
}
return $loader;
}
}
function composerRequire8ccf24e95a95febb275803014c1c9a9a($file)
function composerRequire177dcd3c68ed52652977fcc464bd77bd($file)
{
require $file;
}

View File

@ -123,18 +123,18 @@
"source": {
"type": "git",
"url": "https://github.com/fguillot/JsonRPC.git",
"reference": "d64090706507dccab53e35ad5fcf00ae2502c647"
"reference": "d0feab084422fa937da10e3551196b1c6fdf6918"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/JsonRPC/zipball/d64090706507dccab53e35ad5fcf00ae2502c647",
"reference": "d64090706507dccab53e35ad5fcf00ae2502c647",
"url": "https://api.github.com/repos/fguillot/JsonRPC/zipball/d0feab084422fa937da10e3551196b1c6fdf6918",
"reference": "d0feab084422fa937da10e3551196b1c6fdf6918",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2015-02-13 03:20:58",
"time": "2015-03-25 23:55:18",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -162,12 +162,12 @@
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoFeed.git",
"reference": "8973f403ff6c16fb5200cfac44a58111c564b60d"
"reference": "7c28753d5936ba635435a8e0e941dcabee67b243"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/8973f403ff6c16fb5200cfac44a58111c564b60d",
"reference": "8973f403ff6c16fb5200cfac44a58111c564b60d",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/7c28753d5936ba635435a8e0e941dcabee67b243",
"reference": "7c28753d5936ba635435a8e0e941dcabee67b243",
"shasum": ""
},
"require": {
@ -181,7 +181,7 @@
"suggest": {
"ext-curl": "PicoFeed will use cURL if present"
},
"time": "2015-03-25 18:09:25",
"time": "2015-03-30 23:34:59",
"bin": [
"picofeed"
],

View File

@ -82,6 +82,9 @@ $server->bind('myProcedure', 'Api', 'doSomething');
// Use a class instance instead of the class name
$server->bind('mySecondProcedure', new Api, 'doSomething');
// The procedure and the method are the same
$server->bind('doSomething', 'Api');
echo $server->execute();
```
@ -147,10 +150,10 @@ use JsonRPC\Client;
$client = new Client('http://localhost/server.php');
$results = $client->batch();
$results = $client->batch()
->foo(['arg1' => 'bar'])
->random(1, 100);
->add(4, 3);
->random(1, 100)
->add(4, 3)
->execute('add', [2, 5])
->send();

View File

@ -133,8 +133,12 @@ class Server
* @param mixed $class Class name or instance
* @param string $method Procedure name
*/
public function bind($procedure, $class, $method)
public function bind($procedure, $class, $method = '')
{
if ($method === '') {
$method = $procedure;
}
$this->classes[$procedure] = array($class, $method);
}

View File

@ -176,6 +176,44 @@ catch (PicoFeedException $e) {
}
```
HTTP basic auth
---------------
If a feed requires basic auth headers, you can pass them as parameters to the **download** method, e.g.:
```php
try {
$reader = new Reader;
$user = 'john';
$password = 'doe';
// Provide those values to the download method
$resource = $reader->download('http://linuxfr.org/news.atom', '', '', $user, $password);
// Return true if the remote content has changed
if ($resource->isModified()) {
$parser = $reader->getParser(
$resource->getUrl(),
$resource->getContent(),
$resource->getEncoding()
);
$feed = $parser->execute();
// Save your feed in your database
// ...
}
else {
echo 'Not modified, nothing to do!';
}
}
catch (PicoFeedException $e) {
// Do something...
}
```
Feed and item properties
------------------------

View File

@ -58,9 +58,11 @@ class Reader
* @param string $url Feed url
* @param string $last_modified Last modified HTTP header
* @param string $etag Etag HTTP header
* @param string $username HTTP basic auth username
* @param string $password HTTP basic auth password
* @return \PicoFeed\Client\Client
*/
public function download($url, $last_modified = '', $etag = '')
public function download($url, $last_modified = '', $etag = '', $username = '', $password = '')
{
$url = $this->prependScheme($url);
@ -68,6 +70,8 @@ class Reader
->setConfig($this->config)
->setLastModified($last_modified)
->setEtag($etag)
->setUsername($username)
->setPassword($password)
->execute($url);
}
@ -78,11 +82,13 @@ class Reader
* @param string $url Feed or website url
* @param string $last_modified Last modified HTTP header
* @param string $etag Etag HTTP header
* @param string $username HTTP basic auth username
* @param string $password HTTP basic auth password
* @return \PicoFeed\Client\Client
*/
public function discover($url, $last_modified = '', $etag = '')
public function discover($url, $last_modified = '', $etag = '', $username = '', $password = '')
{
$client = $this->download($url, $last_modified, $etag);
$client = $this->download($url, $last_modified, $etag, $username, $password);
// It's already a feed or the feed was not modified
if (! $client->isModified() || $this->detectFormat($client->getContent())) {
@ -96,7 +102,7 @@ class Reader
throw new SubscriptionNotFoundException('Unable to find a subscription');
}
return $this->download($links[0], $last_modified, $etag);
return $this->download($links[0], $last_modified, $etag, $username, $password);
}
/**

View File

@ -2,7 +2,7 @@
return array(
'test_url' => 'http://www.phoronix.com/scan.php?page=article&item=amazon_ec2_bare&num=1',
'body' => array(
'//article[@class="KonaBody"]',
'//div[@class="KonaBody"]',
),
'strip' => array(
)

View File

@ -2,8 +2,8 @@
return array(
'test_url' => 'http://www.monwindowsphone.com/tout-savoir-sur-le-centre-d-action-de-windows-phone-8-1-t40574.html',
'body' => array(
'//div[@class="postmessage"]'
'//div[@class="blog-post-body"]'
),
'strip' => array(
),
);
);