OSDN Git Service

8092b1ca14f6298d7f0c57aea152a98749a52786
[yanmah2/YANMAH2-season2-.git] / entry_processor.php
1 <?php
2 //YANMAH2 - Yet ANother Mobile Accelerated HatenaHaiku
3 //(c) 2014 YANMAH2 project
4 //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).
5 ?>
6 <?php defined("HELLO") or exit(); ?>
7 <?php
8 if ((isset($entry_processor_mode) && ($entry_processor_mode == 'users' || $entry_processor_mode == 'keyword_users')) || (isset($entries_mode) && $entries_mode == 'favours')){
9 //   echo "...";
10   if (in_array("{$val->user->id}", $ustock)) return;
11   $echo = $echo . "<dt>";
12   if ($get_image == 'on' || (isset($show_icon) && $show_icon == 'yes')){
13           $echo = $echo . '<img src="' . $val->user->profile_image_url . '" width="16" height="16" class="user-icon" alt="" /> ';
14   }
15   if (preg_match("/^(id:{1})([[:alpha:]]{1}[-_a-zA-Z1234567890]{1,30}[[:alnum:]]{1})$/u", $val->keyword)) {
16         $keyword_title = $val->keyword;
17   } else {
18         $keyword_title = $val->target->title;
19   }
20   $echo = $echo . "<a href=\"./entries.php?user={$val->user->id}";
21 //   if ($get_image == 'on') $echo = $echo . "&amp;image=on";
22   $echo = $echo . "\" class=\"hatena-id\">{$val->user->name} (id:{$val->user->id})</a></dt>\n";
23   $echo = $echo . "<dd><a href=\"./entries.php?keyword=".rawurlencode($val->keyword);
24 //   if ($get_image == 'on') $echo = $echo . "&amp;image=on";
25   $echo = $echo . "\" class=\"keyword\">".htmlspecialchars($keyword_title)."</a></dd>\n";
26   $ustock[] = "{$val->user->id}";
27 } else {
28 //タイムスタンプ-0
29   $unix_time = strtotime($val->created_at);
30   if (isset($first_e) && $first_e != '') $first_time = $unix_time; unset($first_e);
31   $entry_body = $val->html_touch;
32 // $entry_body_text = $val->text;
33   if ($entries_mode == 'default' || $entries_mode == 'album'){
34     foreach ($dict as $dfn) {
35 //       var_dump($dfn);
36 //       $dkey = preg_quote("{$entry_body}", '/');
37       $dmt = preg_grep("/".preg_quote("{$entry_body}", '/')."/u", $dfn);
38 //       var_dump($dmt);
39       if (isset($dmt["{$val->user->id}"])){ $spam = $spam + 1; return; }
40     }
41     $dict[] = array("{$val->user->id}" => "{$entry_body}");
42   }
43   if (($entries_mode == 'default'  || $entries_mode == 'album') && 
44       preg_match("/(^{$http_url_regexp}$)/u", "{$val->keyword}")){ $spam = $spam + 1;  return; }
45   if (preg_match("/^(id:{1})([[:alpha:]]{1}[-_a-zA-Z1234567890]{1,30}[[:alnum:]]{1})$/u", $val->keyword)) {
46         $keyword_title = $val->keyword;
47   } else {
48         $keyword_title = $val->target->title;
49   }
50 $entry_body = preg_replace("/^([  ]*<br>){1,}/u", "", $entry_body);
51 $entry_body = preg_replace("/(<br>){1,}$/u", "", $entry_body);
52 $entry_body = preg_replace("/<br>/u", "<br />", $entry_body);
53 $entry_body = preg_replace("/([  ]*<br \/>){3,}/u", "<br /><br />", $entry_body);
54 $entry_body = preg_replace("/<br \/>/u", "<br />\n", $entry_body);
55 // $entry_body = preg_replace("^[  ]<br \/>\n", "<br \/>\n", $entry_body);
56 // var_dump($entry_body);
57 // $entry_body = preg_replace("/([^.!?。!?…‥])\n{1}/u", "\${1}", $entry_body);
58 // $entry_body = preg_replace("/(、)\n/u", "\${1}", $entry_body);
59 // $entry_body = preg_replace("/(<br \/>){1,}$/u", "", $entry_body);
60 //改行削減
61 if (isset($disbr) && $disbr == 'no'){
62 } elseif ($entries_mode == 'friends_timeline' || $entries_mode == 'default' || $entries_mode == 'keyword_timeline'){
63   $list_mark = "-1234567890一二三四五六七八九〇1234567890・*○●◎△▲▽▼□■◇◆×>#;#;";
64   $entry_body = preg_replace("/([  ]*<br \/>){2,}/u", "<br />", $entry_body);
65   $entry_body = preg_replace("/(^[{$list_mark}]{1,}.+|^&gt;.+)(<br \/>)/um", " \${1}\${2}<br />", $entry_body);
66   $entry_body = preg_replace("/<br \/>\n/u", "<br />", $entry_body);
67   $entry_body = preg_replace("/([^><」」』】\]]。.  ]{1})<br \/>([^{$list_mark}  ><「「『【\[[]{1})/u", "\${1} \${2}", $entry_body);
68 //   var_dump($entry_body);
69   $entry_body = preg_replace("/([,、]{1})[ ]{1}/u", "\${1}", $entry_body);
70   $entry_body = preg_replace("/([  ]*<br \/>){2,}/u", "<br />", $entry_body);
71 }
72 //
73 $entry_body = preg_replace("/(<br \/>)/u", "\n\${1}\n", $entry_body);
74 //              var_dump($entry_body_temp);
75 $entry_body = preg_replace("/\n+/u", "\n", $entry_body);
76 $entry_body = preg_replace("/\n$/u", "", $entry_body);
77 if (preg_match("/((<br \/>|\n)*&gt;&gt;(<br \/>|\n))(.+)((<br \/>\n)&lt;&lt;(<br \/>|\n)*)/us", $entry_body)) {
78   $bquote = "1";
79 } else {
80   $bquote = "0";
81 }
82 //$entry_body = $entry_body . "\n";
83 //echo htmlspecialchars(var_dump($entry_body));
84 //文字数制限
85 if ($entry_processor_mode == "entries" && !preg_match('/^(kalen_t|fumobot)$/u', $val->user->id)){
86 //   if ($get_image == 'on'){
87 //      $see_more = "<a href=\"./entry.php?entry={$val->id}&amp;user={$val->user->id}&amp;keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"see-more\">(…)</a>";
88 //   } else {
89   $see_more = "<a href=\"./entry.php?entry={$val->id}&amp;user={$val->user->id}&amp;keyword=" . rawurlencode($val->keyword) . "\" class=\"see-more\">(…)</a>";
90 //   }
91   $plain_body = strip_tags($entry_body);
92   $entry_width = mb_strwidth($plain_body);
93 //   if ($entries_mode == 'default' && $entry_width < 9){ $spam = $spam + 1; return; }
94   if (($entries_mode == 'default'  || $entries_mode == 'album') && 
95       preg_match("/(^{$http_url_regexp}$)|(^{$http_path_regexp}$)|(^{$http_url_regexp}.+{$http_url_regexp}$)/us", $plain_body) && 
96       !preg_match("/<img[^>]+>/u", $entry_body)){ $spam = $spam + 1;  return; }
97   $tranc_width = $entry_limit - ($entry_limit/3);
98   if ($entry_width > ($entry_limit)){
99         $plain_body = mb_strimwidth($plain_body, 0, $tranc_width, '', "UTF-8");
100 //      $entry_body = mb_strimwidth($entry_body, 0, $tranc_width, '', "UTF-8");
101   //            echo "...";
102         $text_a = explode("\n", $entry_body);
103         $plain_a = explode("\n", $plain_body);
104 //      var_dump($text_a);
105         $tail = count($plain_a) - 1;
106         $text_a[$tail] = $plain_a[$tail];
107         $text_a = array_slice($text_a, 0, $tail + 1);
108 /*      $text_a[$tail] = strip_tags($text_a[$tail]);
109         $text_a[$tail] = preg_replace("/<.*$/u", "", $text_a[$tail]);*/
110         $entry_body = implode("\n", $text_a) . $see_more;
111         //var_dump($entry_body_temp);
112   }
113 }
114 //引用記法
115 // $entry_body = preg_replace("/(&gt;&gt;\n)(.+)(&lt;&lt;)/us", "<blockquote>\${2}</blockquote>", $entry_body);
116 if ($bquote == 1) {
117         $entry_body = preg_replace("/(\n|<br \/>)*&gt;&gt;(\n|<br \/>)/us", "<blockquote>", $entry_body);
118         $entry_body = preg_replace("/(\n|<br \/>)&lt;&lt;(\n|<br \/>)*/us", "</blockquote>", $entry_body);
119         $entry_body = preg_replace("/(<blockquote>|<\/blockquote>)<br \/>/u", "\${1}", $entry_body);
120 }
121 if (preg_match("/<blockquote>/u", $entry_body) && !preg_match("/<\/blockquote>/u", $entry_body)){
122   $entry_body = $entry_body."</blockquote>";
123 }
124 // $entry_body = preg_replace("/(<blockquote>)(.+)(\n<<)/us", "\${1}\${2}\n</blockquote>", $entry_body);
125 //
126 // $entry_body = nl2br($entry_body);
127 //for りおきゅん
128 // if ($val->user->id == 'Rio_Baxxter' && $val->keyword == '地震情報'){
129 //   $rio_a = explode("\n", $entry_body);
130 //   $rio_b = array();
131 //   foreach ($rio_a as $rio){
132 //      $gmap = '';
133 //      if (preg_match("/(http:\/\/maps\.google\.co\.*[^\/]+\/){$http_path_regexp}+/", $rio)) $gmap = mb_ereg_replace("(.*)(<a href=\")(http:\/\/maps\.google\.co\.*[^\/]+\/)({$http_path_regexp}*)(q=)(-*[[:digit:]]{1,3}\.[[:digit:]]+)(,)(-*[[:digit:]]{1,3}\.[[:digit:]]+)({$http_path_regexp}*)(\">)([^<]*)(<\/a>)(.*)", "<br />\nmap:\\6:\\8", $rio);
134 //      $rio_b[] = $rio.$gmap;
135 //   }
136 //   $entry_body = implode("\n", $rio_b);
137 // }
138 //
139 // if ($get_image == 'on'){
140 // //  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/keyword\/([^\/\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}&amp;image=on\" class=\"keyword\">", $entry_body);
141 //   $entry_body = preg_replace("/<a href=\"http:\/\/h[^\.]*\.hatena\.[^\/]+\/touch\/target\?word=([^\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}&amp;image=on\" class=\"keyword\">", $entry_body);
142 // //  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/([^\/\"]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}&amp;image=on\" class=\"user\">", $entry_body);
143 //   $entry_body = preg_replace("/<a href=\"http:\/\/h[^\.]*\.hatena\.[^\/]+\/touch\/([^\/]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}&amp;image=on\" class=\"user\">", $entry_body);
144 //   if ($val->user->id == 'fumobot') $entry_body = preg_replace("/<a[^>]*href=\"(http:\/\/h[[:alnum:]]*\.hatena\.[^\/]+\/*)\/keyword\/([^\"]+)\"[^>]*>/u", "<a href=\"./entries.php?keyword=\${2}&amp;image=on\" class=\"keyword\">", $entry_body);
145 //   $entry_body = preg_replace("/<a[^>]*href=\"(http:\/\/h[[:alnum:]]*\.hatena\.[^\/]+\/*)\/touch\/asin\/([[:alnum:]]+)\"[^>]*>/u", "<a href=\"./entries.php?keyword=asin%3A\${2}&amp;image=on\" class=\"keyword\">", $entry_body);
146 // } else {
147 //  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/keyword\/([^\/\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}\" class=\"keyword\">", $entry_body);
148   $entry_body = preg_replace("/<a href=\"http:\/\/h[^\.]*\.hatena\.[^\/]+\/touch\/target\?word=([^\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}\" class=\"keyword\">", $entry_body);
149 //  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/([^\/\"]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}\" class=\"user\">", $entry_body);
150   $entry_body = preg_replace("/<a href=\"http:\/\/h[^\.]*\.hatena\.[^\/]+\/touch\/([^\/]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}\" class=\"user\">", $entry_body);
151 //   if ($val->user->id == 'fumobot')$entry_body = preg_replace("/<a[^>]*href=\"(http:\/\/h[[:alnum:]]*\.hatena\.[^\/]+\/*)\/keyword\/([^\"]+)\"[^>]*>/u", "<a href=\"./entries.php?keyword=\${2}\" class=\"keyword\">", $entry_body);
152   $entry_body = preg_replace("/<a[^>]*href=\"(http:\/\/h[[:alnum:]]*\.hatena\.[^\/]+\/*)\/touch\/asin\/([[:alnum:]]+)\"[^>]*>/u", "<a href=\"./entries.php?keyword=asin%3A\${2}\" class=\"keyword\">", $entry_body);
153 // }
154 $entry_body = preg_replace("/<div class=\"*user-map\"*><a[^>]*><img[^>]*alt=\"((map):(-*[[:digit:]]{1,3}\.*[[:digit:]]*):(-*[[:digit:]]{1,3}\.*[[:digit:]]*))\"[^>]*><\/a><\/div>/u", "\${1}", $entry_body);
155
156 if ($get_image != 'on'){
157   $entry_body = preg_replace("/<a[^>]*><img[^>]*class=\"*(profile-image|favicon)\"*[^>]*><\/a>/u", "", $entry_body);
158   $entry_body = preg_replace("/<div[^>]*><iframe[^>]*src=\"http:\/\/www\.youtube\.com\/embed\/([^\"]+)\"[^>]*><\/iframe><\/div>/u", "<a href=\"http://m.youtube.com/watch?v=\${1}\">YouTube(\${1})</a>", $entry_body);
159 } else {
160   if ($device_who == 'ktai' || $device_who == 'android-old'){
161         $entry_body = preg_replace("/<div[^>]*><iframe[^>]*src=\"http:\/\/www\.youtube\.com\/embed\/([^\"]+)\"[^>]*><\/iframe><\/div>/u", "<a href=\"http://m.youtube.com/watch?v=\${1}\"><img src=\"http://img.youtube.com/vi/\${1}/0.jpg\" alt=\"\" /></a>", $entry_body);
162   } else {
163         $entry_body = preg_replace("/<div[^>]*>(<iframe[^>]*src=\"http:\/\/www\.youtube\.com\/embed\/([^\"]+)\"[^>]*><\/iframe>)<\/div>/u", "\${1}", $entry_body);
164   }
165 }
166 //はてなスター
167 if ($val->favorited != "0"){
168 if (isset($starisjs) && $starisjs == '1'){
169   $show_star = '';
170 } else {
171         $show_star = "<span class=\"hatena-star\"><a href=\"http://s.hatena.ne.jp/mobile/entry?uri=" . rawurlencode("http://h.hatena.ne.jp/{$val->user->id}/{$val->id}") . "\">★{$val->favorited}</a></span>";
172 }
173 } else {
174         $show_star = "";
175         }
176 if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
177 if (isset($starisjs) && $starisjs == '1'){
178   $add_star = '';
179 } else {
180         $add_star = '<input type="submit" value="☆+" title="add-star" class="add-star-button" style="vertical-align: middle;"><input type="hidden" name="posting" value="favo" /><input type="hidden" name="entry" value="' . $val->id . '" /><input type="hidden" name="return" value="' . htmlspecialchars($self_anchor_possibly_with_pagenum, ENT_QUOTES);
181         if (isset($entry_processor_mode) && $entry_processor_mode != 'entry') $add_star = $add_star . '&amp;reftime=-'.$first_time . ',0'. '#'.$val->id;
182         $add_star = $add_star . '" /> ';
183 }
184 }       else {
185         $add_star = '';
186 }
187 //キーワードの前処理
188 /*if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
189   $headend = "</form><br />";
190 } else {*/
191   $headend = "<br />";
192 // }
193 if ($entries_mode == 'keyword_timeline'){
194   $entry_kw = '';
195 } elseif (mb_ereg_match("^{$http_url_regexp}$",htmlspecialchars($val->keyword, ENT_QUOTES))){
196         $entry_kw = "URL:%KEYWORD%</span>{$headend}\n";
197 //      var_dump($entry_body);
198 } elseif (preg_match("/^asin:[[:alnum:]]+$/u", $val->keyword)){
199         $entry_kw = "ASIN:%KEYWORD%</span>{$headend}\n";
200 } elseif (!isset($val->keyword)){
201         $entry_kw = "</span>{$headend}\n";
202 /*} elseif (mb_strpos($entry_body, "{$val->keyword}=") !== FALSE) {
203         //var_dump($val["keyword"]);
204         $entry_body = str_replace("{$val->keyword}=","%KEYWORD%</span>{$headend}\n<span class=\"entry-body\">\n",$entry_body);*/
205 } elseif (preg_match("/^(id:{1})(.+)/u", $val->keyword) == 0) {
206 //      var_dump($entry_body);
207         $entry_kw = "%KEYWORD%</span>{$headend}\n";
208 } else {
209         $entry_kw = "%KEYWORD%</span>{$headend}\n";
210 }
211 //var_dump($entry_body);
212 if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
213         $replying = '<a href="./entry.php?entry=' . $val->id . '&amp;user=' . $val->user->id . '&amp;keyword=' . rawurlencode($val->keyword) . '" class="replying">Re</a> ';
214 } else {
215   $replying = '';
216 }
217 //
218 // var_dump($entry_body);
219 //公式モバイル版における各エントリへのリンク URL 生成
220 //$refer_link = $haiku_official_url . $val->user->id . '/' . $val->id;
221 $refer_link = "http://{$haiku_host}/" . $val->user->id . "/" . $val->id;
222 //タイムスタンプ
223 if (preg_match("/[0-2][0-9]:[0-9]{2}:[0-9]{2}/u", $val->keyword)){
224   $dating = date("Y-m-d H:i:s", $unix_time);
225 } else {
226   $day = date("Ymd", $unix_time);
227   $time = date("H:i", $unix_time);
228   $year = date("Y", $unix_time);
229   $today = date("Ymd");
230   $tyear = date("Y");
231   if ($year < $tyear){
232         $dating = date("Y-m-d", $unix_time).' '.$time;
233   } elseif ($day == $today){
234         $dating = ''.$time;
235   } elseif ($day == $today-1){
236         $dating = '昨日 '.$time;
237   } elseif ($day == $today-2){
238         $dating = '一昨日 '.$time;
239   } elseif ($day <= $today-3 && $day >= $today-6){
240         $wdaynum = getdate($unix_time);
241         $wdaylabel = array('日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日');
242         $dating = $wdaylabel[$wdaynum['wday']].' '.$time;
243   } else {
244         $dating = date("Y-m-d", $unix_time).' '.$time;
245   }
246 }
247 $entry_body_a = explode("\n", $entry_body);
248 $entry_body_b = array();
249 foreach ($entry_body_a as $line){
250   if ($get_image != 'on'){
251         if (preg_match("/<a[^>]*href=\".+(youtube|ugomemo|nicovideo).+\"[^>]*><img/u", $line)){
252           $line = preg_replace("/<img[^>]*alt=\"([^>\"]*)\"[^>]*>/ui", "\${1}", $line);
253           
254         } else {
255           $line = preg_replace("/<img[^>]*src=\"([^>\"]*)\"[^>]*>/uie", "parse_url('\\1', PHP_URL_HOST) . '(' . basename('\\1') . ')';", $line);
256           
257         }
258   }
259   if (preg_match("/<a[^>]*href=\".+(youtube|ugomemo|nicovideo).+\"[^>]*><img/u", $line)){
260         $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);
261   } elseif (preg_match("/<a[^>]*href=\"({$http_url_regexp})\"[^>]*>(<img[^>]*src=\")({$http_url_regexp})(\"[^>]*>)/u", $line)){
262         $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);
263   }
264 //   if (!preg_match("/<a[^>]*href=\"(http:\/\/d\.hatena\.(ne\.jp|com)\/keyword\/{$http_dir_regexp})\"[^>]*>([^<]+)<\/a>/ue", $line)){
265   if (mb_check_encoding(urldecode($line), 'UTF-8')){
266         $line = preg_replace("/<a[^>]*href=\"(http:{$http_path_regexp})\"[^>]*>([^<]+)<\/a>/ue", "'<a href=\"{$mobile_gateway}'.rawurlencode(rawurldecode('\\1')).'\">'.rawurldecode('\\2').'</a>';", $line);
267   } else {
268   }
269   $line = mb_ereg_replace('\\\("|\'|\\\)', "\\1", $line);
270   $entry_body_b[] = $line;
271 }
272 $entry_body = implode("\n", $entry_body_b);
273
274 // var_dump($entry_body);
275 //map 記法の処理
276 if ($get_image == 'on'){
277   $entry_body = preg_replace("/(map):(-*[[:digit:]]{1,3}\.*[[:digit:]]*):(-*[[:digit:]]{1,3}\.*[[:digit:]]*)/u", "<a href=\"http://www.google.co.jp/m/local?site=local&amp;q=\${2}%2C\${3}\" class=\"to-map\"><img src=\"http://maps.google.com/maps/api/staticmap?maptype=mobile&amp;markers=\${2}%2C\${3}&amp;sensor=false&amp;size=140x140&amp;zoom=13\" width=\"140\" height=\"140\" /></a><br />[ココ]<a href=\"http://c.hatena.ne.jp/s/nearby?lat=\${2}&amp;lon=\${3}\" class=\"to-coco\">この地点の近くのスポット</a>", $entry_body);
278 } else {
279   $entry_body = preg_replace("/(map):(-*[[:digit:]]{1,3}\.*[[:digit:]]*):(-*[[:digit:]]{1,3}\.*[[:digit:]]*)/u", "<a href=\"http://www.google.co.jp/m/local?site=local&amp;q=\${2}%2C\${3}\" class=\"to-map\">\${1}:\${2}:\${3}</a><br />[ココ]<a href=\"http://c.hatena.ne.jp/s/nearby?lat=\${2}&amp;lon=\${3}\" class=\"to-coco\">この地点の近くのスポット</a>", $entry_body);
280 }
281 //表示
282 $echo = $echo . "<div class=\"entry\"";
283 if (!isset($eprocessor_sub_mode) || $eprocessor_sub_mode != 'presult'){
284   $echo = $echo . " id=\"{$val->id}\"";
285 }
286 $echo = $echo . ">";
287
288 if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
289   if (isset($starisjs) && $starisjs == '1'){
290   } else {
291     $echo = $echo . '<form method="post" action="';
292     $echo = $echo . './post.php';
293   //   if ($device_who == 'android' && preg_match("/(1\.6)|(1\.5)/", $_SERVER['HTTP_USER_AGENT'])) $echo = $echo . $self_anchor_possibly_with_pagenum;
294   //    if (isset($entry_processor_mode) && $entry_processor_mode != 'entry') $echo = $echo . '&amp;reftime=-'.$first_time . ',0'. '#'.$val->id;
295     $echo = $echo . '" class="star-form">';
296   }
297 }
298 $echo = $echo . "<span class=\"entry-head\">";
299 if ($get_image == 'on' || (isset($show_icon) && $show_icon == 'yes')){
300         $echo = $echo . '<img src="' . $val->user->profile_image_url . '" width="16" height="16" class="user-icon" alt="" /> ';
301 }
302
303 //キーワードの処理
304 if (!isset($val->keyword)){
305         $entry_body = ' ' . $add_star . $show_star . $entry_body;
306 }
307 if ($entries_mode == 'keyword_timeline'){
308   $entry_kw = $add_star . $show_star . '</span>' . $headend . "\n";
309 } else {
310 // if ($get_image == 'on'){
311 //   $entry_kw = str_replace("%KEYWORD%","<a href=\"./entries.php?keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"keyword\">". htmlspecialchars($val->target->title, ENT_QUOTES) . "</a> {$add_star}{$show_star}",$entry_kw);
312 // } else {
313   $entry_kw = str_replace("%KEYWORD%","<a href=\"./entries.php?keyword=" . rawurlencode($val->keyword) . "\" class=\"keyword\">". htmlspecialchars($val->target->title, ENT_QUOTES) . "</a> {$add_star}{$show_star}",$entry_kw);
314 // }
315
316 //id キーワードの処理
317   if (preg_match('/^(id:{1}[a-zA-Z]{1}[-_a-zA-Z1234567890]{1,30}[a-zA-Z1234567890]{1})$/u',$val->keyword) >= 1){
318 //   if ($get_image == 'on'){
319 //      $entry_kw = "<a href=\"./entries.php?keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"keyword\">" . htmlspecialchars($val->target->word, ENT_QUOTES) . "</a> {$add_star}{$show_star}</span>{$headend}\n";
320 //   } else {
321         $entry_kw = "<a href=\"./entries.php?keyword=" . rawurlencode($val->keyword) . "\" class=\"keyword\">" . htmlspecialchars($val->target->word, ENT_QUOTES) . "</a> {$add_star}{$show_star}</span>{$headend}\n";
322 //   }
323   }
324 }
325 //Reply-to
326 if ($val->in_reply_to_status_id != ''){
327 //      echo "...";
328 //   if ($get_image == 'on'){
329 //      $reply_to = "<span class=\"reply-to reply\"><a href=\"./entry.php?entry={$val->in_reply_to_status_id}&amp;user={$val->in_reply_to_user_id}&amp;keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"hatena-id\">[← " . $val->in_reply_to_user_id . " へ</a></span>";
330 //   } else {
331         $reply_to = "<span class=\"reply-to reply\"><a href=\"./entry.php?entry={$val->in_reply_to_status_id}&amp;user={$val->in_reply_to_user_id}&amp;keyword=" . rawurlencode($val->keyword) . "\" class=\"hatena-id\">[← " . $val->in_reply_to_user_id . " へ</a></span>";
332 //   }
333         if (mb_substr_count($entry_body, '<br />') < 1){
334                 if (preg_match('/\[画像\(.+\)\]/u', $entry_body) || preg_match('/<img[^>]+\/>/u', $entry_body)){
335                         $reply_to = $reply_to."<br />\n";
336                 } else {
337                         $reply_to = $reply_to.' ';
338                 }
339         } else {
340                 $reply_to = $reply_to."<br />\n";
341         }
342         $entry_body = $reply_to.$entry_body;
343 }
344 //Reply-from
345 if (isset($reply_from)){
346         unset($reply_from);
347 }
348 if (isset($in_reply)){
349         unset($in_reply);
350 }
351 if (isset($val->replies[0]->id)){
352   $in_reply = '';
353         foreach($val->replies as $replies){
354 //        if ($get_image == 'on'){
355 //              $in_reply = $in_reply . " <a href=\"./entry.php?entry={$replies->id}&user={$replies->user->id}&amp;keyword=" . rawurlencode($val->keyword) . "&amp;image=on\" class=\"hatena-id\">[← {$replies->user->id} から</a> ";
356 //        } else {
357                 $in_reply = $in_reply . " <a href=\"./entry.php?entry={$replies->id}&user={$replies->user->id}&amp;keyword=" . rawurlencode($val->keyword) . "\" class=\"hatena-id\">[← {$replies->user->id} から</a> ";
358 //        }
359         }
360         $reply_from = "<span class=\"reply-from reply\">{$in_reply}</span>";
361 } else {
362   $reply_from = '';
363 }
364 //
365 // $entry_body = preg_replace("/(<a[^>]+>)([^<]+)(<\/a>)/ue", "'\\1'.urldecode('\\2').'\\3';", $entry_body);
366 // var_dump($entry_body);
367 $entry_body = mb_ereg_replace('\\\("|\'|\\\)', "\\1", $entry_body);
368 // var_dump($entry_body);
369 // $entry_body = $entry_body . "<br />\n";
370 $echo = $echo . "{$dating} ";
371 $echo = $echo . $entry_kw;
372 $echo = $echo . "<p class=\"entry-body\">\n";
373 $echo = $echo . $entry_body;
374 $echo = $echo . "</p>\n";
375 $echo = $echo . "<span class=\"dating\">";
376 $echo = $echo . "by <a href=\"./entries.php?user=";
377 $echo = $echo . $val->user->id;
378 //   if ($get_image == 'on') $echo = $echo . "&amp;image=on";
379 $echo = $echo . "\" class=\"hatena-id\" title=\"id:{$val->user->screen_name}\">";
380 $echo = $echo . htmlspecialchars($val->user->name, ENT_QUOTES);
381 $echo = $echo . '</a> ';
382 $echo = $echo . ' ';
383 if ($entry_processor_mode == 'entry'){
384   $echo = $echo . 'from ' . $val->source . ' ';
385 }
386 $echo = $echo . "{$replying}{$reply_from} <a href=\"{$refer_link}\" class=\"to-original-link\">&nbsp;†&nbsp;</a>";
387 $echo = $echo . '</span>';
388 if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
389 if (isset($starisjs) && $starisjs == '1'){
390 } else {
391   $echo  = $echo . "</form>";
392 }
393
394 $echo = $echo . "</div><hr />\n";
395 }
396 ?>