1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
20 package NDWeb::Pages::Settings;
22 use warnings FATAL => 'all';
24 use CGI qw/:standard/;
27 use base qw/NDWeb::XMLPage/;
29 $NDWeb::Page::PAGES{settings} = __PACKAGE__;
34 $self->{TITLE} = 'Edit site preferences';
35 my $DBH = $self->{DBH};
37 if (defined param 'cmd'){
38 if(param('cmd') eq 'stylesheet'){
39 my $query = $DBH->prepare(q{UPDATE users SET css = NULLIF($2,'Default') WHERE uid = $1});
40 $query->execute($ND::UID,escapeHTML(param 'stylesheet')) or $ND::ERROR .= p $DBH->errstr;
43 if(param('oldpass') && param('pass')){
44 my $query = $DBH->prepare('UPDATE users SET password = MD5(?) WHERE password = MD5(?) AND uid = ?');
45 $query->execute(param('pass'),param('oldpass'),$ND::UID);
47 my ($css) = $DBH->selectrow_array(q{SELECT css FROM users WHERE uid = $1},undef,$ND::UID);
48 my @stylesheets = ({Style => 'Default'});
49 $css = '' unless defined $css;
50 while (<stylesheets/*.css>){
51 if(m{stylesheets/(\w+)\.css}){
52 push @stylesheets,{Style => $1, Selected => $1 eq $css ? 1 : 0};
55 $BODY->param(StyleSheets => \@stylesheets);