X-Git-Url: https://git.p6c8.net/selfforum.git/blobdiff_plain/9b9648223ab2db3960298d04b83ecdd147ec21e9..e4c8bdafb631e419bdfdad87b6d80e17470044c4:/selfforum-cgi/user/fo_posting.pl?ds=sidebyside diff --git a/selfforum-cgi/user/fo_posting.pl b/selfforum-cgi/user/fo_posting.pl index 1fe42a9..5046a5c 100644 --- a/selfforum-cgi/user/fo_posting.pl +++ b/selfforum-cgi/user/fo_posting.pl @@ -16,6 +16,7 @@ use vars qw( $Shared $Script $Config + $VERSION ); # locate the script @@ -27,13 +28,17 @@ BEGIN { $Config = "$Bin/config"; $Script = ($null =~ /^.*\/(.*)$/)? $1 : $null; -# my $null = $0; #$null =~ s/\\/\//g; # for win :-( +# my $null = $0; # $Bin = ($null =~ /^(.*)\/.*$/)? $1 : '.'; -# $Config = "$Bin/../../../cgi-config/devforum"; -# $Shared = "$Bin/../../../cgi-shared"; +# $Config = "$Bin/../../daten/forum/config"; +# $Shared = "$Bin/../../cgi-shared"; # $Script = ($null =~ /^.*\/(.*)$/)? $1 : $null; } +# setting umask, remove or comment it, if you don't need +# +umask 006; + use lib "$Shared"; use CGI::Carp qw(fatalsToBrowser); @@ -41,6 +46,10 @@ use Conf; use Conf::Admin; use Posting::Cache; +# Version check +# +$VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + # load script configuration and admin default conf. # my $conf = read_script_conf ($Config, $Shared, $Script); @@ -74,11 +83,11 @@ $request -> severance; ### Posting::Request ########################################################### package Posting::Request; -use Arc::Archive; +use Arc::Starter; use CheckRFC; use Encode::Plain; $Encode::Plain::utf8 = 1; # generally convert from UTF-8 use Encode::Posting; -use Lock qw(:ALL); +use Lock; use Posting::_lib qw( hr_time parse_xml_file @@ -132,16 +141,7 @@ sub new { sub severance { my $self = shift; - my $stat = cut_tail ({ - forumFile => $self -> {conf} -> {forum_file_name}, - messagePath => $self -> {conf} -> {message_path}, - archivePath => $self -> {conf} -> {original} -> {files} -> {archivePath}, - lockFile => $self -> {conf} -> {original} -> {files} -> {sev_lock}, - adminDefault => $self -> {conf} -> {admin}, - cachePath => $self -> {conf} -> {original} -> {files} -> {cachePath} - }); -# die $stat->{(keys %$stat)[0]} if (%$stat); - + start_severance ($self -> {conf} -> {original} -> {files} -> {sev_app}); } ### sub response ############################################################### @@ -500,7 +500,7 @@ sub save { # unlock forum main file # if ($self -> {forum} -> {flocked}) { - violent_unlock_file($self -> {conf} -> {forum_file_name}) unless write_unlock_file ($self -> {conf} -> {forum_file_name}); + $self -> {forum} -> {flocked} -> unlock; $self -> {forum} -> {flocked} = 0; } @@ -538,13 +538,12 @@ sub parse_cgi { # sub load_main_file { my $self = shift; - my $lock_stat; + my $forum = new Lock ($self -> {conf} -> {forum_file_name}); - unless ($lock_stat = write_lock_file ($self -> {conf} -> {forum_file_name})) { - if (defined $lock_stat) { + unless ($forum -> lock(LH_EXCL)) { + unless ($forum -> masterlocked) { # occupied or no w-bit set for the directory..., hmmm # - violent_unlock_file ($self -> {conf} -> {forum_file_name}); $self -> {error} = { spec => 'occupied', type => 'repeat' @@ -562,7 +561,7 @@ sub load_main_file { } } else { - $self -> {forum} -> {flocked} = 1; + $self -> {forum} -> {flocked} = $forum; ( $self -> {forum} -> {threads}, $self -> {forum} -> {last_thread}, $self -> {forum} -> {last_message}, @@ -837,8 +836,29 @@ sub check_cgi { # (my $val_ww = $val) =~ s/\s+//g; - $val_ww =~ y/a-zA-Z//cd - if (exists ($formdata -> {$name {$_}} -> {type}) and $formdata -> {$name {$_}} -> {type} eq 'name'); + if (exists ($formdata -> {$name {$_}} -> {type}) and $formdata -> {$name {$_}} -> {type} eq 'name') { + $val_ww =~ y/a-zA-Z//cd; + + my @badlist; +# my @badlist = map {qr/\Q$_/i} qw ( +# # insert badmatchlist here +# ); + +# push @badlist => map {qr/\b\Q$_\E\b/i} qw( +# # insert badwordlist here +# ); + + for (@badlist) { + if ($val_ww =~ /$_/) { + $self -> {error} = { + spec => 'undesired', + desc => $name{$_}, + type => 'fatal' + }; + return; + } + } + } if (length $val_ww < $formdata -> {$name {$_}} -> {minlength}) { $self -> {error} = { @@ -935,11 +955,11 @@ sub fetch { my $formdata = $self -> {conf} -> {form_data}; if (@{$self -> {fetch}}) { - my $filename = $self -> {conf} -> {message_path}.'t'.$self -> {fup_tid}.'.xml'; + my $thread = new Lock ($self -> {conf} -> {message_path}.'t'.$self -> {fup_tid}.'.xml'); - if (lock_file ($filename)) { - my $xml = parse_xml_file ($filename); - violent_unlock_file($filename) unless unlock_file ($filename); + if ($thread -> lock (LH_SHARED)) { + my $xml = parse_xml_file ($thread -> filename); + $thread -> unlock; if ($xml) { my $mnode = get_message_node ($xml, 't'.$self -> {fup_tid}, 'm'.$self -> {fup_mid});