「掲示板」の編集履歴(バックアップ)一覧はこちら

掲示板」(2005/12/14 (水) 12:18:05) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

<?php if (phpversion() >= "4.1.0") { extract($_GET); extract($_POST); extract($_SERVER); extract($_COOKIE); } //■基本設定 $masterpass = "0000"; //管理パスワード $bbstitle = "BBS"; //掲示板タイトル $homeurl = 'http://www7.atwiki.jp/chacha/pages/35.html'; //戻る先URL $stylesheet = 'style.css'; //CSSファイル指定 $my_url = $_SERVER{'PHP_SELF'}; $logfile = 'log.txt'; //ログファイル名 $default_num = 10; //ログ表示数 $reslimit = 7; //返信できる最大数 $new_sort =1; //新しく書き込みされたスレッドを一番上に表示なら1しないなら0 $new_mark = '<img src="./image/pen.gif">'; //↑の表示文字 $new_time = 24; //Newがつく時間 //クッキー名 $cookie_name = "noblogbbs_c"; //■文字数 $name_max = 30; //名前文字数(全角) $title_max = 50; //タイトル文字数(全角) $com_max =2000; //メッセージ文字数(全角) $pass_max = 8; //パスワード文字数(半角) //■文字色 $colorvalue = array('#000000'=>'黒','blue'=>'青','green'=>'緑','yellow'=>'黄','white'=>'白','pink'=>'桃'); // 選択クラス名を定義(クラス名=>選択時表示名 $collen = 6; //折り返しの数 //================================================// //■メイン // //================================================// $dp = new Display(); $rg = new Regist(); $sr = new Search(); $pl = new Pastlog(); if($_SERVER['REQUEST_METHOD'] == "GET"){ $_POST['mode'] = &$_GET['mode']; } if($_POST['mode'] =="write" || $_POST['mode'] =="reswrite"){ $rg->set_cookie(); } $dp->header_html();//ヘッダー $dp->menu_bar();//メニューバー switch($_POST['mode']): case 'write-h': // 書き込みフォーム $rg->write_html("write"); break; case 'write': // 書き込み処理 $rg->write_main(); break; case 'reswrite': // レス処理 $rg->reswrite_main(); break; case 'correction-h': //記事修正画面 $rg->write_html("correction"); break; case 'correction': //記事修正処理 $rg->correction_main(); break; case 'serach-h': // 検索表示 $sr->serach_html(); break; case 'serach': // 検索表示 $sr->serach(); break; case 'delete': // 削除処理 $rg->delete(); break; case 'past': // 過去ログ $pl->past_html(); break; case 'th_view': // スレッド表示 $dp->thread_view(); break; default: $dp->view();// 一覧表示 break; endswitch; $dp->footer_html();//フッター exit(); //================================================// //■書き込み部 // //◇write_html() 新規投稿画面 //◇write() 書き込み処理 //◇write_check 文字チェック // //================================================// class Regist{ //================================================// //□投稿画面 //================================================// function write_html($mode,$sid="",$error ="",$r_name="",$r_mail="",$r_url="",$r_title="",$r_com=""){ global $cookie_name,$colorvalue,$collen,$name_max,$title_max,$com_max,$pass_max; //クッキーがあるか調べる if (isset($_COOKIE["$cookie_name"])) { $cookie = $_COOKIE["$cookie_name"]; } //クッキー list($c_name,$c_mail,$c_url,$c_col,$c_pass) = split("<>", $cookie); //入力ミスで戻ってきたのじゃなければクッキー if($r_name == ""){ $r_name = $c_name; } if($r_mail == ""){ $r_mail = $c_mail; } if($r_url == ""){ $r_url = $c_url; } $r_col = $c_col; if($mode =="write" ){ $titlcom ="<h3>新規スレッド作成フォーム</h3>"; $modeflg ="<span class=\"error\">*</span>"; }elseif($mode =="correction"){ //受け取り $sid =$_GET['id']; //記事データ読み込み $line = $this->get_line($sid); //配列を文字列に list($r_snum,$r_num ,$o_title, $r_time, $o_name, $o_mail, $o_url, $o_com,$o_col,,,, $r_que,) =split("<>", $line); echo"$sid"; $r_title = $o_title; $r_mail = $o_mail; $r_col = $o_col; $r_url = $o_url; if($r_com ==""){ $o_com = str_replace("<br/>", "\r\n", $o_com); //Win系は\r\n $r_com = $o_com; } $titlcom ="<h3>スレッド修正フォーム</h3>"; $modeflg ="<span class=\"error\">*</span>"; $conflg ="<br/><span class=\"error\">パスワードは新規作成した際のパスワードをいれてください。</span>"; $ques ="<tr> <td><b>解決済み?:</b></td> <td><select name=\"question\"> <option value=\"0\" selected>質問</option> <option value=\"1\">解決!</option> </select> </td> </tr> "; }else{ $titlcom ="<h3>返信フォーム</h3>"; $modeflg =""; } //フォントカラー準備 //初期化 $select = array(""); //フォントカラー表示 $i=0; foreach($colorvalue as $key => $value) { //初期値決定 if($r_col == $key){ $checked="checked"; }else{ $checked=""; //クッキーがない場合 if($r_col==""){ $checked = "checked"; //ダミー書き込み $r_col ="true"; } } //折り返し if($i==$collen){ $i=0; array_push($select,"<br/>"); } //格納 array_push($select,"<input type=radio name=color value=\"$key\"$checked>$value"); $i++; } echo <<<EOM <div align="center" > <table class="write-h-table"> <tr> <td>{$titlcom} <span class="error">$error</span> $conflg </td> </tr> </table> <form action="$PHP_SELF" method="post"> <input type=hidden name="mode" value="$mode"> <input type=hidden name="sid" value="$sid"> <table class ="write-table"> <tr> <td><span class="error">*</span><b>名前:</b></td> <td><input type=text name=name size=40 value="$r_name" title ="全角{$name_max}文字以内"></td> </tr><tr> <td><b>E-mail:</b></td> <td><input type=text name=mail size=40 value="$r_mail"></td> </tr> EOM; //スレッド作成の場合はタイトル入力 if($mode =="write"|| $mode =="correction"){ echo"<tr> <td><span class=\"error\">*</span><b>タイトル:</b></td\> <td><input type=text name=title size=40 value=\"$r_title\" title =\"全角{$title_max}文字以内\"></td> </tr>"; } echo <<<EOM <tr> <td><span class="error">*</span><b>メッセージ:</b></td> <td><textarea rows="7" name="comment" cols="35" "title=全角{$com_max}文字以内">$r_com</textarea></td> </tr><tr> <td><b>URL:</b></td> <td><input type=text name=url size=50 value="http://$r_url"></td> </tr><tr> <td><b>フォントカラー:</b></td> <td> EOM; //配列を文字列で表示(implode) echo implode("\n",$select); echo <<<EOM </td> </tr><tr> <td>{$modeflg}<b>パスワード:</b></td> <td><input type="password" name=pass value="$c_pass" size="10" maxlength="$pass_max" title="半角英数{$pass_max}文字以内"></td> </tr>$ques<tr> <td colspan="2" height="40"><input type=submit value="投稿する"><input type=reset value="リセット"><br> *は必須次項<br/> メッセージは{$com_max}文字以内 </td> </tr> </table> </form> </div> EOM; } //================================================// //□1行のみ読み込み //================================================// function get_line($sid){ global $logfile; //ログ読み込み $lines = file($logfile); $line=""; //親記事探し foreach($lines as $line){ list($snum,$num) = split("<>", $line); //見つかった if($sid == $snum &&$num ==0){ break; } } return $line; } //================================================// //□書き込み処理 //================================================// function write_main(){ global $logfile,$my_url; $name =$_POST['name']; $title =$_POST['title']; $mail =$_POST['mail']; $url =$_POST['url']; $color =$_POST['color']; $com = $_POST['comment']; $pass = $_POST['pass']; $que = 0; //文字数チェック $this->write_check("write"); //時間を取得 $time = gmdate("Y/m/d H:i:s",time()+9*60*60); // パスワードの暗号化 $pass = $this->mod_pass($pass); //ホスト取得 $host =$this->get_host(); //ログ読み込み $lines = file($logfile); //前回の記事読み込み list($b_snum,$b_num ,$b_title, $b_time, $b_name, $b_mail, $b_url, $b_com,$b_color, $b_pass, $b_res,$b_cnt, $b_que,$b_host) = split("<>", $lines[0]); //二重投稿防止 if(($b_name == $name) &&($b_com == $com)){ die("二重投稿は禁止です。"); } //スレッドNO+ $snum =1 + $b_snum; //数初期化 $num = 0;//記事内No $cnt = 0;//参照数 $res = 0;//返信数 //改行用 $com = str_replace("\r\n", "\r", $com); //Win系は\r\n $com = str_replace("\r", "\n", $com); //Mac系は\r $com = str_replace("\n", "<br/>", $com);//<br>に置き換え //特殊文字 $name = $this->str_change($name); $title = $this->str_change($title); $com = $this->str_change($com); //URL置き換え $url = ereg_replace("http://","",$url); //書き込み準備 $line="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host\n"; //書き込み $this->write("write",$line); //一覧にもどる $this->back_html($my_url); } //================================================// //□レス処理 //================================================// function reswrite_main(){ global $logfile,$my_url; $name =$_POST['name']; $mail =$_POST['mail']; $url =$_POST['url']; $color =$_POST['color']; $com = $_POST['comment']; $que = $_POST['question']; $pass = $_POST['pass']; $sid = $_POST['sid']; //文字数チェック $this->write_check("reswrite",$sid); //時間を取得 $time = gmdate("Y/m/d H:i:s",time()+9*60*60); // パスワードの暗号化 $pass = $this->mod_pass($pass); //ホスト取得 $host =$this->get_host(); //ログ読み込み $lines = file($logfile); //前記事探し for($i=0; $i<sizeof($lines); $i++){ list($o_snum,$o_num, $o_title ,$o_time, $o_name, $o_mail, $o_url, $o_com,$o_color, $o_pass, $o_res, $o_cnt,$o_que,$o_host) = split("<>", $lines[$i]); //見つかった if($sid == $o_snum){ break; } } //二重投稿防止 if(($o_name == $name) &&($o_com == $com)){ die("二重投稿は禁止です。\n"); } //値代入 $num =1 + $o_num;//No+ $res = 1+$o_res;//返信数 $snum = $sid;//親記事No $cnt = 0;//参照数 //改行用 $com = str_replace("\r\n", "\r", $com); //Win系は\r\n $com = str_replace("\r", "\n", $com); //Mac系は\r $com = str_replace("\n", "<br/>", $com);//<br>に置き換え //URL置き換え $url = ereg_replace("http://","",$url); //特殊文字 $com = $this->str_change($com); $name = $this->str_change($name); $title = $this->str_change($title); //書き込み準備 $line="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host\n"; //書き込み $this->write("reswrite",$line,$sid); //一覧にもどる $this->back_html("{$my_url}?mode=th_view&id={$sid}"); } //================================================// //□修正処理 //================================================// function correction_main(){ global $logfile,$my_url; $name =$_POST['name']; $title =$_POST['title']; $mail =$_POST['mail']; $url =$_POST['url']; $color =$_POST['color']; $com = $_POST['comment']; $que = $_POST['question']; $pass = $_POST['pass']; //受け取り $sid =$_POST['sid']; // $id = $_POST['id']; // echo"$sid"; //文字数チェック $this->write_check("correction",$sid); //時間を取得 $time = gmdate("Y/m/d H:i:s",time()+9*60*60); // パスワードの暗号化 $pass = $this->mod_pass($pass); //ホスト取得 $host =$this->get_host(); //記事データ読み込み $line = $this->get_line($sid); list($o_snum,$o_num, $o_title ,$o_time, $o_name, $o_mail, $o_url, $o_com,$o_color, $o_pass, $o_res, $o_cnt,$o_que,$o_host) = split("<>", $line); //値代入 $num = $o_num;//No+ $res = $o_res;//返信数 $snum = $sid;//親記事No $cnt = $o_cnt;//参照数 //改行用 $com = str_replace("\r\n", "\r", $com); //Win系は\r\n $com = str_replace("\r", "\n", $com); //Mac系は\r $com = str_replace("\n", "<br/>", $com);//<br>に置き換え //URL置き換え $url = ereg_replace("http://","",$url); //特殊文字 $com = $this->str_change($com); $name = $this->str_change($name); $title = $this->str_change($title); //書き込み準備 $line="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host\n"; //書き込み $this->write("correction",$line,$sid); //一覧にもどる $this->back_html("{$my_url}?mode=th_view&id={$sid}"); } //================================================// //■書き込み //================================================// function write($mode,$line,$sid="0"){ global $logfile; //ログ読み込み $lines = file($logfile); //ファイルオープン $fp = fopen($logfile,"w")or error("ログファイルを開けません"); //ロック開始 flock($fp, LOCK_EX); //レスの場合 if($mode =="reswrite"){ $check = 0; for($i = 0;$i<sizeof($lines); $i++){ list($o_snum,$o_num, $o_title ,$o_time, $o_name, $o_mail, $o_url, $o_com,$o_color, $o_pass, $o_res, $o_cnt,$o_que,$o_host) = split("<>", $lines[$i]); //該当記事かどうか if($check == 0 && $sid == $o_snum){ $line = rtrim($line);//空白削除 fputs($fp,"$line\n");//書き込み $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp,"$lines[$i]\n");//現行ログ書き込み $check =1; }else{ $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp,"$lines[$i]\n");//現行ログ書き込み } } //記事修正の場合 }elseif($mode =="correction"){ for($i = 0;$i<sizeof($lines); $i++){ list($o_snum,$o_num, $o_title ,$o_time, $o_name, $o_mail, $o_url, $o_com,$o_color, $o_pass, $o_res, $o_cnt,$o_que,$o_host) = split("<>", $lines[$i]); //該当記事かどうか if($sid == $o_snum && $o_num == 0){ $line = rtrim($line);//空白削除 fputs($fp,"$line\n");//書き込み }else{ $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp,"$lines[$i]\n");//現行ログ書き込み } } //新規スレッド作成の場合 }else{ fputs($fp, $line); //先頭に書き込み for($i = 0;$i<sizeof($lines); $i++){ $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp, "$lines[$i]\n"); //現行ログ書き込み } } //ロックを解除する flock($fp, LOCK_UN); //ファイルクローズ fclose($fp); echo"書き込みました。"; } //================================================// //□文字チェック // // ◇$get モード判別 // //================================================// function write_check($mode,$sid="",$id=""){ global $name_max,$title_max,$com_max,$pass_max; //名前文字数チェック if(strlen($_POST['name']) > ($name_max*2)){ $error .="名前が全角{$name_max}文字を超えています<br/>"; }elseif($_POST['name'] == ""){ $error .="名前が入力されていません<br/>"; } if($mode =="write" || $mode =="correction"){ //タイトル文字数チェック if(strlen($_POST['title']) > ($title_max*2)){ $error .="タイトルが全角{$title_max}文字を超えています<br/>"; }elseif($_POST['title'] == ""){ $error .="タイトルが入力されていません<br/>"; } } //メッセージ文字数チェック if(strlen($_POST['comment']) > ($com_max*2)){ $error .="コメントが全角{$com_max}文字を超えています<br/>"; }elseif($_POST['comment'] == ""){ $error .="メッセージが入力されていません<br/>"; } //メアド形式チェック if($_POST['mail'] != "" && !preg_match('/[\w.-]+\@[\w.-]+\.[a-zA-Z]{2,3}/', $_POST['email'])){ $error .="メールアドレスの入力内容が正しくありません<br/>"; $_POST['email'] =""; } if($mode =="correction"){ //記事修正ならパスワードチェック // echo"文字チェック $sid $id<br>"; if($this->pass_check($_POST['pass'],$sid,$id) == 0){ $error .="パスワードが間違っています<br/>"; } }else{ //パスワード文字数チェック if(strlen($_POST['pass']) > ($pass_max)){ $error .="パスワードが半角{$com_max}文字を超えています<br/>"; }elseif($_POST['pass'] == "" && $get =="write"){ $error .="パスワードが入力されていません<br/>"; } } if($error != ""){ //いらんとこ消す $url = ereg_replace("http://","",$_POST['url']); //書き込み画面へ $this->write_html($mode,$sid,$error,$_POST['name'],$_POST['email'],$url,$_POST['title'],$_POST['comment']); exit(); } } //================================================// //□パスワードチェック //================================================// function pass_check($pass,$sid,$id="0"){ global $logfile; $pass =md5($pass); // ログ読み込み $lines = file($logfile); //echo"パスチェック時スレッドNo $sid 記事No $id $pass<br>"; //パスワードチェック $match=0; for($i=0; $i<sizeof($lines); $i++){ list($b_snum,$b_num ,$b_title, $b_time, $b_name, $b_mail, $b_url, $b_com,$b_color, $b_pass, $b_res,$b_cnt, $b_que,$b_host) = split("<>", $lines[$i]); //該当記事かどうか // echo"◇検索 スレッドNo $b_snum 記事No $b_num $b_pass<br>"; if($id == 0){ //スレッド見つけた if($sid == $b_snum && $pass == $b_pass){ $match=1; break; } }else{ //記事見つけた if($sid == $b_snum && $id == $b_num && $pass == $b_pass){ $match=1; break; } } } //echo "まっちした?$match"; return $match; } //================================================// //□文字修正 //================================================// function str_change($str){ //\を削除 if(get_magic_quotes_gpc()){ $str = stripslashes($str); } $str = str_replace("&amp;", "&", $str); $str = str_replace("&quot;", '"', $str); return $str; } //================================================// //□ホストアドレス取得 //================================================// function get_host(){ $host = getenv("REMOTE_HOST"); $addr = getenv("REMOTE_ADDR"); if($host == "" || $host == $addr){ $host = @gethostbyaddr($addr); } return $host; } //================================================// //クッキー //================================================// function set_cookie(){ global $cookie_name; $name =$_POST['name']; $mail =$_POST['mail']; $url =$_POST['url']; $color =$_POST['color']; $pass = $_POST['pass']; //http://削る $url = ereg_replace("http://","",$url); //クッキーに書き込む内容 $cook_val = array($name,$mail,$url,$color,$pass); //配列を文字列に $cookie_val =implode("<>", $cook_val); //時間 $data =time()+60*60*24*7; //クッキーセット setcookie($cookie_name,$cookie_val,$data); } //================================================// //URLにじゃんぷ //================================================// function back_html($url) { echo "<meta http-equiv=\"refresh\" content=\"0;url='{$url}'\">"; } //================================================// //パスワード暗号化 //================================================// function mod_pass($pass) { if($pass != ""){ $pass = md5($pass); } return $pass; } //================================================// //□削除処理 // // ◇$sid スレッドNo // ◇$id 記事No // ◇$match パスワードチェックor記事があるかないか // ◇$delflg スレッド削除かどうか // //================================================// function delete(){ global $logfile; $sid =$_POST['sid']; $id =$_POST['id']; $pass = $_POST['pass']; if($id !=0){ //スレッド削除でなければNoずらす(表示Noは一個ずれてるので) $id = $id -1; } //echo"スレッドNo $sid 記事No $id"; // ログ読み込み $lines = file($logfile); //パスワードチェック if($this->pass_check($pass,$sid,$id) ==0){ die("該当スレッドがない。もしくは、パスワードが違います。"); } //ログオープン $fp = @fopen($logfile,"w"); //ロック開始 flock($fp, LOCK_EX); //削除する記事検索 $match=0; $delflg =0; for($i=0; $i<sizeof($lines); $i++){ list($b_snum,$b_num ,$b_title, $b_time, $b_name, $b_mail, $b_url, $b_com,$b_color, $b_pass, $b_res,$b_cnt, $b_que,$b_host) = split("<>", $lines[$i]); //該当記事かどうか if($sid == $b_snum){ if($id == 0 || $delflg ==1){ //スレッド削除ならレス記事も削除 $delflg= 1; $match=1; continue; } elseif($id == $b_num){ //指定されたNoのみ削除 $match=1; continue; }else{ //親記事削除ないなら他の記事は残す fputs($fp,$lines[$i]); } }else{ fputs($fp,$lines[$i]); } } //ロックを解除する flock($fp, LOCK_UN); //ファイルクローズ fclose($fp); if($match==0){ echo"該当記事がありません。"; }else{ echo"削除しました。"; } } } //================================================// //■表示部 // //◇menu_bar() メニューバー //◇thread_view() スレッド表示 //◇view() 記事一覧 //◇page_navi() ページナビ //◇point_get() 現在位置取得 //◇page_count() ページ総数計算 // //================================================// class Display{ var $snum; //スレッドNo var $num; //記事内No var $title; //スレッドタイトル var $time; //時間 var $name; //投稿者名前 var $mail; //投稿者メルアド var $url; //投稿者URL var $com; //コメント var $pass; //パスワード var $cnt; //参照数 var $res; //返信数 var $que; //質問 var $host; //リモートホスト //================================================// //□メニューバー //================================================// function menu_bar(){ global $bbstitle,$homeurl; echo <<<EOM <div align="center"> <p> <a href="$homeurl">ホーム</a> | <a href="${_SERVER['PHP_SELF']}">記事一覧</a> | <a href="$PHP_SELF?mode=write-h">新規投稿</a> | <a href="$PHP_SELF?mode=serach-h">検索</a> | <a href="$PHP_SELF?mode=past">過去ログ</a> </p> </div> <div class="hr"></div> EOM; } //================================================// // スレッド表示 // // $sid スレッド番号 // $match 見つかったかどうかのフラグ // $resflg レスフラグ // $t_cnt 親記事数 // //================================================// function thread_view(){ global $my_url,$logfile,$default_num,$reslimit; //受け取り $sid =$_GET['id']; //親記事数カウント $page_all = $this->page_count(); //初期化 $match=0; // ログ読み込み $lines = file($logfile); $resflg =0;//レスフラグ //表示 for($i=0; $i<sizeof($lines) && $match ==0; $i++){ list($snum,$num, $title ,$time, $name, $mail, $url, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); if($sid == $snum){ //スレッド見つかった if($num==0){ //親記事見つかった $cnt++; $match =1; break; }elseif($num =! 0 && $resflg==0){ //レスがあった場合 $resflg =1; } } } //書き込み準備 $line="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host\n"; //ログオープン $fp = @fopen($logfile,"w"); //ロック開始 flock($fp, LOCK_EX); for($i=0; $i<sizeof($lines); $i++){ list($b_snum,$b_num ,$b_title, $b_time, $b_name, $b_mail, $b_url, $b_com,$b_color, $b_pass, $b_res,$b_cnt, $b_que,$b_host) = split("<>", $lines[$i]); //該当記事かどうか if($sid == $b_snum && $b_num == 0){ $line = rtrim($line);//空白削除 fputs($fp,"$line\n"); }else{ $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp,"$lines[$i]\n"); } } //ロックを解除する flock($fp, LOCK_UN); //ファイルクローズ fclose($fp); //見つからなかった場合 if($match ==0){ echo"該当記事が見つかりません。"; } //置き換え if($mail){ $name ="<a href=\"mailto:$mail\">$name</a>"; } if($url){ $urltag ="<a href=\"http://$url\">HP</a>"; }else{ $urltag =""; } //No1から $num++; //親記事表示 echo" <table align=\"center\" class=\"thread-table\"> <tr> <td>{$title}<br><br/> □{$name} No.{$num} 日付:{$time} $urltag<br/> <br/> <div class=\"comment\"><font color=\"$color\">$com</font></div><br/> <span class=\"right\"><a href=\"$my_url?mode=correction-h&id={$sid}\">修正</a></span></td> </tr> </table> "; //レスがある場合 if($resflg ==1){ echo"<table align=\"center\" class=\"thread-table\">"; $res_view = array(""); $rcnt=0; //レス表示 for($i=0; $i<sizeof($lines); $i++){ list($snum,$num, $title ,$time, $name, $mail, $url, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); if($sid == $snum && $num !=0){ $res_view[$rcnt]="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host"; $rcnt++; } } for($j= $rcnt-1; $j >= 0; $j--){ list($snum,$num, $title ,$time, $name, $mail, $url, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $res_view[$j]); if($mail){ $name ="<a href=\"mailto:$mail\">$name</a>"; } $num++; echo" <tr> <td>□{$name} No.{$num} 日付:{$time}<br/> <br/> <div class=\"comment\"><font color=\"$color\">$com</font></div></td> </tr> "; } echo"</table>"; } //書き込みフォーム //書き込み数がいっぱいならもう書き込めない if($rcnt < $reslimit-1){ //reswriteでレスモード $rg = new Regist(); $rg->write_html("reswrite",$sid); }else{ echo"もうこれ以上書き込めません。"; } //削除フォーム $this->delete_html($sid,"1001"); } //================================================// //□記事一覧 // // $pagenow 現在ページ // $page_all 総ページ数 // $pn ポインタ位置 // $t_cnt 親記事数 // //================================================// function view(){ global $logfile,$default_num,$new_time,$new_mark; //テーブル開始 echo "<table border=\"1\" align=\"center\" class=\"view-table\"> <tr> <td class=\"table-que\"></td> <td class=\"table-no\">No.</td> <td class=\"table-title\">タイトル</td> <td class=\"table-name\">投稿者</td> <td class=\"table-count\">参照数</td> <td class=\"table-count\">返信数</td> <td class=\"table-update\">最終更新</td> </tr>"; // 現在のページ取得 if($_GET['page']){ //値を受け取っている場合 $pagenow = $_GET['page']; }else{ //1記事から $pagenow = 1; } //親記事数カウント $page_all = $this->page_count(); // ログ読み込み $lines = file($logfile); //現在位置定義 $t_cnt =0; //親記事数 $pn=0; //ポインタは先頭 //更新時間でソート $lines = $this->sort_line($lines); //2ページ目以降 if($pagenow != 1){ //ポインタ位置代入 $pn = $this->point_get($pagenow,$lines); } $tugi=0; //表示 for($i=$pn; $t_cnt < $default_num && $i< sizeof($lines); $i++){ //代入 //新すれにはNew list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host,$v_name) = split("<>", $lines[$i]); $nowtime = gmdate("Y/m/d H:i:s",time()+9*60*60); if($nowtime - $time <= $new_time*60*60){ $new = $new_mark; }else{ $new =""; } //親記事発見 if($num== 0){ echo "<tr> <td>$que</td> <td>$snum</td> <td><a href=\"$PHP_SELF?mode=th_view&id={$snum}\">$title</a> $new</td> <td>$name</td> <td>$cnt</td> <td>$res</td> <td>$time<br/>by $v_name</td> </tr>"; //親記事でカウント $t_cnt++; } } echo "</table>"; //ページナビゲーション $this->page_navi($page_all,$pagenow); //削除フォーム $this->delete_html("","0"); } //================================================// //□ソート //================================================// function sort_line($lines){ global $new_sort; $tugi=0; $view_lines=array(); for($i=0; $i< sizeof($lines); $i++){ //代入 list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); if($tugi != $snum){ $tugi = $snum; $v_res =$res; $v_name=$name; $v_time=$time; } if($que==0){ $que ="質問"; }else{ $que ="解決"; } //親記事発見 if($num== 0){ $v_line ="$snum<>$num<>$title<>$v_time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$v_res<>$cnt<>$que<>$host<>$v_name\n"; array_push($view_lines,"$v_line"); } } if($new_sort ==1){ usort($view_lines,'cmp'); } return $view_lines; } //================================================// //□ページナビゲーション // // // // $page_all ページ総数 // // $pagenow 現在のページ // // $num_remainder 残り件数(最後の残り端数用) // // // //================================================// function page_navi($page_all,$pagenow){ global $default_num; echo"<div align=\"center\">"; //端数があるかないか if($page_all < ($pagenow +1) * $default_num){ $num_remainder = (($pagenow+1)* $default_num) - $page_all; $num_remainder = $default_num - $num_remainder; }else{ $num_remainder = $default_num; } //総ページ数をカウント $page_all = ceil($page_all / $default_num); //前の件数 //1ページ目なら前の件数はリンクなし if($pagenow == 1) { $prev = "前件なし"; }else { //ページが前に戻るので-1 $prevpage = $pagenow - 1; $prev = "<a href=\"$PHP_SELF?page={$prevpage}\">前の{$default_num}件</a>"; } //次の件数 //最後のページ目なら次の件数はリンクなし if($pagenow == $page_all) { $next = "次件なし"; } else { //ページを先に進めるので+1 $nextpage = $pagenow + 1; $next = "<a href=\"$PHP_SELF?page={$nextpage}\">次の{$num_remainder}件</a>"; } echo "<p>$prev | $pagenow / $page_all ページ | $next</p></div>"; } //================================================// //□削除画面 // //================================================// function delete_html($sid,$id){ global $pass_max,$cookie_name; //クッキーがあるか調べる if (isset($_COOKIE["$cookie_name"])) { $cookie = $_COOKIE["$cookie_name"]; } list($c_name,$c_mail,$c_url,$c_col,$c_pass) = split("<>", $cookie); // echo"スレッドNo $sid 記事No $id"; //スレッド削除なら if($id == 0){ $idname = "id"; //送信name $idvalue = 0; //送信値 $delname = "sid"; //削除No }else{ $idname = "sid"; //送信name $idvalue = $sid; //送信値 $delname = "id"; //削除No } echo <<<EOM <div align="right"> <form action="$PHP_SELF" method="post"> <input type=hidden name="mode" value="delete"> <input type=hidden name="$idname" value="$idvalue"> <table class="delete-table"> <tr> <td nowrap >削除No:<input type=text name="$delname" size=8 class="ipt"></td> <td nowrap >パスワード:</b><input type=password name=pass size=8 maxlength="$pass_max" value ="$c_pass" class="ipt"></td> <td nowrap ><input type=submit value="削除する"></td> </tr> </table> </form> </div> EOM; } //================================================// // ヘッダー //================================================// function header_html(){ global $stylesheet,$bbstitle,$charset,$jcode; echo <<<HTML <html> <head> <meta http-equiv="Content-Language" content="ja"> <meta http-equiv="Content-Type" content="text/html; charset=$charset[$jcode]"> <title>$bbstitle</title> <link rel="stylesheet" type="text/css" href="$stylesheet"> </head> <body> <h1>$bbstitle</h1> HTML; } //================================================// // フッター //================================================// function footer_html(){ echo <<<HTML <div class="hr"></div> </body></html> HTML; } //================================================// //□現在位置取得 // // $pagenow 現在ページ // $end 終了位置 // $t_cnt 親記事数 // //================================================// function point_get($pagenow,$lines){ global $default_num; //終了位置 $end =($pagenow - 1)*$default_num; $t_cnt =0; //親記事数 for($i= 0; $t_cnt<$end && $i< sizeof($lines); $i++){ list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); //親記事発見 if($num== 0){ //親記事数でカウント $t_cnt++; } } //現在位置返す return $i; } //================================================// //□記事数計算 // // $t_cnt 親記事数 // //================================================// function page_count(){ global $logfile; // ログ読み込み $lines = file($logfile); $t_cnt = 0; //親記事数カウント for($i=0; $i<sizeof($lines); $i++){ list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); if($num==0){ $t_cnt++; } } //ない場合は1代入 if($t_cnt == 0){ $t_cnt =1; } return $t_cnt; } } //================================================// //検索部 //================================================// class Search{ //================================================// //検索画面 //================================================// function serach_html(){ echo <<<EOM 検索 <form action="$PHP_SELF" method="post"> <input type=hidden name="mode" value="serach"> <table class="delete-table"> <tr> <td>検索文字:<input type=text name=serach size=20></td> </tr><tr> <td>and:<input type=radio name=flg value="and" checked> or:<input type=radio name=flg value="or"></td> </tr><tr> <td ><input type=submit value="検索"></td> </tr> </table> </form> EOM; } //================================================// //検索 //================================================// function serach(){ global $logfile; $sword = $_POST['serach']; $flg = $_POST['flg']; //マッチしたNoを配列で取得 $hits = $this->serach_main($sword,$flg); //配列であれば中身あり if(is_array($hits)){ //1行目は空白なので $hit =count($hits); echo "<b>{$sword}</b>の{$flg}検索結果{$hit}件"; }else{ echo"みつかりませんでした。"; exit; } // ログ読み込み $lines = file($logfile); //みつかったスレッド一覧表示 echo "<table border=\"1\" align=\"center\" class=\"view-table\"> <tr> <td class=\"table-que\"></td> <td class=\"table-no\">No.</td> <td class=\"table-title\">タイトル</td> <td class=\"table-name\">投稿者</td> <td class=\"table-count\">参照数</td> <td class=\"table-count\">返信数</td> <td class=\"table-update\">最終更新</td> </tr>"; for($i=0; $i<sizeof($lines); $i++){ list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); //マッチした記事数だけ foreach($hits as $hit){ if($hit ==$snum && $num ==0){ //Noが一致 if($tugi != $snum){ //スレッドNo切り替わったとき $tugi = $snum; $v_res =$res; $v_name=$name; } if($que==0){ $que ="質問"; }else{ $que ="解決"; } echo" <tr> <td>$que</td> <td>$snum</td> <td><a href=\"$PHP_SELF?mode=th_view&id={$snum}\">$title</td> <td>$name</td> <td>$cnt</td> <td>$v_res</td> <td>$time<br/>by $v_name</td> </tr>"; } } } echo "</table>"; } //================================================// //照合 //================================================// function serach_main($sword,$flg){ global $logfile; // ログ読み込み $lines = file($logfile); if(!(isset($sword)) || $sword ==""){ //なにも入力されていない。 return FALSE; }else{ if(get_magic_quotes_gpc()){ $sword = stripslashes($sword); } //配列に切り分け $keys = preg_split("/( | )+/", trim($sword)); $result=array(); $match =0; $b_snum=0; //検索 foreach($lines as $line){ for($i=0;$i< count($keys); $i++){ if($keys[$i]==""){ //なにもない行はスキップ continue; } if($flg=="or"){ //or検索 if(stristr($line, $keys[$i])){ //みつかったらスレッドNo取得 $match =1; list($snum,)= split("<>", $line); } }else{ //and検索 if(stristr($line, $keys[$i])){ //みつかったらスレッドNo取得 $match =1; list($snum,)= split("<>", $line); }else{ //1個でも違えばそこで終わり $match =0; break; } } //マッチした場合は配列に格納 if($match == 1 &&$b_snum !=$snum){ $b_snum = $snum; array_push($result,$snum); } } } return $result; } } } //================================================// //過去ログ //================================================// class Pastlog{ function past_html(){ global $bbstitle,$homeurl; echo <<<EOM 過去ログ EOM; } } //================================================// //□ユーザソート定義 //================================================// function cmp($a,$b){ list(,,,$a_time,) = split("<>", $a); list(,,,$b_time,) = split("<>", $b); if ($a_time == $b_time) return 0; return ($a_time > $b_time) ? -1 : 1; } ?>
<?php if (phpversion() >= "4.1.0") { extract($_GET); extract($_POST); extract($_SERVER); extract($_COOKIE); } //■基本設定 $masterpass = "0000"; //管理パスワード $bbstitle = "BBS"; //掲示板タイトル $homeurl = 'http://www7.atwiki.jp/chacha/pages/35.html'; //戻る先URL $stylesheet = 'style.css'; //CSSファイル指定 $my_url = $_SERVER{'PHP_SELF'}; //基本変更なし $logfile = 'log.txt'; //ログファイル名 $default_num = 10; //ログ表示数 $reslimit = 100; //返信できる最大数 $threadlimit = 4; //スレッド最大数(古いスレは消去) $new_sort =1; //新しく書き込みされたスレッドを一番上に表示なら1しないなら0 $true_tags = "<b><i><s><strong><br/>"; //許可するタグ //クッキー名 $cookie_name = "noblogbbs_c"; //■文字数 $name_max = 30; //名前文字数(全角) $title_max = 50; //タイトル文字数(全角) $com_max =2000; //メッセージ文字数(全角) $pass_max = 8; //パスワード文字数(半角) //■文字色 $colorvalue = array('#000000'=>'黒','blue'=>'青','green'=>'緑','yellow'=>'黄','white'=>'白','pink'=>'桃'); // 選択クラス名を定義(クラス名=>選択時表示名 $collen = 6; //折り返しの数 //================================================// //■メイン // //================================================// $dp = new Display(); $rg = new Regist(); $sr = new Search(); $pl = new Pastlog(); if($_SERVER['REQUEST_METHOD'] == "GET"){ $_POST['mode'] = &$_GET['mode']; } if($_POST['mode'] =="write" || $_POST['mode'] =="reswrite"){ $rg->set_cookie(); } $dp->header_html();//ヘッダー $dp->menu_bar();//メニューバー switch($_POST['mode']): case 'write-h': // 書き込みフォーム $rg->write_html("write"); break; case 'write': // 書き込み処理 $rg->write_main(); break; case 'reswrite': // レス処理 $rg->reswrite_main(); break; case 'correction-h': //記事修正画面 $rg->write_html("correction"); break; case 'correction': //記事修正処理 $rg->correction_main(); break; case 'serach-h': // 検索表示 $sr->serach_html(); break; case 'serach': // 検索表示 $sr->serach(); break; case 'delete': // 削除処理 $rg->delete_main(); break; case 'past': // 過去ログ $pl->past_html(); break; case 'th_view': // スレッド表示 $dp->thread_view(); break; default: $dp->view();// 一覧表示 break; endswitch; $dp->footer_html();//フッター exit(); //================================================// //■書き込み部 // //◇write_html() 新規投稿画面 //◇write() 書き込み処理 //◇write_check 文字チェック // //================================================// class Regist{ //================================================// //□投稿画面 //================================================// function write_html($mode,$sid="",$error ="",$r_name="",$r_mail="",$r_url="",$r_title="",$r_com=""){ global $cookie_name,$colorvalue,$collen,$name_max,$title_max,$com_max,$pass_max; //クッキーがあるか調べる if (isset($_COOKIE["$cookie_name"])) { $cookie = $_COOKIE["$cookie_name"]; } //クッキー list($c_name,$c_mail,$c_url,$c_col,$c_pass) = split("<>", $cookie); //入力ミスで戻ってきたのじゃなければクッキー if($r_name == ""){ $r_name = $c_name; } if($r_mail == ""){ $r_mail = $c_mail; } if($r_url == ""){ $r_url = $c_url; } $r_col = $c_col; if($mode =="write" ){ $titlcom ="<h3>新規スレッド作成フォーム</h3>"; $modeflg ="<span class=\"error\">*</span>"; }elseif($mode =="correction"){ //受け取り $sid =$_GET['id']; //記事データ読み込み $line = $this->get_line($sid); //配列を文字列に list($r_snum,$r_num ,$o_title, $r_time, $o_name, $o_mail, $o_url, $o_com,$o_col,,,, $r_que,) =split("<>", $line); echo"$sid"; $r_title = $o_title; $r_mail = $o_mail; $r_col = $o_col; $r_url = $o_url; if($r_com ==""){ $o_com = str_replace("<br/>", "\r\n", $o_com); //Win系は\r\n $r_com = $o_com; } $titlcom ="<h3>スレッド修正フォーム</h3>"; $modeflg ="<span class=\"error\">*</span>"; $conflg ="<br/><span class=\"error\">パスワードは新規作成した際のパスワードをいれてください。</span>"; $ques ="<tr> <td><b>解決済み?:</b></td> <td><select name=\"question\"> <option value=\"0\" selected>質問</option> <option value=\"1\">解決!</option> </select> </td> </tr> "; }else{ $titlcom ="<h3>返信フォーム</h3>"; $modeflg =""; } //フォントカラー準備 //初期化 $select = array(""); //フォントカラー表示 $i=0; foreach($colorvalue as $key => $value) { //初期値決定 if($r_col == $key){ $checked="checked"; }else{ $checked=""; //クッキーがない場合 if($r_col==""){ $checked = "checked"; //ダミー書き込み $r_col ="true"; } } //折り返し if($i==$collen){ $i=0; array_push($select,"<br/>"); } //格納 array_push($select,"<input type=radio name=color value=\"$key\"$checked>$value"); $i++; } echo <<<EOM <div align="center" > <table class="write-h-table"> <tr> <td>{$titlcom} <span class="error">$error</span> $conflg </td> </tr> </table> <form action="$PHP_SELF" method="post"> <input type=hidden name="mode" value="$mode"> <input type=hidden name="sid" value="$sid"> <table class ="write-table"> <tr> <td><span class="error">*</span><b>名前:</b></td> <td><input type=text name=name size=40 value="$r_name" title ="全角{$name_max}文字以内"></td> </tr><tr> <td><b>E-mail:</b></td> <td><input type=text name=mail size=40 value="$r_mail"></td> </tr> EOM; //スレッド作成の場合はタイトル入力 if($mode =="write"|| $mode =="correction"){ echo"<tr> <td><span class=\"error\">*</span><b>タイトル:</b></td\> <td><input type=text name=title size=40 value=\"$r_title\" title =\"全角{$title_max}文字以内\"></td> </tr>"; } echo <<<EOM <tr> <td><span class="error">*</span><b>メッセージ:</b></td> <td><textarea rows="7" name="comment" cols="35" "title=全角{$com_max}文字以内">$r_com</textarea></td> </tr><tr> <td><b>URL:</b></td> <td><input type=text name=url size=50 value="http://$r_url"></td> </tr><tr> <td><b>フォントカラー:</b></td> <td> EOM; //配列を文字列で表示(implode) echo implode("\n",$select); echo <<<EOM </td> </tr><tr> <td>{$modeflg}<b>パスワード:</b></td> <td><input type="password" name=pass value="$c_pass" size="10" maxlength="$pass_max" title="半角英数{$pass_max}文字以内"></td> </tr>$ques<tr> <td colspan="2" height="40"><input type=submit value="投稿する"><input type=reset value="リセット"><br> *は必須次項<br/> メッセージは{$com_max}文字以内 </td> </tr> </table> </form> </div> EOM; } //================================================// //□1行のみ読み込み //================================================// function get_line($sid){ global $logfile; //ログ読み込み $lines = file($logfile); $line=""; //親記事探し foreach($lines as $line){ list($snum,$num) = split("<>", $line); //見つかった if($sid == $snum &&$num ==0){ break; } } return $line; } //================================================// //□書き込み処理 //================================================// function write_main(){ global $logfile,$my_url; $name =$_POST['name']; $title =$_POST['title']; $mail =$_POST['mail']; $url =$_POST['url']; $color =$_POST['color']; $com = $_POST['comment']; $pass = $_POST['pass']; $que = 0; //文字数チェック $this->write_check("write"); //時間を取得 $time = gmdate("Y/m/d H:i:s",time()+9*60*60); // パスワードの暗号化 $pass = $this->mod_pass($pass); //ホスト取得 $host =$this->get_host(); //ログ読み込み $lines = file($logfile); //前回の記事読み込み list($b_snum,$b_num ,$b_title, $b_time, $b_name, $b_mail, $b_url, $b_com,$b_color, $b_pass, $b_res,$b_cnt, $b_que,$b_host) = split("<>", $lines[0]); //二重投稿防止 if(($b_name == $name) &&($b_com == $com)){ die("二重投稿は禁止です。"); } //スレッドNO+ $snum =1 + $b_snum; //数初期化 $num = 0;//記事内No $cnt = 0;//参照数 $res = 0;//返信数 //改行用 $com = str_replace("\r\n", "\r", $com); //Win系は\r\n $com = str_replace("\r", "\n", $com); //Mac系は\r $com = str_replace("\n", "<br/>", $com);//<br>に置き換え //特殊文字 $name = $this->str_change($name); $title = $this->str_change($title); $com = $this->str_change($com); //URL置き換え $url = ereg_replace("http://","",$url); //書き込み準備 $line="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host\n"; //書き込み $this->write("write",$line); //一覧にもどる $this->back_html($my_url); } //================================================// //□レス処理 //================================================// function reswrite_main(){ global $logfile,$my_url; $name =$_POST['name']; $mail =$_POST['mail']; $url =$_POST['url']; $color =$_POST['color']; $com = $_POST['comment']; $que = $_POST['question']; $pass = $_POST['pass']; $sid = $_POST['sid']; //文字数チェック $this->write_check("reswrite",$sid); //時間を取得 $time = gmdate("Y/m/d H:i:s",time()+9*60*60); // パスワードの暗号化 $pass = $this->mod_pass($pass); //ホスト取得 $host =$this->get_host(); //ログ読み込み $lines = file($logfile); //前記事探し for($i=0; $i<sizeof($lines); $i++){ list($o_snum,$o_num, $o_title ,$o_time, $o_name, $o_mail, $o_url, $o_com,$o_color, $o_pass, $o_res, $o_cnt,$o_que,$o_host) = split("<>", $lines[$i]); //見つかった if($sid == $o_snum){ break; } } //二重投稿防止 if(($o_name == $name) &&($o_com == $com)){ die("二重投稿は禁止です。\n"); } //値代入 $num =1 + $o_num;//No+ $res = 1+$o_res;//返信数 $snum = $sid;//親記事No $cnt = 0;//参照数 //改行用 $com = str_replace("\r\n", "\r", $com); //Win系は\r\n $com = str_replace("\r", "\n", $com); //Mac系は\r $com = str_replace("\n", "<br/>", $com);//<br>に置き換え //URL置き換え $url = ereg_replace("http://","",$url); //特殊文字 $com = $this->str_change($com); $name = $this->str_change($name); $title = $this->str_change($title); //書き込み準備 $line="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host\n"; //書き込み $this->write("reswrite",$line,$sid); //一覧にもどる $this->back_html("{$my_url}?mode=th_view&id={$sid}"); } //================================================// //□修正処理 //================================================// function correction_main(){ global $logfile,$my_url; $name =$_POST['name']; $title =$_POST['title']; $mail =$_POST['mail']; $url =$_POST['url']; $color =$_POST['color']; $com = $_POST['comment']; $que = $_POST['question']; $pass = $_POST['pass']; //受け取り $sid =$_POST['sid']; // $id = $_POST['id']; // echo"$sid"; //文字数チェック $this->write_check("correction",$sid); //時間を取得 $time = gmdate("Y/m/d H:i:s",time()+9*60*60); // パスワードの暗号化 $pass = $this->mod_pass($pass); //ホスト取得 $host =$this->get_host(); //記事データ読み込み $line = $this->get_line($sid); list($o_snum,$o_num, $o_title ,$o_time, $o_name, $o_mail, $o_url, $o_com,$o_color, $o_pass, $o_res, $o_cnt,$o_que,$o_host) = split("<>", $line); //値代入 $num = $o_num;//No+ $res = $o_res;//返信数 $snum = $sid;//親記事No $cnt = $o_cnt;//参照数 //改行用 $com = str_replace("\r\n", "\r", $com); //Win系は\r\n $com = str_replace("\r", "\n", $com); //Mac系は\r $com = str_replace("\n", "<br/>", $com);//<br>に置き換え //URL置き換え $url = ereg_replace("http://","",$url); //特殊文字 $com = $this->str_change($com); $name = $this->str_change($name); $title = $this->str_change($title); //書き込み準備 $line="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host\n"; //書き込み $this->write("correction",$line,$sid); //一覧にもどる $this->back_html("{$my_url}?mode=th_view&id={$sid}"); } //================================================// //■書き込み //================================================// function write($mode,$line,$sid="0"){ global $logfile,$threadlimit; //スレッド数数える $th_num = Display::page_count(); //件数が超えていれば削除処理 if($mode =="write" && $threadlimit <= $th_num){ //ログ読み込み $o_lines = file($logfile); //ソート $o_lines = Display::sort_line($o_lines); //最後の行を取り出す $o_line = array_slice($o_lines,$th_num-1); //いるのはスレNoと記事Noだけ list($o_snum,$o_num) = split("<>", $o_line[0]); //最後の行削除 $this->delete($o_snum,$o_num); } $lines = file($logfile); //ファイルオープン $fp = fopen($logfile,"w")or error("ログファイルを開けません"); //ロック開始 flock($fp, LOCK_EX); //レスの場合 if($mode =="reswrite"){ $check = 0; for($i = 0;$i<sizeof($lines); $i++){ list($o_snum,$o_num, $o_title ,$o_time, $o_name, $o_mail, $o_url, $o_com,$o_color, $o_pass, $o_res, $o_cnt,$o_que,$o_host) = split("<>", $lines[$i]); //該当記事かどうか if($check == 0 && $sid == $o_snum){ $line = rtrim($line);//空白削除 fputs($fp,"$line\n");//書き込み $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp,"$lines[$i]\n");//現行ログ書き込み $check =1; }else{ $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp,"$lines[$i]\n");//現行ログ書き込み } } //記事修正の場合 }elseif($mode =="correction"){ for($i = 0;$i<sizeof($lines); $i++){ list($o_snum,$o_num, $o_title ,$o_time, $o_name, $o_mail, $o_url, $o_com,$o_color, $o_pass, $o_res, $o_cnt,$o_que,$o_host) = split("<>", $lines[$i]); //該当記事かどうか if($sid == $o_snum && $o_num == 0){ $line = rtrim($line);//空白削除 fputs($fp,"$line\n");//書き込み }else{ $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp,"$lines[$i]\n");//現行ログ書き込み } } //新規スレッド作成の場合 }else{ fputs($fp, $line); //先頭に書き込み for($i = 0;$i<sizeof($lines); $i++){ $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp, "$lines[$i]\n"); //現行ログ書き込み } } //ロックを解除する flock($fp, LOCK_UN); //ファイルクローズ fclose($fp); echo"書き込みました。"; } //================================================// //□文字チェック // // ◇$get モード判別 // //================================================// function write_check($mode,$sid="",$id=""){ global $name_max,$title_max,$com_max,$pass_max; //名前文字数チェック if(strlen($_POST['name']) > ($name_max*2)){ $error .="名前が全角{$name_max}文字を超えています<br/>"; }elseif($_POST['name'] == ""){ $error .="名前が入力されていません<br/>"; } if($mode =="write" || $mode =="correction"){ //タイトル文字数チェック if(strlen($_POST['title']) > ($title_max*2)){ $error .="タイトルが全角{$title_max}文字を超えています<br/>"; }elseif($_POST['title'] == ""){ $error .="タイトルが入力されていません<br/>"; } } //メッセージ文字数チェック if(strlen($_POST['comment']) > ($com_max*2)){ $error .="コメントが全角{$com_max}文字を超えています<br/>"; }elseif($_POST['comment'] == ""){ $error .="メッセージが入力されていません<br/>"; } //メアド形式チェック if($_POST['mail'] != "" && !preg_match('/[\w.-]+\@[\w.-]+\.[a-zA-Z]{2,3}/', $_POST['email'])){ $error .="メールアドレスの入力内容が正しくありません<br/>"; $_POST['email'] =""; } if($mode =="correction"){ //記事修正ならパスワードチェック // echo"文字チェック $sid $id<br>"; if($this->pass_check($_POST['pass'],$sid,$id) == 0){ $error .="パスワードが間違っています<br/>"; } }else{ //パスワード文字数チェック if(strlen($_POST['pass']) > ($pass_max)){ $error .="パスワードが半角{$com_max}文字を超えています<br/>"; }elseif($_POST['pass'] == "" && $get =="write"){ $error .="パスワードが入力されていません<br/>"; } } if($error != ""){ //いらんとこ消す $url = ereg_replace("http://","",$_POST['url']); //書き込み画面へ $this->write_html($mode,$sid,$error,$_POST['name'],$_POST['email'],$url,$_POST['title'],$_POST['comment']); exit(); } } //================================================// //□パスワードチェック //================================================// function pass_check($pass,$sid,$id="0"){ global $logfile; $pass =md5($pass); // ログ読み込み $lines = file($logfile); //echo"パスチェック時スレッドNo $sid 記事No $id $pass<br>"; //パスワードチェック $match=0; for($i=0; $i<sizeof($lines); $i++){ list($b_snum,$b_num ,$b_title, $b_time, $b_name, $b_mail, $b_url, $b_com,$b_color, $b_pass, $b_res,$b_cnt, $b_que,$b_host) = split("<>", $lines[$i]); //該当記事かどうか // echo"◇検索 スレッドNo $b_snum 記事No $b_num $b_pass<br>"; if($id == 0){ //スレッド見つけた if($sid == $b_snum && $pass == $b_pass){ $match=1; break; } }else{ //記事見つけた if($sid == $b_snum && $id == $b_num && $pass == $b_pass){ $match=1; break; } } } //echo "まっちした?$match"; return $match; } //================================================// //□文字修正 //================================================// function str_change($str){ global $true_tags; //\を削除 if(get_magic_quotes_gpc()){ $str = stripslashes($str); } $str = str_replace("&amp;", "&", $str); $str = str_replace("&quot;", '"', $str); //許可タグ以外除去 $str = strip_tags($str, $true_tags); return $str; } //================================================// //□ホストアドレス取得 //================================================// function get_host(){ $host = getenv("REMOTE_HOST"); $addr = getenv("REMOTE_ADDR"); if($host == "" || $host == $addr){ $host = @gethostbyaddr($addr); } return $host; } //================================================// //クッキー //================================================// function set_cookie(){ global $cookie_name; $name =$_POST['name']; $mail =$_POST['mail']; $url =$_POST['url']; $color =$_POST['color']; $pass = $_POST['pass']; //http://削る $url = ereg_replace("http://","",$url); //クッキーに書き込む内容 $cook_val = array($name,$mail,$url,$color,$pass); //配列を文字列に $cookie_val =implode("<>", $cook_val); //時間 $data =time()+60*60*24*7; //クッキーセット setcookie($cookie_name,$cookie_val,$data); } //================================================// //URLにじゃんぷ //================================================// function back_html($url) { echo "<meta http-equiv=\"refresh\" content=\"0;url='{$url}'\">"; } //================================================// //パスワード暗号化 //================================================// function mod_pass($pass) { if($pass != ""){ $pass = md5($pass); } return $pass; } //================================================// //□削除処理 // // ◇$sid スレッドNo // ◇$id 記事No // ◇$match パスワードチェックor記事があるかないか // ◇$delflg スレッド削除かどうか // //================================================// function delete_main(){ $sid =$_POST['sid']; $id =$_POST['id']; $pass = $_POST['pass']; if($id !=0){ //スレッド削除でなければNoずらす(表示Noは一個ずれてるので) $id = $id -1; } //echo"スレッドNo $sid 記事No $id"; //パスワードチェック if($this->pass_check($pass,$sid,$id) ==0){ die("該当スレッドがない。もしくは、パスワードが違います。"); } //削除処理 $match = $this->delete($sid,$id); if($match==0){ echo"該当記事がありません。"; }else{ echo"削除しました。"; } } //削除処理 function delete($sid,$id=0){ global $logfile; // ログ読み込み $lines = file($logfile); //ログオープン $fp = @fopen($logfile,"w"); //ロック開始 flock($fp, LOCK_EX); //削除する記事検索 $match=0; $delflg =0; for($i=0; $i<sizeof($lines); $i++){ list($b_snum,$b_num ,$b_title, $b_time, $b_name, $b_mail, $b_url, $b_com,$b_color, $b_pass, $b_res,$b_cnt, $b_que,$b_host) = split("<>", $lines[$i]); //該当記事かどうか if($sid == $b_snum){ if($id == 0 || $delflg ==1){ //スレッド削除ならレス記事も削除 $delflg= 1; $match=1; continue; } elseif($id == $b_num){ //指定されたNoのみ削除 $match=1; continue; }else{ //親記事削除ないなら他の記事は残す fputs($fp,$lines[$i]); } }else{ fputs($fp,$lines[$i]); } } //ロックを解除する flock($fp, LOCK_UN); //ファイルクローズ fclose($fp); return $match; } } //================================================// //■表示部 // //◇menu_bar() メニューバー //◇thread_view() スレッド表示 //◇view() 記事一覧 //◇page_navi() ページナビ //◇point_get() 現在位置取得 //◇page_count() ページ総数計算 // //================================================// class Display{ var $snum; //スレッドNo var $num; //記事内No var $title; //スレッドタイトル var $time; //時間 var $name; //投稿者名前 var $mail; //投稿者メルアド var $url; //投稿者URL var $com; //コメント var $pass; //パスワード var $cnt; //参照数 var $res; //返信数 var $que; //質問 var $host; //リモートホスト //================================================// //□メニューバー //================================================// function menu_bar(){ global $bbstitle,$homeurl; echo <<<EOM <div align="center"> <p> <a href="$homeurl">ホーム</a> | <a href="${_SERVER['PHP_SELF']}">記事一覧</a> | <a href="$PHP_SELF?mode=write-h">新規投稿</a> | <a href="$PHP_SELF?mode=serach-h">検索</a> </p> </div> <div class="hr"></div> EOM; } //================================================// // スレッド表示 // // $sid スレッド番号 // $match 見つかったかどうかのフラグ // $resflg レスフラグ // $t_cnt 親記事数 // //================================================// function thread_view(){ global $my_url,$logfile,$default_num,$reslimit; //受け取り $sid =$_GET['id']; //親記事数カウント $page_all = $this->page_count(); //初期化 $match=0; // ログ読み込み $lines = file($logfile); $resflg =0;//レスフラグ //表示 for($i=0; $i<sizeof($lines) && $match ==0; $i++){ list($snum,$num, $title ,$time, $name, $mail, $url, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); if($sid == $snum){ //スレッド見つかった if($num==0){ //親記事見つかった $cnt++; $match =1; break; }elseif($num =! 0 && $resflg==0){ //レスがあった場合 $resflg =1; } } } //書き込み準備 $line="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host\n"; //ログオープン $fp = @fopen($logfile,"w"); //ロック開始 flock($fp, LOCK_EX); for($i=0; $i<sizeof($lines); $i++){ list($b_snum,$b_num ,$b_title, $b_time, $b_name, $b_mail, $b_url, $b_com,$b_color, $b_pass, $b_res,$b_cnt, $b_que,$b_host) = split("<>", $lines[$i]); //該当記事かどうか if($sid == $b_snum && $b_num == 0){ $line = rtrim($line);//空白削除 fputs($fp,"$line\n"); }else{ $lines[$i] = rtrim($lines[$i]);//空白削除 fputs($fp,"$lines[$i]\n"); } } //ロックを解除する flock($fp, LOCK_UN); //ファイルクローズ fclose($fp); //見つからなかった場合 if($match ==0){ echo"該当記事が見つかりません。"; } //置き換え if($mail){ $name ="<a href=\"mailto:$mail\">$name</a>"; } if($url){ $urltag ="<a href=\"http://$url\">HP</a>"; }else{ $urltag =""; } //No1から $num++; $com = $this->a_link($com); //親記事表示 echo" <table align=\"center\" class=\"thread-table\"> <tr> <td>{$title}<br><br/> □{$name} No.{$num} 日付:{$time} $urltag<br/> <br/> <div class=\"comment\"><font color=\"$color\">$com</font></div><br/> <span class=\"right\"><a href=\"$my_url?mode=correction-h&id={$sid}\">修正</a></span></td> </tr> </table> "; //レスがある場合 if($resflg ==1){ echo"<table align=\"center\" class=\"thread-table\">"; $res_view = array(""); $rcnt=0; //レス表示 for($i=0; $i<sizeof($lines); $i++){ list($snum,$num, $title ,$time, $name, $mail, $url, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); if($sid == $snum && $num !=0){ $res_view[$rcnt]="$snum<>$num<>$title<>$time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$res<>$cnt<>$que<>$host"; $rcnt++; } } for($j= $rcnt-1; $j >= 0; $j--){ list($snum,$num, $title ,$time, $name, $mail, $url, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $res_view[$j]); if($mail){ $name ="<a href=\"mailto:$mail\">$name</a>"; } $com = $this->a_link($com); $num++; echo" <tr> <td>□{$name} No.{$num} 日付:{$time}<br/> <br/> <div class=\"comment\"><font color=\"$color\">$com</font></div></td> </tr> "; } echo"</table>"; } //書き込みフォーム //書き込み数がいっぱいならもう書き込めない if($rcnt < $reslimit-1){ //reswriteでレスモード Regist::write_html("reswrite",$sid); }else{ echo"もうこれ以上書き込めません。"; } //削除フォーム $this->delete_html($sid,"1001"); } //================================================// //□記事一覧 // // $pagenow 現在ページ // $page_all 総ページ数 // $pn ポインタ位置 // $t_cnt 親記事数 // //================================================// function view(){ global $logfile,$default_num,$new_time,$new_mark; //テーブル開始 echo "<table border=\"1\" align=\"center\" class=\"view-table\"> <tr> <td class=\"table-que\"></td> <td class=\"table-no\">No.</td> <td class=\"table-title\">タイトル</td> <td class=\"table-name\">投稿者</td> <td class=\"table-count\">参照数</td> <td class=\"table-count\">返信数</td> <td class=\"table-update\">最終更新</td> </tr>"; // 現在のページ取得 if($_GET['page']){ //値を受け取っている場合 $pagenow = $_GET['page']; }else{ //1記事から $pagenow = 1; } //親記事数カウント $page_all = $this->page_count(); // ログ読み込み $lines = file($logfile); //現在位置定義 $t_cnt =0; //親記事数 $pn=0; //ポインタは先頭 //更新時間でソート $lines = $this->sort_line($lines); //2ページ目以降 if($pagenow != 1){ //ポインタ位置代入 $pn = $this->point_get($pagenow,$lines); } $tugi=0; //表示 for($i=$pn; $t_cnt < $default_num && $i< sizeof($lines); $i++){ //代入 list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host,$v_name) = split("<>", $lines[$i]); //親記事発見 if($num== 0){ echo "<tr> <td>$que</td> <td>$snum</td> <td><a href=\"$PHP_SELF?mode=th_view&id={$snum}\">$title</a> $new</td> <td>$name</td> <td>$cnt</td> <td>$res</td> <td>$time<br/>by $v_name</td> </tr>"; //親記事でカウント $t_cnt++; } } echo "</table>"; //ページナビゲーション $this->page_navi($page_all,$pagenow); //削除フォーム $this->delete_html("","0"); } //================================================// //□ソート //================================================// function sort_line($lines){ global $new_sort; $tugi=0; $view_lines=array(); for($i=0; $i< sizeof($lines); $i++){ //代入 list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); if($tugi != $snum){ $tugi = $snum; $v_res =$res; $v_name=$name; $v_time=$time; } if($que==0){ $que ="質問"; }else{ $que ="解決"; } //親記事発見 if($num== 0){ $v_line ="$snum<>$num<>$title<>$v_time<>$name<>$mail<>$url<>$com<>$color<>$pass<>$v_res<>$cnt<>$que<>$host<>$v_name\n"; array_push($view_lines,"$v_line"); } } if($new_sort ==1){ usort($view_lines,'cmp'); } return $view_lines; } //================================================// //□ページナビゲーション // // // // $page_all ページ総数 // // $pagenow 現在のページ // // $num_remainder 残り件数(最後の残り端数用) // // // //================================================// function page_navi($page_all,$pagenow){ global $default_num; echo"<div align=\"center\">"; //端数があるかないか if($page_all < ($pagenow +1) * $default_num){ $num_remainder = (($pagenow+1)* $default_num) - $page_all; $num_remainder = $default_num - $num_remainder; }else{ $num_remainder = $default_num; } //総ページ数をカウント $page_all = ceil($page_all / $default_num); //前の件数 //1ページ目なら前の件数はリンクなし if($pagenow == 1) { $prev = "前件なし"; }else { //ページが前に戻るので-1 $prevpage = $pagenow - 1; $prev = "<a href=\"$PHP_SELF?page={$prevpage}\">前の{$default_num}件</a>"; } //次の件数 //最後のページ目なら次の件数はリンクなし if($pagenow == $page_all) { $next = "次件なし"; } else { //ページを先に進めるので+1 $nextpage = $pagenow + 1; $next = "<a href=\"$PHP_SELF?page={$nextpage}\">次の{$num_remainder}件</a>"; } echo "<p>$prev | $pagenow / $page_all ページ | $next</p></div>"; } //================================================// //□削除画面 // //================================================// function delete_html($sid,$id){ global $pass_max,$cookie_name; //クッキーがあるか調べる if (isset($_COOKIE["$cookie_name"])) { $cookie = $_COOKIE["$cookie_name"]; } list($c_name,$c_mail,$c_url,$c_col,$c_pass) = split("<>", $cookie); // echo"スレッドNo $sid 記事No $id"; //スレッド削除なら if($id == 0){ $idname = "id"; //送信name $idvalue = 0; //送信値 $delname = "sid"; //削除No }else{ $idname = "sid"; //送信name $idvalue = $sid; //送信値 $delname = "id"; //削除No } echo <<<EOM <div align="right"> <form action="$PHP_SELF" method="post"> <input type=hidden name="mode" value="delete"> <input type=hidden name="$idname" value="$idvalue"> <table class="delete-table"> <tr> <td nowrap >削除No:<input type=text name="$delname" size=8 class="ipt"></td> <td nowrap >パスワード:</b><input type=password name=pass size=8 maxlength="$pass_max" value ="$c_pass" class="ipt"></td> <td nowrap ><input type=submit value="削除する"></td> </tr> </table> </form> </div> EOM; } //================================================// // ヘッダー //================================================// function header_html(){ global $stylesheet,$bbstitle,$charset,$jcode; echo <<<HTML <html> <head> <meta http-equiv="Content-Language" content="ja"> <meta http-equiv="Content-Type" content="text/html; charset=$charset[$jcode]"> <title>$bbstitle</title> <link rel="stylesheet" type="text/css" href="$stylesheet"> </head> <body> <h1>$bbstitle</h1> HTML; } //================================================// // フッター //================================================// function footer_html(){ echo <<<HTML <div class="hr"></div> </body></html> HTML; } //================================================// //□現在位置取得 // // $pagenow 現在ページ // $end 終了位置 // $t_cnt 親記事数 // //================================================// function point_get($pagenow,$lines){ global $default_num; //終了位置 $end =($pagenow - 1)*$default_num; $t_cnt =0; //親記事数 for($i= 0; $t_cnt<$end && $i< sizeof($lines); $i++){ list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); //親記事発見 if($num== 0){ //親記事数でカウント $t_cnt++; } } //現在位置返す return $i; } //================================================// //□記事数計算 // // $t_cnt 親記事数 // //================================================// function page_count(){ global $logfile; // ログ読み込み $lines = file($logfile); $t_cnt = 0; //親記事数カウント for($i=0; $i<sizeof($lines); $i++){ list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); if($num==0){ $t_cnt++; } } //ない場合は1代入 if($t_cnt == 0){ $t_cnt =1; } return $t_cnt; } //自動リンク function a_link($url){ $matchval ="/\b(?:https?|shttp):\/\/(?:(?:[-_.!~*'()a-zA-Z0-9;:&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*@)?(?:(?:[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.)*[a-zA-Z](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.?|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(?::[0-9]*)?(?:\/(?:[-_.!~*'()a-zA-Z0-9:@&=+\$,]|%[0-9A-Fa-f][0-9A-Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+\$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)*(?:\/(?:[-_.!~*'()a-zA-Z0-9:@&=+\$,]|%[0-9A-Fa-f][0-9A-Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+\$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)*)*)?(?:\?(?:[-_.!~*'()a-zA-Z0-9;\/?:@&=+\$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)?(?:#(?:[-_.!~*'()a-zA-Z0-9;\/?:@&=+\$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)?/"; $url = preg_replace($matchval,"<a href=\"\\0\" target=\"_blank\">\\0</a>",$url); return $url; } } //================================================// //検索部 //================================================// class Search{ //================================================// //検索画面 //================================================// function serach_html(){ echo <<<EOM <div align ="center"> <table class="write-h-table"> <tr> <td><b>検索</b> </td> </tr> </table> <form action="$PHP_SELF" method="post"> <input type=hidden name="mode" value="serach"> <table <table "class="delete-table"> <tr> <td>検索文字:<input type=text name=serach size=20></td> </tr><tr> <td>and:<input type=radio name=flg value="and" checked> or:<input type=radio name=flg value="or"></td> </tr><tr> <td ><input type=submit value="検索"></td> </tr> </table> </form> </div> EOM; } //================================================// //検索 //================================================// function serach(){ global $logfile; $sword = $_POST['serach'];//検索文字 $flg = $_POST['flg'];//and or //マッチしたNoを配列で取得 $hits = $this->serach_main($sword,$flg); //配列であれば中身あり if(is_array($hits)){ //1行目は空白なので $hit =count($hits); echo "<b>{$sword}</b>の{$flg}検索結果{$hit}件"; }else{ echo"みつかりませんでした。"; exit; } // ログ読み込み $lines = file($logfile); //ソート $lines = Display::sort_line($lines); //みつかったスレッド一覧表示 echo "<table border=\"1\" align=\"center\" class=\"view-table\"> <tr> <td class=\"table-que\"></td> <td class=\"table-no\">No.</td> <td class=\"table-title\">タイトル</td> <td class=\"table-name\">投稿者</td> <td class=\"table-count\">参照数</td> <td class=\"table-count\">返信数</td> <td class=\"table-update\">最終更新</td> </tr>"; for($i=0; $i<sizeof($lines); $i++){ list($snum,$num, $title ,$time, $name, $mail, $urll, $com,$color, $pass, $res, $cnt,$que,$host) = split("<>", $lines[$i]); //マッチした記事数だけ foreach($hits as $hit){ if($hit ==$snum && $num ==0){ //Noが一致 echo" <tr> <td>$que</td> <td>$snum</td> <td><a href=\"$PHP_SELF?mode=th_view&id={$snum}\">$title</td> <td>$name</td> <td>$cnt</td> <td>$res</td> <td>$time<br/>by $v_name</td> </tr>"; } } } echo "</table>"; } //================================================// //照合 //================================================// function serach_main($sword,$flg){ global $logfile; // ログ読み込み $lines = file($logfile); if(!(isset($sword)) || $sword ==""){ //なにも入力されていない。 return FALSE; }else{ if(get_magic_quotes_gpc()){ $sword = stripslashes($sword); } //配列に切り分け $keys = preg_split("/( | )+/", trim($sword)); $result=array(); $match =0; $b_snum=0; //検索 foreach($lines as $line){ for($i=0;$i< count($keys); $i++){ if($keys[$i]==""){ //なにもない行はスキップ continue; } if($flg=="or"){ //or検索 if(stristr($line, $keys[$i])){ //みつかったらスレッドNo取得 $match =1; list($snum,)= split("<>", $line); } }else{ //and検索 if(stristr($line, $keys[$i])){ //みつかったらスレッドNo取得 $match =1; list($snum,)= split("<>", $line); }else{ //1個でも違えばそこで終わり $match =0; break; } } //マッチした場合は配列に格納 if($match == 1 &&$b_snum !=$snum){ $b_snum = $snum; array_push($result,$snum); } } } return $result; } } } //================================================// //過去ログ //================================================// class Pastlog{ function past_html(){ global $bbstitle,$homeurl; echo <<<EOM 過去ログ EOM; } } //================================================// //□ユーザソート定義 //================================================// function cmp($a,$b){ list(,,,$a_time,) = split("<>", $a); list(,,,$b_time,) = split("<>", $b); if ($a_time == $b_time) return 0; return ($a_time > $b_time) ? -1 : 1; } ?>

表示オプション

横に並べて表示:
変化行の前後のみ表示:
人気記事ランキング
目安箱バナー