##########著作権表示(削除禁止)################### #Project by 0zero City de かんたんCGI #Script_name:zc_pcnt.pl $ver = 'ZC_PCNT ver-0.9';#'02/07/10 #Copyright(c)1998-2002 0zero City de かんたんCGI #Person in charge:Miki Nishio #Nakamuraku,Nagoyashi,Aichi, #All rights reserved. 2002/07/10 #The date which beginning script completed. 2002/05/20 #E-mail:zerocity@sb.starcat.ne.jp $home_url = 'http://www.zerocity.net/'; ################################################### # #::::::::::::::::::::::::::::注意事項:::::::::::::::::::::::::: #・このCGIスクリプトはフリーソフトですが著作権は放棄していません #・添付されている画像はフリーですが著作権は放棄していません #・著作権の表示(Copyright)は削除・変更禁止です #・このスクリプトを使用しての如何なる障害も作者及び制作サイトも # 責任は負いません #・詳しい利用規定は必ずお読み下さい #・詳しい利用規定 [URL-http://www.zerocity.net/cgi/miniregu.html] #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # #-------よくある質問CGIのetc/Windows上でCGIを実行--------------------------- # http://www.zerocity.net/q&a.html #=============================================================================== ###########################設定はここから####################################### #=============================================================================== #日本語処理用ライブラリ-------------------------------------★ require 'cgi-bin/zc_pcnt/jcode.pl'; #=============================================================================== #このスクリプトの設置場所-----------------------------------★★ $script = '././zc_pcnt.pl'; # #zc_pcnt.plの http で始まる絶対パス $tg_url = 'http://www.katekate.net/cgi-bin/zc_pcnt/zc_pcnt.pl'; #=============================================================================== #カウントデータファイル名-----------------------------------★★★★ $base = 'cgi-bin/zc_pcnt/count.dat'; #=============================================================================== #ホームページアドレス---------------------------------------★★★★★ $home = 'http://www.katekate.net/'; # #管理用パスワード-------------------------------------------★★★★★ $passw = 'katekate'; # #設定用パスワード-------------------------------------------★★★★★ $setpas = 'katekate'; #=============================================================================== #フォームの送信方法-----------------------------------------★★★★★★ $method = 'POST'; #=============================================================================== ###########################お好みに合わせて設定################################# #=============================================================================== #CGIスクリプト名 $title = 'ZC_PAGE-COUNTERU'; # #一覧の背景色 $b_color = '#FFFFFF'; # #壁紙を使用する場合は壁紙名$p_or_t $bg = 'back.gif'; # #一覧表示画面にパスワードをかける場合は 1 かけない場合は 2 $v_pass = 1; # #パスワード入力欄のタイプを「text」にする場合は 1「password」にする場合は 2 $p_or_t = 1; # #COOKIEを利用して同一人物をカウントしない時間 #1日の場合は 24 と時間単位で指定して下さい #使用しないときは 0 にしてください $incnt = 0; # #ロックファイル(データ破損機能)を使う場合は 1; 使わない場合は 0; $symlink = 0; #=============================================================================== ###########################設定はここまで####################################### #=============================================================================== &decode; $lockfile = './zc_pcnt.lock'; ##FORMデータによる分岐## if ($FORM{'call'} eq 'p_set') { &page; } else { &html; } ##ページ操作## sub page { ##パスワードチェック## if($FORM{'s_p'} ne $setpas) { &error(notpass); } ##エラーチェック## if ($FORM{'p_c'} =~ /\D/) { &error(not_word); } ##ロック開始## if ($symlink == 1) { &soft_lock; } ##カウンターファイルオープン## if(!open (DAT,"$base")) { &error(find_file); } @BASE = ; close (DAT); ##重複確認## foreach $cl (@BASE) { ($code,$name,$counts,$tag,) = split(/<->/,$cl); if($FORM{'p_c'} == "$code" && !$FORM{'p_n'}) { push(@ERASE,$cl); $flag = 1; } elsif($FORM{'p_c'} == "$code" && $FORM{'p_n'}) { $cl_value = "$FORM{'p_c'}\<\-\>$FORM{'p_n'}\<\-\>0\<\-\>$tg_url?pn\=$FORM{'p_c'}\<\-\>\n"; push(@NEW,$cl_value); $flag = 1; } else { push(@NEW,$cl); } } ##新ページを定義## if(!$flag) { $value = "$FORM{'p_c'}\<\-\>$FORM{'p_n'}\<\-\>0\<\-\>$tg_url?pn\=$FORM{'p_c'}\<\-\>\n"; unshift(@NEW,$value); } ##書込処理## if(!open (DAT,">$base")) { &error(find_file); } print DAT @NEW; close(DAT); ##ロックファイル削除## if (-e $lockfile) { unlink($lockfile); } &html; } ##カウント## sub count { if($incnt >= 1) { &get_cookie; } ##ロック開始## if ($symlink == 1) { &soft_lock; } ##カウンターファイルオープン## if(!open (DAT,"$base")) { &error(find_file); } @BASE = ; close (DAT); foreach $cl (@BASE) { ($code,$name,$counts,$tag,) = split(/<->/,$cl); if($FORM{'pn'} == "$code") { $cntup = $counts+1; $newline = "$code\<\-\>$name\<\-\>$cntup\<\-\>$tag\<\-\>\n"; push(@NEW,$newline); } else { push(@NEW,$cl); } } if(!open (DAT,">$base")) { &error(find_file); } print DAT @NEW; close(DAT); ##COOKIE書き込み## if ($incnt >= 1) { $accflag = 1; &cookie; } ##ロックファイル削除## if (-e $lockfile) { unlink($lockfile); } ##画像出力## @d_img = ('47','49','46','38','39','61','01','00','01','00','80','00','00','00','00','00','ff','ff','ff','2c','00','00','00','00','01','00','01','00','00','02','01','4c','00','3b','00','00','00','00','00','00','00','00','00','00','00','00','00','00'); print "Content-type: image/gif\n\n"; foreach (@d_img) { print pack('C*',hex($_)); } exit; } ##管理ページ## sub html { ##条件分岐## if($FORM{'pn'}) { &count; } ##パスワードチェック## if($v_pass == 1 && $FORM{'mpass'}) { if($FORM{'mpass'} ne $passw) { &error(notpass); } } else { &pass; } ##ロック開始## if ($symlink == 1) { &soft_lock; } ##データオープン## if(!open (DAT,"$base")) { &error(find_file); } @BASE = ; close (DAT); ##表示開始## &header; print "
$title
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
<<ホームに戻る利用方法>>
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
ページ番号ページ名設定用パス処理ボタン
 
\n"; print "

現在のページ番号・名前・カウント\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; foreach $line (@BASE) { ($code,$name,$counts,$tagu,) = split(/<->/,$line); print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if($FORM{'call'} eq 't_v' && $FORM{'t_c'} == "$code") { print "\n"; print "\n"; print "\n"; } } print "
番号名  前カウントタグボタン
$code$name$counts
<IMG Src\=\"$tagu\" Width\=\"1\" Height\=\"1\">

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "

ページ設定手順
[1]ページ番号を記入他のページと重複しない半角数字
[2]ページ名を記入カウントするページの名前
[3]設定用パスを記入最初に設定した設定用パス
[4]ENTERボタンを押すカウントするページが上に追加される
[5]カウント用タグを入手カウントするページのタグ表\示を押す(上の表\)
[6]タグをカウントするページに記入<BODY>〜<BODY>内のお好きな場所に記入

ページ削除手順
[1]削除するページ番号を記入半角数字で削除するページ番号
[2]設定用パスを記入最初に設定した設定用パス
[3]ENTERボタンを押すページが削除される

ページ名変更手順
[1]変更するページ番号を記入半角数字で変更するページ番号
[2]新しいページ名を記入新しいページの名前
[3]設定用パスを記入最初に設定した設定用パス
[4]ENTERボタンを押すページ名が変更される(カウントは0にリセット)

\n"; ©right; print "\n"; ##ロックファイル削除## if (-e $lockfile) { unlink($lockfile); } exit; } ##パス入力画面## sub pass { if($p_or_t == 1) { $win_typ = 'text'; } else { $win_typ = 'password'; } ##表示開始## &header; print "
$title\n"; print "
管理用パスワードを入れ ENTER を押して下さい
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; ©right; print "\n"; exit; } ##HTMLヘッダー## sub header { print "Content-type: text/html\n\n"; print < $title EOHTM } ##COOKIE書込## sub cookie { ($secg,$ming,$hourg,$mdayg,$mong,$yearg,$wdayg,$ydayg,$isdstg) = gmtime(time + $incnt*60*60); $yearg += 1900; if ($secg < 10) { $secg = "0$secg"; } if ($ming < 10) { $ming = "0$ming"; } if ($hourg < 10) { $hourg = "0$hourg"; } if ($mdayg < 10) { $mdayg = "0$mdayg"; } $month = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$mong]; $youbi = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')[$wdayg]; $date_gmt = "$youbi, $mdayg\-$month\-$yearg $hourg:$ming:$secg GMT"; $cook= "ACCFLAG\:$accflag"; print "Set-Cookie: $ckname=$cook; expires=$date_gmt\n"; } ##COOKIE取得## sub get_cookie { @pairs = split(/\;/,$ENV{'HTTP_COOKIE'}); foreach $pair (@pairs) { local($name, $value) = split(/\=/, $pair); $name =~ s/ //g; $DUMMY{$name} = $value; } @pairs = split(/,/,$DUMMY{$ckname}); foreach $pair (@pairs) { local($name, $value) = split(/\:/, $pair); $COOKIE{$name} = $value; } } ##フォームからのデータを連想配列に格納## sub decode { if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $formdata, $ENV{'CONTENT_LENGTH'}); } else { $formdata = $ENV{'QUERY_STRING'}; } @pairs = split(/&/,$formdata); ##区切り文字・タグ等の処理## foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\n//g; $value =~ s/\,/,/g; &jcode'convert(*value,'sjis'); $FORM{$name} = $value; } } ##著作権表示(削除禁止)## sub copyright { print "
--\(C\)$ver--
\n"; } ##ファイルロック## sub soft_lock { $try=5; while(-f "$lockfile"){ if(--$try<=0) { &error(bisy); } sleep(1); } if(!open(FILE,">$lockfile")) { &error(bisy); } close(FILE); } ##エラー処理## sub error { if (-e $lockfile) { unlink($lockfile); } $error = $_[0]; if ($error eq 'find_file') { $errmsg = 'データ用ファイルがないか書き込み削除が出来ません'; } elsif ($error eq 'notpass') { $errmsg = 'パスワードが違います。'; } elsif ($error eq 'not_word') { $errmsg = 'ページの番号に半角数字以外が使われています'; } elsif ($error eq 'bisy') { $errmsg = '只今ロック中です。'; } else { $errmsg = '原因不明です もう一度試してみてください'; } &header; print "
$title


\n"; print "
An error was outputted
\n"; print "(エラーが出ました)
\n"; print "
As for the expected cause
\n"; print "(原因は以下が予\想されます)
\n"; print "
$errmsg
\n"; print "\n"; exit; }