summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/af_unburn/init.php53
-rw-r--r--plugins/auth_ldap/init.php135
-rw-r--r--plugins/auth_remote/init.php3
-rw-r--r--plugins/googlereaderkeys/init.php4
-rw-r--r--plugins/mail/init.php7
-rw-r--r--plugins/mailto/init.js32
-rw-r--r--plugins/mailto/init.php93
-rw-r--r--plugins/mailto/mail.pngbin0 -> 192 bytes
-rw-r--r--plugins/updater/init.php40
9 files changed, 342 insertions, 25 deletions
diff --git a/plugins/af_unburn/init.php b/plugins/af_unburn/init.php
index b68796fb4..a0c51c97e 100644
--- a/plugins/af_unburn/init.php
+++ b/plugins/af_unburn/init.php
@@ -29,11 +29,11 @@ class Af_Unburn extends Plugin {
if (strpos($article["plugin_data"], "unburn,$owner_uid:") === FALSE) {
- $ch = curl_init($article["link"]);
+ $ch = curl_init(geturl($article["link"]));
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT);
$contents = @curl_exec($ch);
@@ -74,5 +74,54 @@ class Af_Unburn extends Plugin {
return $article;
}
+
+ function geturl($url){
+
+ (function_exists('curl_init')) ? '' : die('cURL Must be installed for geturl function to work. Ask your host to enable it or uncomment extension=php_curl.dll in php.ini');
+
+ $curl = curl_init();
+ $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
+ $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
+ $header[] = "Cache-Control: max-age=0";
+ $header[] = "Connection: keep-alive";
+ $header[] = "Keep-Alive: 300";
+ $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
+ $header[] = "Accept-Language: en-us,en;q=0.5";
+ $header[] = "Pragma: ";
+
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0 Firefox/5.0');
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
+ curl_setopt($curl, CURLOPT_HEADER, true);
+ curl_setopt($curl, CURLOPT_REFERER, $url);
+ curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
+ curl_setopt($curl, CURLOPT_AUTOREFERER, true);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); //CURLOPT_FOLLOWLOCATION Disabled...
+ curl_setopt($curl, CURLOPT_TIMEOUT, 60);
+
+ $html = curl_exec($curl);
+
+ $status = curl_getinfo($curl);
+ curl_close($curl);
+
+ if($status['http_code']!=200){
+ if($status['http_code'] == 301 || $status['http_code'] == 302) {
+ list($header) = explode("\r\n\r\n", $html, 2);
+ $matches = array();
+ preg_match("/(Location:|URI:)[^(\n)]*/", $header, $matches);
+ $url = trim(str_replace($matches[1],"",$matches[0]));
+ $url_parsed = parse_url($url);
+ return (isset($url_parsed))? geturl($url, $referer):'';
+ }
+ $oline='';
+ foreach($status as $key=>$eline){$oline.='['.$key.']'.$eline.' ';}
+ $line =$oline." \r\n ".$url."\r\n-----------------\r\n";
+ $handle = @fopen('./curl.error.log', 'a');
+ fwrite($handle, $line);
+ return FALSE;
+ }
+ return $url;
+ }
}
?>
diff --git a/plugins/auth_ldap/init.php b/plugins/auth_ldap/init.php
new file mode 100644
index 000000000..e1a4c49f1
--- /dev/null
+++ b/plugins/auth_ldap/init.php
@@ -0,0 +1,135 @@
+<?php
+/**
+ * Tiny Tiny RSS plugin for LDAP authentication
+ * @author hydrian ([email protected])
+ * @copyright GPL2
+ * Requires php-ldap and PEAR Net::LDAP2
+ */
+
+/**
+ * Configuration
+ * Put the following options in config.php and customize them for your environment
+ *
+ * define('LDAP_AUTH_SERVER_URI, 'ldaps://LDAPServerHostname:port/');
+ * define('LDAP_AUTH_USETLS, FALSE); // Enable TLS Support for ldaps://
+ * define('LDAP_AUTH_ALLOW_UNTRUSTED_CERT', TRUE); // Allows untrusted certificate
+ * define('LDAP_AUTH_BINDDN', 'cn=serviceaccount,dc=example,dc=com');
+ * define('LDAP_AUTH_BINDPW', 'ServiceAccountsPassword');
+ * define('LDAP_AUTH_BASEDN', 'dc=example,dc=com');
+ * // ??? will be replaced with the entered username(escaped) at login
+ * define('LDAP_AUTH_SEARCHFILTER', '(&(objectClass=person)(uid=???))');
+ */
+
+/**
+ * Notes -
+ * LDAP search does not support follow ldap referals. Referals are disabled to
+ * allow proper login. This is particular to Active Directory.
+ *
+ * Also group membership can be supported if the user object contains the
+ * the group membership via attributes. The following LDAP servers can
+ * support this.
+ * * Active Directory
+ * * OpenLDAP support with MemberOf Overlay
+ *
+ */
+class Auth_Ldap extends Plugin implements IAuthModule {
+
+ private $link;
+ private $host;
+ private $base;
+
+ function about() {
+ return array(0.01,
+ "Authenticates against an LDAP server (configured in config.php)",
+ "hydrian",
+ true);
+ }
+
+ function init($host) {
+ $this->link = $host->get_link();
+ $this->host = $host;
+ $this->base = new Auth_Base($this->link);
+
+ $host->add_hook($host::HOOK_AUTH_USER, $this);
+ }
+
+ private function _log($msg) {
+ trigger_error($msg, E_USER_WARN);
+ }
+
+ function authenticate($login, $password) {
+ if ($login && $password) {
+ if (!function_exists('ldap_connect')) {
+ trigger_error('auth_ldap requires PHP\'s PECL LDAP package installed.');
+ return FALSE;
+ }
+ if (!require_once('Net/LDAP2.php')) {
+ trigger_error('auth_ldap requires the PEAR package Net::LDAP2');
+ return FALSE;
+ }
+ $parsedURI=parse_url(LDAP_AUTH_SERVER_URI);
+ if ($parsedURI === FALSE) {
+ $this->_log('Could not parse LDAP_AUTH_SERVER_URI in config.php');
+ return FALSE;
+ }
+ $ldapConnParams=array(
+ 'host'=>$parsedURI['scheme'].'://'.$parsedURI['host'],
+ 'basedn'=>LDAP_AUTH_BASEDN,
+ 'options' => array('LDAP_OPT_REFERRALS' => 0)
+ );
+ $ldapConnParams['starttls']= defined('LDAP_AUTH_USETLS') ?
+ LDAP_AUTH_USETLS : FALSE;
+
+ if (is_int($parsedURI['port'])) {
+ $ldapConnParams['port']=$parsedURI['port'];
+ }
+ // Making connection to LDAP server
+ if (LDAP_AUTH_ALLOW_UNTRUSTED_CERT === TRUE) {
+ putenv('LDAPTLS_REQCERT=never');
+ }
+ $ldapConn = Net_LDAP2::connect($ldapConnParams);
+ if (Net_LDAP2::isError($ldapConn)) {
+ $this->_log('Could not connect to LDAP Server: '.$ldapConn->getMessage());
+ return FALSE;
+ }
+ // Bind with service account
+ $binding=$ldapConn->bind(LDAP_AUTH_BINDDN, LDAP_AUTH_BINDPW);
+ if (Net_LDAP2::isError($binding)) {
+ $this->_log('Cound not bind service account: '.$binding->getMessage());
+ return FALSE;
+ }
+ //Searching for user
+ $completedSearchFiler=str_replace('???',$login,LDAP_AUTH_SEARCHFILTER);
+ $filterObj=Net_LDAP2_Filter::parse($completedSearchFiler);
+ $searchResults=$ldapConn->search(LDAP_AUTH_BASEDN, $filterObj);
+ if (Net_LDAP2::isError($searchResults)) {
+ $this->_log('LDAP Search Failed: '.$searchResults->getMessage());
+ return FALSE;
+ } elseif ($searchResults->count() === 0) {
+ return FALSE;
+ } elseif ($searchResults->count() > 1 ) {
+ $this->_log('Multiple DNs found for username '.$login);
+ return FALSE;
+ }
+ //Getting user's DN from search
+ $userEntry=$searchResults->shiftEntry();
+ $userDN=$userEntry->dn();
+ //Binding with user's DN.
+ $loginAttempt=$ldapConn->bind($userDN, $password);
+ $ldapConn->disconnect();
+ if ($loginAttempt === TRUE) {
+ return $this->base->auto_create_user($login);
+ } elseif ($loginAttempt->getCode() == 49) {
+ return FALSE;
+ } else {
+ $this->_log('Unknown Error: Code: '.$loginAttempt->getCode().
+ ' Message: '.$loginAttempt->getMessage());
+ return FALSE;
+ }
+ }
+ return false;
+ }
+
+}
+
+?>
diff --git a/plugins/auth_remote/init.php b/plugins/auth_remote/init.php
index 65f188b8f..7c8d835f8 100644
--- a/plugins/auth_remote/init.php
+++ b/plugins/auth_remote/init.php
@@ -40,6 +40,9 @@ class Auth_Remote extends Plugin implements IAuthModule {
function authenticate($login, $password) {
$try_login = db_escape_string($_SERVER["REMOTE_USER"]);
+ // php-cgi
+ if (!$try_login) $try_login = db_escape_string($_SERVER["REDIRECT_REMOTE_USER"]);
+
if (!$try_login) $try_login = $this->get_login_by_ssl_certificate();
# if (!$try_login) $try_login = "test_qqq";
diff --git a/plugins/googlereaderkeys/init.php b/plugins/googlereaderkeys/init.php
index 97133d305..92bf626e6 100644
--- a/plugins/googlereaderkeys/init.php
+++ b/plugins/googlereaderkeys/init.php
@@ -21,8 +21,8 @@ class GoogleReaderKeys extends Plugin {
$hotkeys["j"] = "next_article_noscroll";
$hotkeys["k"] = "prev_article_noscroll";
- $hotkeys["N"] = "next_feed";
- $hotkeys["P"] = "prev_feed";
+ $hotkeys["*n"] = "next_feed";
+ $hotkeys["*p"] = "prev_feed";
$hotkeys["v"] = "open_in_new_window";
$hotkeys["r"] = "feed_refresh";
$hotkeys["(32)|space"] = "next_article";
diff --git a/plugins/mail/init.php b/plugins/mail/init.php
index 2e972cf61..84fd5d3b2 100644
--- a/plugins/mail/init.php
+++ b/plugins/mail/init.php
@@ -59,10 +59,9 @@ class Mail extends Plugin {
$tpl->readTemplateFromFile("templates/email_article_template.txt");
- $tpl->setVariable('USER_NAME', $_SESSION["name"]);
- $tpl->setVariable('USER_EMAIL', $user_email);
- $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"]);
-
+ $tpl->setVariable('USER_NAME', $_SESSION["name"], true);
+ $tpl->setVariable('USER_EMAIL', $user_email, true);
+ $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
$result = db_query($this->link, "SELECT link, content, title
FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
diff --git a/plugins/mailto/init.js b/plugins/mailto/init.js
new file mode 100644
index 000000000..8f7656a07
--- /dev/null
+++ b/plugins/mailto/init.js
@@ -0,0 +1,32 @@
+function mailtoArticle(id) {
+ try {
+ if (!id) {
+ var ids = getSelectedArticleIds2();
+
+ if (ids.length == 0) {
+ alert(__("No articles are selected."));
+ return;
+ }
+
+ id = ids.toString();
+ }
+
+ if (dijit.byId("emailArticleDlg"))
+ dijit.byId("emailArticleDlg").destroyRecursive();
+
+ var query = "backend.php?op=pluginhandler&plugin=mailto&method=emailArticle&param=" + param_escape(id);
+
+ dialog = new dijit.Dialog({
+ id: "emailArticleDlg",
+ title: __("Forward article by email"),
+ style: "width: 600px",
+ href: query});
+
+ dialog.show();
+
+ } catch (e) {
+ exception_error("emailArticle", e);
+ }
+}
+
+
diff --git a/plugins/mailto/init.php b/plugins/mailto/init.php
new file mode 100644
index 000000000..bbc0dffa4
--- /dev/null
+++ b/plugins/mailto/init.php
@@ -0,0 +1,93 @@
+<?php
+class MailTo extends Plugin {
+
+ private $link;
+ private $host;
+
+ function about() {
+ return array(1.0,
+ "Share article via email (using mailto: links, invoking your mail client)",
+ "fox");
+ }
+
+ function init($host) {
+ $this->link = $host->get_link();
+ $this->host = $host;
+
+ $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
+ }
+
+ function get_js() {
+ return file_get_contents(dirname(__FILE__) . "/init.js");
+ }
+
+ function hook_article_button($line) {
+ return "<img src=\"".theme_image($link, 'plugins/mailto/mail.png')."\"
+ class='tagsPic' style=\"cursor : pointer\"
+ onclick=\"mailtoArticle(".$line["id"].")\"
+ alt='Zoom' title='".__('Forward by email')."'>";
+ }
+
+ function emailArticle() {
+
+ $param = db_escape_string($_REQUEST['param']);
+
+ require_once "lib/MiniTemplator.class.php";
+
+ $tpl = new MiniTemplator;
+ $tpl_t = new MiniTemplator;
+
+ $tpl->readTemplateFromFile("templates/email_article_template.txt");
+
+ $tpl->setVariable('USER_NAME', $_SESSION["name"], true);
+ $tpl->setVariable('USER_EMAIL', $user_email, true);
+ $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
+
+
+ $result = db_query($this->link, "SELECT link, content, title
+ FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
+ id IN ($param) AND owner_uid = " . $_SESSION["uid"]);
+
+ if (db_num_rows($result) > 1) {
+ $subject = __("[Forwarded]") . " " . __("Multiple articles");
+ }
+
+ while ($line = db_fetch_assoc($result)) {
+
+ if (!$subject)
+ $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
+
+ $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
+ $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
+
+ $tpl->addBlock('article');
+ }
+
+ $tpl->addBlock('email');
+
+ $content = "";
+ $tpl->generateOutputToString($content);
+
+ $mailto_link = htmlspecialchars("mailto: ?subject=".urlencode($subject).
+ "&body=".urlencode($content));
+
+ print __("Clicking the following link to invoke your mail client:");
+
+ print "<div class=\"tagCloudContainer\">";
+ print "<a target=\"_blank\" href=\"$mailto_link\">".
+ __("Forward selected article(s) by email.")."</a>";
+ print "</div>";
+
+ print __("You should be able to edit the message before sending in your mail client.");
+
+ print "<p>";
+
+ print "<div style='text-align : center'>";
+ print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>";
+ print "</div>";
+
+ //return;
+ }
+
+}
+?>
diff --git a/plugins/mailto/mail.png b/plugins/mailto/mail.png
new file mode 100644
index 000000000..4d3fe7751
--- /dev/null
+++ b/plugins/mailto/mail.png
Binary files differ
diff --git a/plugins/updater/init.php b/plugins/updater/init.php
index d940aefeb..4f9ee86bd 100644
--- a/plugins/updater/init.php
+++ b/plugins/updater/init.php
@@ -79,7 +79,6 @@ class Updater extends Plugin {
$stop = true; break;
}
-
array_push($log, "Checking for latest version...");
$version_info = json_decode(fetch_file_contents("http://tt-rss.org/version.php"),
@@ -91,7 +90,7 @@ class Updater extends Plugin {
}
$target_version = $version_info["version"];
- $target_dir = "$parent_dir/tt-rss-$target_version";
+ $target_dir = "$parent_dir/Tiny-Tiny-RSS-$target_version";
array_push($log, "Target version: $target_version");
$params["target_version"] = $target_version;
@@ -110,7 +109,7 @@ class Updater extends Plugin {
case 1:
$target_version = $params["target_version"];
- array_push($log, "Downloading checksums...");
+/* array_push($log, "Downloading checksums...");
$md5sum_data = fetch_file_contents("http://tt-rss.org/download/md5sum.txt");
if (!$md5sum_data) {
@@ -134,16 +133,18 @@ class Updater extends Plugin {
$stop = true; break;
}
- $params["target_md5sum"] = $target_md5sum;
+ $params["target_md5sum"] = $target_md5sum; */
+
+ array_push($log, "Proceeding to download...");
break;
case 2:
$target_version = $params["target_version"];
- $target_md5sum = $params["target_md5sum"];
+ // $target_md5sum = $params["target_md5sum"];
array_push($log, "Downloading distribution tarball...");
- $tarball_url = "http://tt-rss.org/download/tt-rss-$target_version.tar.gz";
+ $tarball_url = "https://github.com/gothfox/Tiny-Tiny-RSS/archive/$target_version.tar.gz";
$data = fetch_file_contents($tarball_url);
if (!$data) {
@@ -151,14 +152,14 @@ class Updater extends Plugin {
$stop = true; break;
}
- array_push($log, "Verifying tarball checksum...");
+ /* array_push($log, "Verifying tarball checksum...");
$test_md5sum = md5($data);
if ($test_md5sum != $target_md5sum) {
array_push($log, "Downloaded checksum doesn't match (got $test_md5sum, expected $target_md5sum).");
$stop = true; break;
- }
+ } */
$tmp_file = tempnam(sys_get_temp_dir(), 'tt-rss');
array_push($log, "Saving download to $tmp_file");
@@ -180,14 +181,6 @@ class Updater extends Plugin {
$stop = true; break;
}
- $old_dir = tmpdirname($parent_dir, "tt-rss-old");
-
- array_push($log, "Renaming tt-rss directory to ".basename($old_dir));
- if (!rename($work_dir, $old_dir)) {
- array_push($log, "Unable to rename tt-rss directory.");
- $stop = true; break;
- }
-
array_push($log, "Extracting tarball...");
system("tar zxf $tmp_file", $system_rc);
@@ -196,7 +189,20 @@ class Updater extends Plugin {
$stop = true; break;
}
- $target_dir = "$parent_dir/tt-rss-$target_version";
+ $target_dir = "$parent_dir/Tiny-Tiny-RSS-$target_version";
+
+ if (!is_dir($target_dir)) {
+ array_push($log, "Target directory ($target_dir) not found.");
+ $stop = true; break;
+ }
+
+ $old_dir = tmpdirname($parent_dir, "tt-rss-old");
+
+ array_push($log, "Renaming tt-rss directory to ".basename($old_dir));
+ if (!rename($work_dir, $old_dir)) {
+ array_push($log, "Unable to rename tt-rss directory.");
+ $stop = true; break;
+ }
array_push($log, "Renaming target directory...");
if (!rename($target_dir, $work_dir)) {