--JAVAscriptで呼び出すカウンタスクリプト --解説 http://mizusawa.no-ip.com:8080/js_as_counter/index.html --Tanaka's OSAX 2.01が必要です。 --ver0.1 2003/1/30 最初のバージョン --ver0.2 2003/12/1 カウントファイル名の指定が可能に。例:counter.acgi?cntFile=indexCount2 property thisDir : "" --スクリプトのあるディレクトリが入る property countFile : "" --カウントファイル名 property crlf : (ASCII character 13) & (ASCII character 10) on run set thisDir to (":" as alias) as string --パス取得 --自動取得↑がうまくいかない場合は↓手動で設定してね。 --set thisDir to "" --スクリプトのあるパス end run on handle CGI request urlPath searching for getData with posted data postData --受けた引数を一本化 if (postData as text) = "" then set postGetData to getData as text else set postGetData to postData as text end if set countFile to "indexCount" -- ★★★ カウントファイル名初期化 ★★★--------------設定必須 if postGetData ュ "" then --空でなければ --中身を分解。OSAX使用 set {cntFile} to MT Parse CGI postGetData --cntFileを取り出す set countFile to cntFile --カウントファイル名を差し替え end if try set oldNum to (MT Read File ((thisDir as text) & countFile)) --カウンタファイルの読込 set newNum to oldNum + 1 on error errnum --ファイルがなかったら set newNum to 1 -- set newNum to errnum & return & thisDir & countFile end try MT Write File newNum to file (thisDir & countFile) --カウンタファイルに上書き --表示処理 --set retJava to "Content-Type: text/javascript" & crlf & crlf set retJava to "document.write('" & newNum & "');" & crlf return retJava end handle CGI request