// --------------------------------------------------------------------------- // 環境メッセンジャー 一覧ページ // // 2005. 8.16 Ver.0.1 E.Mizuguchi // // --------------------------------------------------------------------------- include 'start.php'; include 'dao.php'; // 環境変数からから前ページ情報を取得 $area_id = $_REQUEST['id']; $page = $_REQUEST['page']; if($area_id =="" || ctype_digit($area_id) == false || $area_id > 90){ header("HTTP/1.0 404 Not Found"); exit; } // pageが数字かチェック if($page !="" && ctype_digit($page) == false ){ header("HTTP/1.0 404 Not Found"); exit; } // デバック用表示 //echo"
"; //print_r($_REQUEST); //地域情報取得 $areas = area_search($con,$area_id); //環境メッセンジャー件数取得 $count_pref = message_count($con,$area_id); //検索 $max = 20; $offset = $page * $max; $messages = message_search($con,$area_id,$max,$offset); //検索対象とページ数の設定 $msgcount = count($messages); if ($page == "" || $page == 0){ $page = 0; $prevpage = 0; $nextpage = $page +1; }else{ $prevpage = $page - 1; $nextpage = $page + 1; } ?>環境メッセンジャー
echo "".$areas['name'].""; //画像選択 echo ""; echo "
".$areas['name']."の環境メッセンジャーは".$count_pref."名
"; ?>新着情報//コメントの最大値を取得 if(count($messages) < 5){ $maxindex = count($messages) - 1; }else{ $maxindex = 5; } //画面上部の見出しを取得(最大5件) for ($j = 0; $j < $maxindex; $j++){ $user_id = $messages[$j]['user_id']; $regdate = substr($messages[$j]['regdate'],0,19); if($user_id != ""){ $users = users_search($con,$user_id); } echo "
- ".$messages[$j]['title']."(".$areas['name'].")(".$users['name'].")(".$regdate.")
"; } // 0件の場合 if($maxindex == 0){ echo "- この地域にメッセージはありません
\n"; } ?>for($i = 0; $i < (count($messages) - 1); $i++){ $user_id = $messages[$i]['user_id']; $regdate = substr($messages[$i]['regdate'],0,19); if($user_id != ""){ $users = users_search($con,$user_id); $user_count = message_user_count($con,$user_id); } echo " "; echo "
"; } function getsize($photo){ $i_size = GetImageSize($photo); $size_x = $i_size[0]; $size_y = $i_size[1]; if($size_x >= $size_y) { $width = "width=\"180\""; $height = ""; } else { $width = ""; $height = "height=\"180\""; } return "$width $height"; } ?>"; echo " ".$messages[$i]['title']." "; echo " ".$regdate." 投稿者:".$users['name']."(".$user_count.") "; echo " "; if ($messages[$i]['imgpath'] != "" && file_exists($messages[$i]['imgpath'])){ $size = getsize($messages[$i]['imgpath']); echo " "; echo ""; } $comment = $messages[$i]['comment']; $comment = nl2br($comment); $comment = ereg_replace("(https?|ftp|news)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)","\\1\\2", $comment); //半角チェック。半角ばかり75文字以上なら自動改行 if (preg_match("/[^a-zA-Z0-9!\"#$%&'()*+>~|,.]/",$comment) == false){ $comment = wordwrap($comment,70,"\n",1); } echo "
".$comment."
$num = count($messages); // for debug //echo "o $offset: ma $max c: $count_pref nu:$num"; echo ""; ?>