"; };
if ($EMAIL == ""){ $ERROR .= "EMAILが空欄です。
"; };
if ($TITLE == ""){ $ERROR .= "TITLEが空欄です。
"; };
if ($MESS == ""){ $ERROR .= "MESSAGEが空欄です。
"; };
if ($ERROR == ""){
$SQL = "select max(id) from bbs where room='$room';";
$result = pg_exec($connect,$SQL);
$s_no = pg_result($result,0,0) + 1;
$ip = gethostbyaddr(getenv("REMOTE_ADDR"));
$NAME = strip_tags($NAME);
$EMAIL = strip_tags($EMAIL);
$URL = strip_tags($URL);
$TITLE = strip_tags($TITLE);
$MESS = strip_tags($MESS);
$MESS = ereg_replace("(https?|ftp|news)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)","\\1\\2",$MESS);
$SQL = "insert into bbs values('$s_no','$room','$NAME','$EMAIL','$URL','$TITLE','$MESS',now(),'$ip');";
$result = pg_exec($connect,$SQL);
//クッキーセット
setcookie("FB_NAME","$NAME",time()+2592000);
setcookie("FB_EMAIL","$EMAIL",time()+2592000);
setcookie("FB_URL","$URL",time()+2592000);
$TITLE = "";
$MESS = "";
//おふみ対応
if($room == "bbs1002"){
$inskey = date("Ymd",time());
$SQL = "insert into ofumi values('$inskey',0,0,0,0);";
$result = pg_exec($connect,$SQL);
}
}
}
if($room != ""){
if ($NAME == ""){ $NAME = $FB_NAME; };
if ($EMAIL == ""){ $EMAIL = $FB_EMAIL; };
if ($URL == ""){ $URL = $FB_URL; };
if ($URL == ""){ $URL = "http://"; };
//通常表示
// ヘッダーテンプレート読み込み
$fp = fopen($template1,"r");
$strhead = fread($fp,filesize($template1));
fclose($fp);
// フォームテンプレート読み込み
//おふみ対応
if($room == "bbs1002" and $pass == "moroman"){
$fp = fopen($template4,"r");
$strform = fread($fp,filesize($template1));
fclose($fp);
}
$strhead = str_replace("#FORM#",$strform,$strhead);
// コンテンツテンプレート読み込み
$fp = fopen($template2,"r");
$strmain = fread($fp,filesize($template2));
fclose($fp);
// フッターテンプレート読み込み
$fp = fopen($template3,"r");
$strfoot = fread($fp,filesize($template3));
fclose($fp);
if ($reply != ""){
$sql = "select * from bbs where room='$room' and id='$reply';";
$result = pg_exec($connect,$sql);
$rs = pg_fetch_array($result,0);
$TITLE = "RE:" . $rs[title];
$MESS = ">" . $rs[body];
$MESS = str_replace("\n","\n>",$MESS);
}
// 内容挿入
$strhead = str_replace("#PATH#",$path,$strhead);
$strmain = str_replace("#PATH#",$path,$strmain);
$strfoot = str_replace("#PATH#",$path,$strfoot);
$strhead = str_replace("#NAME#",$NAME,$strhead);
$strhead = str_replace("#EMAIL#",$EMAIL,$strhead);
$strhead = str_replace("#URL#",$URL,$strhead);
$strhead = str_replace("#TITLE#",$TITLE,$strhead);
$strhead = str_replace("#MESS#",$MESS,$strhead);
$strhead = str_replace("#ERROR#",$ERROR,$strhead);
$strhead = str_replace("#ROOM#",$room,$strhead);
$strfoot = str_replace("#ROOM#",$room,$strfoot);
if ($offset == ""){
$offset = 0;
}
$stroffset = "";
$SQL = "select id from bbs where room='$room';";
$result = pg_exec($connect,$SQL);
$totalRows = pg_numrows($result);
if ($offset > 0){
$backcnt = $offset - $view;
if ($backcnt < 0){
$backcnt = 0;
}
$stroffset = "<Prev";
}
$stroffset .= "|";
if ($offset + $view < $totalRows){
$nextcnt = $offset + $view;
$stroffset .= "Next>";
}
$strhead = str_replace("#STROFFSET#",$stroffset,$strhead);
$strfoot = str_replace("#STROFFSET#",$stroffset,$strfoot);
$counter = 0;
$sql = "select * from bbs where room='$room' order by id desc limit $view offset $offset;";
$result = pg_exec($connect,$sql);
$totalRows = pg_numrows($result);
while($counter < $totalRows){
$rs = pg_fetch_array($result,$counter);
$strtemp = $strmain;
$room = $rs[room];
$subno = $rs[id];
$subtitle = $rs[title];
$subdate = substr($rs[date],0,19);
// $subdate = $rs[date];
$submail = $rs[email];
$subname = $rs[name];
$suburl = $rs[url];
$submess = $rs[body];
$submess = str_replace("\n","
",$submess);
$strtemp = str_replace("#SUBROOM#",$room,$strtemp);
$strtemp = str_replace("#SUBNO#",$subno,$strtemp);
$strtemp = str_replace("#SUBTITLE#",$subtitle,$strtemp);
$strtemp = str_replace("#SUBDATE#",$subdate,$strtemp);
$strtemp = str_replace("#SUBMAIL#",$submail,$strtemp);
$strtemp = str_replace("#SUBNAME#",$subname,$strtemp);
if ($suburl == "http://"){
$editurl = "";
}else{
$editurl = "URL";
}
$strtemp = str_replace("#SUBURL#",$editurl,$strtemp);
$strtemp = str_replace("#SUBMESS#",$submess,$strtemp);
$strtemp = str_replace("#SUBREPLY#",$subno,$strtemp);
$key = substr($rs[date],0,4) . substr($rs[date],5,2) . substr($rs[date],8,2);
$strtemp = str_replace("#KEY#",$key,$strtemp);
$strout .= $strtemp;
$counter++;
}
$submess = str_replace("\n","
",$submess);
$SQL = "select max(id) from bbs where room='$ROOM';";
$result = pg_exec($connect,$SQL);
$s_no = pg_result($result,0,0);
echo $s_no . "
";
// コンテンツ表示
print($strhead);
print($strout);
print($strfoot);
}
pg_close($connect);
?>