/[suikacvs]/markup/h2h/implementation/classic/h2h-edit/remote.ja.html.cgi
Suika

Contents of /markup/h2h/implementation/classic/h2h-edit/remote.ja.html.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Thu Aug 12 10:33:31 2004 UTC (20 years, 11 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Branch point for: norakuro-d
Imported into CVS repository - originally dated 2001-08-22

1 #!/usr/bin/perl
2
3 use Suika::CGI;
4
5 Suika::CGI::Error::die('open', file => $Suika::CGI::param{file})
6 unless -e $Suika::CGI::param{file};
7 Suika::CGI::Error::die('open', file => $Suika::CGI::param{file})
8 unless $Suika::CGI::param{file} =~
9 m#\.(?:h2h|hnf|html|txt)(?:\.(?:jis|euc|sjis|sj3|ej3))?$#;
10 if ($Suika::CGI::param{file} =~ m#^/usr/local/apache/htdocs/okuchuu/blue-oceans/([\x00-\xFF]+)$#) {
11 Suika::CGI::Error::die('open', file => $Suika::CGI::param{file})
12 unless $main::ENV{REMOTE_USER} =~ m#^(?:fujii|wakaba)$#;
13 $Suika::CGI::param{uri} ||= 'http://suika.fam.cx/okuchuu/blue-oceans/'.$1;
14 } elsif ($Suika::CGI::param{file} =~ m#^/usr/local/apache/htdocs/([\x00-\xFF]+)$#) {
15 Suika::CGI::Error::die('open', file => $Suika::CGI::param{file})
16 unless $main::ENV{REMOTE_USER} eq 'wakaba';
17 $Suika::CGI::param{uri} ||= 'http://suika.fam.cx/'.$1;
18 } elsif ($Suika::CGI::param{file} =~ m#^/home/wakaba/public_html/([\x00-\xFF]+)$#) {
19 Suika::CGI::Error::die('open', file => $Suika::CGI::param{file})
20 unless $main::ENV{REMOTE_USER} eq 'wakaba';
21 $Suika::CGI::param{uri} ||= 'http://suika.fam.cx/~wakaba/'.$1;
22 } else {
23 ## Permissionally deny.
24 Suika::CGI::Error::die('open', file => $Suika::CGI::param{file});
25 }
26
27 if ($Suika::CGI::param{mode} eq 'post') {
28 print edit_post(%Suika::CGI::param);
29 } else {
30 print edit_input(%Suika::CGI::param);
31 }
32
33 sub edit_input {
34 my %o = @_;
35
36 open H2H, $o{file}
37 or Suika::CGI::Error::die('open', file => $o{file});
38 my $h2h = _html(join('', <H2H>));
39 close H2H;
40
41 jcode::jis(<<EOH);
42 Content-Type: text/html; charset=jis_encoding
43 Content-Style-Type: text/css
44
45 <html lang="ja">
46 <head>
47 <title>$o{file}</title>
48 <link rel="stylesheet" href="/s/simpledoc" />
49 <meta name="ROBOTS" content="NOINDEX" />
50 </head>
51 <body>
52 <h1>ҏW</h1>
53
54 <form action="?" method="post" accept-charset="iso-2022-jp">
55
56 <p>{:<br />
57 <input type="hidden" name="file" value="$o{file}" />
58 <input type="hidden" name="mode" value="post" />
59 <textarea name="body" style="width: 90%; height: 20em; font-size: 100%">
60 $h2h
61 </textarea>
62 </p>
63
64 <p>
65 <input type="submit" value="OK" />
66 </p>
67 </form>
68
69 <address>
70 [<a href="/">/</a>]
71 [<a href="$o{uri}">$o{uri}</a>]
72 </address>
73 </body>
74 </html>
75 EOH
76 }
77
78 sub edit_post {
79 my %o = @_;
80
81 Suika::CGI::Error::die('empty') unless $o{body};
82 open H2H, '> '.$o{file}
83 or Suika::CGI::Error::die('write', file => $o{file});
84 print H2H $o{body};
85 close H2H;
86
87 edit_input(%o);
88 }
89
90 sub _html {
91 my $s = shift;
92 $s =~ s/&/&amp;/g;
93 $s =~ s/</&lt;/g;
94 $s =~ s/>/&gt;/g;
95 $s =~ s/"/&quot;/g;
96 $s;
97 }
98
99 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24