$YaBBChatplver = '1.94-win32 for YaBB Gold SP1'; ######################################### # Main script for Chatroom sub mainscript { require "$vardir/ChatSettings.txt"; # load cookie # foreach (split(/; /,$ENV{'HTTP_COOKIE'})) { $_ =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; ($cookie,$value) = split(/=/); $yyCookies{$cookie} = $value; } if( $yyCookies{$cookiepassword} ) { $password = $yyCookies{$cookiepassword}; $username = $yyCookies{$cookieusername} || 'Guest'; } else { $passwordcook = ''; $username = 'Guest'; } ############# fopen(FILE, "$memberdir/$username.dat"); @settings = ; fclose(FILE); $position = $settings[7]; $position =~ s/\n//g; if ($username ne 'Guest'){ $userdisplayname = $settings[1]; $userdisplayname =~ s/\n//g; $username =~ s/\n//g; } else { $userdisplayname = 'Guest'; } $spassword = $settings[0]; $spassword =~ s/\n//g; if ($enable_guestposting == 1){ } else { if ($password eq "") { exit; } } ############ $userlevel =1; if ($level1 eq $position) { $userlevel = 1; } if ($level2 eq $position) { $userlevel = 2; } if ($level3 eq $position) { $userlevel = 3; } if ($level4 eq $position) { $userlevel = 4; } if ($level5 eq $position) { $userlevel = 5; } if ($level6 eq $position) { $userlevel = 6; } ############### $cgiurl = "$boardurl/YaBB.$yyext?board=&action=chatnow"; $logouturl = "$imagesdir/close.htm"; $kickouturl = "$imagesdir/close.htm"; $onlinefile = "$vardir/online.txt"; $messfile = "$vardir/says.txt"; $wordcolorfile = "$vardir/ecolor.txt"; $addsaysfile = "$vardir/eaddsays.txt"; $imagefile = "$vardir/eimage.txt"; $txt{'img1'} = " $chadmtxt{'60'}"; $txt{'img2'} = " $chadmtxt{'31'}"; $txt{'img3'} = " $chadmtxt{'55'}"; $txt{'img4'} = " $chadmtxt{'56'}"; $txt{'img5'} = " $chadmtxt{'57'}"; $txt{'img6'} = "
 $chadmtxt{'58'}"; $img1 = "$imagesdir/chatreload.gif"; $img2 = "$imagesdir/chatonlinelist.gif"; $img3 = "$imagesdir/chathelp.gif"; $img4 = "$imagesdir/chatclearscreen.gif"; $img5 = "$imagesdir/chatkick.gif"; $img6 = "$imagesdir/chatquit.gif"; $saysback = $color{'chatsaysback'}; $saysword = $color{'chatsaysword'}; $loginword = $color{'chatloginword'}; $logoutword = $color{'chatlogoutword'}; $onlineback = $color{'chatonlineback'}; $onlineword = $color{'chatonlineword'}; $typeback = $color{'chattypeback'}; $typeword = $color{'chattypeword'}; $funcback = $color{'chatfuncback'}; $funcword = $color{'chatfuncword'}; $fastback = $color{'chatfastback'}; $sysmess = $color{'chatsysmess'}; $reload = $chatreload; $kicktime = 300; $image_size = 3; $allow_mess = $chat_allow_mess; $time_miss = +0; $level_towho = 1; $level_cls = 4; $level_html = 3; $level_kick = 5; $level_seelevel = 3; $level_seeprivate= 6; ############### $title = "$mbname $chadmtxt{'59'} $infos[7]"; print "Content-type: text/html;CHARSET=win\n"; print "Pragma:no-cache\n\n"; $kicked = 0; $kickoutway ="level1"; $exist="no"; $|=1; &get_data; &set_var; if ($job eq "login") { &write_online(online); &write_mess(login) if ($exist eq "no"); &return_whole; } elsif ($job eq "logout") { &write_online(outline); &write_mess(logout) if ($exist ne "no"); &return_logout; } elsif ($job eq "setfunc") { &return_func; } elsif ($job eq "settype") { &write_online(online); &return_type; } elsif ($job eq "look") { &write_online(online); &return_mess; } elsif ($job eq "setup") { &return_up; } elsif ($job eq "tell") { &return_tell; } elsif ($job eq "says") { &write_online(online); if ($kicked!=1) { &write_mess(says); } &return_mess; } elsif ($job eq "online") { &write_online(online); &return_online(online); } elsif ($job eq "setkick") { if ($userlevel>=$level_kick) { &write_online(online); &return_online(kickout); } else { &chaterror("No User Right"); } } elsif ($job eq "kickout") { if ($userlevel>=$level_kick) { if ($kickoutuser) { &write_online(kickout); } &return_mess; } else { &chaterror("No User Right"); } } elsif ($job eq "typecls") { &return_cls; &write_mess(setcls); &return_mess; } exit; } # end of main script #################### ######################################### # Writes new chat messages to says.txt file sub write_mess { $write_mess_subject=$_[0]; fopen(MESS,"$messfile") || die $!; @mess = ; fclose(MESS); fopen(MESS,">$messfile") || die $!; $total_mess1=0; $total_mess2=0; $sizeofmessarray = @mess; if (($write_mess_subject eq "says") && ($sizeofmessarray >= $allow_mess)) { $deadzone = shift @mess; } foreach $message (@mess) { ($mark,$chkuserip,$chkusername,$chkuserlevel,$chktowhoway,$chktowhoip,$chktowhoname,$chktowholevel,$chkwordcolor,$chkaddsays,$chksays,$chkaddimage,$chktime,$markend,$last) = split(/∥/, $message); if ((($mark eq "says") || ($mark eq "login") || ($mark eq "setcls") || ($mark eq "logout")) && ($markend eq "end")) { if ($mark eq "says") { if (($chktowhoway eq "private") && (($chktowhoip ne "toall") || ($chktowhoname ne "toall") || ($chktowholevel ne "toall"))) { if (($total_mess2<$allow_mess) && ($total_mess1<$allow_mess)) {print MESS "$message";} $total_mess2++;} else { if ($total_mess1<$allow_mess) {print MESS "$message";} $total_mess1++;} } elsif (($mark eq "login") || ($mark eq "logout") || ($mark eq "setcls")) { if ($total_mess1<$allow_mess) {print MESS "$message";} $total_mess1++;} } } if ($write_mess_subject eq "login") { print MESS "login∥$userip∥$userdisplayname∥$userlevel∥∥∥∥∥∥∥∥∥$normal_time∥end∥\n"; $total_mess1++;} elsif ($write_mess_subject eq "logout") { print MESS "logout∥$userip∥$userdisplayname∥$userlevel∥∥∥∥∥∥∥∥∥$normal_time∥end∥\n"; $total_mess1++;} elsif ($write_mess_subject eq "setcls") { print MESS "setcls∥$userip∥$userdisplayname∥$userlevel∥∥∥∥∥∥∥∥∥$normal_time∥end∥\n"; $total_mess1++;} if ($write_mess_subject eq "says") { print MESS "says∥$userip∥$userdisplayname∥$userlevel∥$towhoway∥$towho∥$wordcolor∥$addsays∥$says∥$addimage∥$normal_time∥end∥\n"; if (($towhoway eq "private") && ($towho ne "toall∥toall∥toall")) {$total_mess2++;} else {$total_mess1++;} } fclose(MESS); } ######################################### # Writes who is chatting to online.txt file sub write_online { $write_online_subject = $_[0]; fopen(ONLINE,"$onlinefile") || die $!; @online = ; fclose(ONLINE); @online = sort @online; $lastcheck = ""; $done = 0; fopen(ONLINE,">$onlinefile") || die $!; foreach $online_line (@online) { ($mark,$chkuserip,$chkusername,$chkuserlevel,$chktime,$chksec,$chkkickout,$chkkickoutway,$markend,$last)=split(/∥/,$online_line); if (($mark eq "online") && ($markend eq "end")) { if ($lastcheck ne "$chkuserip∥$chkusername∥$chkuserlevel") { if (($write_online_subject eq "online") && ($chkuserip eq $userip) && ($chkusername eq $username) && ($chkuserlevel eq $userlevel)) { print ONLINE "online∥$userip∥$username∥$userlevel∥$normal_time∥$now_sec∥$chkkickout∥$chkkickoutway∥end∥\n"; if ($chkkickout eq "kickouted") { $kicked =1; $kickoutway=$chkkickoutway; } $done=1; } elsif (($write_online_subject eq "outline") && ($chkuserip eq $userip) && ($chkusername eq $username) && ($chkuserlevel eq $userlevel) && ($chkkickout ne "kickouted")) { print ONLINE ""; $exist="yes"; } elsif (($write_online_subject eq "kickout") && ($kickoutuser eq "$chkuserip∥$chkusername∥$chkuserlevel")) { print ONLINE "online∥$kickoutuser∥$normal_time∥$now_sec∥kickouted∥$kickoutway∥end∥\n"; $done=1; } else { if ((($chksec<$cut1_sec) || ($chksec>$cut2_sec)) && ($chkkickout ne "kickouted")) { print ONLINE ""; } elsif ((($chksec<$cut3_sec) || ($chksec>$cut4_sec)) && ($chkkickout eq "kickouted")) { print ONLINE ""; } else { print ONLINE "$online_line"; } } } $lastcheck = "$chkuserip∥$chkusername∥$chkuserlevel"; } } if (($write_online_subject eq "online") && ($done==0)) { print ONLINE "online∥$userip∥$username∥$userlevel∥$normal_time∥$now_sec∥∥∥end∥\n"; } elsif (($write_online_subject eq "kickout") && ($done==0)) { print ONLINE "online∥$kickoutuser∥∥$normal_time∥$now_sec∥kickouted∥$kickoutway∥end∥\n"; } fclose(ONLINE); } ######################################### # Reads says.txt and displays chat messages in main frame of Chatroom window sub return_mess { require "$sourcedir/YaBBC.pl"; fopen(MESS,"$messfile") || die $!; @mess = ; fclose(MESS); if (($kicked==1) && ($kickoutway eq "level1")) { print "$title\n"; print "\n"; print "\n"; print "\n"; } elsif (($kicked==1) && ($kickoutway eq "level2")) { print "$title\n"; print "\n"; print "\n"; print "\n"; } elsif (($kicked==1) && ($kickoutway eq "level4")) { print "$title\n"; print "\n"; print "\n"; print "\n"; } else { print "Chatting Screen\n"; print "\n"; print "\n"; if ($want eq "yes") { print "\n"; } print qq~ ~; print "\n"; print "\n"; print "\n"; print "\n"; foreach $message (@mess) { $message =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g; $message =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g; $message =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1$2~g; $message =~ s/\&/\&/g; $message =~ s/"/\"/g; $message =~ s/ / \ /g; $message =~ s//]/g; &DoUBBC; &LoadCensorList; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $message =~ s~\Q$tmpa\E~$tmpb~gi; } ($mark,$chkuserip,$chkusername,$chkuserlevel,$chktowhoway,$chktowhoip,$chktowhoname,$chktowholevel,$chkwordcolor,$chkaddsays,$chksays,$chkaddimage,$chktime,$markend,$last) = split(/∥/, $message); if ((($mark eq "says") || ($mark eq "login") || ($mark eq "setcls") || ($mark eq "logout")) && ($markend eq "end")) { if ($want eq "yes") { $chktime="【$chktime】";$showip="【$chkuserip】";} else {$chktime="";} if ($want2 eq "yes") {$start="
";} else {$start="
";} if ($chkaddimage ne "") {$chkaddimage="$chkaddimage";} if ($mark eq "says") { if (($chktowhoip eq "toall") && ($chktowhoname eq "toall") && ($chktowholevel eq "toall")) { print "$chktime$chkusername
$chkaddsays: $chksays$chkaddimage$start\n";} elsif ((($chktowhoip ne "toall") || ($chktowhoname ne "toall") || ($chktowholevel ne "toall")) && ($chktowhoway eq "public")) { print "$chktime$chkusername
$chkaddsays to $chktowhoname: $chksays$chkaddimage
$start\n";} elsif ((($chktowhoip ne "toall") || ($chktowhoname ne "toall") || ($chktowholevel ne "toall")) && ($chktowhoway eq "private") && ((($userip eq $chkuserip) && ($username eq $chkusername) && ($userlevel eq $chkuserlevel)) || (($userip eq $chktowhoip) && ($username eq $chktowhoname) && ($userlevel eq $chktowholevel)) || (($userlevel>$chkuserlevel) && ($userlevel>$chktowholevel) && ($userlevel>=$level_seeprivate)))) { $chkaddsays =~ s/says//g; print "$chktime$chkusername $chkaddsays $chadmtxt{'49'} $chktowhoname: $chksays$chkaddimage$start\n";} } elsif ($mark eq "login") { if ($chkuserlevel eq $level_kick) { print "$chktime[$chadmtxt{'48'}: $chadmtxt{'53'} $chkusername $chadmtxt{'50'}]$start\n";} elsif ($chkuserlevel eq $level_cls) { print "$chktime[$chadmtxt{'48'}: $chkusername $chadmtxt{'50'}]$start\n";} elsif ($chkuserlevel eq $level_html) { print "$chktime[$chadmtxt{'48'}: $chadmtxt{'54'} $chkusername $chadmtxt{'50'}]$start\n";} else { print "$chktime$chadmtxt{'48'}: $chkusername $chadmtxt{'50'}$start\n";} } elsif ($mark eq "logout") { print "$chktime$chadmtxt{'48'}: $chkusername $chadmtxt{'51'}$start\n";} elsif ($mark eq "setcls") { print "$chadmtxt{'48'}: $chktime$chkusername $chadmtxt{'52'}
\n";} } } print "\n"; } } ######################################### # Display form across bottom of Chatroom window (text box, colors, emotions, picts, public/private) sub return_type { fopen(ONLINE,"$onlinefile") || die $!; @online = ; fclose(ONLINE); @online = sort @online; fopen(WORDCOLOR,"$wordcolorfile") || die $!; @wordcolor = ; fclose(WORDCOLOR); fopen(ADDSAYS,"$addsaysfile") || die $!; @addsays = ; fclose(ADDSAYS); fopen(IMAGE,"$imagefile") || die $!; @image = ; fclose(IMAGE); print "\n"; print "Typing Area\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; srand; $ram=int(rand($#wordcolor+1)); $temp=0; print "$chadmtxt{'47'}\n"; print "
\n"; print "$chadmtxt{'44'}:\n"; print "$chadmtxt{'42'}:\n"; print "$chadmtxt{'38'}:\n"; print "$chadmtxt{'40'}:\n"; print "
\n"; print "
\n"; } ######################################### # Display info at top of Chatroom window sub return_up { $levelname="Basic"; if ($userlevel >= $level_towho){$levelname="Register";} if ($userlevel >= $level_cls){$levelname="Clear";} if ($userlevel >= $level_html){$levelname="Language";} if ($userlevel >= $level_kick){$levelname="Kick";} if ($userlevel >= $level_seeprivate){$levelname="Admin";} print "Data\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "[ $chadmtxt{'30'} $nyear, $nmon, $nday ] "; print "[ $chadmtxt{'29'} $nhour : $nmin ]\n"; print "[ $chadmtxt{'26'} $userip] [ $chadmtxt{'27'} $userlevel ] [ $chadmtxt{'28'} $levelname ]
\n"; print "\n"; } ######################################### # Reads online.txt file and displays who is currently chatting sub return_online { $return_online_subject = $_[0]; fopen(ONLINE,"$onlinefile") || die $!; @online = ; fclose(ONLINE); @online = sort @online; if ($return_online_subject eq "online") { $temp="online"; print "Users Online\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$chadmtxt{'31'}
\n"; print "\n"; } elsif ($return_online_subject eq "kickout") { print "Kick Program\n"; print "\n"; print "\n"; print "

\n"; print "
\n"; print "\n"; print "\n"; } $lastcheck = ""; foreach $online_line (@online) { ($mark,$chkuserip,$chkusername,$chkuserlevel,$chktime,$chksec,$chkkickout,$chkkickoutway,$markend,$last)=split(/∥/,$online_line); if (($mark eq "online") && ($markend eq "end")) { if (($lastcheck ne "$chkuserip∥$chkusername∥$chkuserlevel") && (!(($return_online_subject eq "online") && ($userlevel<$level_seelevel) && ($chkkickout eq "kickouted")))) { if (($return_online_subject eq "kickout") && ($userlevel>=$level_kick)) { print ""; print ""; if ($chkuserlevel<$userlevel) {print "";} elsif ($chkuserlevel>=$userlevel) {print "";} print ""; if ($chkkickout eq "kickouted") { if ($chkkickoutway eq "level1"){$chkkickoutway="Kick Out";} if ($chkkickoutway eq "level3"){$chkkickoutway="Ban saying";} print ""; } else { print ""; } print "\n"; } else { if ($chkkickoutway ne "kickouted"){ print ""; } } $lastcheck = "$chkuserip∥$chkusername∥$chkuserlevel"; } } print "
ChooseNameLocationLevelLast loginControl Status
"; if ($chkuserlevel<$userlevel) { print ""; } else { print "Non"; } print "$chkusername$chkuseripLevel $chkuserlevel$userlevel$chktime$chkkickoutwayNon
"; $user++; fopen(FILE, "$memberdir/$chkusername.dat"); @settings = ; fclose(FILE); if ($chkusername ne 'Guest'){ $chkuserdisplayname = $settings[1]; $chkuserdisplayname =~ s/\n//g; } else { $chkuserdisplayname = 'Guest'; } print "$chkuserdisplayname"; if ($userlevel>=$level_seelevel) { if ($chkuserlevel<$userlevel) {print " ($chkuserlevel)";} if ($chkuserlevel>=$userlevel) {print " ($chkuserlevel)";} if ($chkkickout eq "kickouted") {print "*";} } } print "
\n"; if ($job eq "online"){ print "
$chadmtxt{'62'} $user $chadmtxt{'63'}
\n";} if (($return_online_subject eq "kickout") && ($userlevel>=$level_kick)) { print "
\n"; if ($userlevel>=$level_allipkick) { print "\n"; } print "\n"; print "

\n"; print "\n"; } print "
\n"; } ######################################### # Display menu in lower righthand corner of Chatroom sub return_func { print "func\n"; print <<"ccs"; ccs print "\n"; print "$txt{'img1'}
\n"; print "$txt{'img2'}
\n"; print "$txt{'img3'}
\n"; if ($userlevel>=$level_cls){ print "$txt{'img4'}
\n"; } if ($userlevel>=$level_kick){ print "$txt{'img5'}
\n"; } print "$txt{'img6'}
\n"; print "
\n"; } ######################################### # Setup various frames within Chatroom window sub return_whole { print "$title\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } ######################################### # Display info screen at startup and if "info" clicked sub return_tell { print "$title\n"; print "\n"; print "\n"; print "

\n"; print "
\n"; print "
$chadmtxt{'33'}

\n"; print "$mbname $chadmtxt{'32'}\n"; print "


  1. \n"; print "$chadmtxt{'34'}\n"; print "
  2. $chadmtxt{'35'}\n"; print "
  3. $chadmtxt{'36'}\n"; print "
  4. $chadmtxt{'37'}\n"; print "
\n"; print "
\n"; } ######################################### # Call close.htm to close out chatroom windows sub return_logout { print "$title\n"; print "\n"; print "\n"; print "\n"; } ######################################### # Get returned data from Chatroom forms sub get_data { @querys = split(/&/, $ENV{'QUERY_STRING'}); foreach $query (@querys) { ($name, $value) = split(/=/, $query); $FORM{$name} = $value; } if ("Administrator" eq $settings[7]) { $userlevel = 6; $allow_html = 1; } } ######################################### # Assign returned data to proper variables, check for errors sub set_var { if ($FORM{'job'}) { $job = "$FORM{'job'}"; &chkempty($job,"No data found"); } else { &chaterror("No data found $yyCookies{$cookieusername}"); } if ($FORM{'towhoway'}) { $towhoway = "$FORM{'towhoway'}"; $towhoway =~ s/\n//g; } if ($FORM{'towho'}) { $towho = "$FORM{'towho'}"; $towho =~ s/\n//g; } if ($FORM{'wordcolor'}) { $wordcolor = "$FORM{'wordcolor'}"; $wordcolor =~ s/\n//g; } if ($FORM{'says'}) { $says = "$FORM{'says'}"; $says =~ s/\n//g; $says =~ s/∥//g; &chkempty($says,"No Chat"); } else { if ($job eq "says") { &chaterror("No Chat"); } } if ($FORM{'addsays'}) { $addsays = "$FORM{'addsays'}"; $addsays =~ s/\n//g; $addsays =~ s/∥//g; } if ($FORM{'addimage'}) { $addimage = "$FORM{'addimage'}"; $addimage =~ s/\n//g; $addimage =~ s/∥//g; } if ($FORM{'kickoutuser'}) { $kickoutuser = "$FORM{'kickoutuser'}"; $kickoutuser =~ s/\n//g; } if ($FORM{'kickoutway'}) { $kickoutway = "$FORM{'kickoutway'}"; $kickoutway =~ s/\n//g; } if ($FORM{'logouturl'}) { $logouturl = "$FORM{'logouturl'}"; $logouturl =~ s/\n//g; } if ($FORM{'foururl'}) { $foururl = "$FORM{'foururl'}"; $foururl =~ s/\n//g; } if ($FORM{'fourscrolling'}) { $fourscrolling = "$FORM{'fourscrolling'}"; $fourscrolling =~ s/\n//g; } $want = $FORM{'class'}; $want2 = $FORM{'class2'}; $userip = $ENV{'REMOTE_ADDR'}; ($nsec,$nmin,$nhour,$nday,$nmon,$nyear,$wday,$yday,$isdst) = localtime(time+(3600*$time_miss)); $nyear = $nyear - 100 + 2000; if ($nsec<10) {$nsec="0$nsec";} if ($nmin<10) {$nmin="0$nmin";} if ($nhour>12) {$nhour-=12;} if ($nhour<10) {$nhour="0$nhour";} $nmon=$nmon+1; if ($nmon<10) {$nmon="0$nmon";} if ($nday<10) {$nday="0$nday";} $normal_time ="$nhour\:$nmin\:$nsec"; $now_sec =$nsec + ($nmin*60) + ($nhour*60*60) + ($nday*24*60*60); $cut1_sec =$now_sec-($reload*4.2); $cut2_sec =$now_sec+($reload*4.2); $cut3_sec =$now_sec-($kicktime); $cut4_sec =$now_sec+($kicktime); $reload_double=$reload*3; $userinfo ="&username=$username&userid=$userid&userpassword=$userpassword&class=$want&class2=$want2"; } ######################################### # Check to see if chatroom text box was empty when pressed sub chkempty { $chkval = $_[0]; $chkerr = $_[1]; $chkval =~ s/ //g; $chkval =~ s/
//g; $chkval =~ s/\n//g; if ($chkval eq "") { &chaterror($chkerr); } } ######################################### # Wipe Chat sub return_cls { fopen(MAIN,">$messfile"); print MAIN ""; fclose(MAIN); } ######################################### # Error handling sub chaterror { $chaterror_subject = $_[0]; print "ERROR\n"; print "\n"; print "\n"; print "

\n"; print "ERROR $chaterror_subject\n"; print "

\n"; } 1;