Initial commit.

This commit is contained in:
2026-03-10 21:25:26 +08:00
commit 78739bf725
3089 changed files with 472990 additions and 0 deletions

View File

@@ -0,0 +1,145 @@
#! /usr/bin/perl -w
# Woman's Voice
# 1-guestbook.cgi: The guestbook.
# Copyright (c) 2003-2021 imacat.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Author: imacat <imacat@mail.imacat.idv.tw>
# First written: 2003-04-06
use 5.008;
use utf8;
use strict;
use warnings;
use lib $ENV{"DOCUMENT_ROOT"} . qw(/magicat/lib/perl5);
use Selima::wov;
local $SIG{"__DIE__"} = \&http_500;
my $d = new Selima::Destroy;
# Prototype declaration
sub main();
sub check_get();
sub check_post();
sub html_page($);
sub html_foreword();
initenv(-session => 0,
-this_table => "guestbook",
-dbi_lock => {"guestbook" => LOCK_EX},
-lastmod => 1,
-page_param => {"keywords" => N_("your voice"),
"class" => "guestbook",
"javascripts" => [qw(/scripts/guestbook.js)]});
main;
exit 0;
sub main() {
local ($_, %_);
my ($error, $processor);
# If the request is a GET query
if ($ENV{"REQUEST_METHOD"} ne "POST") {
$error = check_get;
# If an error occurs
if (defined $error) {
html_page $error;
# Display the page
} else {
html_page retrieve_status;
}
# If a form was POSTed from the client
} else {
$error = check_post;
# If an error occurs
if (defined $error) {
error_redirect $error;
# Else, save the data
} else {
$processor = new Selima::wov::Processor::Guestbook::Public($POST);
$processor->process;
http_303 $REQUEST_FILE;
}
}
return;
}
# check_get: Check the GET arguments
sub check_get() {
local ($_, %_);
# Old styled page number
http_301 $REQUEST_FILE if defined $GET->param("no");
# List handler handles its own error
return;
}
# check_post: Check the POSTed form
sub check_post() {
local ($_, %_);
my ($checker, $error);
# Run the checker
$checker = new Selima::wov::Checker::Guestbook::Public(curform);
$error = $checker->check(qw(message name identity location
email url flood dup spam));
return $error if defined $error;
# OK
return;
}
# html_page: Display the page
sub html_page($) {
local ($_, %_);
my ($status, $LIST, $FORM, $args);
$status = $_[0];
$FORM = new Selima::wov::Form::Guestbook::Public($status);
$LIST = new Selima::wov::List::Guestbook::Public;
$args = $LIST->page_param;
html_header "妳的女聲", "Your Voice", $args;
html_foreword;
html_errmsg $status;
$FORM->html;
$LIST->html;
html_footer $args;
return;
}
##################################
# Subroutines to manage the data #
##################################
# html_foreword: Print the HTML foreword
sub html_foreword() {
local ($_, %_);
print << "EOT";
<div class="intro">
<p>發聲就是政治,是權力,是對主體性的要求。</p>
<p>女聲就是女人的聲音。聲音有的好聽,有的不好聽,有的悅耳,有的嘈雜。
也許\是學者、是政要、是學生、是女兒、是媽媽、是女同性戀、是雙性戀、是
女工、是菲傭、是公娼、是私娼、是雛妓、是打工辣妹、是家庭主婦、是心理
女性。可能都是,也可能都不是。這些都是女人,她們的聲音都同等重要,在
差異中尋求最適合自己的生存策略。</p>
<p>更重要的是,身為女人,是政治行動,不只是天生的命運。</p>
</div>
EOT
return;
}
no utf8;

View File

@@ -0,0 +1,121 @@
#! /usr/bin/perl -w
# Woman's Voice
# 1-subs_counter.cgi: The subscriber counter.
# Copyright (c) 2003-2021 imacat.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Author: imacat <imacat@mail.imacat.idv.tw>
# First written: 2003-05-17
use 5.008;
use strict;
use warnings;
use lib $ENV{"DOCUMENT_ROOT"} . qw(/magicat/lib/perl5);
use Selima::wov;
local $SIG{"__DIE__"} = \&http_500;
my $d = new Selima::Destroy;
# Prototype declaration
sub main();
sub get_counter();
sub html_image($);
use Fcntl qw(:flock :seek);
use GD;
use IO::NestedCapture qw(CAPTURE_STDOUT);
use constant DATA_FILE => "/var/lib/mailman/lists/wov/config.pck";
use constant COUNTER_PROG => "/usr/libexec/total_members";
use constant LISTNAME => "wov";
use vars qw(@FGCOLOR @BGCOLOR $FONT);
@FGCOLOR = (0, 0, 0); # #000000 Black
@BGCOLOR = (255, 255, 255); # #FFFFFF White
$FONT = gdLargeFont;
use constant TRANSPARENT => 1;
initenv( -allowed => [qw(GET HEAD)],
-session => 0,
-dbi => DBI_NONE,
-lastmod => 1,
-lmfiles => [DATA_FILE],
-multilang => 0);
use vars qw($COUNTER $MTIME);
main;
exit 0;
sub main() {
local ($_, %_);
get_counter();
html_image($COUNTER);
return;
}
# get_counter: Get the subscriber counter
sub get_counter() {
local ($_, %_);
my $OUT;
# Obtain the mtime of the subscriber database file
$_ = (stat DATA_FILE)[9];
# We should update the counter
if (!defined $MTIME || $MTIME != $_) {
# Update the timestamp
$MTIME = $_;
@_ = (COUNTER_PROG, LISTNAME);
open $OUT, "-|", @_ or http_500 COUNTER_PROG . ": $!";
defined($COUNTER = <$OUT>) or http_500 COUNTER_PROG . ": $!";
close $OUT or http_500 COUNTER_PROG . ": $!";
chomp $COUNTER;
}
return $COUNTER;
}
# html_image: Make the image from the counter value
sub html_image($) {
local $_;
my ($counter, $image, $width, $height, $fgcolor, $bgcolor);
$counter = $_[0];
# Group the counter with commas at thousand digits.
$counter = fmtno($counter);
# Initialize the image object
# Get the width and height
$width = $FONT->width * (length $counter);
$height = $FONT->height;
# Create an image object
$image = GD::Image->new($width, $height);
# Create the forground/background color objects
$fgcolor = $image->colorAllocate(@FGCOLOR);
$bgcolor = $image->colorAllocate(@BGCOLOR);
# Draw the image
# Set the transparent background
$image->transparent($bgcolor) if TRANSPARENT;
# Paint the background
$image->filledRectangle(0, 0, $width, $height, $bgcolor);
# Write the text
$image->string($FONT, 0, 0, $counter, $fgcolor);
# Output
$CONTENT_TYPE = "image/png";
binmode IO::NestedCapture->instance->{"STDOUT_current"}[-1], ":raw";
print $image->png;
return;
}