#!/usr/local/bin/perl # DarkChat (C) 1997 by Sierra Kempster. All rights reserved. # This script is freeware, but please do not distribute without this notice, # and email darkmoon@lunamorena.net to let me know it's being used. I won't # butt in, but I like to know when my work is appreciated! :) # Inspired by Mike Wheeler's ChatPro. # For more information, email: darkmoon@lunamorena.net or visit Darkmoon's home # page at http://www.lunamorena.net/ ################# # Configuration # ################# $title = "Darkmoon's Web Chat"; $title_graphic = "/~darkmoon/cgi-bin/darkchat/chat.gif"; # BODY tag $background = "/~darkmoon/cgi-bin/darkchat/background.gif"; $bgcolor = "#222222"; $text = "#FFFFAA"; $link = "#AAFFAA"; $vlink = "#AAAAFF"; $alink = "#AAFFAA"; # Color for old messages $oldcolor = "#7700FF"; # Color for actions $actioncolor = "#AAFFAA"; # Color for private messages $privcolor = "#FFFFFF"; # Time (in seconds) to keep messages. $keep = 1200; # URL for this script - you won't have to change this on most servers. $this_script = "darkchat.pl"; # Path for data files $data_path = "/www/home/users/d/darkmoon/cgi-bin/darkchat"; # URL users go to when they hit the "Leave" button. $leave_url = "http://www.lunamorena.net/"; # URL for help file $help_url = "http://www.lunamorena.net/perl/darkchat/help.html"; # Image to indicate new message $chat_blt = "/~darkmoon/cgi-bin/darkchat/chatblt.gif"; ##################### # End Configuration # ##################### $ver = "1.1.1"; $salt = "chat"; @time = localtime(time); foreach $time (@time) { $time = "0$time" if($time < 10); } $nicetime = "$time[2]:$time[1]:$time[0]"; $time = time; srand($$); &parse_form; if(($action =~ /[Pp]ost/) || ($action =~ /[Mm]ore/) || ($action =~ /[Cc]hat/)) { &begin; &check_user; &post if($action =~ /[Pp]ost/); undef $message if($action =~ /[Pp]ost/); &display; &end; } elsif($action =~ /[Pp]rivate/) { &begin; &check_user; &private; &end; } elsif($to_name) { &begin; &check_user; &send_private; &display; &end; } elsif($action =~ /[Ll]eave/) { print"Location: $leave_url\n\n"; $user = $username; &remove_user; } else { &begin; if($title_graphic) { print"
\n"; } else { print"
\n"; } &login; &end; } ############### # Subroutines # ############### sub display { ⊤ &reload; print"
| \n";
&list_users;
print" \n"; &show_private; print" | \n\n"; &show_messages; print" | \n"; print"
\n"; print"DarkChat v$ver Copyright © 1997 Sierra Kempster. All rights reserved.\n"; print"\n\n"; exit; } sub login { print"
| Choose a Nickname: | |
| And a Password: | |
| Your email or web address (optional): | |
| \n"; print" | |
\n"; } else { print"
\n"; }
print"
\n";
print"\n";
print"\n";
print"\n";
print"\n";
print"\n";
print"
\n"; &login; &end; } elsif($password !~ /^\w{3,}$/) { print"Passwords must be alphanumeric, at least 3 characters long, with no spaces.
\n";
&login;
&end;
}
elsif(-f "$data_path/users/$username")
{
open(PASSWORD, "$data_path/users/$username");
while( \n";
&login;
&end;
}
last;
}
}
}
else
{
open(PASSWORD, ">$data_path/users/$username");
print(PASSWORD "Pass:$pass\n");
print(PASSWORD "Email:$email\n") if($email);
print(PASSWORD "Reload:$nicetime\n");
print(PASSWORD "Time:$time\n");
print(PASSWORD "IP:$ENV{REMOTE_ADDR}\n");
print(PASSWORD "--NEW--\n");
print(PASSWORD "From DarkChat:Click here for help with the chat.|$time|$nicetime\n") if($help_url);
print(PASSWORD "From DarkChat:Please use the leave button to leave so your nick won't remain in use.|$time|$nicetime\n");
$temp = (rand 10);
system"cp $data_path/messages $data_path/$temp";
open(OLD, "$data_path/$temp");
open(NEW, ">$data_path/messages");
print(NEW "Join:$username|$nicetime|$time|\n");
while( \n"; }
else { print" \n"; }
print"Private Message: \n";
print" \n";
print"Send to: \n";
print"\n" if($privcolor);
open(USER, "$data_path/users/$username");
while(
\n";
print"
\n";
}
sub private
{
print"\n";
print"\n";
print"Nickname Last Load \n";
opendir(USERS, "$data_path/users");
local(@users) = grep /^\w+$/, readdir USERS;
closedir(USERS);
foreach $user (@users)
{
open(INFO, "$data_path/users/$user");
while(";
if($email)
{
if($email =~ /^http:\/\//) { print""; }
else { print""; }
}
print"$user";
print"" if($email);
print" $reload \n";
undef $email;
}
}
print"$title
\n";
opendir(DIR, "$data_path/users");
local(@users) = grep /^\w+$/, readdir DIR;
closedir(USERS);
foreach $user (@users) { print"\n" if($user ne $username); }
print"
\n";
print"\n";
print"\n";
print"
\n";
&show_private;
}
sub send_private
{
$temp = (rand 10);
# Add to recipient
system"cp $data_path/users/$to_name $data_path/$temp";
open(OLDTO, "$data_path/$temp");
open(NEWTO, ">$data_path/users/$to_name");
while(" if(($msgtime > $oldtime) && ($chat_blt));
print"*NEW* " if(($msgtime > $oldtime) && ($chat_blt eq ""));
print"$type at $msgnice:
$msgtext
\n" if($msgtime > $time-$keep);
}
}
close(USER);
print"\n" if($privcolor);
}
sub nice_time
{
@newtime = localtime($usetime);
foreach $part (@newtime) { $part = "0$part" if($part < 10); }
$niceusetime = "$newtime[2]:$newtime[1]:$newtime[0]";
}