@@ -24,8 +24,9 @@ |
||
| 24 | 24 | ]; |
| 25 | 25 | |
| 26 | 26 | foreach ($server_params as $n => $p) { |
| 27 | - if (isset($_SERVER[$p])) |
|
| 28 | - $context .= "\n$n: ".$_SERVER[$p]; |
|
| 27 | + if (isset($_SERVER[$p])) { |
|
| 28 | + $context .= "\n$n: ".$_SERVER[$p]; |
|
| 29 | + } |
|
| 29 | 30 | } |
| 30 | 31 | |
| 31 | 32 | // passed error message may contain invalid unicode characters, failing to insert an error here |
@@ -1,47 +1,47 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Logger_SQL { |
| 3 | 3 | |
| 4 | - private $pdo; |
|
| 4 | + private $pdo; |
|
| 5 | 5 | |
| 6 | - public function log_error($errno, $errstr, $file, $line, $context) { |
|
| 6 | + public function log_error($errno, $errstr, $file, $line, $context) { |
|
| 7 | 7 | |
| 8 | - // separate PDO connection object is used for logging |
|
| 9 | - if (!$this->pdo) { |
|
| 10 | - $this->pdo = Db::instance()->pdo_connect(); |
|
| 11 | - } |
|
| 8 | + // separate PDO connection object is used for logging |
|
| 9 | + if (!$this->pdo) { |
|
| 10 | + $this->pdo = Db::instance()->pdo_connect(); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - if ($this->pdo && get_schema_version() > 117) { |
|
| 13 | + if ($this->pdo && get_schema_version() > 117) { |
|
| 14 | 14 | |
| 15 | - $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; |
|
| 15 | + $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; |
|
| 16 | 16 | |
| 17 | - // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge |
|
| 18 | - $context = mb_substr($context, 0, 8192); |
|
| 17 | + // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge |
|
| 18 | + $context = mb_substr($context, 0, 8192); |
|
| 19 | 19 | |
| 20 | - $server_params = [ |
|
| 21 | - "IP" => "REMOTE_ADDR", |
|
| 22 | - "Request URI" => "REQUEST_URI", |
|
| 23 | - "User agent" => "HTTP_USER_AGENT", |
|
| 24 | - ]; |
|
| 20 | + $server_params = [ |
|
| 21 | + "IP" => "REMOTE_ADDR", |
|
| 22 | + "Request URI" => "REQUEST_URI", |
|
| 23 | + "User agent" => "HTTP_USER_AGENT", |
|
| 24 | + ]; |
|
| 25 | 25 | |
| 26 | - foreach ($server_params as $n => $p) { |
|
| 27 | - if (isset($_SERVER[$p])) |
|
| 28 | - $context .= "\n$n: ".$_SERVER[$p]; |
|
| 29 | - } |
|
| 26 | + foreach ($server_params as $n => $p) { |
|
| 27 | + if (isset($_SERVER[$p])) |
|
| 28 | + $context .= "\n$n: ".$_SERVER[$p]; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - // passed error message may contain invalid unicode characters, failing to insert an error here |
|
| 32 | - // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc |
|
| 33 | - $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8'); |
|
| 34 | - $context = UConverter::transcode($context, 'UTF-8', 'UTF-8'); |
|
| 31 | + // passed error message may contain invalid unicode characters, failing to insert an error here |
|
| 32 | + // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc |
|
| 33 | + $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8'); |
|
| 34 | + $context = UConverter::transcode($context, 'UTF-8', 'UTF-8'); |
|
| 35 | 35 | |
| 36 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log |
|
| 36 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log |
|
| 37 | 37 | (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES |
| 38 | 38 | (?, ?, ?, ?, ?, ?, NOW())"); |
| 39 | - $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]); |
|
| 39 | + $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]); |
|
| 40 | 40 | |
| 41 | - return $sth->rowCount(); |
|
| 42 | - } |
|
| 41 | + return $sth->rowCount(); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return false; |
|
| 45 | - } |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |
@@ -186,8 +186,9 @@ |
||
| 186 | 186 | $cat = clean(trim(mb_strtolower($srccat))); |
| 187 | 187 | |
| 188 | 188 | // we don't support numeric tags |
| 189 | - if (is_numeric($cat)) |
|
| 190 | - $cat = 't:'.$cat; |
|
| 189 | + if (is_numeric($cat)) { |
|
| 190 | + $cat = 't:'.$cat; |
|
| 191 | + } |
|
| 191 | 192 | |
| 192 | 193 | $cat = preg_replace('/[,\'\"]/', "", $cat); |
| 193 | 194 | |
@@ -1,209 +1,209 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | abstract class FeedItem_Common extends FeedItem { |
| 3 | - protected $elem; |
|
| 4 | - protected $xpath; |
|
| 5 | - protected $doc; |
|
| 6 | - |
|
| 7 | - public function __construct($elem, $doc, $xpath) { |
|
| 8 | - $this->elem = $elem; |
|
| 9 | - $this->xpath = $xpath; |
|
| 10 | - $this->doc = $doc; |
|
| 11 | - |
|
| 12 | - try { |
|
| 3 | + protected $elem; |
|
| 4 | + protected $xpath; |
|
| 5 | + protected $doc; |
|
| 6 | + |
|
| 7 | + public function __construct($elem, $doc, $xpath) { |
|
| 8 | + $this->elem = $elem; |
|
| 9 | + $this->xpath = $xpath; |
|
| 10 | + $this->doc = $doc; |
|
| 11 | + |
|
| 12 | + try { |
|
| 13 | 13 | |
| 14 | - $source = $elem->getElementsByTagName("source")->item(0); |
|
| 14 | + $source = $elem->getElementsByTagName("source")->item(0); |
|
| 15 | 15 | |
| 16 | - // we don't need <source> element |
|
| 17 | - if ($source) { |
|
| 18 | - $elem->removeChild($source); |
|
| 19 | - } |
|
| 20 | - } catch (DOMException $e) { |
|
| 21 | - // |
|
| 22 | - } |
|
| 23 | - } |
|
| 16 | + // we don't need <source> element |
|
| 17 | + if ($source) { |
|
| 18 | + $elem->removeChild($source); |
|
| 19 | + } |
|
| 20 | + } catch (DOMException $e) { |
|
| 21 | + // |
|
| 22 | + } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function get_element() { |
|
| 26 | - return $this->elem; |
|
| 27 | - } |
|
| 25 | + public function get_element() { |
|
| 26 | + return $this->elem; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function get_author() { |
|
| 30 | - $author = $this->elem->getElementsByTagName("author")->item(0); |
|
| 29 | + public function get_author() { |
|
| 30 | + $author = $this->elem->getElementsByTagName("author")->item(0); |
|
| 31 | 31 | |
| 32 | - if ($author) { |
|
| 33 | - $name = $author->getElementsByTagName("name")->item(0); |
|
| 32 | + if ($author) { |
|
| 33 | + $name = $author->getElementsByTagName("name")->item(0); |
|
| 34 | 34 | |
| 35 | - if ($name) { |
|
| 36 | - return clean($name->nodeValue); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - $email = $author->getElementsByTagName("email")->item(0); |
|
| 40 | - |
|
| 41 | - if ($email) { |
|
| 42 | - return clean($email->nodeValue); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - if ($author->nodeValue) { |
|
| 46 | - return clean($author->nodeValue); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - $author_elems = $this->xpath->query("dc:creator", $this->elem); |
|
| 51 | - $authors = []; |
|
| 52 | - |
|
| 53 | - foreach ($author_elems as $author) { |
|
| 54 | - array_push($authors, clean($author->nodeValue)); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - return implode(", ", $authors); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - public function get_comments_url() { |
|
| 61 | - //RSS only. Use a query here to avoid namespace clashes (e.g. with slash). |
|
| 62 | - //might give a wrong result if a default namespace was declared (possible with XPath 2.0) |
|
| 63 | - $com_url = $this->xpath->query("comments", $this->elem)->item(0); |
|
| 35 | + if ($name) { |
|
| 36 | + return clean($name->nodeValue); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + $email = $author->getElementsByTagName("email")->item(0); |
|
| 40 | + |
|
| 41 | + if ($email) { |
|
| 42 | + return clean($email->nodeValue); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + if ($author->nodeValue) { |
|
| 46 | + return clean($author->nodeValue); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + $author_elems = $this->xpath->query("dc:creator", $this->elem); |
|
| 51 | + $authors = []; |
|
| 52 | + |
|
| 53 | + foreach ($author_elems as $author) { |
|
| 54 | + array_push($authors, clean($author->nodeValue)); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + return implode(", ", $authors); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + public function get_comments_url() { |
|
| 61 | + //RSS only. Use a query here to avoid namespace clashes (e.g. with slash). |
|
| 62 | + //might give a wrong result if a default namespace was declared (possible with XPath 2.0) |
|
| 63 | + $com_url = $this->xpath->query("comments", $this->elem)->item(0); |
|
| 64 | 64 | |
| 65 | - if ($com_url) { |
|
| 66 | - return clean($com_url->nodeValue); |
|
| 67 | - } |
|
| 65 | + if ($com_url) { |
|
| 66 | + return clean($com_url->nodeValue); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - //Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common. |
|
| 70 | - //'text/html' for type is too restrictive? |
|
| 71 | - $com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0); |
|
| 72 | - |
|
| 73 | - if ($com_url) { |
|
| 74 | - return clean($com_url->nodeValue); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - public function get_comments_count() { |
|
| 79 | - //also query for ATE stuff here |
|
| 80 | - $query = "slash:comments|thread:total|atom:link[@rel='replies']/@thread:count"; |
|
| 81 | - $comments = $this->xpath->query($query, $this->elem)->item(0); |
|
| 82 | - |
|
| 83 | - if ($comments) { |
|
| 84 | - return clean($comments->nodeValue); |
|
| 85 | - } |
|
| 86 | - } |
|
| 69 | + //Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common. |
|
| 70 | + //'text/html' for type is too restrictive? |
|
| 71 | + $com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0); |
|
| 72 | + |
|
| 73 | + if ($com_url) { |
|
| 74 | + return clean($com_url->nodeValue); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + public function get_comments_count() { |
|
| 79 | + //also query for ATE stuff here |
|
| 80 | + $query = "slash:comments|thread:total|atom:link[@rel='replies']/@thread:count"; |
|
| 81 | + $comments = $this->xpath->query($query, $this->elem)->item(0); |
|
| 82 | + |
|
| 83 | + if ($comments) { |
|
| 84 | + return clean($comments->nodeValue); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // this is common for both Atom and RSS types and deals with various media: elements |
|
| 89 | - public function get_enclosures() { |
|
| 90 | - $encs = []; |
|
| 88 | + // this is common for both Atom and RSS types and deals with various media: elements |
|
| 89 | + public function get_enclosures() { |
|
| 90 | + $encs = []; |
|
| 91 | 91 | |
| 92 | - $enclosures = $this->xpath->query("media:content", $this->elem); |
|
| 92 | + $enclosures = $this->xpath->query("media:content", $this->elem); |
|
| 93 | 93 | |
| 94 | - foreach ($enclosures as $enclosure) { |
|
| 95 | - $enc = new FeedEnclosure(); |
|
| 94 | + foreach ($enclosures as $enclosure) { |
|
| 95 | + $enc = new FeedEnclosure(); |
|
| 96 | 96 | |
| 97 | - $enc->type = clean($enclosure->getAttribute("type")); |
|
| 98 | - $enc->link = clean($enclosure->getAttribute("url")); |
|
| 99 | - $enc->length = clean($enclosure->getAttribute("length")); |
|
| 100 | - $enc->height = clean($enclosure->getAttribute("height")); |
|
| 101 | - $enc->width = clean($enclosure->getAttribute("width")); |
|
| 97 | + $enc->type = clean($enclosure->getAttribute("type")); |
|
| 98 | + $enc->link = clean($enclosure->getAttribute("url")); |
|
| 99 | + $enc->length = clean($enclosure->getAttribute("length")); |
|
| 100 | + $enc->height = clean($enclosure->getAttribute("height")); |
|
| 101 | + $enc->width = clean($enclosure->getAttribute("width")); |
|
| 102 | 102 | |
| 103 | - $medium = clean($enclosure->getAttribute("medium")); |
|
| 104 | - if (!$enc->type && $medium) { |
|
| 105 | - $enc->type = strtolower("$medium/generic"); |
|
| 106 | - } |
|
| 103 | + $medium = clean($enclosure->getAttribute("medium")); |
|
| 104 | + if (!$enc->type && $medium) { |
|
| 105 | + $enc->type = strtolower("$medium/generic"); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
| 109 | - if ($desc) { |
|
| 110 | - $enc->title = clean($desc->nodeValue); |
|
| 111 | - } |
|
| 108 | + $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
| 109 | + if ($desc) { |
|
| 110 | + $enc->title = clean($desc->nodeValue); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - array_push($encs, $enc); |
|
| 114 | - } |
|
| 113 | + array_push($encs, $enc); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - $enclosures = $this->xpath->query("media:group", $this->elem); |
|
| 116 | + $enclosures = $this->xpath->query("media:group", $this->elem); |
|
| 117 | 117 | |
| 118 | - foreach ($enclosures as $enclosure) { |
|
| 119 | - $enc = new FeedEnclosure(); |
|
| 118 | + foreach ($enclosures as $enclosure) { |
|
| 119 | + $enc = new FeedEnclosure(); |
|
| 120 | 120 | |
| 121 | - $content = $this->xpath->query("media:content", $enclosure)->item(0); |
|
| 121 | + $content = $this->xpath->query("media:content", $enclosure)->item(0); |
|
| 122 | 122 | |
| 123 | - if ($content) { |
|
| 124 | - $enc->type = clean($content->getAttribute("type")); |
|
| 125 | - $enc->link = clean($content->getAttribute("url")); |
|
| 126 | - $enc->length = clean($content->getAttribute("length")); |
|
| 127 | - $enc->height = clean($content->getAttribute("height")); |
|
| 128 | - $enc->width = clean($content->getAttribute("width")); |
|
| 123 | + if ($content) { |
|
| 124 | + $enc->type = clean($content->getAttribute("type")); |
|
| 125 | + $enc->link = clean($content->getAttribute("url")); |
|
| 126 | + $enc->length = clean($content->getAttribute("length")); |
|
| 127 | + $enc->height = clean($content->getAttribute("height")); |
|
| 128 | + $enc->width = clean($content->getAttribute("width")); |
|
| 129 | 129 | |
| 130 | - $medium = clean($content->getAttribute("medium")); |
|
| 131 | - if (!$enc->type && $medium) { |
|
| 132 | - $enc->type = strtolower("$medium/generic"); |
|
| 133 | - } |
|
| 130 | + $medium = clean($content->getAttribute("medium")); |
|
| 131 | + if (!$enc->type && $medium) { |
|
| 132 | + $enc->type = strtolower("$medium/generic"); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - $desc = $this->xpath->query("media:description", $content)->item(0); |
|
| 136 | - if ($desc) { |
|
| 137 | - $enc->title = clean($desc->nodeValue); |
|
| 138 | - } else { |
|
| 139 | - $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
| 140 | - if ($desc) { |
|
| 141 | - $enc->title = clean($desc->nodeValue); |
|
| 142 | - } |
|
| 143 | - } |
|
| 135 | + $desc = $this->xpath->query("media:description", $content)->item(0); |
|
| 136 | + if ($desc) { |
|
| 137 | + $enc->title = clean($desc->nodeValue); |
|
| 138 | + } else { |
|
| 139 | + $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
| 140 | + if ($desc) { |
|
| 141 | + $enc->title = clean($desc->nodeValue); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - array_push($encs, $enc); |
|
| 146 | - } |
|
| 147 | - } |
|
| 145 | + array_push($encs, $enc); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - $enclosures = $this->xpath->query("media:thumbnail", $this->elem); |
|
| 149 | + $enclosures = $this->xpath->query("media:thumbnail", $this->elem); |
|
| 150 | 150 | |
| 151 | - foreach ($enclosures as $enclosure) { |
|
| 152 | - $enc = new FeedEnclosure(); |
|
| 151 | + foreach ($enclosures as $enclosure) { |
|
| 152 | + $enc = new FeedEnclosure(); |
|
| 153 | 153 | |
| 154 | - $enc->type = "image/generic"; |
|
| 155 | - $enc->link = clean($enclosure->getAttribute("url")); |
|
| 156 | - $enc->height = clean($enclosure->getAttribute("height")); |
|
| 157 | - $enc->width = clean($enclosure->getAttribute("width")); |
|
| 154 | + $enc->type = "image/generic"; |
|
| 155 | + $enc->link = clean($enclosure->getAttribute("url")); |
|
| 156 | + $enc->height = clean($enclosure->getAttribute("height")); |
|
| 157 | + $enc->width = clean($enclosure->getAttribute("width")); |
|
| 158 | 158 | |
| 159 | - array_push($encs, $enc); |
|
| 160 | - } |
|
| 159 | + array_push($encs, $enc); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - return $encs; |
|
| 163 | - } |
|
| 162 | + return $encs; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - public function count_children($node) { |
|
| 166 | - return $node->getElementsByTagName("*")->length; |
|
| 167 | - } |
|
| 165 | + public function count_children($node) { |
|
| 166 | + return $node->getElementsByTagName("*")->length; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - public function subtree_or_text($node) { |
|
| 170 | - if ($this->count_children($node) == 0) { |
|
| 171 | - return $node->nodeValue; |
|
| 172 | - } else { |
|
| 173 | - return $node->c14n(); |
|
| 174 | - } |
|
| 175 | - } |
|
| 169 | + public function subtree_or_text($node) { |
|
| 170 | + if ($this->count_children($node) == 0) { |
|
| 171 | + return $node->nodeValue; |
|
| 172 | + } else { |
|
| 173 | + return $node->c14n(); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - public static function normalize_categories($cats) { |
|
| 177 | + public static function normalize_categories($cats) { |
|
| 178 | 178 | |
| 179 | - $tmp = []; |
|
| 179 | + $tmp = []; |
|
| 180 | 180 | |
| 181 | - foreach ($cats as $rawcat) { |
|
| 182 | - $tmp = array_merge($tmp, explode(",", $rawcat)); |
|
| 183 | - } |
|
| 181 | + foreach ($cats as $rawcat) { |
|
| 182 | + $tmp = array_merge($tmp, explode(",", $rawcat)); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - $tmp = array_map(function($srccat) { |
|
| 186 | - $cat = clean(trim(mb_strtolower($srccat))); |
|
| 185 | + $tmp = array_map(function($srccat) { |
|
| 186 | + $cat = clean(trim(mb_strtolower($srccat))); |
|
| 187 | 187 | |
| 188 | - // we don't support numeric tags |
|
| 189 | - if (is_numeric($cat)) |
|
| 190 | - $cat = 't:'.$cat; |
|
| 188 | + // we don't support numeric tags |
|
| 189 | + if (is_numeric($cat)) |
|
| 190 | + $cat = 't:'.$cat; |
|
| 191 | 191 | |
| 192 | - $cat = preg_replace('/[,\'\"]/', "", $cat); |
|
| 192 | + $cat = preg_replace('/[,\'\"]/', "", $cat); |
|
| 193 | 193 | |
| 194 | - if (DB_TYPE == "mysql") { |
|
| 195 | - $cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat); |
|
| 196 | - } |
|
| 194 | + if (DB_TYPE == "mysql") { |
|
| 195 | + $cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat); |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - if (mb_strlen($cat) > 250) { |
|
| 199 | - $cat = mb_substr($cat, 0, 250); |
|
| 200 | - } |
|
| 198 | + if (mb_strlen($cat) > 250) { |
|
| 199 | + $cat = mb_substr($cat, 0, 250); |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - return $cat; |
|
| 203 | - }, $tmp); |
|
| 202 | + return $cat; |
|
| 203 | + }, $tmp); |
|
| 204 | 204 | |
| 205 | - asort($tmp); |
|
| 205 | + asort($tmp); |
|
| 206 | 206 | |
| 207 | - return array_unique($tmp); |
|
| 208 | - } |
|
| 207 | + return array_unique($tmp); |
|
| 208 | + } |
|
| 209 | 209 | } |
@@ -124,8 +124,9 @@ |
||
| 124 | 124 | |
| 125 | 125 | while ($line = $sth->fetch()) { |
| 126 | 126 | |
| 127 | - if (!$subject) |
|
| 128 | - $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
| 127 | + if (!$subject) { |
|
| 128 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
| 129 | + } |
|
| 129 | 130 | |
| 130 | 131 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
| 131 | 132 | $tnote = strip_tags($line["note"]); |
@@ -1,47 +1,47 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class Mail extends Plugin { |
| 3 | 3 | |
| 4 | - /* @var PluginHost $host */ |
|
| 5 | - private $host; |
|
| 4 | + /* @var PluginHost $host */ |
|
| 5 | + private $host; |
|
| 6 | 6 | |
| 7 | - public function about() { |
|
| 8 | - return array(1.0, |
|
| 9 | - "Share article via email", |
|
| 10 | - "fox"); |
|
| 11 | - } |
|
| 7 | + public function about() { |
|
| 8 | + return array(1.0, |
|
| 9 | + "Share article via email", |
|
| 10 | + "fox"); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function init($host) { |
|
| 14 | - $this->host = $host; |
|
| 13 | + public function init($host) { |
|
| 14 | + $this->host = $host; |
|
| 15 | 15 | |
| 16 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
| 17 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 18 | - } |
|
| 16 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
| 17 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function get_js() { |
|
| 21 | - return file_get_contents(dirname(__FILE__)."/mail.js"); |
|
| 22 | - } |
|
| 20 | + public function get_js() { |
|
| 21 | + return file_get_contents(dirname(__FILE__)."/mail.js"); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function save() { |
|
| 25 | - $addresslist = $_POST["addresslist"]; |
|
| 24 | + public function save() { |
|
| 25 | + $addresslist = $_POST["addresslist"]; |
|
| 26 | 26 | |
| 27 | - $this->host->set($this, "addresslist", $addresslist); |
|
| 27 | + $this->host->set($this, "addresslist", $addresslist); |
|
| 28 | 28 | |
| 29 | - echo __("Mail addresses saved."); |
|
| 30 | - } |
|
| 29 | + echo __("Mail addresses saved."); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function hook_prefs_tab($args) { |
|
| 33 | - if ($args != "prefPrefs") { |
|
| 34 | - return; |
|
| 35 | - } |
|
| 32 | + public function hook_prefs_tab($args) { |
|
| 33 | + if ($args != "prefPrefs") { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 37 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 38 | 38 | title=\"<i class='material-icons'>mail</i> ".__('Mail plugin')."\">"; |
| 39 | 39 | |
| 40 | - print "<p>".__("You can set predefined email addressed here (comma-separated list):")."</p>"; |
|
| 40 | + print "<p>".__("You can set predefined email addressed here (comma-separated list):")."</p>"; |
|
| 41 | 41 | |
| 42 | - print "<form dojoType=\"dijit.form.Form\">"; |
|
| 42 | + print "<form dojoType=\"dijit.form.Form\">"; |
|
| 43 | 43 | |
| 44 | - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 44 | + print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
| 45 | 45 | evt.preventDefault(); |
| 46 | 46 | if (this.validate()) { |
| 47 | 47 | console.log(dojo.objectToQuery(this.getValues())); |
@@ -55,140 +55,140 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | </script>"; |
| 57 | 57 | |
| 58 | - print_hidden("op", "pluginhandler"); |
|
| 59 | - print_hidden("method", "save"); |
|
| 60 | - print_hidden("plugin", "mail"); |
|
| 58 | + print_hidden("op", "pluginhandler"); |
|
| 59 | + print_hidden("method", "save"); |
|
| 60 | + print_hidden("plugin", "mail"); |
|
| 61 | 61 | |
| 62 | - $addresslist = $this->host->get($this, "addresslist"); |
|
| 62 | + $addresslist = $this->host->get($this, "addresslist"); |
|
| 63 | 63 | |
| 64 | - print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\" |
|
| 64 | + print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\" |
|
| 65 | 65 | name='addresslist'>$addresslist</textarea>"; |
| 66 | 66 | |
| 67 | - print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
| 68 | - __("Save")."</button>"; |
|
| 67 | + print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
| 68 | + __("Save")."</button>"; |
|
| 69 | 69 | |
| 70 | - print "</form>"; |
|
| 70 | + print "</form>"; |
|
| 71 | 71 | |
| 72 | - print "</div>"; |
|
| 73 | - } |
|
| 72 | + print "</div>"; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function hook_article_button($line) { |
|
| 76 | - return "<i class='material-icons' style=\"cursor : pointer\" |
|
| 75 | + public function hook_article_button($line) { |
|
| 76 | + return "<i class='material-icons' style=\"cursor : pointer\" |
|
| 77 | 77 | onclick=\"Plugins.Mail.send(".$line["id"].")\" |
| 78 | 78 | title='".__('Forward by email')."'>mail</i>"; |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - public function emailArticle() { |
|
| 81 | + public function emailArticle() { |
|
| 82 | 82 | |
| 83 | - $ids = explode(",", $_REQUEST['param']); |
|
| 84 | - $ids_qmarks = arr_qmarks($ids); |
|
| 83 | + $ids = explode(",", $_REQUEST['param']); |
|
| 84 | + $ids_qmarks = arr_qmarks($ids); |
|
| 85 | 85 | |
| 86 | - print_hidden("op", "pluginhandler"); |
|
| 87 | - print_hidden("plugin", "mail"); |
|
| 88 | - print_hidden("method", "sendEmail"); |
|
| 86 | + print_hidden("op", "pluginhandler"); |
|
| 87 | + print_hidden("plugin", "mail"); |
|
| 88 | + print_hidden("method", "sendEmail"); |
|
| 89 | 89 | |
| 90 | - $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE |
|
| 90 | + $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE |
|
| 91 | 91 | id = ?"); |
| 92 | - $sth->execute([$_SESSION['uid']]); |
|
| 92 | + $sth->execute([$_SESSION['uid']]); |
|
| 93 | 93 | |
| 94 | - if ($row = $sth->fetch()) { |
|
| 95 | - $user_email = htmlspecialchars($row['email']); |
|
| 96 | - $user_name = htmlspecialchars($row['full_name']); |
|
| 97 | - } |
|
| 94 | + if ($row = $sth->fetch()) { |
|
| 95 | + $user_email = htmlspecialchars($row['email']); |
|
| 96 | + $user_name = htmlspecialchars($row['full_name']); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - if (!$user_name) { |
|
| 100 | - $user_name = $_SESSION['name']; |
|
| 101 | - } |
|
| 99 | + if (!$user_name) { |
|
| 100 | + $user_name = $_SESSION['name']; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - print_hidden("from_email", "$user_email"); |
|
| 104 | - print_hidden("from_name", "$user_name"); |
|
| 103 | + print_hidden("from_email", "$user_email"); |
|
| 104 | + print_hidden("from_name", "$user_name"); |
|
| 105 | 105 | |
| 106 | - require_once "lib/MiniTemplator.class.php"; |
|
| 106 | + require_once "lib/MiniTemplator.class.php"; |
|
| 107 | 107 | |
| 108 | - $tpl = new MiniTemplator; |
|
| 108 | + $tpl = new MiniTemplator; |
|
| 109 | 109 | |
| 110 | - $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
| 110 | + $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
| 111 | 111 | |
| 112 | - $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
| 113 | - $tpl->setVariable('USER_EMAIL', $user_email, true); |
|
| 114 | - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
| 112 | + $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
| 113 | + $tpl->setVariable('USER_EMAIL', $user_email, true); |
|
| 114 | + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
| 115 | 115 | |
| 116 | - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note |
|
| 116 | + $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note |
|
| 117 | 117 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
| 118 | 118 | id IN ($ids_qmarks) AND owner_uid = ?"); |
| 119 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 119 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
| 120 | 120 | |
| 121 | - if (count($ids) > 1) { |
|
| 122 | - $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
| 123 | - } |
|
| 121 | + if (count($ids) > 1) { |
|
| 122 | + $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - while ($line = $sth->fetch()) { |
|
| 125 | + while ($line = $sth->fetch()) { |
|
| 126 | 126 | |
| 127 | - if (!$subject) |
|
| 128 | - $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
| 127 | + if (!$subject) |
|
| 128 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
| 129 | 129 | |
| 130 | - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
| 131 | - $tnote = strip_tags($line["note"]); |
|
| 132 | - if ($tnote != '') { |
|
| 133 | - $tpl->setVariable('ARTICLE_NOTE', $tnote, true); |
|
| 134 | - $tpl->addBlock('note'); |
|
| 135 | - } |
|
| 136 | - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
| 130 | + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
| 131 | + $tnote = strip_tags($line["note"]); |
|
| 132 | + if ($tnote != '') { |
|
| 133 | + $tpl->setVariable('ARTICLE_NOTE', $tnote, true); |
|
| 134 | + $tpl->addBlock('note'); |
|
| 135 | + } |
|
| 136 | + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
| 137 | 137 | |
| 138 | - $tpl->addBlock('article'); |
|
| 139 | - } |
|
| 138 | + $tpl->addBlock('article'); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - $tpl->addBlock('email'); |
|
| 141 | + $tpl->addBlock('email'); |
|
| 142 | 142 | |
| 143 | - $content = ""; |
|
| 144 | - $tpl->generateOutputToString($content); |
|
| 143 | + $content = ""; |
|
| 144 | + $tpl->generateOutputToString($content); |
|
| 145 | 145 | |
| 146 | - print "<table width='100%'><tr><td>"; |
|
| 146 | + print "<table width='100%'><tr><td>"; |
|
| 147 | 147 | |
| 148 | - $addresslist = explode(",", $this->host->get($this, "addresslist")); |
|
| 148 | + $addresslist = explode(",", $this->host->get($this, "addresslist")); |
|
| 149 | 149 | |
| 150 | - print __('To:'); |
|
| 150 | + print __('To:'); |
|
| 151 | 151 | |
| 152 | - print "</td><td>"; |
|
| 152 | + print "</td><td>"; |
|
| 153 | 153 | |
| 154 | 154 | /* print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\" |
| 155 | 155 | style=\"width : 30em;\" |
| 156 | 156 | name=\"destination\" id=\"emailArticleDlg_destination\">"; */ |
| 157 | 157 | |
| 158 | - print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); |
|
| 158 | + print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); |
|
| 159 | 159 | |
| 160 | 160 | /* print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\" |
| 161 | 161 | style=\"z-index: 30; display : none\"></div>"; */ |
| 162 | 162 | |
| 163 | - print "</td></tr><tr><td>"; |
|
| 163 | + print "</td></tr><tr><td>"; |
|
| 164 | 164 | |
| 165 | - print __('Subject:'); |
|
| 165 | + print __('Subject:'); |
|
| 166 | 166 | |
| 167 | - print "</td><td>"; |
|
| 167 | + print "</td><td>"; |
|
| 168 | 168 | |
| 169 | - print "<input dojoType='dijit.form.ValidationTextBox' required='true' |
|
| 169 | + print "<input dojoType='dijit.form.ValidationTextBox' required='true' |
|
| 170 | 170 | style='width : 30em;' name='subject' value=\"$subject\" id='subject'>"; |
| 171 | 171 | |
| 172 | - print "</td></tr>"; |
|
| 172 | + print "</td></tr>"; |
|
| 173 | 173 | |
| 174 | - print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea' |
|
| 174 | + print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea' |
|
| 175 | 175 | style='height : 200px; font-size : 12px; width : 98%' rows=\"20\" |
| 176 | 176 | name='content'>$content</textarea>"; |
| 177 | 177 | |
| 178 | - print "</td></tr></table>"; |
|
| 178 | + print "</td></tr></table>"; |
|
| 179 | 179 | |
| 180 | - print "<footer>"; |
|
| 181 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> "; |
|
| 182 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>"; |
|
| 183 | - print "</footer>"; |
|
| 180 | + print "<footer>"; |
|
| 181 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> "; |
|
| 182 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>"; |
|
| 183 | + print "</footer>"; |
|
| 184 | 184 | |
| 185 | - //return; |
|
| 186 | - } |
|
| 185 | + //return; |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - public function sendEmail() { |
|
| 189 | - $reply = array(); |
|
| 188 | + public function sendEmail() { |
|
| 189 | + $reply = array(); |
|
| 190 | 190 | |
| 191 | - /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']), |
|
| 191 | + /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']), |
|
| 192 | 192 | strip_tags($_REQUEST['from_name'])); |
| 193 | 193 | //$mail->AddAddress($_REQUEST['destination']); |
| 194 | 194 | $addresses = explode(';', $_REQUEST['destination']); |
@@ -201,29 +201,29 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | $rc = $mail->Send(); */ |
| 203 | 203 | |
| 204 | - $to = $_REQUEST["destination"]; |
|
| 205 | - $subject = strip_tags($_REQUEST["subject"]); |
|
| 206 | - $message = strip_tags($_REQUEST["content"]); |
|
| 207 | - $from = strip_tags($_REQUEST["from_email"]); |
|
| 204 | + $to = $_REQUEST["destination"]; |
|
| 205 | + $subject = strip_tags($_REQUEST["subject"]); |
|
| 206 | + $message = strip_tags($_REQUEST["content"]); |
|
| 207 | + $from = strip_tags($_REQUEST["from_email"]); |
|
| 208 | 208 | |
| 209 | - $mailer = new Mailer(); |
|
| 209 | + $mailer = new Mailer(); |
|
| 210 | 210 | |
| 211 | - $rc = $mailer->mail(["to_address" => $to, |
|
| 212 | - "headers" => ["Reply-To: $from"], |
|
| 213 | - "subject" => $subject, |
|
| 214 | - "message" => $message]); |
|
| 211 | + $rc = $mailer->mail(["to_address" => $to, |
|
| 212 | + "headers" => ["Reply-To: $from"], |
|
| 213 | + "subject" => $subject, |
|
| 214 | + "message" => $message]); |
|
| 215 | 215 | |
| 216 | - if (!$rc) { |
|
| 217 | - $reply['error'] = $mailer->error(); |
|
| 218 | - } else { |
|
| 219 | - //save_email_address($destination); |
|
| 220 | - $reply['message'] = "UPDATE_COUNTERS"; |
|
| 221 | - } |
|
| 216 | + if (!$rc) { |
|
| 217 | + $reply['error'] = $mailer->error(); |
|
| 218 | + } else { |
|
| 219 | + //save_email_address($destination); |
|
| 220 | + $reply['message'] = "UPDATE_COUNTERS"; |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - print json_encode($reply); |
|
| 224 | - } |
|
| 223 | + print json_encode($reply); |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /* function completeEmails() { |
|
| 226 | + /* function completeEmails() { |
|
| 227 | 227 | $search = $_REQUEST["search"]; |
| 228 | 228 | |
| 229 | 229 | print "<ul>"; |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | print "</ul>"; |
| 238 | 238 | } */ |
| 239 | 239 | |
| 240 | - public function api_version() { |
|
| 241 | - return 2; |
|
| 242 | - } |
|
| 240 | + public function api_version() { |
|
| 241 | + return 2; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | 244 | } |
@@ -25,19 +25,19 @@ |
||
| 25 | 25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | - $QR_BASEDIR = dirname(__FILE__).DIRECTORY_SEPARATOR; |
|
| 28 | + $QR_BASEDIR = dirname(__FILE__).DIRECTORY_SEPARATOR; |
|
| 29 | 29 | |
| 30 | - // Required libs |
|
| 30 | + // Required libs |
|
| 31 | 31 | |
| 32 | - include $QR_BASEDIR."qrconst.php"; |
|
| 33 | - include $QR_BASEDIR."qrconfig.php"; |
|
| 34 | - include $QR_BASEDIR."qrtools.php"; |
|
| 35 | - include $QR_BASEDIR."qrspec.php"; |
|
| 36 | - include $QR_BASEDIR."qrimage.php"; |
|
| 37 | - include $QR_BASEDIR."qrinput.php"; |
|
| 38 | - include $QR_BASEDIR."qrbitstream.php"; |
|
| 39 | - include $QR_BASEDIR."qrsplit.php"; |
|
| 40 | - include $QR_BASEDIR."qrrscode.php"; |
|
| 41 | - include $QR_BASEDIR."qrmask.php"; |
|
| 42 | - include $QR_BASEDIR."qrencode.php"; |
|
| 32 | + include $QR_BASEDIR."qrconst.php"; |
|
| 33 | + include $QR_BASEDIR."qrconfig.php"; |
|
| 34 | + include $QR_BASEDIR."qrtools.php"; |
|
| 35 | + include $QR_BASEDIR."qrspec.php"; |
|
| 36 | + include $QR_BASEDIR."qrimage.php"; |
|
| 37 | + include $QR_BASEDIR."qrinput.php"; |
|
| 38 | + include $QR_BASEDIR."qrbitstream.php"; |
|
| 39 | + include $QR_BASEDIR."qrsplit.php"; |
|
| 40 | + include $QR_BASEDIR."qrrscode.php"; |
|
| 41 | + include $QR_BASEDIR."qrmask.php"; |
|
| 42 | + include $QR_BASEDIR."qrencode.php"; |
|
| 43 | 43 | |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | $outputCode .= "\n\n".$anotherCode."\n\n"; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - $versionDataEx = explode("\n", file_get_contents($versionFile));
|
|
| 62 | + $versionDataEx = explode("\n", file_get_contents($versionFile));
|
|
| 63 | 63 | |
| 64 | 64 | $outputContents = file_get_contents($headerFile); |
| 65 | 65 | $outputContents .= "\n\n/*\n * Version: ".trim($versionDataEx[0])."\n * Build: ".trim($versionDataEx[1])."\n */\n\n"; |
@@ -33,4 +33,4 @@ |
||
| 33 | 33 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | - |
|
| 37 | 36 | \ No newline at end of file |
| 37 | + |
|
| 38 | 38 | \ No newline at end of file |
@@ -335,10 +335,10 @@ |
||
| 335 | 335 | |
| 336 | 336 | // Version information pattern ----------------------------------------- |
| 337 | 337 | |
| 338 | - // Version information pattern (BCH coded). |
|
| 338 | + // Version information pattern (BCH coded). |
|
| 339 | 339 | // See Table 1 in Appendix D (pp.68) of JIS X0510:2004. |
| 340 | 340 | |
| 341 | - // size: [QRSPEC_VERSION_MAX - 6] |
|
| 341 | + // size: [QRSPEC_VERSION_MAX - 6] |
|
| 342 | 342 | |
| 343 | 343 | public static $versionPattern = array( |
| 344 | 344 | 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, |
@@ -115,8 +115,9 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | for ($i = 1; $i <= QRSPEC_VERSION_MAX; $i++) {
|
| 117 | 117 | $words = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level]; |
| 118 | - if ($words >= $size) |
|
| 119 | - return $i; |
|
| 118 | + if ($words >= $size) { |
|
| 119 | + return $i; |
|
| 120 | + } |
|
| 120 | 121 | } |
| 121 | 122 | |
| 122 | 123 | return -1; |
@@ -152,8 +153,9 @@ discard block |
||
| 152 | 153 | //---------------------------------------------------------------------- |
| 153 | 154 | public static function maximumWords($mode, $version) |
| 154 | 155 | {
|
| 155 | - if ($mode == QR_MODE_STRUCTURE) |
|
| 156 | - return 3; |
|
| 156 | + if ($mode == QR_MODE_STRUCTURE) { |
|
| 157 | + return 3; |
|
| 158 | + } |
|
| 157 | 159 | |
| 158 | 160 | if ($version <= 9) {
|
| 159 | 161 | $l = 0; |
@@ -299,8 +301,9 @@ discard block |
||
| 299 | 301 | //---------------------------------------------------------------------- |
| 300 | 302 | public static function putAlignmentPattern($version, &$frame, $width) |
| 301 | 303 | {
|
| 302 | - if ($version < 2) |
|
| 303 | - return; |
|
| 304 | + if ($version < 2) { |
|
| 305 | + return; |
|
| 306 | + } |
|
| 304 | 307 | |
| 305 | 308 | $d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0]; |
| 306 | 309 | if ($d < 0) {
|
@@ -352,8 +355,9 @@ discard block |
||
| 352 | 355 | //---------------------------------------------------------------------- |
| 353 | 356 | public static function getVersionPattern($version) |
| 354 | 357 | {
|
| 355 | - if ($version < 7 || $version > QRSPEC_VERSION_MAX) |
|
| 356 | - return 0; |
|
| 358 | + if ($version < 7 || $version > QRSPEC_VERSION_MAX) { |
|
| 359 | + return 0; |
|
| 360 | + } |
|
| 357 | 361 | |
| 358 | 362 | return self::$versionPattern[$version - 7]; |
| 359 | 363 | } |
@@ -370,11 +374,13 @@ discard block |
||
| 370 | 374 | |
| 371 | 375 | public static function getFormatInfo($mask, $level) |
| 372 | 376 | {
|
| 373 | - if ($mask < 0 || $mask > 7) |
|
| 374 | - return 0; |
|
| 377 | + if ($mask < 0 || $mask > 7) { |
|
| 378 | + return 0; |
|
| 379 | + } |
|
| 375 | 380 | |
| 376 | - if ($level < 0 || $level > 3) |
|
| 377 | - return 0; |
|
| 381 | + if ($level < 0 || $level > 3) { |
|
| 382 | + return 0; |
|
| 383 | + } |
|
| 378 | 384 | |
| 379 | 385 | return self::$formatInfo[$level][$mask]; |
| 380 | 386 | } |
@@ -554,8 +560,9 @@ discard block |
||
| 554 | 560 | //---------------------------------------------------------------------- |
| 555 | 561 | public static function newFrame($version) |
| 556 | 562 | {
|
| 557 | - if ($version < 1 || $version > QRSPEC_VERSION_MAX) |
|
| 558 | - return null; |
|
| 563 | + if ($version < 1 || $version > QRSPEC_VERSION_MAX) { |
|
| 564 | + return null; |
|
| 565 | + } |
|
| 559 | 566 | |
| 560 | 567 | if (!isset(self::$frames[$version])) {
|
| 561 | 568 | |
@@ -573,8 +580,9 @@ discard block |
||
| 573 | 580 | } |
| 574 | 581 | } |
| 575 | 582 | |
| 576 | - if (is_null(self::$frames[$version])) |
|
| 577 | - return null; |
|
| 583 | + if (is_null(self::$frames[$version])) { |
|
| 584 | + return null; |
|
| 585 | + } |
|
| 578 | 586 | |
| 579 | 587 | return self::$frames[$version]; |
| 580 | 588 | } |
@@ -25,17 +25,17 @@ |
||
| 25 | 25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | - define('N1', 3);
|
|
| 29 | - define('N2', 3);
|
|
| 30 | - define('N3', 40);
|
|
| 31 | - define('N4', 10);
|
|
| 28 | + define('N1', 3);
|
|
| 29 | + define('N2', 3);
|
|
| 30 | + define('N3', 40);
|
|
| 31 | + define('N4', 10);
|
|
| 32 | 32 | |
| 33 | - class QRmask {
|
|
| 33 | + class QRmask {
|
|
| 34 | 34 | |
| 35 | - public $runLength = array(); |
|
| 35 | + public $runLength = array(); |
|
| 36 | 36 | |
| 37 | - //---------------------------------------------------------------------- |
|
| 38 | - public function __construct() |
|
| 37 | + //---------------------------------------------------------------------- |
|
| 38 | + public function __construct() |
|
| 39 | 39 | {
|
| 40 | 40 | $this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0); |
| 41 | 41 | } |
@@ -230,8 +230,9 @@ |
||
| 230 | 230 | |
| 231 | 231 | $frameY = $frame[$y]; |
| 232 | 232 | |
| 233 | - if ($y > 0) |
|
| 234 | - $frameYM = $frame[$y - 1]; |
|
| 233 | + if ($y > 0) { |
|
| 234 | + $frameYM = $frame[$y - 1]; |
|
| 235 | + } |
|
| 235 | 236 | |
| 236 | 237 | for ($x = 0; $x < $width; $x++) {
|
| 237 | 238 | if (($x > 0) && ($y > 0)) {
|
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | abstract class FeedItem { |
| 3 | - abstract function get_id(); |
|
| 4 | - abstract function get_date(); |
|
| 5 | - abstract function get_link(); |
|
| 6 | - abstract function get_title(); |
|
| 7 | - abstract function get_description(); |
|
| 8 | - abstract function get_content(); |
|
| 9 | - abstract function get_comments_url(); |
|
| 10 | - abstract function get_comments_count(); |
|
| 11 | - abstract function get_categories(); |
|
| 12 | - abstract function get_enclosures(); |
|
| 13 | - abstract function get_author(); |
|
| 14 | - abstract function get_language(); |
|
| 3 | + abstract function get_id(); |
|
| 4 | + abstract function get_date(); |
|
| 5 | + abstract function get_link(); |
|
| 6 | + abstract function get_title(); |
|
| 7 | + abstract function get_description(); |
|
| 8 | + abstract function get_content(); |
|
| 9 | + abstract function get_comments_url(); |
|
| 10 | + abstract function get_comments_count(); |
|
| 11 | + abstract function get_categories(); |
|
| 12 | + abstract function get_enclosures(); |
|
| 13 | + abstract function get_author(); |
|
| 14 | + abstract function get_language(); |
|
| 15 | 15 | } |
| 16 | 16 | |