]>
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> #
9 # Description: vote a posting, return the posting view #
11 ################################################################################
22 my $null = $0; $null =~ s/\\/\//g
; # for win :-(
23 $Bin = ($null =~ /^(.*)\/.*$/)?
$1 : '.';
24 $Shared = "$Bin/../shared";
25 $Config = "$Bin/config";
26 $Script = ($null =~ /^.*\/(.*)$/)?
$1 : $null;
29 # $Bin = ($null =~ /^(.*)\/.*$/)? $1 : '.';
30 # $Config = "$Bin/../../daten/forum/config";
31 # $Shared = "$Bin/../../cgi-shared";
32 # $Script = ($null =~ /^.*\/(.*)$/)? $1 : $null;
35 # setting umask, remove or comment it, if you don't need
40 use CGI
::Carp
qw(fatalsToBrowser);
45 use Template
::Posting
;
54 ################################################################################
62 sub VERSION
{(q
$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
64 my $conf = read_script_conf
($Config, $Shared, $Script);
66 my $show = $conf -> {show
};
67 my $show_forum = $show -> {Forum
};
68 my $show_posting = $show -> {Posting
};
69 my $cgi = $show -> {assign
} -> {cgi
};
70 my $tree = $show -> {assign
} -> {thread
};
71 my $adminDefault = read_admin_conf
($conf -> {files
} -> {adminDefault
});
73 my $forum_file = $conf -> {files
} -> {forum
};
74 my $message_path = $conf -> {files
} -> {messagePath
};
76 my $formdata = $show_posting -> {form
} -> {data
};
77 my $fup = param
($formdata -> {followUp
} -> {name
}) || '';
78 my $unid = param
($formdata -> {uniqueID
} -> {name
}) || '';
81 my ($tid, $mid) = map {$_ || 0} split /;/ => $fup, 2;
83 $tid = (defined $tid and $tid=~/(\d+)/)?
$1: 0;
84 $mid = (defined $mid and $mid=~/(\d+)/)?
$1: 0;
86 if ($tid and $mid and $unid) {
88 print header
(-type
=> 'text/html');
90 my $cache = new Posting
::Cache
($conf->{files
}->{cachePath
});
93 if ($hash = $cache -> pick
({thread
=> $tid, posting
=> $mid})) {
94 unless (exists ($hash->{voteRef
}->{$unid})) {
99 $hash->{voteRef
}->{$_}->{IP
} => $hash->{voteRef
}->{$_}->{time}
100 } keys %{$hash->{voteRef
}};
104 unless (exists($iphash{$ip}) and $iphash{$ip}>($time-$adminDefault->{Voting
}->{voteLock
}*60)) {
105 if (request_method
eq 'POST') {
106 $cache -> add_voting
(
113 );# or die $cache->error;
119 print_posting_as_HTML
(
121 $show_posting -> {templateFile
},
122 { assign
=> $show_posting -> {assign
},
125 adminDefault
=> $adminDefault,
126 messages
=> $conf -> {template
} -> {messages
},
127 form
=> $show_posting -> {form
},
130 voted
=> $voted || '',
131 cachepath
=> $conf -> {files
} -> {cachePath
}
136 print header
(-status
=> '204 No Response');
141 ### end of fo_voting.pl ########################################################
patrick-canterino.de