OSDN Git Service

画像省略時のスタイル改善。
[yanmah2/YANMAH2-season2-.git] / entry_processor.php
index 8092b1c..b9dddae 100644 (file)
@@ -18,10 +18,8 @@ if ((isset($entry_processor_mode) && ($entry_processor_mode == 'users' || $entry
        $keyword_title = $val->target->title;
   }
   $echo = $echo . "<a href=\"./entries.php?user={$val->user->id}";
-//   if ($get_image == 'on') $echo = $echo . "&amp;image=on";
   $echo = $echo . "\" class=\"hatena-id\">{$val->user->name} (id:{$val->user->id})</a></dt>\n";
   $echo = $echo . "<dd><a href=\"./entries.php?keyword=".rawurlencode($val->keyword);
-//   if ($get_image == 'on') $echo = $echo . "&amp;image=on";
   $echo = $echo . "\" class=\"keyword\">".htmlspecialchars($keyword_title)."</a></dd>\n";
   $ustock[] = "{$val->user->id}";
 } else {
@@ -29,11 +27,9 @@ if ((isset($entry_processor_mode) && ($entry_processor_mode == 'users' || $entry
   $unix_time = strtotime($val->created_at);
   if (isset($first_e) && $first_e != '') $first_time = $unix_time; unset($first_e);
   $entry_body = $val->html_touch;
-// $entry_body_text = $val->text;
   if ($entries_mode == 'default' || $entries_mode == 'album'){
     foreach ($dict as $dfn) {
 //       var_dump($dfn);
-//       $dkey = preg_quote("{$entry_body}", '/');
       $dmt = preg_grep("/".preg_quote("{$entry_body}", '/')."/u", $dfn);
 //       var_dump($dmt);
       if (isset($dmt["{$val->user->id}"])){ $spam = $spam + 1; return; }
@@ -52,11 +48,6 @@ $entry_body = preg_replace("/(<br>){1,}$/u", "", $entry_body);
 $entry_body = preg_replace("/<br>/u", "<br />", $entry_body);
 $entry_body = preg_replace("/([  ]*<br \/>){3,}/u", "<br /><br />", $entry_body);
 $entry_body = preg_replace("/<br \/>/u", "<br />\n", $entry_body);
-// $entry_body = preg_replace("^[  ]<br \/>\n", "<br \/>\n", $entry_body);
-// var_dump($entry_body);
-// $entry_body = preg_replace("/([^.!?。!?…‥])\n{1}/u", "\${1}", $entry_body);
-// $entry_body = preg_replace("/(、)\n/u", "\${1}", $entry_body);
-// $entry_body = preg_replace("/(<br \/>){1,}$/u", "", $entry_body);
 //改行削減
 if (isset($disbr) && $disbr == 'no'){
 } elseif ($entries_mode == 'friends_timeline' || $entries_mode == 'default' || $entries_mode == 'keyword_timeline'){
@@ -71,7 +62,6 @@ if (isset($disbr) && $disbr == 'no'){
 }
 //
 $entry_body = preg_replace("/(<br \/>)/u", "\n\${1}\n", $entry_body);
-//             var_dump($entry_body_temp);
 $entry_body = preg_replace("/\n+/u", "\n", $entry_body);
 $entry_body = preg_replace("/\n$/u", "", $entry_body);
 if (preg_match("/((<br \/>|\n)*&gt;&gt;(<br \/>|\n))(.+)((<br \/>\n)&lt;&lt;(<br \/>|\n)*)/us", $entry_body)) {
@@ -79,40 +69,28 @@ if (preg_match("/((<br \/>|\n)*&gt;&gt;(<br \/>|\n))(.+)((<br \/>\n)&lt;&lt;(<br
 } else {
   $bquote = "0";
 }
-//$entry_body = $entry_body . "\n";
-//echo htmlspecialchars(var_dump($entry_body));
 //文字数制限
 if ($entry_processor_mode == "entries" && !preg_match('/^(kalen_t|fumobot)$/u', $val->user->id)){
-//   if ($get_image == 'on'){
-//     $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>";
-//   } else {
   $see_more = "<a href=\"./entry.php?entry={$val->id}&amp;user={$val->user->id}&amp;keyword=" . rawurlencode($val->keyword) . "\" class=\"see-more\">(…)</a>";
-//   }
   $plain_body = strip_tags($entry_body);
   $entry_width = mb_strwidth($plain_body);
-//   if ($entries_mode == 'default' && $entry_width < 9){ $spam = $spam + 1; return; }
   if (($entries_mode == 'default'  || $entries_mode == 'album') && 
       preg_match("/(^{$http_url_regexp}$)|(^{$http_path_regexp}$)|(^{$http_url_regexp}.+{$http_url_regexp}$)/us", $plain_body) && 
       !preg_match("/<img[^>]+>/u", $entry_body)){ $spam = $spam + 1;  return; }
   $tranc_width = $entry_limit - ($entry_limit/3);
   if ($entry_width > ($entry_limit)){
        $plain_body = mb_strimwidth($plain_body, 0, $tranc_width, '', "UTF-8");
-//     $entry_body = mb_strimwidth($entry_body, 0, $tranc_width, '', "UTF-8");
-  //           echo "...";
        $text_a = explode("\n", $entry_body);
        $plain_a = explode("\n", $plain_body);
 //     var_dump($text_a);
        $tail = count($plain_a) - 1;
        $text_a[$tail] = $plain_a[$tail];
        $text_a = array_slice($text_a, 0, $tail + 1);
-/*     $text_a[$tail] = strip_tags($text_a[$tail]);
-       $text_a[$tail] = preg_replace("/<.*$/u", "", $text_a[$tail]);*/
        $entry_body = implode("\n", $text_a) . $see_more;
        //var_dump($entry_body_temp);
   }
 }
 //引用記法
-// $entry_body = preg_replace("/(&gt;&gt;\n)(.+)(&lt;&lt;)/us", "<blockquote>\${2}</blockquote>", $entry_body);
 if ($bquote == 1) {
        $entry_body = preg_replace("/(\n|<br \/>)*&gt;&gt;(\n|<br \/>)/us", "<blockquote>", $entry_body);
        $entry_body = preg_replace("/(\n|<br \/>)&lt;&lt;(\n|<br \/>)*/us", "</blockquote>", $entry_body);
@@ -121,36 +99,9 @@ if ($bquote == 1) {
 if (preg_match("/<blockquote>/u", $entry_body) && !preg_match("/<\/blockquote>/u", $entry_body)){
   $entry_body = $entry_body."</blockquote>";
 }
-// $entry_body = preg_replace("/(<blockquote>)(.+)(\n<<)/us", "\${1}\${2}\n</blockquote>", $entry_body);
-//
-// $entry_body = nl2br($entry_body);
-//for りおきゅん
-// if ($val->user->id == 'Rio_Baxxter' && $val->keyword == '地震情報'){
-//   $rio_a = explode("\n", $entry_body);
-//   $rio_b = array();
-//   foreach ($rio_a as $rio){
-//     $gmap = '';
-//     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);
-//     $rio_b[] = $rio.$gmap;
-//   }
-//   $entry_body = implode("\n", $rio_b);
-// }
-//
-// if ($get_image == 'on'){
-// //  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/keyword\/([^\/\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}&amp;image=on\" class=\"keyword\">", $entry_body);
-//   $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);
-// //  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/([^\/\"]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}&amp;image=on\" class=\"user\">", $entry_body);
-//   $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);
-//   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);
-//   $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);
-// } else {
-//  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/keyword\/([^\/\"]+)\" class=\"keyword\">/u", "<a href=\"./entries.php?keyword=\${1}\" class=\"keyword\">", $entry_body);
   $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);
-//  $entry_body = preg_replace("/<a href=\"\/*[^\/]*\/([^\/\"]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}\" class=\"user\">", $entry_body);
   $entry_body = preg_replace("/<a href=\"http:\/\/h[^\.]*\.hatena\.[^\/]+\/touch\/([^\/]+)\/\" class=\"user\">/u", "<a href=\"./entries.php?user=\${1}\" class=\"user\">", $entry_body);
-//   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);
   $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);
-// }
 $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);
 
 if ($get_image != 'on'){
@@ -185,11 +136,7 @@ if (isset($starisjs) && $starisjs == '1'){
        $add_star = '';
 }
 //キーワードの前処理
-/*if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
-  $headend = "</form><br />";
-} else {*/
   $headend = "<br />";
-// }
 if ($entries_mode == 'keyword_timeline'){
   $entry_kw = '';
 } elseif (mb_ereg_match("^{$http_url_regexp}$",htmlspecialchars($val->keyword, ENT_QUOTES))){
@@ -199,9 +146,6 @@ if ($entries_mode == 'keyword_timeline'){
        $entry_kw = "ASIN:%KEYWORD%</span>{$headend}\n";
 } elseif (!isset($val->keyword)){
        $entry_kw = "</span>{$headend}\n";
-/*} elseif (mb_strpos($entry_body, "{$val->keyword}=") !== FALSE) {
-       //var_dump($val["keyword"]);
-       $entry_body = str_replace("{$val->keyword}=","%KEYWORD%</span>{$headend}\n<span class=\"entry-body\">\n",$entry_body);*/
 } elseif (preg_match("/^(id:{1})(.+)/u", $val->keyword) == 0) {
 //     var_dump($entry_body);
        $entry_kw = "%KEYWORD%</span>{$headend}\n";
@@ -217,7 +161,6 @@ if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
 //
 // var_dump($entry_body);
 //公式モバイル版における各エントリへのリンク URL 生成
-//$refer_link = $haiku_official_url . $val->user->id . '/' . $val->id;
 $refer_link = "http://{$haiku_host}/" . $val->user->id . "/" . $val->id;
 //タイムスタンプ
 if (preg_match("/[0-2][0-9]:[0-9]{2}:[0-9]{2}/u", $val->keyword)){
@@ -261,7 +204,6 @@ foreach ($entry_body_a as $line){
   } elseif (preg_match("/<a[^>]*href=\"({$http_url_regexp})\"[^>]*>(<img[^>]*src=\")({$http_url_regexp})(\"[^>]*>)/u", $line)){
        $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);
   }
-//   if (!preg_match("/<a[^>]*href=\"(http:\/\/d\.hatena\.(ne\.jp|com)\/keyword\/{$http_dir_regexp})\"[^>]*>([^<]+)<\/a>/ue", $line)){
   if (mb_check_encoding(urldecode($line), 'UTF-8')){
        $line = preg_replace("/<a[^>]*href=\"(http:{$http_path_regexp})\"[^>]*>([^<]+)<\/a>/ue", "'<a href=\"{$mobile_gateway}'.rawurlencode(rawurldecode('\\1')).'\">'.rawurldecode('\\2').'</a>';", $line);
   } else {
@@ -274,9 +216,9 @@ $entry_body = implode("\n", $entry_body_b);
 // var_dump($entry_body);
 //map 記法の処理
 if ($get_image == 'on'){
-  $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);
+  $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 />", $entry_body);
 } else {
-  $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);
+  $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 />", $entry_body);
 }
 //表示
 $echo = $echo . "<div class=\"entry\"";
@@ -290,8 +232,6 @@ if (isset($_SESSION['auth']) && $_SESSION['auth'] === TRUE){
   } else {
     $echo = $echo . '<form method="post" action="';
     $echo = $echo . './post.php';
-  //   if ($device_who == 'android' && preg_match("/(1\.6)|(1\.5)/", $_SERVER['HTTP_USER_AGENT'])) $echo = $echo . $self_anchor_possibly_with_pagenum;
-  //   if (isset($entry_processor_mode) && $entry_processor_mode != 'entry') $echo = $echo . '&amp;reftime=-'.$first_time . ',0'. '#'.$val->id;
     $echo = $echo . '" class="star-form">';
   }
 }
@@ -307,29 +247,18 @@ if (!isset($val->keyword)){
 if ($entries_mode == 'keyword_timeline'){
   $entry_kw = $add_star . $show_star . '</span>' . $headend . "\n";
 } else {
-// if ($get_image == 'on'){
-//   $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);
-// } else {
   $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);
-// }
 
 //id キーワードの処理
   if (preg_match('/^(id:{1}[a-zA-Z]{1}[-_a-zA-Z1234567890]{1,30}[a-zA-Z1234567890]{1})$/u',$val->keyword) >= 1){
-//   if ($get_image == 'on'){
-//     $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";
-//   } else {
-       $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";
-//   }
+
+  $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";
   }
 }
 //Reply-to
 if ($val->in_reply_to_status_id != ''){
 //     echo "...";
-//   if ($get_image == 'on'){
-//     $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>";
-//   } else {
        $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>";
-//   }
        if (mb_substr_count($entry_body, '<br />') < 1){
                if (preg_match('/\[画像\(.+\)\]/u', $entry_body) || preg_match('/<img[^>]+\/>/u', $entry_body)){
                        $reply_to = $reply_to."<br />\n";
@@ -351,31 +280,27 @@ if (isset($in_reply)){
 if (isset($val->replies[0]->id)){
   $in_reply = '';
        foreach($val->replies as $replies){
-//       if ($get_image == 'on'){
-//             $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> ";
-//       } else {
                $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> ";
-//       }
        }
        $reply_from = "<span class=\"reply-from reply\">{$in_reply}</span>";
 } else {
   $reply_from = '';
 }
 //
-// $entry_body = preg_replace("/(<a[^>]+>)([^<]+)(<\/a>)/ue", "'\\1'.urldecode('\\2').'\\3';", $entry_body);
-// var_dump($entry_body);
 $entry_body = mb_ereg_replace('\\\("|\'|\\\)', "\\1", $entry_body);
 // var_dump($entry_body);
-// $entry_body = $entry_body . "<br />\n";
 $echo = $echo . "{$dating} ";
 $echo = $echo . $entry_kw;
-$echo = $echo . "<p class=\"entry-body\">\n";
+if ($get_image == 'on'){
+  $echo = $echo . "<p class=\"entry-body eb-rich\">";
+} else {
+  $echo = $echo . "<p class=\"entry-body\">";
+}
 $echo = $echo . $entry_body;
 $echo = $echo . "</p>\n";
 $echo = $echo . "<span class=\"dating\">";
 $echo = $echo . "by <a href=\"./entries.php?user=";
 $echo = $echo . $val->user->id;
-//   if ($get_image == 'on') $echo = $echo . "&amp;image=on";
 $echo = $echo . "\" class=\"hatena-id\" title=\"id:{$val->user->screen_name}\">";
 $echo = $echo . htmlspecialchars($val->user->name, ENT_QUOTES);
 $echo = $echo . '</a> ';