summaryrefslogtreecommitdiff
path: root/app/models/Feed.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-27 21:08:29 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-27 21:08:29 +0200
commit0e95494e29353a9ae31fb1196c6c9aaf556ae981 (patch)
treeda499463fda30157c172d92a1e02e972a6c6d6e5 /app/models/Feed.php
parent2a52d315bed725d5997a42547673bccfe2409b5d (diff)
Fix issue #26 : possibilité de s'abonner à des flux derrière authentification HTTP + correction quelques traductions
Diffstat (limited to 'app/models/Feed.php')
-rw-r--r--app/models/Feed.php27
1 files changed, 22 insertions, 5 deletions
diff --git a/app/models/Feed.php b/app/models/Feed.php
index 222e22256..08cf7425f 100644
--- a/app/models/Feed.php
+++ b/app/models/Feed.php
@@ -59,9 +59,13 @@ class Feed extends Model {
if ($raw) {
return $this->httpAuth;
} else {
+ $pos_colon = strpos ($this->httpAuth, ':');
+ $user = substr ($this->httpAuth, 0, $pos_colon);
+ $pass = substr ($this->httpAuth, $pos_colon + 1);
+
return array (
- 'username' => '',
- 'password' => ''
+ 'username' => $user,
+ 'password' => $pass
);
}
}
@@ -134,7 +138,12 @@ class Feed extends Model {
);
} else {
$feed = new SimplePie ();
- $feed->set_feed_url (preg_replace ('/&amp;/', '&', $this->url));
+ $url = preg_replace ('/&amp;/', '&', $this->url);
+ if ($this->httpAuth != '') {
+ $url = preg_replace ('#((.+)://)(.+)#', '${1}' . $this->httpAuth . '@${3}', $url);
+ }
+
+ $feed->set_feed_url ($url);
$feed->set_cache_location (CACHE_PATH);
$feed->init ();
@@ -144,6 +153,9 @@ class Feed extends Model {
$subscribe_url = $feed->subscribe_url ();
if (!is_null ($subscribe_url) && $subscribe_url != $this->url) {
+ if ($this->httpAuth != '') {
+ $subscribe_url = preg_replace ('#((.+)://)((.+)@)(.+)#', '${1}${5}', $subscribe_url);
+ }
$this->_url ($subscribe_url);
}
$title = $feed->get_title ();
@@ -205,7 +217,7 @@ class Feed extends Model {
class FeedDAO extends Model_pdo {
public function addFeed ($valuesTmp) {
- $sql = 'INSERT INTO feed (id, url, category, name, website, description, lastUpdate, priority, error) VALUES(?, ?, ?, ?, ?, ?, ?, 10, 0)';
+ $sql = 'INSERT INTO feed (id, url, category, name, website, description, lastUpdate, priority, httpAuth, error) VALUES(?, ?, ?, ?, ?, ?, ?, 10, ?, 0)';
$stm = $this->bd->prepare ($sql);
$values = array (
@@ -216,6 +228,7 @@ class FeedDAO extends Model_pdo {
$valuesTmp['website'],
$valuesTmp['description'],
$valuesTmp['lastUpdate'],
+ base64_encode ($valuesTmp['httpAuth']),
);
if ($stm && $stm->execute ($values)) {
@@ -231,6 +244,10 @@ class FeedDAO extends Model_pdo {
$set = '';
foreach ($valuesTmp as $key => $v) {
$set .= $key . '=?, ';
+
+ if ($key == 'httpAuth') {
+ $valuesTmp[$key] = base64_encode ($v);
+ }
}
$set = substr ($set, 0, -2);
@@ -408,7 +425,7 @@ class HelperFeed {
$list[$key]->_lastUpdate ($dao['lastUpdate']);
$list[$key]->_priority ($dao['priority']);
$list[$key]->_pathEntries ($dao['pathEntries']);
- $list[$key]->_httpAuth ($dao['httpAuth']);
+ $list[$key]->_httpAuth (base64_decode ($dao['httpAuth']));
if (isset ($dao['id'])) {
$list[$key]->_id ($dao['id']);