summaryrefslogtreecommitdiff
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
parent2a52d315bed725d5997a42547673bccfe2409b5d (diff)
Fix issue #26 : possibilité de s'abonner à des flux derrière authentification HTTP + correction quelques traductions
-rwxr-xr-xapp/controllers/configureController.php10
-rwxr-xr-xapp/controllers/feedController.php12
-rw-r--r--app/i18n/en.php7
-rw-r--r--app/i18n/fr.php3
-rw-r--r--app/layout/aside_feed.phtml8
-rw-r--r--app/models/Feed.php27
-rw-r--r--app/views/configure/feed.phtml11
7 files changed, 62 insertions, 16 deletions
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php
index 81a8e97d7..f4d1a38e7 100755
--- a/app/controllers/configureController.php
+++ b/app/controllers/configureController.php
@@ -90,11 +90,19 @@ class configureController extends ActionController {
$cat = Request::param ('category', 0);
$path = Request::param ('path_entries', '');
$priority = Request::param ('priority', 0);
+ $user = Request::param ('http_user', '');
+ $pass = Request::param ('http_pass', '');
+
+ $httpAuth = '';
+ if ($user != '' || $pass != '') {
+ $httpAuth = $user . ':' . $pass;
+ }
$values = array (
'category' => $cat,
'pathEntries' => $path,
- 'priority' => $priority
+ 'priority' => $priority,
+ 'httpAuth' => $httpAuth
);
if ($feedDAO->updateFeed ($id, $values)) {
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php
index 1232ddff4..c235e8b0f 100755
--- a/app/controllers/feedController.php
+++ b/app/controllers/feedController.php
@@ -16,11 +16,20 @@ class feedController extends ActionController {
if (Request::isPost ()) {
$url = Request::param ('url_rss');
$cat = Request::param ('category');
+ $user = Request::param ('username');
+ $pass = Request::param ('password');
$params = array ();
try {
$feed = new Feed ($url);
$feed->_category ($cat);
+
+ $httpAuth = '';
+ if ($user != '' || $pass != '') {
+ $httpAuth = $user . ':' . $pass;
+ }
+ $feed->_httpAuth ($httpAuth);
+
$feed->load ();
$feedDAO = new FeedDAO ();
@@ -31,7 +40,8 @@ class feedController extends ActionController {
'name' => $feed->name (),
'website' => $feed->website (),
'description' => $feed->description (),
- 'lastUpdate' => time ()
+ 'lastUpdate' => time (),
+ 'httpAuth' => $feed->httpAuth (),
);
if ($feedDAO->searchByUrl ($values['url'])) {
diff --git a/app/i18n/en.php b/app/i18n/en.php
index 921f86ddc..1bb7c2213 100644
--- a/app/i18n/en.php
+++ b/app/i18n/en.php
@@ -9,7 +9,7 @@ return array (
'configuration' => 'Configuration',
'general_and_reading' => 'General and reading',
'categories' => 'Categories',
- 'category' => 'Catégory',
+ 'category' => 'Category',
'shortcuts' => 'Shortcuts',
'about' => 'About',
@@ -88,7 +88,7 @@ return array (
'cancel' => 'Cancel',
'back_to_rss_feeds' => '← Go back to your RSS feeds',
- 'feeds_moved_category_deleted' => 'When you delete a category, their feeds are automatically classified under <em>%s</ em>.',
+ 'feeds_moved_category_deleted' => 'When you delete a category, their feeds are automatically classified under <em>%s</em>.',
'category_number' => 'Category n°%d',
'ask_empty' => 'Clear ?',
'number_feeds' => '%d feeds',
@@ -123,6 +123,7 @@ return array (
'no' => 'No',
'css_path_on_website' => 'Articles CSS path on original website',
'retrieve_truncated_feeds' => 'Retrieves truncated RSS feeds (attention, requires more time!)',
+ 'http_authentication' => 'HTTP Authentication',
'http_username' => 'HTTP username',
'http_password' => 'HTTP password',
'blank_to_disable' => 'Leave blank to disable',
@@ -198,7 +199,7 @@ return array (
'september' => 'september',
'october' => 'october',
'november' => 'november',
- 'december' => 'décember',
+ 'december' => 'december',
// special format for date() function
'Jan' => '\J\a\n\u\a\r\y',
'Feb' => '\F\e\b\r\u\a\r\y',
diff --git a/app/i18n/fr.php b/app/i18n/fr.php
index 3178f3687..c5bba9d07 100644
--- a/app/i18n/fr.php
+++ b/app/i18n/fr.php
@@ -123,7 +123,8 @@ return array (
'no' => 'Non',
'css_path_on_website' => 'Chemin CSS des articles sur le site d\'origine',
'retrieve_truncated_feeds' => 'Permet de récupérer les flux tronqués (attention, demande plus de temps !)',
- 'http_username' => 'Username HTTP',
+ 'http_authentication' => 'Authentification HTTP',
+ 'http_username' => 'Identifiant HTTP',
'http_password' => 'Mot de passe HTTP',
'blank_to_disable' => 'Laissez vide pour désactiver',
'not_yet_implemented' => 'Pas encore implémenté',
diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml
index ff03b5552..4be37868d 100644
--- a/app/layout/aside_feed.phtml
+++ b/app/layout/aside_feed.phtml
@@ -21,6 +21,14 @@
</label>
</li>
<?php } ?>
+
+ <li class="dropdown-header"><?php echo Translate::t ('http_authentication'); ?></li>
+ <li class="input">
+ <input type="text" name="username" id="username" placeholder="<?php echo Translate::t ('username'); ?>" />
+ </li>
+ <li class="input">
+ <input type="password" name="password" id="password" placeholder="<?php echo Translate::t ('password'); ?>" />
+ </li>
</ul>
</div>
<button class="btn" type="submit"><i class="icon i_add"></i></button>
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']);
diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml
index 73b70ec4c..0d9c5cae6 100644
--- a/app/views/configure/feed.phtml
+++ b/app/views/configure/feed.phtml
@@ -58,20 +58,21 @@
<i class="icon i_help"></i> <?php echo Translate::t ('retrieve_truncated_feeds'); ?>
</div>
</div>
-<!--
+
+ <?php $auth = $this->flux->httpAuth (false); ?>
<div class="form-group">
<label class="group-name" for="http_user"><?php echo Translate::t ('http_username'); ?></label>
<div class="group-controls">
- <input type="text" name="http_user" id="http_user" value="<?php echo Translate::t ('not_yet_implemented'); ?>" />
+ <input type="text" name="http_user" id="http_user" value="<?php echo $auth['username']; ?>" />
<i class="icon i_help"></i> <?php echo Translate::t ('access_protected_feeds'); ?>
</div>
<label class="group-name" for="http_pass"><?php echo Translate::t ('http_password'); ?></label>
<div class="group-controls">
- <input type="text" name="http_pass" id="http_pass" value="<?php echo Translate::t ('not_yet_implemented'); ?>" />
+ <input type="password" name="http_pass" id="http_pass" value="<?php echo $auth['password']; ?>" />
</div>
</div>
--->
+
<div class="form-group form-actions">
<div class="group-controls">
@@ -82,5 +83,5 @@
</form>
</div>
<?php } else { ?>
-<div class="alert"><span class="alert-head"><?php echo Translate::t ('no_selected_feed'); ?></span> <?php echo Translate::t ('think_to_add'); ?></div>
+<div class="alert alert-warn"><span class="alert-head"><?php echo Translate::t ('no_selected_feed'); ?></span> <?php echo Translate::t ('think_to_add'); ?></div>
<?php } ?>