From aa60999b978f777f63e221b752b1011110f63bd0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 26 Jan 2012 13:48:14 +0400 Subject: [PATCH] allow subscribing to twitter feeds without oauth (if require auth checkbox is unset) --- classes/dlg.php | 5 +++-- classes/rpc.php | 3 ++- include/functions.php | 12 ++---------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/classes/dlg.php b/classes/dlg.php index 55eb5e37e..cd098d396 100644 --- a/classes/dlg.php +++ b/classes/dlg.php @@ -284,12 +284,13 @@ class Dlg extends Protected_Handler { " + style=\"width : 10em;\" name='pass'\">". + "

".__("OAuth will be used automatically for Twitter feeds.")."

"; print "
-
"; diff --git a/classes/rpc.php b/classes/rpc.php index 1da3a14ec..58e25a456 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -188,8 +188,9 @@ class RPC extends Protected_Handler { $cat = db_escape_string($_REQUEST['cat']); $login = db_escape_string($_REQUEST['login']); $pass = db_escape_string($_REQUEST['pass']); + $need_auth = db_escape_string($_REQUEST['need_auth']) != ""; - $rc = subscribe_to_feed($this->link, $feed, $cat, $login, $pass); + $rc = subscribe_to_feed($this->link, $feed, $cat, $login, $pass, $need_auth); print json_encode(array("result" => $rc)); } diff --git a/include/functions.php b/include/functions.php index 415047458..3ace20f86 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1843,14 +1843,6 @@ } /** - * Subscribes the user to the given feed - * - * @param resource $link Database connection - * @param string $url Feed URL to subscribe to - * @param integer $cat_id Category ID the feed shall be added to - * @param string $auth_login (optional) Feed username - * @param string $auth_pass (optional) Feed password - * * @return integer Status code: * 0 - OK, Feed already exists * 1 - OK, Feed added @@ -1862,7 +1854,7 @@ * 5 - Couldn't download the URL content. */ function subscribe_to_feed($link, $url, $cat_id = 0, - $auth_login = '', $auth_pass = '') { + $auth_login = '', $auth_pass = '', $need_auth = false) { require_once "include/rssfuncs.php"; @@ -1877,7 +1869,7 @@ $has_oauth = db_fetch_result($result, 0, 'twitter_oauth'); - if (!$has_oauth || strpos($url, '://api.twitter.com') === false) { + if (!$need_auth || !$has_oauth || strpos($url, '://api.twitter.com') === false) { if (!fetch_file_contents($url, false, $auth_login, $auth_pass)) return 5; if (url_is_html($url, $auth_login, $auth_pass)) {