http://???/~foo/bar/index.htmlに設置する場合(すべての必要ファイルは同一ディレクトリにあることが必須条件) /~foo/bar ┳ index.html このファイルにコメント文(SSI)または<IMG>タグをD&Dします。(属性以外は編集可能です) (chmod 755) ┣ rand.pl Perlスクリプト ┣ rand_pl.log <IMG SRC="???">を格納したファイル:選択された1行がそのまま表示される。 ┣ .htaccess SSIを使用可能にするためのファイル(ファイル名がドットではじまります)。 ┣ (rand.cgi) CGIスクリプト ┗ (rand_cgi.log) ファイル名のみを格納したファイル
※SSI版のみ<IMG>タグの属性が指定できます。 |
|
|
|
#!/usr/bin/perl
#ランダム画像表示スクリプト
#ログファイルのパス
$log_file = "./";
#ログファイル名
$log_file .= "rand_pl.log";
if (open (LOG, "$log_file")){
@logs = <LOG>;
close (LOG);
} else {
print "\"File does not exist : $log_file\"";
die "\"File does not exist : $log_file\"";
}
srand(time|$$);
$seed = int (rand($#logs)) + 1;
print "$logs[$seed]";
exit;
#!/usr/bin/perl
#ランダム画像表示スクリプト
#ログファイルのパス
$log_file = "./";
#ログファイル名
$log_file .= "rand_cgi.log";
#画像ファイルのパス
$src = "./";
if (open (LOG, "$log_file")){
@logs = <LOG>;
close (LOG);
} else {
print "\"File does not exist : $log_file\"";
die "\"File does not exist : $log_file\"";
}
srand(time|$$);
$seed = int (rand($#logs)) + 1;
$src .= $logs[$seed];
print "Content-type: image/gif\n\n";
if (open (IMAGE, "$src")) {
while (<IMAGE>) {
print;
}
close (IMAGE);
} else {
die "\"File does not exist : $src\"";
}
exit;