• R/O
  • HTTP
  • SSH
  • HTTPS

YANMAH2-season2-: Commit


Commit MetaInfo

Revision325a9fd54ed2f61583430771ad23bac0bc77774e (tree)
Time2016-11-03 17:16:50
AuthorKana Koda <kodakana@user...>
CommiterKana Koda

Log Message

* クエリに指定した文字列が含まれる場合に404にする機能を追加。
* 画像へのリンクはモバイルゲートウェイを通さないようにした(Google Web Light が対応しないため)。
* エラー表示の調整。

Change Summary

Incremental Difference

--- a/.directory
+++ b/.directory
@@ -2,6 +2,9 @@
22 SortOrder=1
33 SortRole=date
44 Sorting=2
5-Timestamp=2014,10,16,21,23,27
5+Timestamp=2016,11,3,16,24,11
66 Version=3
77 ViewMode=1
8+
9+[Settings]
10+HiddenFilesShown=true
--- a/configurable_variables.php
+++ b/configurable_variables.php
@@ -1,6 +1,6 @@
11 <?php
22 //YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
3-//(c) 2014 YANMAH2 project
3+//(c) 2016 YANMAH2 project
44 //This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
55 ?>
66 <?php defined("HELLO") or exit(); ?>
@@ -17,7 +17,7 @@ $entry_limit = 700;
1717 //パスを記入するとそのパスが追加される。
1818 $extra_include_path = "default";
1919 //モバイルゲートウェイの URL
20-$mobile_gateway = "http://www.google.co.jp/gwt/n?u=";
20+$mobile_gateway = "https://googleweblight.com/?lite_url=";
2121 //利用するハイクのホスト(h.hatena.ne.jp|h.hatena.com)
2222 $haiku_host = "h.hatena.ne.jp";
2323 //ハイク公式の URL
@@ -47,6 +47,8 @@ $mobile_gateway_for_images = 'http://mgw.hatena.ne.jp/?';
4747 $style_sheet = './style.php';
4848 //デフォルトの文字コード(UTF-8|SJIS|JIS|EUC-JP)
4949 $charcode = 'UTF-8';
50+//指定した文字列を含むクエリを404にする。
51+$ng_query = array('keyword=id:dmtp21', 'user=dmtp21');
5052 //****************************************************
5153 //各ページに共通のフッタを記入する。
5254 $footer = <<<EOL
--- a/entries.php
+++ b/entries.php
@@ -1,6 +1,6 @@
11 <?php
22 //YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
3-//(c) 2014 YANMAH2 project
3+//(c) 2016 YANMAH2 project
44 //This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
55 ?>
66 <?php
@@ -364,7 +364,7 @@ if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
364364 $echo = $echo . "<p>はてなハイク API からデータを取得できなかったような気がします。</p>\n";
365365 $echo = $echo . "<blockquote>HTTP {$json['http']}<br />";
366366 $echo = $echo . 'XML error '.$contents['ercode'].':'.$contents['ermes'];
367- $echo = $echo . "<br />".strip_tags($json['body'])."</blockquote>\n";
367+ $echo = $echo . "<br /><pre>".strip_tags($json['body'])."</pre></blockquote>\n";
368368 $timeline_putted = FALSE;
369369 } elseif ($contents['stat'] == FALSE && $contents['ercode'] == 'x'){
370370 $echo = $echo . "<p>はてなハイク API からデータを取得できなかったような気がします。</p>\n";
--- a/entry_processor.php
+++ b/entry_processor.php
@@ -1,6 +1,6 @@
11 <?php
22 //YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
3-//(c) 2014 YANMAH2 project
3+//(c) 2016 YANMAH2 project
44 //This program is freesoftware. you can redistribute it and/or modify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
55 ?>
66 <?php defined("HELLO") or exit(); ?>
@@ -190,24 +190,25 @@ if (preg_match("/[0-2][0-9]:[0-9]{2}:[0-9]{2}/u", $val->keyword)){
190190 $entry_body_a = explode("\n", $entry_body);
191191 $entry_body_b = array();
192192 foreach ($entry_body_a as $line){
193- if ($get_image != 'on'){
194- if (preg_match("/<a[^>]*href=\".+(youtube|ugomemo|nicovideo).+\"[^>]*><img/u", $line)){
195- $line = preg_replace("/<img[^>]*alt=\"([^>\"]*)\"[^>]*>/ui", "\${1}", $line);
196-
197- } else {
198- $line = preg_replace("/<img[^>]*src=\"([^>\"]*)\"[^>]*>/uie", "parse_url('\\1', PHP_URL_HOST) . '(' . basename('\\1') . ')';", $line);
199-
200- }
201- }
193+ if ($get_image == 'on'){
202194 if (preg_match("/<a[^>]*href=\".+(youtube|ugomemo|nicovideo).+\"[^>]*><img/u", $line)){
203195 $line = preg_replace("/<a[^>]*href=\"({$http_url_regexp})\"[^>]*>(<img[^>]*src=\")({$http_url_regexp})(\"[^>]*>)/ue", "'<a href=\"\\1\">\\2{$mobile_gateway_for_images}'.rawurlencode(rawurldecode('\\3')).'\\4';", $line);
204196 } elseif (preg_match("/<a[^>]*href=\"({$http_url_regexp})\"[^>]*>(<img[^>]*src=\")({$http_url_regexp})(\"[^>]*>)/u", $line)){
205- $line = preg_replace("/<a[^>]*href=\"(http:{$http_path_regexp})\"[^>]*>(<img[^>]*src=\")({$http_url_regexp})(\"[^>]*>)/ue", "'<a href=\"{$mobile_gateway}'.rawurlencode(rawurldecode('\\3')).'\">\\2{$mobile_gateway_for_images}'.rawurlencode(rawurldecode('\\3')).'\\4';", $line);
197+ $line = preg_replace("/<a[^>]*href=\"(http:{$http_path_regexp})\"[^>]*>(<img[^>]*src=\")({$http_url_regexp})(\"[^>]*>)/ue", "'<a href=\"\\3\">\\2{$mobile_gateway_for_images}'.rawurlencode(rawurldecode('\\3')).'\\4';", $line);
198+ }
206199 }
207200 if (mb_check_encoding(urldecode($line), 'UTF-8')){
208201 $line = preg_replace("/<a[^>]*href=\"(http:{$http_path_regexp})\"[^>]*>([^<]+)<\/a>/ue", "'<a href=\"{$mobile_gateway}'.rawurlencode(rawurldecode('\\1')).'\">'.rawurldecode('\\2').'</a>';", $line);
209202 } else {
210203 }
204+ if ($get_image != 'on'){
205+ if (preg_match("/<a[^>]*href=\".+(youtube|ugomemo|nicovideo).+\"[^>]*><img/u", $line)){
206+ $line = preg_replace("/<img[^>]*alt=\"([^>\"]*)\"[^>]*>/ui", "\${1}", $line);
207+
208+ } else {
209+ $line = preg_replace("/<img[^>]*src=\"([^>\"]*)\"[^>]*>/uie", "parse_url('\\1', PHP_URL_HOST) . '(' . basename('\\1') . ')';", $line);
210+ }
211+ }
211212 $line = mb_ereg_replace('\\\("|\'|\\\)', "\\1", $line);
212213 $entry_body_b[] = $line;
213214 }
--- a/init_processor.php
+++ b/init_processor.php
@@ -1,6 +1,6 @@
11 <?php
22 //YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
3-//(c) 2014 YANMAH2 project
3+//(c) 2016 YANMAH2 project
44 //This program is freesoftware. you can redistribute it and/ormodify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
55 ?>
66 <?php defined("HELLO") or exit(); ?>
@@ -69,6 +69,14 @@ switch ($charcode){
6969 }
7070 ?>
7171 <?php
72+foreach ($ng_query as $ngw){
73+ if (preg_match('/'.preg_quote($ngw, '/').'/u', $_SERVER['QUERY_STRING'])){
74+ header("HTTP/1.0 404 Not Found");
75+ exit();
76+ }
77+}
78+?>
79+<?php
7280 // if (isset($_GET['image']) && isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
7381 // $_SESSION['image'] = $_GET['image'];
7482 // }
--- a/product_definitions.php
+++ b/product_definitions.php
@@ -1,13 +1,13 @@
11 <?php
22 //YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
3-//(c) 2014 YANMAH2 project
3+//(c) 2016 YANMAH2 project
44 //This program is freesoftware. you can redistribute it and/ormodify it under the terms of the [GNU Affero GPL v3](http://www.gnu.org/licenses/agpl.html).
55 ?>
66 <?php defined("HELLO") or exit(); ?>
77 <?php
88 $product_name_abbr = "YANMAH2";
99 $product_name_full = "Yet ANother Mobile Accelerated Hatena-Haiku";
10-$product_version = "season2 2.0b";
10+$product_version = "season2 2.01";
1111 $project_name = "YANMAH2 project";
1212 $project_url = "http://yanmah2.sourceforge.jp/";
1313 $user_agent = $product_name_abbr . '/' . $product_version . ' ' . $_SERVER['SERVER_NAME'];
--- a/style.php
+++ b/style.php
@@ -16,6 +16,8 @@ body {
1616 border-width: 1px;
1717 border-style: solid;
1818 border-color: #888888;
19+ word-break: break-all;
20+
1921 }
2022 blockquote {
2123 color: inherit; background-color: #f6f6f6;
@@ -28,6 +30,9 @@ hr {
2830 address {
2931 font-size: 75%;
3032 }
33+pre {
34+ overflow: scroll;
35+}
3136 #page {
3237 }
3338 #header {
Show on old repository browser