Initial checkin.

Signed-off-by: Thomas Hochstein <thh@thh.name>
This commit is contained in:
Thomas Hochstein 2022-01-29 10:22:11 +01:00
commit 30132626b8
68 changed files with 5497 additions and 0 deletions

24
samples/crontab Normal file
View file

@ -0,0 +1,24 @@
MAILTO=administrator@webinterface.site
PERL5LIB=/srv/www/huhu
CONFIG=/srv/www/SAMPLE/home/etc/SAMPLE_pub.config
BINDIR=/srv/www/huhu/bin
HTMLDIR=/srv/www/SAMPLE/html
# mailget.pl reads incoming mail via POP3, stores them in database.
# If you use procmailrc then you don't need this.
# */5 * * * * $BINDIR/mailget.pl $CONFIG
# Reads database, sends outgoing messages via NNTP.
*/5 * * * * $BINDIR/poster.pl $CONFIG;
# Show number of posts and reaction time.
3 * * * * $BINDIR/statistics.pl $CONFIG > $HTMLDIR/stats/stats.txt
# Remove old records from database
5 3 * * * $BINDIR/removeold.pl $CONFIG
# Reads database, sends reply to sender of mail that message is in queue.
# 10 * * * * $BINDIR/autoreply.pl $CONFIG
# Reads database, announces incoming mail in IRC channel.
# @reboot $BINDIR/ircbot.pl $CONFIG

15
samples/modtable.pl Normal file
View file

@ -0,0 +1,15 @@
#!/usr/bin/perl -w
use strict;
use warnings;
$ENV{'CONTENT_TYPE'} = "multipart/form-data";
use CGI::Carp 'fatalsToBrowser';
BEGIN {
push (@INC,'/srv/www/huhu');
}
use MOD::Handler;
my $h = MOD::Handler->new('/srv/www/sample/home/etc/sample_pub.config');
$h->run();

86
samples/mysql/create.sql Normal file
View file

@ -0,0 +1,86 @@
#
# $Id: create.sql 304 2011-11-02 14:14:01Z root $
#
# Create statement for mysql. Replace @sample@ with your table prefix.
# For example:
# sed 's/@sample@/atm/g' < create.sql
#
CREATE TABLE @sample@ (
ID bigint NOT NULL auto_increment,
# 'spam' ... can be put back to 'pending' queue
# 'moderated' ... tells poster.pl to send the message,
# can be put back to 'pending' queue
# 'rejected' ... a mail was sent to the author - cannot be undone
# 'deleted' ... can be put back to 'pending' queue
# 'posted' ... message was sent to server - cannot be undone
# 'sending' ... poster.pl is trying to send article to server,
# next state is 'moderated', 'posted', or 'broken'
# 'broken' ... poster.pl encountered a fatal error
Status ENUM(
'pending',
'spam',
'moderated',
'rejected',
'deleted',
'posted',
'sending',
'broken'
) NOT NULL,
Sender text NOT NULL,
ReplyTo text,
Subject text NOT NULL,
MessageID text DEFAULT NULL,
Datum DATETIME NOT NULL,
Header longblob NOT NULL,
Body longblob NOT NULL,
Spamcount float DEFAULT 0.0,
Moderator varchar(20),
Moddatum DATETIME,
checksum char(40) UNIQUE,
flag bool DEFAULT 0,
PRIMARY KEY (ID),
KEY(status),
KEY(Datum),
KEY(Moddatum),
KEY(checksum),
KEY(subject(40)),
KEY(flag)
);
# DROP TABLE @sample@_error;
CREATE TABLE @sample@_error (
error_id BIGINT NOT NULL AUTO_INCREMENT,
article_id BIGINT,
error_date DATETIME NOT NULL,
# Number of duplicate (article_id,error_message) tuples.
error_count INT(2) DEFAULT 0 NOT NULL,
error_message TEXT,
PRIMARY KEY (error_id),
UNIQUE(article_id, error_message(40)),
FOREIGN KEY (article_id) REFERENCES @sample@(id) ON DELETE CASCADE
);
CREATE OR REPLACE VIEW @sample@_error_view AS
SELECT id,
flag,
sender AS article_sender,
subject AS article_subject,
status AS article_status,
error_id,
error_date,
error_count,
error_message
FROM @sample@_error AS _error
LEFT JOIN (@sample@ AS _article)
ON _error.article_id = _article.id;
# DROP TABLE @sample@_reply;
CREATE TABLE @sample@_reply (
reply_id BIGINT NOT NULL AUTO_INCREMENT,
article_id BIGINT,
reply_date DATETIME NOT NULL,
reply_message TEXT,
PRIMARY KEY (reply_id),
KEY(article_id),
FOREIGN KEY (article_id) REFERENCES @sample@(id) ON DELETE CASCADE
);

View file

@ -0,0 +1,17 @@
#
# $Id: update-0.05-to-0.06.sql 102 2009-09-16 18:46:27Z alba $
#
# Update from version 0.05 to 0.06
# Check for errors (should return no rows)
SELECT status,posted FROM @sample@ WHERE posted and status <> 'moderated';
SELECT status,posted FROM @sample@ WHERE status = 0;
# Add value 'posted' to column 'status'.
ALTER TABLE @sample@ CHANGE Status Status enum('pending','spam','moderated','rejected','deleted','posted');
# Transfer column 'posted' to column 'status'.
UPDATE @sample@ SET Status = 'posted' WHERE posted;
# Remove column 'posted'.
ALTER TABLE @sample@ DROP column posted;

View file

@ -0,0 +1,22 @@
#
# $Id: update-0.06-to-0.07.sql 115 2009-09-20 10:09:22Z alba $
#
# Update from version 0.06 to 0.07
# First use create.sql to create table @sample@_error
# Copy columns errorcount and errormessage to table @sample@_error
INSERT INTO @sample@_error
(article_id, error_date, error_count, error_message)
SELECT a.id, NOW(), a.errorcount, a.errormessage
FROM @sample@ a
WHERE errorcount > 0;
# Drop columns errorcount and errormessage
ALTER TABLE @sample@ DROP column errorcount;
ALTER TABLE @sample@ DROP column errormessage;
# Test record:
# INSERT INTO @sample@_error (article_id, error_date, error_count, error_message) VALUES(10, NOW(), 17, 'huhu');
# INSERT INTO @sample@_error (article_id, error_date, error_count, error_message) VALUES(11, NOW(), 3, 'berta');
# SELECT * FROM @sample@_error;

View file

@ -0,0 +1,7 @@
#
# $Id: update-0.07-0.08.sql 121 2009-09-20 15:32:22Z alba $
#
# Update from version 0.07 to 0.08
ALTER TABLE @sample@ CHANGE Status Status ENUM('pending','spam','moderated','rejected','deleted','posted','sending');

View file

@ -0,0 +1,16 @@
#
# $Id: update-0.08-0.09.sql 145 2009-10-11 20:00:45Z alba $
#
# Update from version 0.08 to 0.09
# First use create.sql to create table @sample@_reply
# Copy column Answer to table @sample@_reply
INSERT INTO @sample@_reply
(article_id, reply_date, reply_message)
SELECT a.id, IFNULL(a.Moddatum, NOW()), a.answer
FROM @sample@ a
WHERE a.answer is not null;
# Drop column Answer
ALTER TABLE @sample@ DROP COLUMN answer;

View file

@ -0,0 +1,8 @@
#
# $Id: update-0.07-0.08.sql 121 2009-09-20 15:32:22Z alba $
#
# Update from version 0.07 to 0.08
ALTER TABLE @sample@ CHANGE COLUMN Status
Status ENUM('pending','spam','moderated','rejected','deleted','posted','sending','broken') NOT NULL;

19
samples/procmailrc Normal file
View file

@ -0,0 +1,19 @@
#
# Save this file as $HOME/.procmailrc
#
LOGFILE=$HOME/procmail.log
PATH=/usr/bin:/bin
VERBOSE=yes
PERL5LIB=/srv/www/huhu
# save mails in backup directory
:0 c
backup
# trim backup directory
:0 ic
| cd backup && rm -f dummy `ls -t msg.* | sed -e 1,32d`
# add incoming mail to database
:0
| /srv/www/huhu/bin/read-mail.pl /srv/www/SAMPLE/home/etc/SAMPLE_pub.config

14
samples/public.pl Normal file
View file

@ -0,0 +1,14 @@
#!/usr/bin/perl
use strict;
use warnings;
use CGI::Carp 'fatalsToBrowser';
$ENV{'CONTENT_TYPE'} = "multipart/form-data";
BEGIN {
push (@INC,'/srv/www/huhu/');
}
require MOD::PublicHandler;
my $h = MOD::PublicHandler->new('/srv/www/SAMPLE/home/etc/SAMPLE_pub.config');
$h->run();