#!/usr/bin/perl # MimerDesk # Web based groupware and eLearning environment # www.mimerdesk.org # # Copyright (C) 2001 Ionstream Ltd. # www.ionstream.fi # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed with a hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # $Id: publicsite.html,v 1.6 2002/06/06 14:58:02 inf Exp $ ########################################### # # # MimerDesk: Tools - Public site manager # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # (c) Ionstream Oy 1999 - 2001 # # # # Programmed by: Teemu Arina # # # ########################################### # Asetukset ################################## use strict; use vars qw ($APPLICATION $ACTIVEGRP $USER $IP $LAST_ACT $FORWARDED $TIME_USED $trans $IDLE $form $ref $sth $admin_status); use lib::MimerDesk; use CGI::Carp "fatalsToBrowser"; $APPLICATION = "Tools - Public Site"; sub print_template; sub update_sites; # Program ################################## read_config('../config/mimerdesk.cfg'); initialize(); $form = decode_multipart(); $form->{'ID'} =~ tr/0-9//cd; $form->{'auth'} =~ tr/0-9a-z//cd; ($USER, $IP, $LAST_ACT, $FORWARDED, $TIME_USED, $IDLE, $ACTIVEGRP) = authenticate($form->{'ID'}, $form->{'auth'}, $form->{'changeGroup'}); $trans = lib::MimerDesk->new_gettext(program => 'publicsite',language => $config{'language'}); $APPLICATION = $trans->gettext("Tools - Public Site"); if ($form->{'quit'}) {redirect("$config{'loc_server'}$config{'bin_dir'}/index.html?ID=$form->{'ID'}&auth=$form->{'auth'}&quit=quit");} lock_tables('READ', 'users'); db_list("SELECT flags FROM users where nimi = '$USER'"); while (my $ref = $sth->fetchrow_hashref()) {$admin_status = $ref->{'flags'};} db_end(); unlock_tables(); if ($admin_status !~ /P0/) {print_template("$config{'theme'}_accfailure");} if ($form->{'update'}) {update_sites();} else {print_template("$config{'theme'}_publicsite");} sub update_sites { lock_tables('WRITE','frontcontent'); my %columns = (ID => "frontinfo",EN_DATA => prepare_fordb($form->{'page_content'})); db_delete("frontcontent","ID = 'frontinfo'"); db_insert('frontcontent',\%columns); unlock_tables(); print_template("$config{'theme'}_publicsite",'success',$trans->gettext('Page updated.')); } ################################## # Read template and process it # ################################## sub print_template { my ($ref,$fulltemplate); my ($template,$mode,$popuptext) = @_; print_header('pragma'); $ref = get_template('maintemplate',$template); $ref->{'maintemplate'} =~ s/<>/$ref->{$template}/m; $fulltemplate = $ref->{'maintemplate'}; $ref = get_template('js_doClock', 'js_help', 'js_gotosite'); my $stuff = join "", ($ref->{'js_doClock'},$ref->{'js_help'},$ref->{'js_gotosite'}); $fulltemplate =~ s/<>/$mode/m; $fulltemplate =~ s/<>/$popuptext/m; $fulltemplate =~ s/<>/$stuff/ms; $fulltemplate = create_buttons($fulltemplate, 'Tools', 'Public Site', $form); $fulltemplate =~ s/<>/minea/gm; $fulltemplate =~ s/<>/MimerDesk\: $APPLICATION/ms; if ($template ne "$config{'theme'}_accfailure") { lock_tables('READ','frontcontent'); my ($ref) = db_select("*","frontcontent", "ID = 'frontinfo'"); unlock_tables(); ($ref->{"EN_DATA"}) = html_escape($ref->{"EN_DATA"}); $fulltemplate =~ s/<>/$ref->{"EN_DATA"}/m; } $fulltemplate = replace_tags($fulltemplate, $USER, $form->{'auth'}, $form->{'ID'}, $TIME_USED); $fulltemplate = add_popups($fulltemplate, $USER, $form->{'auth'}, $form->{'ID'}); print $fulltemplate; db_end('disconnect'); exit; }