############################################################################### # Subs.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 1 Gold - SP 1.1 # # Released: December 2001; Updated March 22, 2002 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2002 Xnull (www.xnull.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # ############################################################################### $subsplver = "1 Gold - SP 1.1"; use subs 'exit'; $yymain = ""; # set body start to blank &readform; # parse the query &get_date; # get the current date/time $currentboard = $INFO{'board'}; if ($currentboard =~ m~/~){ &fatal_error($txt{'399'}); } if ($currentboard =~ m~\\~){ &fatal_error($txt{'400'}); } if ($currentboard ne '' && currentboard !~ /\A[\s0-9A-Za-z#%+,-\.:=?@^_]+\Z/){ &fatal_error($txt{'399'}); } $currentcat = $INFO{'cat'}; if ($currentcat =~ m~/~){ &fatal_error($txt{'399a'}); } if ($currentcat =~ m~\\~){ &fatal_error($txt{'400a'}); } if ($currentcat ne '' && $currentcat !~ /\A[\s0-9A-Za-z#%+,-\.:=?@^_]+\Z/){ &fatal_error($txt{'399a'}); } $pwseed ||= 'yy'; if (!$user_ip) { if ($ENV{'HTTP_X_FORWARDED_FOR'} && $ENV{'HTTP_X_FORWARDED_FOR'} ne "127.0.0.1") {$user_ip = $ENV{'HTTP_X_FORWARDED_FOR'};} elsif (!$user_ip && $ENV{'HTTP_CLIENT_IP'} && $ENV{'HTTP_CLIENT_IP'} ne "127.0.0.1") {$user_ip = $ENV{'HTTP_CLIENT_IP'};} elsif (!$user_ip && $ENV{'X_CLIENT_IP'} && $ENV{'X_CLIENT_IP'} ne "127.0.0.1") {$user_ip = $ENV{'X_CLIENT_IP'};} else {$user_ip = $ENV{'REMOTE_ADDR'};} } $scripturl = qq~$boardurl/YaBB.$yyext~; if ($currentcat ne "") {$cgi = qq~$scripturl?cat=$currentcat~;} else {$cgi = qq~$scripturl?board=$currentboard~;} if ($currentboard && -e "$boardsdir/$currentboard.mbo" ) { require "$boardsdir/$currentboard.mbo"; } if (-e "$vardir/boards.pwd") {require "$vardir/boards.pwd";} if (-e "$vardir/cat.mco") {require "$vardir/cat.mco";} sub exit { local $| = 1; local $\ = ''; print ''; CORE::exit( $_[0] || 0 ); } sub Del_Max_IM { open(FILE, "$memberdir/$username.msg"); @messages = ; close(FILE); fopen(FILE, ">$memberdir/$username.msg", 1); for ($a = 0; $a < @messages; $a++) { chomp $messages[$a]; if($a < $numibox) { print FILE "$messages[$a]\n"; } } fclose(FILE); } sub Del_Max_IMOUT { open(FILE, "$memberdir/$username.outbox"); @omessages = ; close(FILE); fopen(FILE, ">$memberdir/$username.outbox", 1); for ($a = 0; $a < @omessages; $a++) { chomp $omessages[$a]; if($a < $numobox) { print FILE "$omessages[$a]\n"; } } fclose(FILE); } sub Del_Max_STORE { open(FILE, "$memberdir/$username.imstore"); @smessages = ; close(FILE); fopen(FILE, ">$memberdir/$username.imstore", 1); for ($a = 0; $a < @smessages; $a++) { chomp $smessages[$a]; if($a < $numstore) { print FILE "$smessages[$a]\n"; } } fclose(FILE); } #### Begin YaBBChat insertion sub printwhoisonchat { print "Content-type: text/html\n\n"; $cguests = 0; $cusers = ''; fopen(OF,"$vardir/online.txt") or dienice ("Can't open file: $!"); @ary = ; fclose(OF); foreach $line (@ary) { chomp($line); ($of,$name,$ip,$displayname,$level,$time,$non7,$non8,$non9,$non10,$non11) = split(/°¸/,$line); if( $name ) { &LoadUser($name); if( exists $userprofile{$name} ) { $cusers .= qq~ $displayname, \n~; } else { $cguests++; } } } $cusers =~ s~, \n\Z~~; if ($INFO{'group'} eq "guests") { print "$cguests"; } if ($INFO{'group'} eq "users") { print "$cusers"; } exit; } #### End YaBBChat insertion sub redirectexit { print "Location: $yySetLocation\n\n"; exit; } sub redirectinternal { &LoadIMs; # Load IM's if($currentboard) { if($INFO{'num'}) { require "$sourcedir/Display.pl"; &Display; } else { require "$sourcedir/MessageIndex.pl"; &MessageIndex; } } else { require "$sourcedir/BoardIndex.pl"; &BoardIndex; } exit; } sub template { if($yySetCookies1 || $yySetCookies2 || scalar @otherCookies) { print header(-cookie=>[$yySetCookies1, $yySetCookies2, @otherCookies], -charset=>'$yycharset'); } else { print header(-status=>'200 OK', -charset=>'$yycharset'); } fopen(FILE, "$vardir/continent.txt"); @continent = ; fclose(FILE); chomp @continent; $defaultmap = $continent[0]; $defaultmap = lc($defaultmap); $yyposition = $yytitle; $yytitle = "$mbname - $yytitle"; fopen(FILE, "$vardir/member_of_the_day.txt"); @daymemberdata = ; fclose(FILE); chomp (@daymemberdata); $yydayusername = "$daymemberdata[1]"; $yydayname = "$daymemberdata[2]"; if (length($daymemberdata[3]) > 2) { $yydaylink = "\"$txt{'515'}\""; $yydaylink2 = "$yydayname"; } else { $yydaylink = ""; $yydaylink2 = "$yydayname"; } $yydayprofile = "\"$txt{'467'}\""; $yydayprofile2 = "$yydayname"; if ($daymemberdata[4] =~ /^\http:\/\// ) { if ($userpic_width ne 0) { $tmp_width = "width=$userpic_width"; } else { $tmp_width=""; } if ($userpic_height ne 0) { $tmp_height = "height=$userpic_height"; } else { $tmp_height=""; } $yydayavatar = "\"Avatar\""; } else { $yydayavatar = "\"Avatar\""; } if ($defaultml == 0) { $mldefault = "mlall"; } elsif ($defaultml == 1) { $mldefault = "mlpost"; } elsif ($defaultml == 2) { $mldefault = "mlalfa"; } elsif ($defaultml == 3) { $mldefault = "mlgrp"; } # Order of yabb menu items $yymenu = qq~$img{'home'}$menusep$img{'rules'}$menusep$img{'help'}$menusep$img{'search'}$menusep$img{'memberlist'}~; if($enable_gallery) { $yymenu .= qq~$menusep$img{'gallery'}~; } if ($showlinks ==1){ $yymenu .= qq~$menusep$img{'links'}~; } if ($newcalopen == 1 || $settings[7] eq 'Administrator' || $settings[7] eq $newcalgroup ) { $yymenu .= qq~$menusep$img{'newcalendar'}~; } $yymenu .= qq~$menusep$img{'quiz'}~; if($bdayshowtopimg == '1') { $yymenu .= qq~$menusep$img{'bdays'}~; } $yymenu .= qq~$menusep$img{'games'}~; $yymenu .= qq~$menusep$img{'membermap'}~; if($settings[7] eq 'Administrator') { $yymenu .= qq~$menusep$img{'admin'}~; } if($username eq 'Guest') { $yymenu .= qq~$menusep$img{'login'}$menusep$img{'register'}~; # --- Added for Notify Plus 2.2 --- # if ($username eq 'Guest' && $enable_notification_guest) { $yymenu .= qq~$menusep$img{'notification'}~; } # --- /Added for Notify Plus 2.2 --- # } else { $yymenu .= qq~$menusep$img{'profile'}~; if ($enable_buddies == 1) { $yymenu .= qq~$menusep$img{'buddylist'}~; } if($enable_notification) { $yymenu .= qq~$menusep$img{'notification'}~; } $yymenu .= qq~$menusep$img{'logout'}~; } $yyimages = $imagesdir; ########chat insertion########### require "$vardir/ChatSettings.txt"; chomp $chatgroup; @chatgrouplist = split(",",$chatgroup); $chatgroupflag = 0; foreach $chatgroupitem (@chatgrouplist) { if ($settings[7] eq $chatgroupitem) { $chatgroupflag = 1; } } if ($chatopen == 1 || $settings[7] eq 'Administrator' || $chatgroupflag == 1 ) { $yychat .=qq~ $chadmtxt{'7'}
~; $cguests = 0; $cusers = ''; open(OF,"$vardir/online.txt") or dienice ("Can't open file: $!"); @ary = ; close(OF); foreach $line (@ary) { chomp($line); ($of,$name,$ip,$displayname,$level,$time,$non7,$non8,$non9,$non10,$non11) = split(/°¸/,$line); if( $name ) { if( exists $userprofile{$name} ) { $cusers .= qq~ \n$displayname,\n~; } else { ++$cguests; } } } $yychat .=qq~ $cusers
~; $windowname=$mbname; $windowname=~ s/ //g; $windowname=~ s/\W//g; if ($password eq ""){ if ($enable_guestposting == 0){ $yychat .=qq~$chadmtxt{'8'}~; } else { $yychat .=qq~$chadmtxt{'9'}$cguests
\n
$chadmtxt{'10'}~; } } elsif ($password ne "") { if ($enable_guestposting == 1){ $yychat .=qq~$chadmtxt{'9'}$cguests
~; } $yychat .=qq~
$chadmtxt{'10'}~; } $yychat .=qq~
~; } ########chat ended############ # Begin FTT Corporation language mod &getlngtemplatefile; fopen(TEMPLATE,"$lngtemplatefile.html") || die("$txt{'23'}: template.html"); # Begin FTT Corporation language mod @yytemplate =