#!/usr/local/bin/perl $script = "yudo.html"; require './lib/jcode.pl'; require './lib/teikei.pl'; require './lib/dbsetup.pl'; # バックナンバー表示数 $bncount = 20; &decode; $p = $in{'p'}; if ($p eq ""){ $p = 1; } if ($in{'No'} eq "0"){ &all;} else{ &page;} $setcook1 = &setCookie("ID", $COOKIE{ID}); &html; sub page{ &count; &DBConnect; $nowNo = $in{'No'}; if ($nowNo eq ""){ @res = (); $sth = $db->prepare("select max(No) from yudo where flag = \"on\""); if(!$sth->execute){ &error ("error code : E-01"); } $nowNo = $sth->fetchrow; } $sth = $db->prepare("select No,title,msg from yudo where No = \"$nowNo\" and flag = \"on\""); if(!$sth->execute){ &error ("error code : E-01"); } while(@res = $sth->fetchrow) { foreach(@res){ jcode::convert(\$_, 'sjis'); $_ =~ s/"/"/g; } $No = $res[0]; $title = $res[1]; $msg = $res[2]; } &DBDisconnect; $center .= <
遊道 -ゆうどう-
第$No回 $title
$msg
プロフィール 岡久 泰久 パチンコ産業コンサルタント

EOF } #----------------------# # バックナンバーページ # #----------------------# sub all { &DBConnect; $nowNo = $in{'No'}; if ($nowNo eq ""){ @res = (); $sth = $db->prepare("select max(No) from yudo where flag = \"on\""); if(!$sth->execute){ &error ("error code : E-01"); } $nowNo = $sth->fetchrow; } $sth = $db->prepare("select No,title,msg from yudo where No = \"$nowNo\" and flag = \"on\""); if(!$sth->execute){ &error ("error code : E-01"); } while(@res = $sth->fetchrow) { foreach(@res){ jcode::convert(\$_, 'sjis'); $_ =~ s/"/"/g; } $No = $res[0]; $title = $res[1]; $msg = $res[2]; } &DBDisconnect; $center .= <
遊道 -ゆうどう-
バックナンバー 一覧
EOF $start = ($p - 1) * $bncount; &DBConnect; $sth = $db->prepare("select No from yudo where flag = \"on\""); $allcount = eval{ $rows = $sth->execute }; $sth = $db->prepare("select No,title from yudo where flag = \"on\" order by No DESC LIMIT $start,$bncount"); if(!$sth->execute){ &error ("error code : E-05"); } $i = 0; while(@res = $sth->fetchrow) { foreach(@res){ jcode::convert(\$_, 'sjis'); $_ =~ s/"/"/g; } $i++; $No = $res[0]; $title2 = $res[1]; $center .= "\n"; } &DBDisconnect; # 総ページ数 $uc = ($allcount % $bncount); if ($uc == 0){ $user_cnt = int($allcount / $bncount); }else{ $user_cnt = int(($allcount / $bncount) + 1); } if ($p != 1){ $back = $p - 1; $center .= ""; } if ($p < $user_cnt){ $next = $p + 1; $center .= "過去の記事"; } $center .= <戻る EOF } #----------# # カウンタ # #----------# sub count { # カウントファイル $log = "count/yudo.dat"; # ロックファイル名 $lockfile = 'count/lock/yudo.lock'; &lock; #カウントファイル読込み open(IN,"$log"); $in_line = ; close(IN); #カウント1増やす $in_line++; #カウントファイル書込み open(OUT,">$log"); print OUT $in_line; close(OUT); &unlock; } sub lock { local($retry) = 5; while (!mkdir($lockfile, 0755)) { sleep(1); } } sub unlock { rmdir($lockfile); }