]>
git.p6c8.net - selfforum.git/blob - selfforum-cgi/user/fo_voting.pl
3 ################################################################################
5 # File: user/fo_voting.pl #
7 # Authors: André Malo <nd@o3media.de>, 2001-04-23 #
9 # Description: vote a posting, return the posting view #
11 ################################################################################
23 my $null = $0; $null =~ s/\\/\//g
; # for win :-(
24 $Bin = ($null =~ /^(.*)\/.*$/)?
$1 : '.';
25 $Shared = "$Bin/../shared";
26 $Config = "$Bin/config";
27 $Script = ($null =~ /^.*\/(.*)$/)?
$1 : $null;
30 # $Bin = ($null =~ /^(.*)\/.*$/)? $1 : '.';
31 # $Config = "$Bin/../../daten/forum/config";
32 # $Shared = "$Bin/../../cgi-shared";
33 # $Script = ($null =~ /^.*\/(.*)$/)? $1 : $null;
36 # setting umask, remove or comment it, if you don't need
41 use CGI
::Carp
qw(fatalsToBrowser);
46 use Template
::Posting
;
48 use CGI
qw(param header remote_addr request_method);
52 $VERSION = do { my @r =(q
$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x
$#r, @r };
54 my $conf = read_script_conf
($Config, $Shared, $Script);
56 my $show = $conf -> {show
};
57 my $show_forum = $show -> {Forum
};
58 my $show_posting = $show -> {Posting
};
59 my $cgi = $show -> {assign
} -> {cgi
};
60 my $tree = $show -> {assign
} -> {thread
};
61 my $adminDefault = read_admin_conf
($conf -> {files
} -> {adminDefault
});
63 my $forum_file = $conf -> {files
} -> {forum
};
64 my $message_path = $conf -> {files
} -> {messagePath
};
66 my $formdata = $show_posting -> {form
} -> {data
};
67 my $fup = param
($formdata -> {followUp
} -> {name
}) || '';
68 my $unid = param
($formdata -> {uniqueID
} -> {name
}) || '';
71 my ($tid, $mid) = map {$_ || 0} split /;/ => $fup, 2;
73 $tid = ($tid=~/(\d+)/)[0] || 0;
74 $mid = ($mid=~/(\d+)/)[0] || 0;
76 if ($tid and $mid and $unid) {
78 print header
(-type
=> 'text/html');
80 my $cache = new Posting
::Cache
($conf->{files
}->{cachePath
});
83 if ($hash = $cache -> pick
({thread
=> $tid, posting
=> $mid})) {
84 unless (exists ($hash->{voteRef
}->{$unid})) {
89 $hash->{voteRef
}->{$_}->{IP
} => $hash->{voteRef
}->{$_}->{time}
90 } keys %{$hash->{voteRef
}};
94 unless (exists($iphash{$ip}) and $iphash{$ip}>($time-$adminDefault->{Voting
}->{voteLock
}*60)) {
95 if (request_method
eq 'POST') {
96 $cache -> add_voting
(
103 );# or die $cache->error;
109 print_posting_as_HTML
(
111 $show_posting -> {templateFile
},
112 { assign
=> $show_posting -> {assign
},
115 adminDefault
=> $adminDefault,
116 messages
=> $conf -> {template
} -> {messages
},
117 form
=> $show_posting -> {form
},
120 voted
=> $voted || '',
121 cachepath
=> $conf -> {files
} -> {cachePath
}
126 print header
(-status
=> '204 No Response');
131 ### end of fo_voting.pl ########################################################
patrick-canterino.de