From 0ac2f52e14373ab77b691af7ba517323c9b1a52c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 18 Mar 2013 18:20:48 +0400 Subject: rework updater to use github tarballs; add some additional logging and prevent old directory being renamed pointlessly in a few cases (closes #559) --- plugins/updater/init.php | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'plugins') 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)) { -- cgit v1.2.3 From 5b18c93622e97b9a251f3b85bdb088022fd5c0f3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 18 Mar 2013 20:59:48 +0400 Subject: tweak hotkey map notation to allow stuff like shift-arrows --- plugins/googlereaderkeys/init.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') 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"; -- cgit v1.2.3 From e2b0054be49b513a63b3870fcc65f45f30b5b338 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 19 Mar 2013 01:10:02 +0400 Subject: experimental patch to enable compatibility with php safe_mode --- plugins/af_unburn/init.php | 53 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) (limited to 'plugins') 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; + } } ?> -- cgit v1.2.3 From 0c4677bf9bcbf6aa00981313551b30374e73f7ba Mon Sep 17 00:00:00 2001 From: hydrian Date: Mon, 18 Mar 2013 23:50:09 -0400 Subject: Initial release of auth_ldap --- plugins/auth_ldap/init.php | 135 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 plugins/auth_ldap/init.php (limited to 'plugins') diff --git a/plugins/auth_ldap/init.php b/plugins/auth_ldap/init.php new file mode 100644 index 000000000..1985e38e8 --- /dev/null +++ b/plugins/auth_ldap/init.php @@ -0,0 +1,135 @@ +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; + } + +} + +?> -- cgit v1.2.3 From 8d0da886420d5ac7d62e600a996891e9bdc43840 Mon Sep 17 00:00:00 2001 From: hydrian Date: Tue, 19 Mar 2013 00:16:42 -0400 Subject: comment --- plugins/auth_ldap/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/auth_ldap/init.php b/plugins/auth_ldap/init.php index 1985e38e8..e1a4c49f1 100644 --- a/plugins/auth_ldap/init.php +++ b/plugins/auth_ldap/init.php @@ -21,7 +21,7 @@ */ /** - * Notes + * Notes - * LDAP search does not support follow ldap referals. Referals are disabled to * allow proper login. This is particular to Active Directory. * -- cgit v1.2.3 From 23923ca726c0d93db6dd81eb8d94d6b5f04310eb Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 19 Mar 2013 13:39:26 +0400 Subject: auth_remote: add REDIRECT_ version of REMOTE_USER for php-cgi configured through mod_actions (closes #597) --- plugins/auth_remote/init.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins') 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"; -- cgit v1.2.3 From 1d5cf085a37e8e016242c9cfea631a90861ab306 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 19 Mar 2013 18:32:49 +0400 Subject: implement mail plugin using mailto: links; deprecate mail plugin --- plugins/mail/init.php | 9 +++-- plugins/mailto/init.js | 32 +++++++++++++++++ plugins/mailto/init.php | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ plugins/mailto/mail.png | Bin 0 -> 192 bytes 4 files changed, 129 insertions(+), 5 deletions(-) create mode 100644 plugins/mailto/init.js create mode 100644 plugins/mailto/init.php create mode 100644 plugins/mailto/mail.png (limited to 'plugins') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 2e972cf61..0c8bc40aa 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -6,7 +6,7 @@ class Mail extends Plugin { function about() { return array(1.0, - "Share article via email", + "Share article via email (deprecated)", "fox"); } @@ -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¶m=" + 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 @@ +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 "Zoom"; + } + + 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 ""; + + print __("You should be able to edit the message before sending in your mail client."); + + print "

"; + + print "

"; + print ""; + print "
"; + + //return; + } + +} +?> diff --git a/plugins/mailto/mail.png b/plugins/mailto/mail.png new file mode 100644 index 000000000..4d3fe7751 Binary files /dev/null and b/plugins/mailto/mail.png differ -- cgit v1.2.3 From f044a0b8165348fb2bf4367cced749b9f2e73ee3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 19 Mar 2013 20:39:07 +0400 Subject: undeprecate mail plugin --- plugins/mail/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 0c8bc40aa..84fd5d3b2 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -6,7 +6,7 @@ class Mail extends Plugin { function about() { return array(1.0, - "Share article via email (deprecated)", + "Share article via email", "fox"); } -- cgit v1.2.3