206
my ($ipaddr) = @_;
206
my ($ipaddr) = @_;
208
# Check for a valid IPv4 addr which we know how to parse
208
# Check for a valid IPv4 addr which we know how to parse
209
if ($ipaddr !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
209
if (!$ipaddr || $ipaddr !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
210
return undef;
210
return undef;
837
open HTACCESS, ">data/.htaccess";
837
open HTACCESS, ">data/.htaccess";
838
print HTACCESS <<'END';
838
print HTACCESS <<'END';
839
# nothing in this directory is retrievable unless overriden by an .htaccess
839
# nothing in this directory is retrievable unless overriden by an .htaccess
840
# in a subdirectory
840
# in a subdirectory; the only exception is duplicates.rdf, which is used by
841
# duplicates.xul and must be loadable over the web
841
deny from all
842
deny from all
843
<Files duplicates.rdf>
843
close HTACCESS;
847
close HTACCESS;
844
chmod $fileperm, "data/.htaccess";
848
chmod $fileperm, "data/.htaccess";
54
&calculate_dupes();
54
&calculate_dupes();
56
# Generate a static RDF file containing the default view of the duplicates data.
57
open(CGI, "REQUEST_METHOD=GET QUERY_STRING=ctype=rdf ./duplicates.cgi |")
58
|| die "can't fork duplicates.cgi: $!";
59
open(RDF, ">data/duplicates.tmp")
60
|| die "can't write to data/duplicates.tmp: $!";
63
print RDF if $headers_done;
64
$headers_done = 1 if $_ eq "\n";
68
if (-s "data/duplicates.tmp") {
69
rename("data/duplicates.rdf", "data/duplicates-old.rdf");
70
rename("data/duplicates.tmp", "data/duplicates.rdf");
56
sub check_data_dir {
73
sub check_data_dir {
57
my $dir = shift;
74
my $dir = shift;
32
require "globals.pl";
32
require "globals.pl";
33
require "CGI.pl";
33
require "CGI.pl";
37
# Go directly to the XUL version of the duplicates report (duplicates.xul)
38
# if the user specified ctype=xul. Adds params if they exist, and directs
39
# the user to a signed copy of the script in duplicates.jar if it exists.
40
if ($::FORM{'ctype'} eq "xul") {
41
my $params = CanonicaliseParams($::buffer, ["format", "ctype"]);
42
print "Location: " . (-e "duplicates.jar" ? "duplicates.jar!/" : "") .
43
"duplicates.xul" . ($params ? "?$params" : "") . "\n\n";
35
# Use global templatisation variables.
47
# Use global templatisation variables.
36
use vars qw($template $vars);
48
use vars qw($template $vars);