ラスボスに勝てばエンディングッて所まで漕ぎ着けるも、全然勝てないので売り払い。ここにきていよいよ戦闘がだるい。レベルを上げるのもマントラ埋めるのも飽きた。やる気でない。とりあえず25 時間遊んだし、もういいよな。買値と売値の差額も1,000 円程だったし。
野暮用で花巻に行って来ました。盛岡までは新幹線で30 分足らず。早いよなぁ。そりゃ青森から事業所の支店が次々と撤退していくわけだよ。盛岡支店があれば、青森に支店なんかいらんしね。まぁ盛岡から花巻までは普通列車で50 分くらいかかったわけなんですが。で、用を済ませてさっさと帰路についたわけですが花巻温泉に行きたかった。つか、電車に乗ったの酷く久しぶりだったわ。
移動中はひたすら、西風隆介著『竜の時間 亡国』を読んでました。で、続きが気になるけれど地元に続編が売ってない。これだから田舎は。
ビデオコンバーターを購入しパソコン用のモニタでプレステが楽しめるようになったので、『DIGITAL DEVIL SAGA アバタール・チューナー』を開始。ちなみに購入したビデオコンバーター、アイ・オー・データのVA BOX2 は縦置きスタンド付きッて事で縦置きにする気満々でしたが、モニタのコネクタとか背面に繋げていくとバランス悪すぎて結局は横置きにせざるを得ない。
もう少し、ほんの少し書き換えてみた。
#!/usr/local/bin/perl -wT
# CSS 選択スクリプト getstyle.cgi ver 3.0 by カヅサツ
# http://kadu.vis.ne.jp/main/other/script/selectstyle
use strict;
#----------------------------------------------------------------------------#
# 基本設定
#----------------------------------------------------------------------------#
my %config = (
host => 'http://127.0.0.1/', # サイトのホストとパス
home => 'http://127.0.0.1/index.html', # サイトのトップページ
root => '/', # ルートディレクトリ
days => 365, # クッキーの有効日数
);
#----------------------------------------------------------------------------#
# 処理
#----------------------------------------------------------------------------#
# データ読み込み
my $style = $ENV{QUERY_STRING};
# Cookie 消去(del_cookieなら, 有効日数に負の値を設定)
if ($style eq 'style=del_cookie') {
$config{days} = -1;
}
# Cookie 設定
my($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime(time + $config{days}*86400);
$mon = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec') [$mon];
$wday = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat') [$wday];
my $expires = sprintf("%s, %02d\-%s\-%04d %02d:%02d:%02d GMT",
$wday, $mday, $mon, $year+1900, $hour, $min, $sec);
# 参照元チェック
my $location = $ENV{HTTP_REFERER};
if ($location !~ /^$config{host}/ or $location =~ /getstyle.cgi/) {
$location = $config{home};
}
# ヘッダ出力
print "Status: 302 Found\n";
print "Set-Cookie: $style; expires=$expires; path=$config{root}\n";
print "Location: $location\n";
print <<"_____HTML_____";
Content-type: text/html; charset=Shift_JIS
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<title>Style was changed...</title>
</head>
<body>
<p>スタイルは変更されました。 cookie が利用可能\であれば反映されます。</p>
<ul>
<li><a href="$location">確認</a></li>
</ul>
</body>
</html>
_____HTML_____
そして、
#!/usr/local/bin/perl -wT
# CSS 選択スクリプト putstyle.cgi ver 3.0 by カヅサツ
# http://kadu.vis.ne.jp/main/other/script/selectstyle
use strict;
#----------------------------------------------------------------------------#
# 基本設定
#----------------------------------------------------------------------------#
my %config = (
dir => '/css/', # CSS用ディレクトリ
css => 'default', # デフォルトスタイル
charset => 'Shift_JIS', # 文字符号化方式
);
#----------------------------------------------------------------------------#
# 処理
#----------------------------------------------------------------------------#
# 任意設定(ある種のブラウザに対するデフォルトスタイルを指定)
my $agent = $ENV{HTTP_USER_AGENT};
if ($agent =~ /MSIE 3/) {
$config{css} = 'none';
} elsif ($agent =~ /MSIE 4/) {
$config{css} = 'none';
} elsif ($agent =~ /Emacs/) {
$config{css} = 'none';
} elsif ($agent =~ /Kagetaka/) {
$config{css} = 'none';
} elsif ($agent =~ /iCab/ and $agent =~ /2./) {
$config{css} = 'none';
} elsif ($agent =~ /Mozilla\/4/ and $agent !~ /MSIE/){
$config{css} = 'none';
}
# Cookie 読み込み
my %cookie;
foreach my $xx (split /; */, $ENV{HTTP_COOKIE}) {
my($name, $value) = split /=/, $xx;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$cookie{$name} = $value;
}
my $style = $cookie{style};
# Cookie を読み込まなかった場合、デフォルトスタイル
if ($style eq '') {
$style = $config{css};
}
# LINK 要素の出力
if ($style ne 'none' and $config{css} ne 'none') {
print "\n";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$config{dir}$style.css\" title=\"$style\" charset=\"$config{charset}\">";
}
# 他のPerlスクリプトからrequireされる場合、下のコメントを外す。
#1;
以上に伴い、select タグのname 値とoption タグのvalue 値もちょと変更。そんな訳で、呼び出しフォームの一例は以下の様に。
<form action="/cgi-bin/getstyle.cgi" method="get">
<p>
<label accesskey="S">STYLE :
<select name="style">
<option value="default">Default</option>
<option value="none">None</option>
<option value="del_cookie">Delete Cokkie</option>
</select>
</label>
<input type="submit" value="Query" accesskey="Q">
</p>
</form>
という事で、自分の為の覚え書きでした。
まともなスタイルシートなんて書けないけれど、スタイルシート切り替えスクリプトを使ってみたいんです。そんな考えなしの屁たれがですね、本に書かれている様に、-wT
とuse strict;
を付け足して変数をmy
で修飾してみたわけです。それだけ。ちなみに、
配布元の上記サイトでは既にver 4.1 になってますが、ココでは我が家のハードディスクに埋もれッ放しになっていたver 3.0 を使用。
#!/usr/local/bin/perl -wT
# CSS 選択スクリプト getstyle.cgi ver 3.0 by カヅサツ
# http://kadu.vis.ne.jp/main/other/script/selectstyle
use strict;
#----------------------------------------------------------------------------#
# 基本設定
#----------------------------------------------------------------------------#
# サイトのホストとパス
my $host = 'http://127.0.0.1/';
# デフォルトの飛び先
my $defaultlocation = 'http://127.0.0.1/index.html';
# ルートディレクトリ
my $root = '/';
# 有効期限(日数)
my $exdate = 365;
#----------------------------------------------------------------------------#
# 処理
#----------------------------------------------------------------------------#
# データの読み込み
my $style = $ENV{QUERY_STRING};
# cookie の有効期限。delcookieなら過去にする。
if ($style eq "mainstyle=delcookie") {
$exdate = -1;
}
my($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime(time + $exdate*86400);
$wday = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')[$wday];
$mon = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')[$mon];
my $expires = sprintf("%s, %02d\-%s\-%04d %02d:%02d:%02d GMT", $wday, $mday, $mon, $year+1900, $hour, $min, $sec);
# 参照元チェック
my $location = $ENV{HTTP_REFERER};
if ($location !~ /$host/ or $location =~ /getstyle.cgi/) {
$location = $defaultlocation;
}
# ヘッダの出力
print "Status: 302 Found\n";
print "Set-Cookie: $style; expires=$expires; path=$root\n";
print "Location: $location\n";
print <<"_____HTML_____";
Content-type: text/html; charset=Shift_JIS
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<title>Style was changed...</title>
</head>
<body>
<p>スタイルは変更されました。 cookie が利用可能\であれば反映されます。</p>
<ul>
<li><a href="$location">確認</a></li>
</ul>
</body>
</html>
_____HTML_____
で、
#!/usr/local/bin/perl -wT
# CSS 選択スクリプト putstyle.cgi ver 3.0 by カヅサツ
# http://kadu.vis.ne.jp/main/other/script/selectstyle
use strict;
#----------------------------------------------------------------------------#
# 基本設定
#----------------------------------------------------------------------------#
# CSS用ディレクトリ
my $styledir = 'http://127.0.0.1/css/';
# 文字符号化方式
my $charset = 'Shift_JIS';
# デフォルトスタイル
my $default = 'default';
# デフォルトスタイル(一部ブラウザ)
my $agent = $ENV{'HTTP_USER_AGENT'};
if ($agent =~ /MSIE 3/) {
$default = 'nostyle';
} elsif ($agent =~ /MSIE 4/) {
$default = 'nostyle';
} elsif ($agent =~ /Emacs/) {
$default = 'nostyle';
} elsif ($agent =~ /Kagetaka/) {
$default = 'nostyle';
} elsif ($agent =~ /iCab/ and $agent =~ /2./) {
$default = 'nostyle';
} elsif ($agent =~ /Mozilla\/4/ and $agent !~ /MSIE/) {
$default = 'nostyle';
}
#----------------------------------------------------------------------------#
# 処理
#----------------------------------------------------------------------------#
# Cookieの値を得る
my %cookie;
for my $xx (split /; */, $ENV{HTTP_COOKIE}) {
my($name, $value) = split /=/, $xx;
$value =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/pack("C", hex($1))/eg;
$cookie{$name} = $value;
}
my $style = $cookie{mainstyle};
# Cookie を読み込まなかった時はデフォルトのスタイル
if ($style eq '') {
$style = $default;
}
# LINK 要素の出力
if ($style ne "nostyle" and $default ne "nostyle") {
print "\n";
print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$styledir$style.css\" charset=\"$charset\" title=\"$style\">";
}
# 他のperlスクリプトからrequireされる場合、下のコメントを外す。
#1;
と、まぁこれだけ。
ディープワンに襲われて、逃げ続けると猫が何匹も現れて、その猫たちがディープワンを喰い始めて。いくら何でもディープワンは不味そうだ。野良猫だって喰うわけない。そこで目覚めて、あぁ今のは夢だったのかッて二度寝する夢を見た。