mb_language("Japanese");
mb_internal_encoding("EUC-JP") ;
header("Cache-Control: no-cache");
//クッキーのデフォルト
if(!isset($_COOKIE["cookie"])){
//setcookie("cookie","checked",time() + 60*60*24*14);
setcookie("cookie","",time() - 1);
}
$S = "\t";//区切り文字
$F = "./data/log.txt";
$C = "./data/copy.txt";
$admin = "admin";//管理者用、パスワード。
//記事の投稿
if(!empty($_POST["post"])){
//デバッグ用
//echo $_SERVER['PHP_SELF'] . "
";
//echo $_SERVER['HTTP_REFERER'];
if(!strstr($_SERVER['HTTP_REFERER'],$_SERVER['PHP_SELF'])){
exit ("
caution!!
incorrect access!
caution!!
please input your name & message,at least.
caution!!
please input text within the limits of 2000 chars.
caution!!
please input pass in the range of 4 to 12.
caution!!
e-mail address is incorrect.
caution!!
e-mail address is incorrect.
caution!!
e-mail address is incorrect.
caution!!
e-mail address is incorrect.
caution!!
e-mail address is incorrect.
caution!!
url is incorrect.
caution!!
url is incorrect.
caution!!
url is incorrect.
caution!!
url is incorrect.
");//特定のタグのみ、使用可能(多分)... //$v = htmlspecialchars($v);//特殊文字をHTMLエンティティーに変換する。 $array[$k] = $v; extract($array);//配列名を、変数として展開。 } //パスワード未入力の場合、 if($pass == ""){ $pass = $admin;//管理者権限として仮登録。 } if(isset($_POST["cookie"])){ setcookie("author","$author",time() + 60*60*24*14); setcookie("email","$email",time() + 60*60*24*14); setcookie("url","$url",time() + 60*60*24*14); setcookie("cookie","checked",time() + 60*60*24*14); //setcookie("pass","$pass",time() + 60*60*24*14); }else{ setcookie("author","$author",time() - 1); setcookie("email","$email",time() - 1); setcookie("url","$url",time() - 1); setcookie("cookie","",time() - 1); //setcookie("pass","$pass",time() - 1); } $PX = $_SERVER['HTTP_FORWARDED'];//プロキシ $RA = $_SERVER['REMOTE_ADDR'];//IPアドレス $HN = gethostbyaddr($RA);//ホスト名 $UA = $_SERVER['HTTP_USER_AGENT'];//ブラウザ情報 if($PX == ""){$PX = "none";} if($_FILES['userfile']['name'] != ""){ $str = strrchr($_FILES['userfile']['name'],".");//検索。ファイル名の、"."以降、 if($str != false){ $ext = substr($str,1);//さらに、"."の次の文字以降(拡張子に相当)を取得、 }else{ exit ("caution!!
"); } $dir = getcwd(); $id = uniqid(""); //拡張子が、"jpg"の場合... if($ext == "jpg"){ $default = $dir . "/data/" . $id . ".jpg"; $resized = $dir . "/data/" . $id . "_small.jpg"; move_uploaded_file($_FILES['userfile']['tmp_name'], $default); list($lw,$lh,$type,$attr) = getimagesize($default); if($lw >= $lh){$tl = $lw;}else{$tl = $lh;} $ratio = $tl/120; $sw = $lw/$ratio; $sh = $lh/$ratio; $img1 = @imagecreatefromjpeg($default); $img2 = @imagecreatetruecolor($sw,$sh); imagecopyresampled($img2,$img1,0,0,0,0,$sw,$sh,$lw,$lh); imagejpeg($img2,$resized); $aim = "./data/" . $id . ".jpg"; $aim_small = "./data/" . $id . "_small.jpg"; //拡張子が、"png"の場合... }elseif($ext == "png"){ $default = $dir . "/data/" . $id . ".png"; $resized = $dir . "/data/" . $id . "_small.png"; move_uploaded_file($_FILES['userfile']['tmp_name'], $default); list($lw,$lh,$type,$attr) = getimagesize($default); if($lw >= $lh){$tl = $lw;}else{$tl = $lh;} $ratio = $tl/120; $sw = $lw/$ratio; $sh = $lh/$ratio; $img1 = @imagecreatefrompng($default); $img2 = @imagecreatetruecolor($sw,$sh); imagecopyresampled($img2,$img1,0,0,0,0,$sw,$sh,$lw,$lh); imagepng($img2,$resized); $aim = "./data/" . $id . ".png"; $aim_small = "./data/" . $id . "_small.png"; }else{ exit ("
incorrect file!caution!!
"); } } //デバッグ用 //echo "デフォルト "; //echo "リサイズ"; //$pattern = "(http|ftp|news)(:\/\/[a-zA-Z0-9_\.\~\-\/\?\&\+\=\:\;\@\%\#]+)"; $pattern = "(https?|ftp|news)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)"; $text = ereg_replace($pattern,"\\1\\2",$text); $str = $author . $S . $email . $S . $url . $S . $pass . $S . str_replace("\n", "
jpeg & png only!
", $text) . $S . date("H:i:s, M j, Y") . $S . $PX . $S . $RA . $S . $HN . $S . $UA . $S . @$aim . $S . @$aim_small . "\n"; $H = fopen($F, "a") or die("error is occurred while opening file."); flock($H, LOCK_EX); fputs($H, $str); flock($H, LOCK_UN); fclose($H); //バックアップ。 $H = fopen($C, "a") or die("error is occurred while opening file."); flock($H, LOCK_EX); fputs($H, $str); flock($H, LOCK_UN); fclose($H); //リワインド。 $max = 100;//最大表示件数、"$max"に達すると... $limit = 50;//限界値、"$limit"まで、リワインド。 $all_messages = file($F); if(count($all_messages) >= $max - 1){ for($i=$limit; $i<=count($all_messages); $i++){ $trim_messages .= $all_messages[$i]; } $H = fopen($F,"w") or die("error is occurred while opening file."); flock($H,LOCK_EX); fputs($H,$trim_messages); flock($H,LOCK_UN); fclose($H); } //新規投稿の通知。 $admin = "草森冬弥";//管理者名 $to = "aprilsnow#ek.ciao.jp";//管理者のメールアドレス。 $subject = "mail from bbs";//管理者宛のメールのタイトル。日本語可、 $message = ""; $message .= "新規投稿のお知らせ。" . "\n"; $message .= $_SERVER['HTTP_REFERER'] . " " . "\n\n";//まず、bbsのurl。 $message .= "date : " . date("Y/m/d(D) H:i:s") . "\n";//以下、記事の内容... $message .= "name : " . $author . "\n"; $message .= "e-mail : " . $email . "\n"; $message .= "url : " . $url . "\n"; $message .= "message : " . "\n" . $text . "\n\n"; $message .= "proxy : " . $PX . "\n"; $message .= "remote address : " . $RA . "\n"; $message .= "host name : " . $HN . "\n"; $message .= "user agent : " . $UA . "\n"; $admin = mb_convert_encoding($admin,"EUC-JP","auto"); $to = mb_convert_encoding($to,"EUC-JP","auto"); $subject = mb_convert_encoding($subject,"EUC-JP","auto"); $message = mb_convert_encoding($message,"EUC-JP","auto"); //ヘッダー。半角英数字のみ。 //$header = "From: " . $admin . "<" . $to . ">"; //ヘッダー。日本語込み。おそらくMacでは、文字化け必至... $header = "From:" . mb_encode_mimeheader($admin) . "<" . $to . ">"; mb_send_mail($to,$subject,$message,$header); } //記事の削除 if(!empty($_POST["delete"])){ if(!strstr($_SERVER['HTTP_REFERER'],$_SERVER['PHP_SELF'])){ exit ("caution!!
"); } foreach($_POST as $k => $v){ if(get_magic_quotes_gpc()){ $v = stripslashes($v);//エスケープの解除。 } $v = strip_tags($v);//タグの除去。 $array[$k] = $v; extract($array);//配列名を、変数として展開。 } //$admin = "admin";//管理者用、パスワード。 $lines = file($F); for($i=0; $i
incorrect access!« $title »"; echo " "; //echo "
\n"; } function archives(){ $path = "../data"; $dir_name = dir($path); while($file_name = $dir_name->read()){ if(strstr($file_name,".txt") != ""){ $files[] = $file_name; } } rsort($files); foreach($files as $file){ $archive = substr($file,0,6); $list[] .= $archive; } $list = array_unique($list);//重複する要素を排除し、 $list = array_values($list);//連番のインデックスに再設定... echo "« $title » "; echo ""; echo " « $title » \n"; for($x=0; $x<7; $x++){ echo " \n"; for($y=0; $y<6; $y++){ echo "$wtxt[$x] "; } echo ""; for($x=0; $x<7; $x++){ $d = $y*7+$x+1-$wday;//日付け /* if($cm == $this_month && $d==$this_day){ $quote1 = "["; $quote2 = "]"; }else{ $quote1 = ""; $quote2 = ""; } */ $aim = $year.$month; $path = "../data"; $dir_name = dir($path); while($file_name = $dir_name->read()){ $files[] = $file_name; } rsort($files); foreach($files as $file){ if(strstr($file,$aim) != ""){ $list[] .= $file;//ファイル名 $days[] .= substr($file,6,2);//投稿日(二桁表記)。ファイル名より抽出... } } $d2 = sprintf("%02d",$d);//「投稿日」との比較のため、二桁表記の「日付け」も準備する。 $path = sprintf("../entry.php?path=./data/%04d%02d%02d.txt",$year,$month,$d);//permalink url if(($cm == $this_month && $d==$this_day) && (is_array($days) && in_array($d2,$days))){//「本日」かつ「投稿日」の場合 $tag1 = ""; $tag2 = ""; }elseif($cm == $this_month && $d==$this_day){//「本日」の場合 $tag1 = ""; $tag2 = ""; }elseif(is_array($days) && in_array($d2,$days)){//「投稿日」の場合 $tag1 = ""; $tag2 = ""; }else{//「本日」以外、かつ「投稿日」以外、の場合 $tag1 = ""; $tag2 = ""; } echo " \n"; } echo ""; $param = sprintf("date=%04d%02d%02d",$cy,$cm,$d); $addr = sprintf("%s?%s",$self,$param); if($d>0 && $d<($maxd+1)){ //echo "{$quote1}{$d}{$quote2}"; echo "{$tag1}{$d}{$tag2}"; }else{echo " ";}; echo " \n"; } echo "archives
"; echo ""; for($i=0; $i<5 && $i
"; } function recent_entries(){ $path = "../data"; $dir_name = dir($path); while($file_name = $dir_name->read()){ if(strstr($file_name,".txt") != ""){ $files[] = $file_name; } } rsort($files); foreach($files as $file){ $list[] .= $file; } echo "$title"; } echo " - Show past log ...
"; echo "recent entries
"; echo ""; for($i=0; $i<5 && $i
"; } //$self = $HTTP_SERVER_VARS['PHP_SELF']; $self = "../diary.php"; if($_GET['date'] == ""){ $year = date("Y"); $month = date("m"); $date = date("d"); }else{ $year = substr($_GET['date'],0,4); $month = substr($_GET['date'],4,2); $date = substr($_GET['date'],6,2); } $fn = "../summary.txt"; $all = file_get_contents($fn); $parts = explode("###",$all); $mytitle = $parts[0]; $myurl = $parts[1]; $mydescription = $parts[2]; $link1 = sprintf("%s?date=%04d%02d%02d",$self,$year,$month-1,$date); $link2 = sprintf("%s?date=%04d%02d%02d",$self,$year,$month+1,$date); ?>".$title.""; } echo "
Notice: Undefined variable: mytitle in /home/users/2/ciao.jp-aprilsnow/web/test/diary/bbs/bbs.php on line 473
skip to contentfunction callback(&$value,$key){ $value = mb_convert_encoding($value,"EUC-JP","auto"); } global $S; global $F; $num = 10;//1ページ当たりの表示件数 if(isset($_GET["page"])){ $page = $_GET["page"]; /*All if($page == "All"){ $start = 0; }else{ $start = $page*$num; } */ $start = $page*$num; }else{ $page = 0; $start = 0; } if(file_exists($F)){ $H = file($F); $R = array_reverse($H); /*All if($page == "All"){ $num = count($R); } */ $max = 100;//最大表示件数 $log = count($R);//ログ保存件数 //各ページの出力。 //$maxとは、別に、実数未満("$i<$log")にまとめる。 for($i=$start; ($i<$start+$num and $i<$max and $i<$log); $i++){ @list($author, $email, $url, $pass, $text, $time, $PX, $RA, $HN, $UA, $aim, $aim_small) = explode($S, $R[$i]); echo ""; } /*Back or Next $prev = $page-1; $next = $page+1; if($prev > -1){ echo "Back "; } if(count($R) > $next*$num){ echo "Next"; } */ /*All if($page == "All"){ $num = 10;//再設定 } */ $a1 = floor(count($R)/$num);//商 $a2 = count($R)%$num;//剰余 $all_pages = $a1;//「商」分のページ数 if($a2 != 0){ $all_pages += 1;//「剰余」は、ログの端数に相当。割り切れない場合は、プラス1ページ。 } echo ""; echo "page : "; if($all_pages == 0 or $all_pages == 1){ echo "" . 1 . ""; }elseif(($_GET["page"]+1) < $all_pages){//($_GET["page"]+1) → 現在のページ、 for($i=0; $i<$all_pages; $i++){ if($_GET["page"] == $i){ echo "" . ($i+1) . "* | "; }else{ echo "" . ($i+1) . " | "; } } echo "»"; echo "
"; }else{ echo "« | "; for($i=0; $i<$all_pages; $i++){ if($_GET["page"] == $i){ echo "" . ($i+1) . "* | "; }else{ echo "" . ($i+1) . " | "; } } echo ""; } } ?>
skip to navigation