write(Data_array); $pmes2 -> view(); properties datetype : 時刻表示形式を指定(既定値:"Y/m/d H:i:s") errormessage : エラー時のメッセージ保持 outfiletype : 既定値:"a" flagtag : 既定値:false */ require("pocketmes2.inc"); class pocketbbs_base extends pocketmes2_base { var $flagoutput; var $flagtag; var $outfilename; var $basefilename; var $outfp; var $outfiletype; var $outlockfilename; //----- constructor function pocketbbs_base( $_datafilename = "./data/pmes2.dat",$_maxcount = 10,$_exchangefilename = "",$_outputfilename = "",$_basefilename="") { pocketmes2_base::pocketmes2_base( $_datafilename,$_maxcount,$_exchangefilename); $this -> flagtag = false; $this -> outfilename = $_outputfilename; if(!file_exists($_basefilename)) $_basefilename = ""; $this -> basefilename = $_basefilename; if($_basefilename=="") $this -> outfiletype = "a"; else $this -> outfiletype = "w"; $this -> outfp = false; $this -> outlockfilename = $_outputfilename.".pbbs.lock"; if($_outputfilename == ""){$this -> flagoutput = true;} else {$this -> flagoutput = false;}; } //----- 出力(override) function output($_printstr = ""){ if($_printstr != ""){ //----- 標準出力 if($this -> flagoutput){ print $_printstr; } else { //----- ファイルへ出力 if(!$this -> outfp) { $this -> errormessage = "file couldnot open."; } else { fputs($this -> outfp,$_printstr); } } } } //----- 投稿内容の表示(override) function view(){ if(!$this -> flagoutput) { //----- ファイルのロック $lockfp = fopen($this -> outlockfilename,"w"); flock($lockfp, LOCK_EX); //----- 出力ファイルオープン $this -> outfp = false; if (file_exists($this -> outfilename)) { $this -> outfp = fopen($this -> outfilename,$this -> outfiletype); } else { $this -> outfp = fopen($this -> outfilename,"w"); } } if($this->basefilename!=""){ //----- ベースファイルの処理 if(file_exists($this->basefilename)){ $_chkstr = "%_insertdata_%"; $_bfile = file($this->basefilename); //----- 出力ファイルオープン foreach($_bfile as $_val){ if(ereg($_chkstr,$_val)){ //----- データファイルの処理 pocketmes2_base::view(); } else { $this->output($_val); } } unset($_bfile); } } else { //----- データファイルの処理 pocketmes2_base::view(); } if(!$this -> flagoutput) { fclose($this -> outfp); //----- ロックの解除 flock($lockfp, LOCK_UN); fclose($lockfp); @chmod($this -> outfilename,0666); unlink($this -> outlockfilename); } } //----- 禁則処理(override) function encode($_pal){ foreach($_pal as $_val){ //----- phpタグは全て禁止 $_val = str_replace("","?>",$_val); //add //----- その他のタグはフラグにより禁止 if(!$this -> flagtag){ $_val = str_replace("<","<",$_val); //add $_val = str_replace(">",">",$_val); //add } $_val = str_replace("\n","
",$_val); $_val = str_replace("\r","",$_val); $_val = str_replace(",","%%2C",$_val); $_val = str_replace("\\\\","%%5C",$_val); $ret_data[] = $_val; } return $ret_data; } }; ?>