文書管理CGIを改良しました。改良点は次の2点です
各スクリプトは下記のようになります。また、関連のディレクトリーは次のようになります。
| /home/httpd/cgi-bin/ | A.cgi と page.cgi を置きます。 |
| /home/(user id)/public_html/contents | Jpeg ファイルと、index.html、B.htmlを置きます。 |
改良文書管理 CGI は次の4つの文書からなります。赤字の部分がそれぞれの環境で設定する部分です。準備ができたら netscape http://(hostname)/~(user id)/contents で表示させてみてください。
セキュリーティー的にはあまり感心しないプログラムなので個人的な LAN で使うだけにしてください。(2001/03/05)
表示用のフレームを表示する HTML 文書です。/home/(user id)/public_html/contents に置きます。
<html> <head><title>index.html</title></head> <frameset cols="100, *"> <frame src="http://(hostname)/cgi-bin/A.cgi?location=contents/&size=100%" name="list"> <frame src="B.html" name="main"> </frameset> </html>
文書を表示する main フレームに最初に表示する文書です。/home/(user id)/public_html/contents/ ディレクトリーに置きます。
<html> <head><title>Image viewer</title></head> <body bgcolor="white"> <br><br> <center><h1>Image Viewer Ver 0.1</h1><center> </body>
ディレクトリーの内容をリスト表示する CGI です。/home/httpd/cgi-bin/ ディレクトリーに置きます。
#!/usr/bin/perl
use CGI;
$query = new CGI;
$size = $query->param('size');
$location = $query->param('location');
$docroot = '/home/(user id)/public_html';
$hostname = 'http://lxmaster';
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD><TITLE>index page</TITLE>\n";
print "<BASE TARGET=\"main\"></HEAD>\n";
print "<BODY>\n";
$parent = $location;
$parent =~ s/\/[^\/]*\/[^\/]*$//;
print "<a href=\"$hostname/cgi-bin/A.cgi?location=$parent/&size=$size\" target=\"list\">../</a><br>\n";
@list = `ls $docroot/$location`;
while ($file = shift(@list)) {
chop($file);
if (-d "$docroot/$location/$file") {
print "<a href=\"$hostname/cgi-bin/A.cgi\?location=$location/$file&size=$size\" target=\"list\">$file/</a><br>\n";
}
if ($file =~ /.jpg|.gif/) {
print "<A HREF=\"$hostname/cgi-bin/page.cgi?location=$location/$file\&size=$size\">$file</A><BR>\n";
}
}
print "<BR>\n";
print "<A HREF=\"$hostname/cgi-bin/A.cgi?location=$location\&size=50%\" TARGET=\"list\">50%</A><BR>\n";
print "<A HREF=\"$hostname/cgi-bin/A.cgi?location=$location\&size=100%\" TARGET=\"list\">100%</A><BR>\n";
print "<A HREF=\"$hostname/cgi-bin/A.cgi?location=$location\&size=150%\" TARGET=\"list\">150%</A><BR>\n";
print "<A HREF=\"$hostname/cgi-bin/A.cgi?location=$location\&size=200%\" TARGET=\"list\">200%</A><BR>\n";
print "</BODY>\n";
print "</HTML>\n";
指定されたファイルをフレームに表示するための CGI です。/home/httpd/cgi-bin/ ディレクトリーに置きます。
#!/usr/bin/perl
use CGI;
$query = new CGI;
$location = $query->param('location');
$size = $query->param('size');
$docroot = 'http://(hostname)/~(user id)';
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>page print</TITLE></HEAD>\n";
print "<BODY><IMG SRC=\"$docroot/$location$file\" WIDTH=$size></BODY>\n";
print "</HTML>\n";