#! /usr/bin/perl # index.cgi # ----------------------------------- # Copyright (C) 2000, Michael Stewart # All Rights Reserved # based on S8 Chat http://www.s8.org # load the chat.setup file require "chat.setup"; # If the offline.txt file exists, then the chat is in # maintenance mode, and is closed. Output the message # in the offline.txt and end. if (-e "$path/offline.txt") { open (OFFLINE, "$path/offline.txt"); @offline = ; close OFFLINE; print "Content-Type: text/html\n\n"; print "Fatal Chatroom Error 0 - Maintenance\n"; print "

The chatroom is closed right now for maintenance.
\n"; print "The chatroom administrator left the following message:

\n"; print "
\n";
  foreach $offlineLine (@offline) {
    print "$offlineLine";
  }
  print "
"; print "
\n"; print "Chatroom version $ver Error Code 0 - Maintenance"; exit; } # Check for the cgi-lib, make sure it's readable and require it if (-e "$path/cgi-lib.cgi") { if (-r "$path/cgi-lib.cgi") { require "$path/cgi-lib.cgi"; } else { print "Content-Type: text/html\n\n"; print "Fatal Chatroom Error 2 - cgi-lib Unreadable\n"; print "

The chatroom cannot load the required module cgi-lib.cgi.
\n"; print "This module is required for the chatroom to work correctly.
\n"; print "Please contact the chatroom administrator.

\n"; print "
\n"; print "Chatroom version $ver Error Code 2 - cgi-lib Unreadable"; exit; } } else { print "Content-Type: text/html\n\n"; print "Fatal Chatroom Error 1 - Missing cgi-lib\n"; print "

The chatroom cannot find the required module cgi-lib.cgi.
\n"; print "This module is required for the chatroom to work correctly.
\n"; print "Please contact the chatroom administrator.

\n"; print "
\n"; print "Chatroom version $ver Error Code 1 - Missing cgi-lib"; exit; } # Load the User Input into %in &ReadParse(); unless ($in{'action'}) { # no defined action # if there are multiple chatrooms, show a list of all chats # with descriptions else load the normal chatroom # check for the config file and whether it is readable if (-e "$path/chat.config" && -r "$path/chat.config") { # load the file open (CONFIG, "$path/chat.config"); @chatConfig = ; close CONFIG; # output the Content-Type print "Content-Type: text/html\n\n"; # output a list of the chatrooms # you may customize this as you want # will add customization for this part in a later version print "The Chatrooms\n"; print "$bodytag\n"; print "

Below are the chatrooms that are available:

\n"; foreach $chatConfigLine (@chatConfig) { $chatConfigLine =~ s/\n//; ($room, $name, $description, $pass) = split(/\|/, $chatConfigLine); print "

$name"; if ($pass ne "") { print " (p)"; } print "
\n"; print "$description

\n\n"; } print "

Start a New Chatroom
\n"; print "Start a new private chatroom that will close when you leave.

\n\n"; print "
Chat Version: $ver - $copyinfo"; exit; } else { # redirect to the chatroom print "Content-Type: text/html\n"; print "Location: $url/?action=chat&room=none\n\n"; exit; } } else { # there was an action, process it # get the action $action = $in{'action'}; if ($action eq "chat") { # check for room input unless ($in{'room'}) { print "Content-Type: text/html\n\n"; print "Fatal Chatroom Error 3 - Invalid User Input\n"; print "

A required variable was not passed to the script.
\n"; print "This varible is required for the action you requested.
\n"; print "This error is most likely caused because you are trying to directly
\n"; print "access certain actions. Please goto $url and
\n"; print "run the script from the beginning. Thank You

\n"; print "
\n"; print "Chatroom version $ver Error Code 3 - Invalid User Input"; exit; } else { $chatroom = $in{'room'}; if ($chatroom eq "none") { print "Content-Type: text/html\n\n"; print "The Chatroom\n"; print "\n"; print " \n"; print " \n"; print " This chat requires frames\n"; print ""; exit; } else { # load the chat room open (CONFIG, "$path/chat.config"); @chatConfig = ; close CONFIG; foreach $chatConfigLine (@chatConfig) { $chatConfigLine =~ s/\n//; ($room, $name, $description, $pass) = split(/\|/, $chatConfigLine); if ($room eq $chatroom) { print "Content-Type: text/html\n\n"; print "$name\n"; print "\n"; print " \n"; print " \n"; print " This chat requires frames\n"; print ""; exit; } } # if we get here, then it's an invalid room print "Content-Type: text/html\n\n"; print "Fatal Chatroom Error 4 - Invalid Chat Room\n"; print "

The chat room you have chosen does not exist.
\n"; print "This error is most likely caused because you are trying to directly
\n"; print "access certain actions. Please goto $url and
\n"; print "run the script from the beginning. Thank You

\n"; print "
\n"; print "Chatroom version $ver Error Code 4 - Invalid Chat Room"; exit; } } } else { # invalid action print "Content-Type: text/html\n\n"; print "Fatal Chatroom Error 5 - Invalid Action\n"; print "

The action you have selected does not exist.
\n"; print "This error is most likely caused because you are trying to directly
\n"; print "access certain actions. Please goto $url and
\n"; print "run the script from the beginning. Thank You

\n"; print "
\n"; print "Chatroom version $ver Error Code 5 - Invalid Action"; exit; } }