Merge remote-tracking branch 'origin' into hookhead

Conflicts:
	classes/feeds.php

fix for merging up to the origin
This commit is contained in:
justauser 2013-06-27 11:57:49 -04:00
commit 7171f32dc5
10 changed files with 317 additions and 42 deletions

1
.gitignore vendored
View File

@ -2,7 +2,6 @@
*~ *~
*.DS_Store *.DS_Store
#* #*
lib/floIcon.php
.idea/* .idea/*
config.php config.php
feed-icons/* feed-icons/*

View File

@ -363,12 +363,15 @@ class Feeds extends Handler_Protected {
$date_entered_fmt = T_sprintf("Imported at %s", $date_entered_fmt = T_sprintf("Imported at %s",
make_local_datetime($line["date_entered"], false)); make_local_datetime($line["date_entered"], false));
if (get_pref('SHOW_CONTENT_PREVIEW') ) { # if (get_pref('SHOW_CONTENT_PREVIEW') ) {
if(isset($line["modified_preview"])) # if(isset($line["modified_preview"]))
$content_preview = strip_tags($line["content_preview"]); # $content_preview = strip_tags($line["content_preview"]);
else # else
$content_preview = truncate_string(strip_tags($line["content_preview"]), # $content_preview = truncate_string(strip_tags($line["content_preview"]),
250); # 250);
if (get_pref('SHOW_CONTENT_PREVIEW')) {
$content_preview = " — " . truncate_string(strip_tags($line["content_preview"]),
250);
} }
$score = $line["score"]; $score = $line["score"];
@ -462,7 +465,7 @@ class Feeds extends Handler_Protected {
if (get_pref('SHOW_CONTENT_PREVIEW')) { if (get_pref('SHOW_CONTENT_PREVIEW')) {
if ($content_preview) { if ($content_preview) {
$reply['content'] .= "<span class=\"contentPreview\"> - $content_preview</span>"; $reply['content'] .= "<span class=\"contentPreview\">$content_preview</span>";
} }
} }
@ -581,7 +584,11 @@ class Feeds extends Handler_Protected {
$excerpt_hidden = "style=\"display : none\""; $excerpt_hidden = "style=\"display : none\"";
$reply['content'] .= "<span $excerpt_hidden $reply['content'] .= "<span $excerpt_hidden
<<<<<<< HEAD
id=\"CEXC-$id\" class=\"cdmExcerpt\"> -" . $content_preview . "</span>"; id=\"CEXC-$id\" class=\"cdmExcerpt\"> -" . $content_preview . "</span>";
=======
id=\"CEXC-$id\" class=\"cdmExcerpt\">$content_preview</span>";
>>>>>>> origin
$reply['content'] .= "</span>"; $reply['content'] .= "</span>";
if (!get_pref('VFEED_GROUP_BY_FEED')) { if (!get_pref('VFEED_GROUP_BY_FEED')) {

View File

@ -190,6 +190,7 @@ class Opml extends Handler_Protected {
} }
$tmp_line["cat_filter"] = sql_bool_to_bool($tmp_line["cat_filter"]); $tmp_line["cat_filter"] = sql_bool_to_bool($tmp_line["cat_filter"]);
$tmp_line["inverse"] = sql_bool_to_bool($tmp_line["inverse"]);
unset($tmp_line["feed_id"]); unset($tmp_line["feed_id"]);
unset($tmp_line["cat_id"]); unset($tmp_line["cat_id"]);
@ -363,9 +364,10 @@ class Opml extends Handler_Protected {
$cat_filter = bool_to_sql_bool($rule["cat_filter"]); $cat_filter = bool_to_sql_bool($rule["cat_filter"]);
$reg_exp = $this->dbh->escape_string($rule["reg_exp"]); $reg_exp = $this->dbh->escape_string($rule["reg_exp"]);
$filter_type = (int)$rule["filter_type"]; $filter_type = (int)$rule["filter_type"];
$inverse = bool_to_sql_bool($rule["inverse"]);
$this->dbh->query("INSERT INTO ttrss_filters2_rules (feed_id,cat_id,filter_id,filter_type,reg_exp,cat_filter) $this->dbh->query("INSERT INTO ttrss_filters2_rules (feed_id,cat_id,filter_id,filter_type,reg_exp,cat_filter,inverse)
VALUES ($feed_id, $cat_id, $filter_id, $filter_type, '$reg_exp', $cat_filter)"); VALUES ($feed_id, $cat_id, $filter_id, $filter_type, '$reg_exp', $cat_filter,$inverse)");
} }
foreach ($filter["actions"] as $action) { foreach ($filter["actions"] as $action) {

View File

@ -792,31 +792,10 @@ class Pref_Feeds extends Handler_Protected {
print "<div class=\"dlgSec\">".__("Feed")."</div>"; print "<div class=\"dlgSec\">".__("Feed")."</div>";
print "<div class=\"dlgSecCont\">"; print "<div class=\"dlgSecCont\">";
/* Title */
print "<input dojoType=\"dijit.form.ValidationTextBox\"
disabled=\"1\" style=\"font-size : 16px; width : 20em;\" required=\"1\"
name=\"title\" value=\"\">";
$this->batch_edit_cbox("title");
/* Feed URL */
print "<br/>";
print __('URL:') . " ";
print "<input dojoType=\"dijit.form.ValidationTextBox\" disabled=\"1\"
required=\"1\" regExp='^(http|https)://.*' style=\"width : 20em\"
name=\"feed_url\" value=\"\">";
$this->batch_edit_cbox("feed_url");
/* Category */ /* Category */
if (get_pref('ENABLE_FEED_CATS')) { if (get_pref('ENABLE_FEED_CATS')) {
print "<br/>";
print __('Place in category:') . " "; print __('Place in category:') . " ";
print_feed_cat_select("cat_id", false, print_feed_cat_select("cat_id", false,
@ -862,7 +841,7 @@ class Pref_Feeds extends Handler_Protected {
$this->batch_edit_cbox("auth_login"); $this->batch_edit_cbox("auth_login");
print "<br/><input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\" print "<hr/> <input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\"
placeHolder=\"".__("Password")."\" disabled=\"1\" placeHolder=\"".__("Password")."\" disabled=\"1\"
value=\"\">"; value=\"\">";

View File

@ -590,14 +590,15 @@ class Pref_Filters extends Handler_Protected {
$enabled = checkbox_to_sql_bool($_REQUEST["enabled"]); $enabled = checkbox_to_sql_bool($_REQUEST["enabled"]);
$match_any_rule = checkbox_to_sql_bool($_REQUEST["match_any_rule"]); $match_any_rule = checkbox_to_sql_bool($_REQUEST["match_any_rule"]);
$title = $this->dbh->escape_string($_REQUEST["title"]); $title = $this->dbh->escape_string($_REQUEST["title"]);
$inverse = checkbox_to_sql_bool($_REQUEST["inverse"]);
$this->dbh->query("BEGIN"); $this->dbh->query("BEGIN");
/* create base filter */ /* create base filter */
$result = $this->dbh->query("INSERT INTO ttrss_filters2 $result = $this->dbh->query("INSERT INTO ttrss_filters2
(owner_uid, match_any_rule, enabled, title) VALUES (owner_uid, match_any_rule, enabled, title, inverse) VALUES
(".$_SESSION["uid"].",$match_any_rule,$enabled, '$title')"); (".$_SESSION["uid"].",$match_any_rule,$enabled, '$title', $inverse)");
$result = $this->dbh->query("SELECT MAX(id) AS id FROM ttrss_filters2 $result = $this->dbh->query("SELECT MAX(id) AS id FROM ttrss_filters2
WHERE owner_uid = ".$_SESSION["uid"]); WHERE owner_uid = ".$_SESSION["uid"]);

View File

@ -1110,6 +1110,7 @@ body#ttrssMain #feedTree {
background : #f0f0f0; background : #f0f0f0;
color : #999; color : #999;
border-color : #f0f0f0; border-color : #f0f0f0;
text-shadow : none;
} }
#feedTree .counterNode { #feedTree .counterNode {
@ -1123,10 +1124,9 @@ body#ttrssMain #feedTree {
border-radius : 4px; border-radius : 4px;
vertical-align : middle; vertical-align : middle;
float : right; float : right;
margin-right : 5px; margin : 5px 5px 5px 0px;
position : relative;
top : 2px;
min-width : 23px; min-width : 23px;
text-shadow : 1px 1px rgba(0,0,0,0.2);
} }
#feedTree .dijitTreeRow { #feedTree .dijitTreeRow {

View File

@ -246,9 +246,6 @@ function bwLimitChange(elem) {
<div class='footer'> <div class='footer'>
<a href="http://tt-rss.org/">Tiny Tiny RSS</a> <a href="http://tt-rss.org/">Tiny Tiny RSS</a>
<?php if (!defined('HIDE_VERSION')) { ?>
v<?php echo VERSION ?>
<?php } ?>
&copy; 2005&ndash;<?php echo date('Y') ?> <a href="http://fakecake.org/">Andrew Dolgov</a> &copy; 2005&ndash;<?php echo date('Y') ?> <a href="http://fakecake.org/">Andrew Dolgov</a>
</div> </div>

View File

@ -5,9 +5,9 @@
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$root_dir = dirname(dirname(__FILE__)); $root_dir = dirname(dirname(__FILE__));
if (is_dir("$root_dir/.git") && file_exists("$root_dir/.git/ORIG_HEAD")) { if (is_dir("$root_dir/.git") && file_exists("$root_dir/.git/refs/heads/master")) {
$suffix = substr(trim(file_get_contents("$root_dir/.git/ORIG_HEAD")), 0, 7); $suffix = substr(trim(file_get_contents("$root_dir/.git/refs/heads/master")), 0, 7);
return VERSION_STATIC . ".$suffix"; return VERSION_STATIC . ".$suffix";
} else { } else {

20
lib/floIcon.php Normal file
View File

@ -0,0 +1,20 @@
<?php
// Compatibility shim for hooking up jimIcon to Tiny Tiny RSS.
require_once "jimIcon.php";
class floIconIcon {
function getImageResource() {
return $this->img;
}
}
class floIcon {
function readICO($file) {
$jim = new jimIcon();
$icon = new floIconIcon();
$icon->img = $jim->fromiconstring(file_get_contents($file));
$this->images = array($icon);
}
}
?>

270
lib/jimIcon.php Normal file
View File

@ -0,0 +1,270 @@
<?php
// Simple .ICO parsing. The ICO format is insanely complex and this may
// fail to correctly handle some technically valid files, but it works
// on the majority I've found.
//
// jimIcon was written in 2013 by Jim Paris <jim@jtan.com> and is
// released under the terms of the CC0:
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any arranty.
//
// You may have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// http://creativecommons.org/publicdomain/zero/1.0/
class jimIcon {
// Get an image color from a string
function get_color($str, $img) {
$b = ord($str[0]);
$g = ord($str[1]);
$r = ord($str[2]);
if (strlen($str) > 3) {
$a = 127 - (ord($str[3]) / 2);
if ($a != 0 && $a != 127)
$this->had_alpha = 1;
} else {
$a = 0;
}
if ($a != 127)
$this->all_transaprent = 0;
return imagecolorallocatealpha($img, $r, $g, $b, $a);
}
// Given a string with the contents of an .ICO,
// return a GD image of the icon, or false on error.
function fromiconstring($ico) {
$this->error = "(unknown error)";
$this->had_alpha = 0;
// Read header
if (strlen($ico) < 6) {
$this->error = "too short";
return false;
}
$h = unpack("vzero/vtype/vnum", $ico);
// Must be ICO format with at least one image
if ($h["zero"] != 0 || $h["type"] != 1 || $h["num"] == 0) {
// See if we can just parse it with GD directly
// if it's not ICO format; maybe it was a mislabeled
// PNG or something.
$i = @imagecreatefromstring($ico);
if ($i) {
imagesavealpha($i, true);
return $i;
}
$this->error = "not ICO or other image";
return false;
}
// Read directory entries to find the biggest image
$most_pixels = 0;
for ($i = 0; $i < $h["num"]; $i++) {
$entry = substr($ico, 6 + 16 * $i, 16);
if (!$entry || strlen($entry) < 16)
continue;
$e = unpack("Cwidth/" .
"Cheight/" .
"Ccolors/" .
"Czero/" .
"vplanes/" .
"vbpp/" .
"Vsize/" .
"Voffset/",
$entry);
if ($e["width"] == 0)
$e["width"] = 256;
if ($e["height"] == 0)
$e["height"] = 256;
if ($e["zero"] != 0) {
$this->error = "nonzero reserved field";
return false;
}
$pixels = $e["width"] * $e["height"];
if ($pixels > $most_pixels) {
$most_pixels = $pixels;
$most = $e;
}
}
if ($most_pixels == 0) {
$this->error = "no pixels";
return false;
}
$e = $most;
// Extract image data
$data = substr($ico, $e["offset"], $e["size"]);
if (!$data || strlen($data) != $e["size"]) {
$this->error = "bad image data";
return false;
}
// See if we can parse it (might be PNG format here)
$i = @imagecreatefromstring($data);
if ($i) {
imagesavealpha($img, true);
return $i;
}
// Must be a BMP. Parse it ourselves.
$img = imagecreatetruecolor($e["width"], $e["height"]);
imagesavealpha($img, true);
$bg = imagecolorallocatealpha($img, 255, 0, 0, 127);
imagefill($img, 0, 0, $bg);
// Skip over the BITMAPCOREHEADER or BITMAPINFOHEADER;
// we'll just assume the palette and pixel data follow
// in the most obvious format as described by the icon
// directory entry.
$bitmapinfo = unpack("Vsize", $data);
if ($bitmapinfo["size"] == 40) {
$info = unpack("Vsize/" .
"Vwidth/" .
"Vheight/" .
"vplanes/" .
"vbpp/" .
"Vcompress/" .
"Vsize/" .
"Vxres/" .
"Vyres/" .
"Vpalcolors/" .
"Vimpcolors/", $data);
if ($e["bpp"] == 0) {
$e["bpp"] = $info["bpp"];
}
}
$data = substr($data, $bitmapinfo["size"]);
$height = $e["height"];
$width = $e["width"];
$bpp = $e["bpp"];
// For indexed images, we only support 1, 4, or 8 BPP
switch ($bpp) {
case 1:
case 4:
case 8:
$indexed = 1;
break;
case 24:
case 32:
$indexed = 0;
break;
default:
$this->error = "bad BPP $bpp";
return false;
}
$offset = 0;
if ($indexed) {
$palette = array();
$this->all_transparent = 1;
for ($i = 0; $i < (1 << $bpp); $i++) {
$entry = substr($data, $i * 4, 4);
$palette[$i] = $this->get_color($entry, $img);
}
$offset = $i * 4;
// Hack for some icons: if everything was transparent,
// discard alpha channel.
if ($this->all_transparent) {
for ($i = 0; $i < (1 << $bpp); $i++) {
$palette[$i] &= 0xffffff;
}
}
}
// Assume image data follows in bottom-up order.
// First the "XOR" image
if ((strlen($data) - $offset) < ($bpp * $height * $width / 8)) {
$this->error = "short data";
return false;
}
$XOR = array();
for ($y = $height - 1; $y >= 0; $y--) {
$x = 0;
while ($x < $width) {
if (!$indexed) {
$bytes = $bpp / 8;
$entry = substr($data, $offset, $bytes);
$pixel = $this->get_color($entry, $img);
$XOR[$y][$x] = $pixel;
$x++;
$offset += $bytes;
} elseif ($bpp == 1) {
$p = ord($data[$offset]);
for ($b = 0x80; $b > 0; $b >>= 1) {
if ($p & $b) {
$pixel = $palette[1];
} else {
$pixel = $palette[0];
}
$XOR[$y][$x] = $pixel;
$x++;
}
$offset++;
} elseif ($bpp == 4) {
$p = ord($data[$offset]);
$pixel1 = $palette[$p >> 4];
$pixel2 = $palette[$p & 0x0f];
$XOR[$y][$x] = $pixel1;
$XOR[$y][$x+1] = $pixel2;
$x += 2;
$offset++;
} elseif ($bpp == 8) {
$pixel = $palette[ord($data[$offset])];
$XOR[$y][$x] = $pixel;
$x += 1;
$offset++;
} else {
$this->error = "bad BPP";
return false;
}
}
// End of row padding
while ($offset & 3)
$offset++;
}
// Now the "AND" image, which is 1 bit per pixel. Ignore
// if some of our image data already had alpha values,
// or if there isn't enough data left.
if ($this->had_alpha ||
((strlen($data) - $offset) < ($height * $width / 8))) {
// Just return what we've got
for ($y = 0; $y < $height; $y++) {
for ($x = 0; $x < $width; $x++) {
imagesetpixel($img, $x, $y,
$XOR[$y][$x]);
}
}
return $img;
}
// Mask what we have with the "AND" image
for ($y = $height - 1; $y >= 0; $y--) {
$x = 0;
while ($x < $width) {
for ($b = 0x80;
$b > 0 && $x < $width; $b >>= 1) {
if (!(ord($data[$offset]) & $b)) {
imagesetpixel($img, $x, $y,
$XOR[$y][$x]);
}
$x++;
}
$offset++;
}
// End of row padding
while ($offset & 3)
$offset++;
}
return $img;
}
}
?>