]>
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 ################################################################################
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;
28 my $null = $0; #$null =~ s/\\/\//g; # for win :-(
29 $Bin = ($null =~ /^(.*)\/.*$/)?
$1 : '.';
30 $Config = "$Bin/../../../cgi-config/devforum";
31 $Shared = "$Bin/../../../cgi-shared";
32 $Script = ($null =~ /^.*\/(.*)$/)?
$1 : $null;
36 use CGI
::Carp
qw(fatalsToBrowser);
41 use Template
::Posting
;
43 use CGI
qw(param header remote_addr);
45 print header
(-type
=> 'text/html');
47 my $conf = read_script_conf
($Config, $Shared, $Script);
49 my $show = $conf -> {show
};
50 my $show_forum = $show -> {Forum
};
51 my $show_posting = $show -> {Posting
};
52 my $cgi = $show -> {assign
} -> {cgi
};
53 my $tree = $show -> {assign
} -> {thread
};
54 my $adminDefault = read_admin_conf
($conf -> {files
} -> {adminDefault
});
56 my $forum_file = $conf -> {files
} -> {forum
};
57 my $message_path = $conf -> {files
} -> {messagePath
};
59 my $formdata = $show_posting -> {form
} -> {data
};
60 my $fup = param
($formdata -> {followUp
} -> {name
}) || '';
61 my $unid = param
($formdata -> {uniqueID
} -> {name
}) || '';
64 my ($tid, $mid) = map {$_ || 0} split /;/ => $fup, 2;
66 $tid = ($tid=~/(\d+)/)[0] || 0;
67 $mid = ($mid=~/(\d+)/)[0] || 0;
69 my $cache = new Posting
::Cache
($conf->{files
}->{cacheFile
});
72 if ($hash = $cache -> pick
({thread
=> $tid, posting
=> $mid})) {
73 unless (exists ($hash->{voteRef
}->{$unid})) {
78 $hash->{voteRef
}->{$_}->{IP
} => $hash->{voteRef
}->{$_}->{time}
79 } keys %{$hash->{voteRef
}};
83 unless (exists($iphash{$ip}) and $iphash{$ip}>($time-$adminDefault->{Voting
}->{voteLock
}*60)) {
84 $cache -> add_voting
(
91 ) or die $cache->error;
96 print_posting_as_HTML
(
98 $show_posting -> {templateFile
},
99 { assign
=> $show_posting -> {assign
},
102 adminDefault
=> $adminDefault,
103 messages
=> $conf -> {template
} -> {messages
},
104 form
=> $show_posting -> {form
},
107 voted
=> $voted || '',
108 cachefile
=> $conf -> {files
} -> {cacheFile
}
114 ### end of fo_voting.pl ########################################################
patrick-canterino.de