~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/Configure/UIs/UPDATE.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
 
 
3
package Foswiki::Configure::UIs::UPDATE;
 
4
use base 'Foswiki::Configure::UI';
 
5
 
 
6
use strict;
 
7
 
 
8
use Foswiki::Configure::UI;
 
9
use Foswiki::Configure::FoswikiCfg;
 
10
 
 
11
sub ui {
 
12
    my ( $this, $root, $valuer, $updated ) = @_;
 
13
 
 
14
    $this->{changed} = 0;
 
15
    $this->{updated} = $updated;
 
16
 
 
17
    $this->{output} = CGI::h2('Updating configuration');
 
18
 
 
19
    my $logfile;
 
20
    $this->{log}  = '';
 
21
    $this->{user} = '';
 
22
    if ( defined $Foswiki::query ) {
 
23
        $this->{user} = $Foswiki::query->remote_user() || '';
 
24
    }
 
25
 
 
26
    Foswiki::Configure::FoswikiCfg::save( $root, $valuer, $this );
 
27
 
 
28
    if ( $this->{log} && defined( $Foswiki::cfg{ConfigurationLogName} ) ) {
 
29
        # configuration variable may be coming from POST, and might thus
 
30
        # be tainted, we must be able to trust that the adminstrator has
 
31
        # input a proper path and therefore untaint rigourously
 
32
        # NOTE: this assumes configure is properly hardened through the web
 
33
        # server as instructed in the fine manual!
 
34
        $Foswiki::cfg{ConfigurationLogName} =~ /^(.*)$/;
 
35
        $Foswiki::cfg{ConfigurationLogName} = $1;
 
36
        if ( open( F, '>>', $Foswiki::cfg{ConfigurationLogName} ) ) {
 
37
            print F $this->{log};
 
38
            close(F);
 
39
        }
 
40
    }
 
41
 
 
42
    # Put in a link to the front page of the Foswiki
 
43
    my $url =
 
44
"$Foswiki::cfg{DefaultUrlHost}$Foswiki::cfg{ScriptUrlPath}/view$Foswiki::cfg{ScriptSuffix}/";
 
45
    return
 
46
        $this->{output}
 
47
      . CGI::p()
 
48
      . CGI::strong( 'Setting '
 
49
          . $this->{changed}
 
50
          . ' configuration item'
 
51
          . ( ( $this->{changed} == 1 ) ? '' : 's' )
 
52
          . '.' )
 
53
      . CGI::p()
 
54
      . CGI::a( { href => $url }, "Go to the Foswiki front page" ) . " or ";
 
55
}
 
56
 
 
57
# Listener for when a saved configuration item is changed.
 
58
sub logChange {
 
59
    my ( $this, $keys, $value ) = @_;
 
60
 
 
61
    if ( $this->{updated}->{$keys} ) {
 
62
        $this->{output} .= CGI::h3($keys) . CGI::code($value);
 
63
        $this->{changed}++;
 
64
        $this->{log} .= '| '
 
65
          . gmtime() . ' | '
 
66
          . $this->{user} . ' | '
 
67
          . $keys . ' | '
 
68
          . $value, " |\n";
 
69
    }
 
70
}
 
71
 
 
72
1;
 
73
__DATA__
 
74
#
 
75
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
 
76
#
 
77
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
 
78
# Foswiki Contributors are listed in the AUTHORS file in the root
 
79
# of this distribution. NOTE: Please extend that file, not this notice.
 
80
#
 
81
# Additional copyrights apply to some or all of the code in this
 
82
# file as follows:
 
83
#
 
84
# Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
 
85
# TWiki Contributors are listed in the AUTHORS file in the root
 
86
# of this distribution. NOTE: Please extend that file, not this notice.
 
87
#
 
88
# This program is free software; you can redistribute it and/or
 
89
# modify it under the terms of the GNU General Public License
 
90
# as published by the Free Software Foundation; either version 2
 
91
# of the License, or (at your option) any later version. For
 
92
# more details read LICENSE in the root of this distribution.
 
93
#
 
94
# This program is distributed in the hope that it will be useful,
 
95
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
96
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
97
#
 
98
# As per the GPL, removal of this notice is prohibited.