~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/Configure/Checkers/ScriptUrlPath.pm

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See bottom of file for license and copyright information
 
2
package Foswiki::Configure::Checkers::ScriptUrlPath;
 
3
 
 
4
use strict;
 
5
 
 
6
use Foswiki::Configure::Checker;
 
7
 
 
8
use base 'Foswiki::Configure::Checker';
 
9
 
 
10
sub check {
 
11
    my $this = shift;
 
12
 
 
13
    # Check Script URL Path against REQUEST_URI
 
14
    my $n;
 
15
    my $val    = $Foswiki::cfg{ScriptUrlPath};
 
16
    my $report = '';
 
17
 
 
18
    my $guess = $ENV{REQUEST_URI} || $ENV{SCRIPT_NAME} || '';
 
19
    $guess =~ s(/+configure\b.*$)();
 
20
 
 
21
    if ( defined $val && $val ne 'NOT SET' ) {
 
22
        if ($guess) {
 
23
            if ( $guess !~ /^$val/ ) {
 
24
                $report .= $this->WARN(
 
25
                    'I expected this to look like "' . $guess . '"' );
 
26
            }
 
27
        }
 
28
        else {
 
29
            $report .= $this->WARN(<<HERE);
 
30
This web server does not set REQUEST_URI or SCRIPT_NAME
 
31
so it isn't possible to fully check the correctness of this setting.
 
32
HERE
 
33
        }
 
34
        if ( $val =~ m!/$! ) {
 
35
            $report .= $this->WARN(
 
36
'Don\'t put a / at the end of the path. It\'ll still work, but you will get double // in a few places.'
 
37
            );
 
38
        }
 
39
    }
 
40
    else {
 
41
        if ($guess) {
 
42
            $report .= $this->guessed(0);
 
43
        }
 
44
        else {
 
45
            $report .= $this->WARN(<<HERE);
 
46
This web server does not set REQUEST_URI or SCRIPT_NAME
 
47
so it isn't possible to guess this setting.
 
48
HERE
 
49
            $guess = '';
 
50
        }
 
51
        $Foswiki::cfg{ScriptUrlPath} = $guess;
 
52
    }
 
53
    return $report;
 
54
}
 
55
 
 
56
1;
 
57
__DATA__
 
58
#
 
59
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
 
60
#
 
61
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
 
62
# Foswiki Contributors are listed in the AUTHORS file in the root
 
63
# of this distribution. NOTE: Please extend that file, not this notice.
 
64
#
 
65
# Additional copyrights apply to some or all of the code in this
 
66
# file as follows:
 
67
#
 
68
# Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
 
69
# TWiki Contributors are listed in the AUTHORS file in the root
 
70
# of this distribution. NOTE: Please extend that file, not this notice.
 
71
#
 
72
# This program is free software; you can redistribute it and/or
 
73
# modify it under the terms of the GNU General Public License
 
74
# as published by the Free Software Foundation; either version 2
 
75
# of the License, or (at your option) any later version. For
 
76
# more details read LICENSE in the root of this distribution.
 
77
#
 
78
# This program is distributed in the hope that it will be useful,
 
79
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
80
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
81
#
 
82
# As per the GPL, removal of this notice is prohibited.