#!/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: chat_back.html,v 1.6 2002/06/14 23:37:37 inf Exp $ ############################################ # # # MimerDesk: I-Chat # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # (c) Ionstream Design AY 1999 - 2000 # # # # Programmed by: Teemu Vainio # # # ############################################ use strict; use vars qw ($APPLICATION $ACTIVEGRP $ARTICLE $MONTH $USER $IP $LAST_ACT $FORWARDED $TIME_USED $IDLE $form $ref $sth $poista_kayttaja $trans); use lib::MimerDesk; use CGI::Carp "fatalsToBrowser"; $APPLICATION = 'Communication - Chat'; sub channel_name; 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 => 'chat_back',language => $config{'language'}); $APPLICATION = $trans->gettext('Communication - Chat'); ######################################## # POISTETAAN KÄYTTÄJÄ KÄYTTÄJÄLISTASTA # ######################################## db_list("SELECT * FROM chat_users where USER like '$form->{'kanava'}&%'"); while (my $ref = $sth->fetchrow_hashref()) { (undef, $ref->{'USER'}) = split "&", $ref->{'USER'}; if($ref->{'USER'} eq $USER) { $poista_kayttaja = $ref->{'NICK'}; last; } } db_end(); if (defined($poista_kayttaja)) { my $user = $form->{'kanava'}."&".$USER; db_list("delete from chat_users where USER = '$user'"); db_end(); my $time = time(); if (!$form->{'leavemsg'}) { my $channel_name = channel_name($form->{'kanava'}); #my $messu = sprintf($trans->gettext("%s has left channel %s"),$poista_kayttaja,$channel_name); my $messu = "$poista_kayttaja&$channel_name"; db_list("insert into chatroom_$form->{'kanava'} (LINE, TARGET, SENDER, TIME, TYPE, MESSAGE) values ('NULL','kaikki','i-system','$time','part','$messu')"); db_end(); } } redirect("$config{'loc_server'}$config{'bin_dir'}/chat.html?ID=$form->{'ID'}&auth=$form->{'auth'}"); ########################## # ___ # # ___ | | | \ ___ # # / \ | | | / / \ # # \___ | | |--< \___ # # \ | | | \ \ # # \___/ \__/ |___/ \___/ # # # ########################## ################ # channel_name # ################ # # Hakee tietokannasta kanavan nimen id:n perusteella # sub channel_name { my ($name); lock_tables('READ', 'chatrooms'); db_list("select NAME from chatrooms where ID = @_"); while (my $ref = $sth->fetchrow_hashref()) { $name = $ref->{'NAME'}; } db_end(); unlock_tables(); return $name; }