#!/usr/bin/perl ##################################################################### # ChatPro Script Version 2.51 # # # # by Command-O Software # # http://www.command-o.com # # # # Copyright 1996-2001, All Rights Reserved # # # # By using this script Licensee agrees to all terms of the License # # Agreement. Read it now, if you haven't already. # ##################################################################### $conf_file = "chatpro.conf"; $default_lang_file = "chatpro.lang"; ##################################################################### # CHANGING ANYTHING BELOW THIS LINE WITHOUT THE EXPRESS PERMISSION # # OF COMMAND-O SOFTWARE IS A VIOLATION OF THE LICENSE AGREEMENT # ##################################################################### &main; sub main { $|=1; require($conf_file); if (-e "$plugin_dir/plugin.conf") { require("$plugin_dir/plugin.conf"); } &set_values; $lang_file = $default_lang_file; $lock_file = "lock"; $our_link = "http://www.command-o.com/"; $our_image = "ChatPro 2.5 by
Command-O Software
"; if($profile_plugin) { $profiles_active = 1; require ("$plugin_dir/profile.pl"); } $oshow_status = $show_status; $time = time() + ($time_zone * 3600); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time); #Y2K Display Fix $year =~ s/^\d(\d\d)$/$1/; if ($sec < 10) { $sec = "0$sec"; } if ($min < 10) { $min = "0$min"; } if ($hour < 10) { $hour = "0$hour"; } $mon++; if ($mon < 10) { $mon = "0$mon"; } if ($mday < 10) { $mday = "0$mday"; } if($include_date == 1) { $date = "$mon/$mday/$year $hour\:$min\:$sec"; $archive_date = "$mon/$mday/$year $hour\:$min\:$sec"; } elsif($include_date == 2) { $date = "$hour\:$min\:$sec"; $archive_date = "$mon/$mday/$year $hour\:$min\:$sec"; } else { $date = "$hour\:$min\:$sec"; $archive_date = "$hour\:$min\:$sec"; } &lock; if ($ENV{'QUERY_STRING'} =~ /^topframe/ && !$ENV{'CONTENT_LENGTH'}) { require("$plugin_dir/frames.pl") || die "Couldn't find frames part"; &topframe; } elsif ($ENV{'QUERY_STRING'} =~ /^ct--/) { require("$plugin_dir/advertise.pl") || die "Couldn't find ad part"; &lock; &click_through; &unlock; exit; } elsif ($ENV{'PATH_INFO'} =~ /^\/bottomframe/) { require("$plugin_dir/frames.pl") || die "Couldn't find frames part"; $bottomframe = 1; &bottomframe; } elsif ($ENV{'QUERY_STRING'} =~ /^ad_summary/) { &unlock; require("$plugin_dir/advertise.pl"); &ad_summary; exit; } elsif ($ENV{'QUERY_STRING'} =~ /^register/) { require("$plugin_dir/register.pl"); exit; } else { if($ENV{'CONTENT_LENGTH'}) { &parse_form; &get_variables; if ($admin_plugin && $adminyes && $message =~ /^command::/) { require("$plugin_dir/admin.pl"); &admin_work; } if($admin_plugin && -s "$file_dir/commands.txt") { require("$plugin_dir/admin.pl"); &apply_commands; } &read_files; } else { if ($ENV{'QUERY_STRING'}) { ($tentry,$tout_link) = split(/::/,$ENV{'QUERY_STRING'}); if($tentry) { $entry = $tentry; } if($tout_link) { $out_link = $tout_link; } } $room = $entry; if($custom_room_plugin) { require("$plugin_dir/custom_room.pl"); &custom_room; } require("$lang_file") || die "Could not find language file"; &misc_lang; } if($advertise_plugin && $ad_locations) { require("$plugin_dir/advertise.pl"); } &check_referer; &prelocation; &location; } exit; } sub set_values { $visitors_time = $visitors_time * 60; $chat_time = $chat_time * 60; } ########## # Lock sub lock { while(-e "$file_dir/$lock_file") { if($time + $lock_time < time()) { unlink("$file_dir/$lock_file"); } else { select(undef, undef, undef, 0.25); } } open(LOCK,">$file_dir/$lock_file") || die "Could not create lock file"; close(LOCK); } ######################## # Parse Form sub parse_form { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($nam, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; if($allow_html == 0) { $value =~ s//>/g; } $FORM{$nam} = $value; } } ########### # Get variables from form sub get_variables { if ($FORM{'room'}) { $room = "$FORM{'room'}"; $room =~ s/ /_/g; $room =~ s/\//_/g; } if($custom_room_plugin) { require("$plugin_dir/custom_room.pl"); &custom_room; } require("$lang_file") || die "Could not find language file"; &misc_lang; if ($FORM{'where'}) { $where = "$FORM{'where'}"; } if($FORM{'frames'}) { $frames = "$FORM{'frames'}"; } if ($FORM{'pubroom'}) { $pubroom = "$FORM{'pubroom'}"; $pubroom =~ s/ /_/g; $pubroom =~ s/\//_/g; if($pubroom eq "$pubroom_title") { undef($pubroom); } } if ($FORM{'priroom'}) { $priroom = "$FORM{'priroom'}"; $priroom =~ s/ /_/g; $priroom =~ s/\//_/g; } if ($FORM{'solo'}) { $solo = "$FORM{'solo'}"; if($solo eq "$entire_room") { undef($solo); } } if ($FORM{'link'}) { $link = "$FORM{'link'}"; } if ($FORM{'name'}) { $name = "$FORM{'name'}"; $name =~ s/\/|"|<|>|\&|\(|\)|\$|\*|\?|\\//g; $name =~ s/\s+/ /g; $name =~ s/^\s//g; $name =~ s/\s$//g; $name =~ s/^\.+//g; $name =~ s/_/ /g; $vname = $name; $vname =~ s/ /_/g; } if ($FORM{'load_time'}) { $load_time = "$FORM{'load_time'}"; } if ($FORM{'mail'} =~ /.*\@.*\..*/) { $mail = "$FORM{'mail'}"; $maillink = "$mail"; } if ($FORM{'passwd'}) { $passwd = "$FORM{'passwd'}"; } if ($FORM{'password'}) { $password = "$FORM{'password'}"; } if ($FORM{'passwordb'}) { $passwordb = "$FORM{'passwordb'}"; } if ($FORM{'regno'}) { $regno = "$FORM{'regno'}"; } if ($FORM{'nummes'}) { $nummes = $FORM{'nummes'}; } if ($FORM{'message'}) { $message = $FORM{'message'}; $message =~ s/\cM//g; $tempmessage = $message; $tempmessage =~ s/\s+//g; if($where ne "$reload_text") { if($message =~ / /) { @messagelines = split(/\n/,$message); $count = 0; while($count < @messagelines) { if(length $messagelines[$count] > 80) { $messagelines[$count] = "$messagelines[$count]
";
                  $longline = 1;
               }
               $count++;
            }
            if($longline) {
               $message = join ("\n", @messagelines); 
            }
            $message = "
$message
"; } $message =~ s/http:\/\/\S+/$&<\/a>/g; $message =~ s/https:\/\/\S+/$&<\/a>/g; $message =~ s/ftp:\/\/\S+/$&<\/a>/g; $message =~ s/\S+\@\S+\.\S+/$&<\/a>/g; $message =~ s/\n\n/

/g; $message =~ s/\n/
/g; } $message =~ s/"/"/g; if($filter_plugin) { require("$plugin_dir/filter.pl"); &lang_filter; } } if ($FORM{'ignored'}) { @ignored = split(/\(\)/,$FORM{'ignored'}); } if($profile_plugin && -e "$profile_dir/$vname") { $profile_link = "
$profile_link_text"; $maillink = "$maillink $profile_link"; } if($FORM{'admin'}) { $adminyes = 1; } } ########### # Read files sub read_files { if($where || $solo || $ENV{'PATH_INFO'}){ $origroom = $room; open(MAIN,"$file_dir/chat$room"); @main =

; close(MAIN); @main = @main[(0 .. $max_mes)]; open(VISITORS,"$file_dir/vis$room"); @visitors = ; close(VISITORS); $vname = $name; $vname =~ s/ /_/g; $vname =~ s/\//_/g; open(VFILE,"$vis_dir/$vname"); @vfile = ; close(VFILE); @vfile = @vfile[(0 .. $max_mes)]; } } ############ # Check Referer sub check_referer { if ($ENV{'HTTP_REFERER'} =~ /^http:\/\/([^\/]+)/) { foreach$referer(@valid_referers) { if ($ENV{'HTTP_REFERER'} =~ /$referer/) { $okay_referer = 1; } } } if(!$ENV{'HTTP_REFERER'}) { $okay_referer = 1; } if(!$okay_referer) { &unlock; &login; exit; } } ########## # Prepare for sending them places sub prelocation { if($where eq "$ignore_text" && $ignore_plugin) { require("$plugin_dir/ignore.pl"); &ignore; } if($where eq "$go_there") { $oldroom = $room; if ($priroom) { $room = $priroom; } elsif($pubroom) { $room = $pubroom; } else { $where = $reload_text; } if ($room eq "$oldroom") { $where = "$reload_text"; } } if($message_plugin) { require("$plugin_dir/message.pl"); &message_prep; } } ########## # Where are they coming from? sub location { if ($solo && $where eq "$post_text" && $solo ne $entire_room) { &verify_password; &main_page_lang; &privmsg; &update; &write; &unlock; &reload; } elsif ($where eq "register") { if($frames eq "yes" && !$ENV{'QUERY_STRING'}) { &unlock; &check_name; if($access_control_plugin) { require("$plugin_dir/access_control.pl"); &admit_style; } if($admin_plugin) { require("$plugin_dir/admin.pl"); &check_admin; } require("$plugin_dir/frames.pl") || die "Couldn't find frames part"; &frames; } else { &main_page_lang; &check_name; if($access_control_plugin) { require("$plugin_dir/access_control.pl"); &admit_style; } if($admin_plugin) { require("$plugin_dir/admin.pl"); &check_admin; } &create; ®ister; &write; &unlock; &reload; } } elsif ($where eq "$post_text") { &verify_password; &main_page_lang; &create; &post; &update; &write; &unlock; &reload; } elsif ($where eq "$reload_text") { &verify_password; &main_page_lang; &snag; &create; &update; &write; &unlock; &reload; } elsif ($where eq "$go_there") { &verify_password; if($pubroom || $priroom) { $lang_file = $default_lang_file; if($custom_room_plugin) { require("$plugin_dir/custom_room.pl"); &custom_room; if($message_plugin) { require("$plugin_dir/message.pl"); &message_prep; } } require("$lang_file") || die "Could not find language file"; &misc_lang; &main_page_lang; &create; &change; &write; &unlock; &reload; } else { &main_page_lang; &snag; &create; &update; &write; &unlock; &reload; } } elsif ($where eq "$leave_text") { &verify_password; &leave; &write; &unlock; } elsif ($profile_plugin && $where eq "$edit_profile") { &check_name; if($access_control_plugin) { require("$plugin_dir/access_control.pl"); &admit_style; } if($passlistok) { &edit_profile; } else { &name_taken } } elsif($profile_plugin && $where eq "$update_profile") { &check_name; if($access_control_plugin) { require("$plugin_dir/access_control.pl"); &admit_style; } &update_profile; } elsif($profile_plugin && $where eq "$change_password") { &check_name; if($access_control_plugin) { require("$plugin_dir/access_control.pl"); &admit_style; } &change_password; } elsif($who_is_where_plugin && $where eq "$who_is_where") { &misc_lang; if($where_locations =~ /A/ && !$load_time) { &main_page_lang; &check_name; if($access_control_plugin) { require("$plugin_dir/access_control.pl"); &admit_style; } if($admin_plugin) { require("$plugin_dir/admin.pl"); &check_admin; } } require("$plugin_dir/who_is_where.pl"); &who_is_where; } else { &deletevfiles; &unlock; if(! -e "$file_dir/.htaccess") { $access_dir = $file_dir; &write_htaccess; } if(! -e "$vis_dir/.htaccess") { $access_dir = $vis_dir; &write_htaccess; } if(! -e "$plugin_dir/.htaccess" && -e $plugin_dir) { $access_dir = $plugin_dir; &write_htaccess; } &login; } } ############ # Login sub login { ®_page_lang; opendir(VFILES,$vis_dir); @vfilelist = grep(!/^\.|^_/, readdir (VFILES)); closedir(VFILES); $vtotal = @vfilelist - 1; open(VISITORS,"$file_dir/vis$room"); @visitors = ; close(VISITORS); foreach $visitors_line (@visitors) { ($bogus,$load,$bogus2) = split(/:/,$visitors_line); if ($time - $load < $visitors_time && $load) { push (@visitors_new,"$visitors_line"); } } @visitors = @visitors_new; undef @visitors_new; $vnum = @visitors; print "Content-type: text/html\n\n"; print "$page_title $reg_page\n"; print "\n"; if($font_face ne "") { print "\n"; } print "