Tetra-WebBBS Debugger 6.10

Contents of /home/zoetecnocampoco/public_html/cgi-bin/bbs/lib/webbbs_profile.pl

    1- #<<<
    2- #######################################
    3- #    ---  Tetra-WebBBS  --- 
    4- # By:             tetrabb.com
    5- # Version:        6.10
    6- # Last modified:  2009-11-01
    7- # Copyright (c)   2006-2009
    8- # Website:        http://tetrabb.com
    9- # For more details see license.txt
   10- #
   11- # Core script:    webbbs_profile.pl
   12- # Authors:        Rainer Libowski
   13- #                 Tarty
   14- # Derived from code by Darryl Burgdorf
   15- #######################################
   16- #>>>
   17- 
   18- sub WebBBS {
   19- }
   20- 
   21- sub startup_profile {
   22- if ($RequireProfileEmail) {
   23- $RequireProfile = 1;
   24- $RequireEmail   = 1;
   25- }
   26- &Parse_Form;
   27- &Initialize_Data;
   28- } ## end sub startup_profile
   29- 
   30- sub startup_md_profilesave {
   31- if ($RequireProfileEmail) {
   32- $RequireProfile = 1;
   33- $RequireEmail   = 1;
   34- }
   35- &Parse_Profile;
   36- my $filename = $FORM{'name'};
   37- if ( $tbb->{'get'}->{'md'} eq 'manage' ) {
   38- $filename = $tbb->{'post'}->{'id'};
   39- }
   40- $filename =~ s/[^\w\.\-\']/\+/g;
   41- $filename =~ tr/A-Z/a-z/;
   42- $filename = $UserProfileDir . '/' . $filename . '.txt';
   43- if ( ( !$AdminRun ) && ( -s $filename ) ) {
   44- my $pw_ok = $read5x->check_profile_password( 'username' => $FORM{'name'},
   45-                                              'password' => $FORM{'password'},
   46-                                              'file'     => $filename,
   47- );
   48- if ( !$pw_ok ) {
   49- print "Content-type: text/html\n\n";
   50- &Error( '9610', '9611' );
   51- exit;
   52- }
   53- }
   54- &Initialize_Data;
   55- if ( ( $FORM{'Delete'} )
   56-      || (    ( $tbb->{'get'}->{'md'} eq 'manage' )
   57-           && ( $tbb->{'post'}->{'action'} eq 'delete' ) )
   58-     )
   59- {
   60- &DeleteProfile;
   61- }
   62- else {
   63- &SaveProfile;
   64- }
   65- } ## end sub startup_md_profilesave
   66- 
   67- sub Parse_Profile {
   68- %FORM = %{$post};
   69- delete $FORM{'profilegraphic'};
   70- 
   71- my $is_registered = 0;
   72- if ( lc( $FORM{'name'} ) ne lc( $tbb->{'session'}->{'board_user'}->{'name'} ) ) {
   73- my $verified_ref = $tbb->{'db'}->verify_exists_data( 'type' => 'profile',
   74-                                                      'id'   => $FORM{'name'}, );
   75- if ($verified_ref) {
   76- $is_registered = 1;
   77- }
   78- }
   79- else {
   80- $is_registered = $tbb->{'session'}->{'board_user'}->{'is_registered'};
   81- }
   82- 
   83- @naughtywords = ();
   84- if (    ( !$AdminRun )
   85-      && $NaughtyWordsFile
   86-      && ( !( ( $is_registered && ( $BypassContentFilter == 2 ) ) || ( $BypassContentFilter == 1 ) ) ) )
   87- {
   88- open( NAUGHTY, "$NaughtyWordsFile" );
   89- @naughtywords = <NAUGHTY>;
   90- chomp(@naughtywords);
   91- close(NAUGHTY);
   92- }
   93- $RogueSpace = chr(160);
   94- my $naughty_cnt = 0;
   95- if ($SpamScore) {
   96- $SpamScore = int($SpamScore);
   97- }
   98- foreach $entry ( keys %FORM ) {
   99- $FORM{$entry} =~ s/$RogueSpace/ /g;
  100- if (@naughtywords) {
  101- unless (    ( $entry eq "password" )
  102-          || ( $entry eq "newpass1" )
  103-          || ( $entry eq "newpass2" )
  104-          || ( $entry eq "url" )
  105-          || ( $entry eq "imageurl" ) )
  106- {
  107- if ( $CensorPosts == 1 ) {
  108- foreach $naughtyword (@naughtywords) {
  109- next if ( length($naughtyword) < 2 );
  110- $FORM{$entry} =~ s/$naughtyword/#####/ig;
  111- }
  112- }
  113- else {
  114- foreach $naughtyword (@naughtywords) {
  115- 
  116- next if ( length($naughtyword) < 2 );
  117- 
  118- my $this_naughty_cnt = () = $FORM{$entry} =~ /$naughtyword/ig;
  119- if ($this_naughty_cnt) {
  120- $naughty_cnt += $this_naughty_cnt;
  121- if ( $SpamScore && ( $naughty_cnt >= $SpamScore ) ) {
  122- $tbb->send_error_plain( "1600", "1601", '1700' );
  123- exit;
  124- }
  125- $NaughtyFlag = 1;
  126- }
  127- 
  128- }
  129- }
  130- }
  131- }
  132- unless ( ( $AllowProfileHTML > 1 ) && ( $entry eq "body" ) ) {
  133- $FORM{$entry} =~ s/<!--([^>]|\n)*-->/ /g;
  134- }
  135- if ( ( $AllowProfileHTML < 1 ) || ( $entry ne "body" ) ) {
  136- $FORM{$entry} =~ s/<([^>]|\n)*(>|$)/ /g;
  137- }
  138- $HTMLConvert = 0;
  139- unless ( ( $AllowProfileHTML eq "1" ) && ( $entry eq "body" ) ) {
  140- $FORM{$entry} =~ s/\&/\&\;/g;
  141- $FORM{$entry} =~ s/"/\"\;/g;
  142- $FORM{$entry} =~ s/</\<\;/g;
  143- $FORM{$entry} =~ s/>/\>\;/g;
  144- $HTMLConvert = 1;
  145- }
  146- if ( $entry eq "body" ) {
  147- $FORM{$entry} =~ s/\n/<BR>/g;
  148- $FORM{$entry} = "<P>$FORM{$entry}";
  149- if ($AutoHotlink) {
  150- unless ( $AllowProfileHTML eq "2" ) {
  151- $FORM{$entry} =~ s/\&\;/\&/g;
  152- $FORM{$entry} =~ s/\"\;/"/g;
  153- $FORM{$entry} =~ s/\<\;/</g;
  154- $FORM{$entry} =~ s/\>\;/>/g;
  155- $HTMLConvert = 0;
  156- }
  157- 
  158- $AHL_target = '_blank' unless $AHL_target;
  159- 
  160- $FORM{$entry} =~ s/([ <>])([\w]+:\/\/[\w\*\+\'\!\(\)-?&;,#~=\.\/\$\%\@]+[\w\/])/$1<a href="$2" target="$AHL_target">$2<\/A>/g;
  161- $FORM{$entry} =~ s/([ <>])(www\.[\w\*\+\'\!\(\)-?&;,#~=\.\/\$\%\@]+[\w\/])/$1<a href="http:\/\/$2" target="$AHL_target">$2<\/A>/g;
  162- $FORM{$entry} =~ s/([ <>])([^\s"<>]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?))/$1<a href="mailto:$2">$2<\/A>/g;
  163- }
  164- if (%SmileyCode) {
  165- foreach $key ( keys %SmileyCode ) {
  166- $key2 = $key;
  167- $key2 =~ s/([\[\]\(\)\\\*\+\?\\\|])/\\$1/g;
  168- if ($HTMLConvert) {
  169- $key2 =~ s/\&/\&\;/g;
  170- $key2 =~ s/"/\"\;/g;
  171- $key2 =~ s/</\<\;/g;
  172- $key2 =~ s/>/\>\;/g;
  173- }
  174- $FORM{$entry} =~ s/([ <>])($key2)/$1$SmileyCode{$key}/g;
  175- }
  176- }
  177- if (%FormatCode) {
  178- foreach $key ( keys %FormatCode ) {
  179- $key2 = $key;
  180- $key2 =~ s/([\[\]\(\)\\\*\+\?\\\|])/\\$1/g;
  181- if ($HTMLConvert) {
  182- $key2 =~ s/\&/\&\;/g;
  183- $key2 =~ s/"/\"\;/g;
  184- $key2 =~ s/</\<\;/g;
  185- $key2 =~ s/>/\>\;/g;
  186- }
  187- $FORM{$entry} =~ s/$key2/$FormatCode{$key}/ig;
  188- }
  189- }
  190- $FORM{$entry} =~ s/\s*<br(\s*\/)?>/<BR>/ig;
  191- 
  192- unless ( $FORM{$entry} =~ /<pre>/i ) {
  193- $FORM{$entry} =~ s/<BR>\s\s\s+/<BR><BR>/g;
  194- $FORM{$entry} =~ s/<BR>\t/<BR><BR>/g;
  195- $FORM{$entry} =~ s/\s+/ /g;
  196- $FORM{$entry} =~ s/<BR>\s/<BR>/g;
  197- $FORM{$entry} =~ s/\s<BR>/<BR>/g;
  198- $FORM{$entry} =~ s/<BR><BR>/<P>/g;
  199- $FORM{$entry} =~ s/<P><BR>/<P>/g;
  200- unless ($SingleLineBreaks) {
  201- $FORM{$entry} =~ s/<BR>/ /g;
  202- }
  203- }
  204- }
  205- else {
  206- $FORM{$entry} =~ s/\n/ /g;
  207- }
  208- if ( $FORM{$entry} =~ /<pre>/i ) {
  209- 
  210- $FORM{$entry} =~ s/\s+<BR>/\n<BR>/gi;
  211- $FORM{$entry} =~ s/\s+\n+//gis;
  212- $FORM{$entry} =~ s/<BR>: <PRE>/<BR><PRE>: /gi;
  213- }
  214- else {
  215- $FORM{$entry} =~ s/\s+/ /g;
  216- $FORM{$entry} =~ s/^\s+//g;
  217- $FORM{$entry} =~ s/\s+$//g;
  218- $FORM{$entry} =~ s/<P>/\n<P>/g;
  219- $FORM{$entry} =~ s/<BR>/\n<BR>/g;
  220- $FORM{$entry} =~ s/<P>\n//g;
  221- $FORM{$entry} =~ s/<BR>\n//g;
  222- }
  223- $FORM{$entry} =~ s/^\n//g;
  224- }
  225- undef @naughtywords;
  226- 
  227- $FORM{'ProfileGraphic'} = $post->{'profilegraphic'}->{'content'};
  228- if (    ( $post->{'profilegraphic'}->{'filename'} =~ /\.jpg$/i )
  229-      || ( $post->{'profilegraphic'}->{'filename'} =~ /\.jpeg$/i ) )
  230- {
  231- $PicType = "JPG";
  232- }
  233- elsif ( $post->{'profilegraphic'}->{'filename'} =~ /\.gif$/i ) {
  234- $PicType = "GIF";
  235- }
  236- elsif ( $post->{'profilegraphic'}->{'filename'} =~ /\.png$/i ) {
  237- $PicType = "PNG";
  238- }
  239- 
  240- } ## end sub Parse_Profile
  241- 
  242- sub ListProfiles {
  243- if ( $tbb->{'tbb_admin'} ) {
  244- $ListProfiles      = 1;
  245- $ListAllProfiles   = 1;
  246- $ListEmptyProfiles = 1;
  247- }
  248- if ( !$ListProfiles ) {
  249- $tbb->send_error_plain( "9910", "9912", 'locwprf_1010' );
  250- exit;
  251- }
  252- unless ($ProfileColumns) { $ProfileColumns = 2; }
  253- if ($ListAllProfiles) {
  254- opendir( PROFILES, $UserProfileDir );
  255- @profiles = readdir(PROFILES);
  256- closedir(PROFILES);
  257- foreach $profile (@profiles) {
  258- if ( $profile =~ /^(.*)\.txt$/ ) { $ExtraProfiles{$1} = 1; }
  259- }
  260- undef @profiles;
  261- }
  262- else {
  263- my ( $cutoff, $date );
  264- if ($ProfilesList_ActivityCutoff) {
  265- $cutoff = time() - ( $ProfilesList_ActivityCutoff * 86400 );
  266- }
  267- @sortedmessages = ( sort { $b <=> $a } keys %MessageList );
  268- foreach $message (@sortedmessages) {
  269- $poster = "";
  270- ( $date, undef, $poster, undef ) = split( /\|/, $MessageList{$message} );
  271- if ( $cutoff && ( $date < $cutoff ) ) {
  272- last;
  273- }
  274- $poster =~ s/&pipe;/\|/g;
  275- $Posters{$poster} = 1;
  276- }
  277- }
  278- $ProfileCounter = 0;
  279- foreach $key ( keys %Posters ) {
  280- $ProfileCheck = $key;
  281- $ProfileCheck =~ tr/A-Z/a-z/;
  282- $keycheck = $ProfileCheck;
  283- $ProfileCheck =~ s/[^\w\.\-\']/\+/g;
  284- if ( -e "$UserProfileDir/$ProfileCheck.txt" ) {
  285- $IncludeProfile = 1;
  286- unless ($ListEmptyProfiles) {
  287- $profilesize = int( ( stat("$UserProfileDir/$ProfileCheck.txt") )[7] );
  288- if ( $profilesize < 200 ) {
  289- $IncludeProfile = 0;
  290- open( FILE, "$UserProfileDir/$ProfileCheck.txt" );
  291- @message = <FILE>;
  292- close(FILE);
  293- foreach $line (@message) {
  294- if (    ( $line =~ /^IMAGE>(.+)/i )
  295-      || ( $line =~ /^LINKNAME>(.+)/i )
  296-      || ( $line =~ /^LINKURL>(.+)/i )
  297-      || ( $line =~ /^<P>(.+)/i ) )
  298- {
  299- $IncludeProfile = 1;
  300- last;
  301- }
  302- }
  303- }
  304- }
  305- if ($IncludeProfile) {
  306- unless ( $ProfileList{$ProfileCheck} ) {
  307- $ProfileList{$ProfileCheck} = $key;
  308- $ProfileCounter++;
  309- }
  310- if ( $keycheck ne $key ) {
  311- $ProfileList{$ProfileCheck} = $key;
  312- }
  313- }
  314- delete( $ExtraProfiles{$ProfileCheck} );
  315- }
  316- }
  317- foreach $key ( keys %ExtraProfiles ) {
  318- $ProfileCheck = $key;
  319- if ( -e "$UserProfileDir/$ProfileCheck.txt" ) {
  320- $IncludeProfile = 1;
  321- unless ($ListEmptyProfiles) {
  322- $profilesize = int( ( stat("$UserProfileDir/$ProfileCheck.txt") )[7] );
  323- if ( $profilesize < 200 ) { $IncludeProfile = 0; }
  324- }
  325- open( FILE, "$UserProfileDir/$ProfileCheck.txt" );
  326- @message = <FILE>;
  327- close(FILE);
  328- $profilename = "";
  329- foreach $line (@message) {
  330- if ( $line =~ /^NAME>(.*)/i ) {
  331- $profilename = $1;
  332- }
  333- elsif (    ( $line =~ /^IMAGE>(.+)/i )
  334-         || ( $line =~ /^LINKNAME>(.+)/i )
  335-         || ( $line =~ /^LINKURL>(.+)/i )
  336-         || ( $line =~ /^<P>(.+)/i ) )
  337- {
  338- $IncludeProfile = 1;
  339- last;
  340- }
  341- }
  342- }
  343- if ($IncludeProfile) {
  344- if ($profilename) { $ProfileCheck = $profilename; }
  345- else { $ProfileCheck =~ s/\+/ /g; }
  346- $ProfileList{$key} = $ProfileCheck;
  347- $ProfileCounter++;
  348- }
  349- }
  350- &Header( $text{'2511'}, $MessageHeaderFile );
  351- &Header2( undef, 'profiles' );
  352- print "<h3>$text{'2511'}</h3>\n";
  353- print $cust{'glob_header_e'} . "</div>\n";
  354- if ( $cust{'prof_c21'} ) {
  355- print "<div id=\"prof_c21\">\n", $cust{'prof_c21'}, "</div>\n";
  356- }
  357- print "<div id=\"prof_list\">\n", $cust{'prof_list_s'};
  358- my $ColumnSplit = int( ( $ProfileCounter / $ProfileColumns ) + .99 );
  359- my $cell_w = $ColumnSplit > 1 ? int( 100 / $ProfileColumns ) : 100;
  360- print "\n<table>\n";
  361- print "<tr>\n<td style='width:", $cell_w, "\%\;'>";
  362- $ProfileCounter = 0;
  363- foreach $key ( sort keys(%ProfileList) ) {
  364- 
  365- if ( $ProfileCounter == $ColumnSplit ) {
  366- print "</td>\n<td style='width:", $cell_w, "\%\;'>";
  367- $ProfileCounter = 0;
  368- }
  369- print "\n";
  370- if ( $DisplayProfiles || $AdminRun ) {
  371- print "<a href=\"$DestinationURL$BBSquery";
  372- print 'md' . $QS2 . "profile" . $QS1 . 'id' . $QS2 . "$key\"";
  373- print ">$ProfileList{$key}</a>";
  374- }
  375- else {
  376- print $ProfileList{$key};
  377- }
  378- print "<br>";
  379- $ProfileCounter++;
  380- }
  381- print "</td></tr>\n</table>\n$cust{'prof_list_e'}</div>\n";
  382- if ( $cust{'prof_c22'} ) {
  383- print "<div id=\"prof_c22\">\n" . $cust{'prof_c22'} . "\n</div>\n";
  384- }
  385- &Footer( $MessageFooterFile, "credits" );
  386- } ## end sub ListProfiles
  387- 
  388- sub UserProfile {
  389- if ( ( !$AdminRun ) && ( !$DisplayProfiles ) && ( !$ReturnFromSave ) ) {
  390- $tbb->send_error_plain( "9110", "9113" );
  391- exit;
  392- }
  393- my $startup = 0;
  394- require 'webbbs_share.pl';
  395- if ( !($UserProfile) && $main::tbb->{'get'}->{'id'} ) {
  396- $UserProfile = $main::tbb->{'get'}->{'id'};
  397- }
  398- if ( !($UserProfile) && $main::tbb->{'post'}->{'id'} ) {
  399- $UserProfile = $main::tbb->{'post'}->{'id'};
  400- }
  401- my $verified_ref = $tbb->{'db'}->verify_exists_data( 'type' => 'profile',
  402-                                                      'id'   => $UserProfile, );
  403- if ( !$verified_ref ) {
  404- $tbb->send_error_plain( "9110", "9111" );
  405- exit;
  406- }
  407- eval ' &blog_profile; ';
  408- 
  409- open( FILE, "$verified_ref->{'file'}" )
  410-     || &Error( "9110", "9111" );
  411- @message = <FILE>;
  412- close(FILE);
  413- ( $name, $email, $image_url, $linkname, $linkurl ) = "";
  414- 
  415- foreach $line (@message) {
  416- if    ( $line =~ /^NAME>(.*)/i )       { $name       = $1; }
  417- elsif ( $line =~ /^EMAIL>(.*)/i )      { $email      = $1; }
  418- elsif ( $line =~ /^IP_ADDRESS>(.*)/i ) { $ipaddress  = $1; }
  419- elsif ( $line =~ /^<!--(.*)-->/i )     { $remoteuser = $1; }
  420- elsif ( $line =~ /^PASSWORD>(.*)/i )   { next; }
  421- elsif ( $line =~ /^IMAGE>(.*)/i ) {
  422- ( $image_url, undef ) = &find_pics_location( $1, 'ProfilePics' );
  423- }
  424- elsif ( $line =~ /^LINKNAME>(.*)/i )  { $linkname = $1; }
  425- elsif ( $line =~ /^LINKURL>(.*)/i )   { $linkurl  = $1; }
  426- elsif ( $line =~ /^MODERATED>(.*)/i ) { $profmod  = $1; }
  427- elsif ( !$startup ) {
  428- $startup = 1;
  429- &Header( $text{'2500'}, $MessageHeaderFile );
  430- my %subnav_args = ( 'poster_name' => $name,
  431-                     'poster_id'   => $verified_ref->{'id'}, );
  432- ( $main::navbar_top, $main::navbar_bottom ) =
  433-     $main::tbb->{'tbb_html'}->get_navbar_HTML( 'sub_navbar'  => 'profiles',
  434-                                                'subnav_args' => \%subnav_args, );
  435- unless ($TopNavbarNoPrint) {
  436- print "<div id='nb_top'>\n" . $main::navbar_top . "</div>\n";
  437- }
  438- if ( $cust{'prof_c01'} ) {
  439- print "<div id='prof_c01'>\n", $cust{'prof_c01'}, "\n</div>\n";
  440- }
  441- print '<div id="glob_header">', $cust{'glob_header_s'};
  442- if ($printboardname) {
  443- print "<h2>$boardname</h2>\n";
  444- }
  445- if ($MailPassword) {
  446- print "<p class=\"center\">";
  447- print "$text{'2650'}</p>\n";
  448- require 'webbbs_post.pl';
  449- $body = "$text{'2652'}\n\n$name\n\n";
  450- $body .= "$text{'2653'}\n\n$newpass\n\n";
  451- $body .= "$text{'2654'}\n\n";
  452- $body .= "$text{'2655'}\n";
  453- &SendMail($email);
  454- }
  455- $PosterCount = 0;
  456- if ( !$BlogView ) {
  457- @sortedmessages = ( sort { $a <=> $b } keys %MessageList );
  458- foreach (@sortedmessages) {
  459- $date = $poster = "";
  460- ( $date, undef, $poster, undef ) = split( /\|/, $MessageList{$_} );
  461- $poster =~ s/&pipe;/\|/g;
  462- if ( lc($poster) eq lc($name) ) {
  463- $PosterCount++;
  464- if ( $date > $LastDate ) {
  465- $LastPost = $_;
  466- $LastDate = $date;
  467- }
  468- }
  469- }
  470- }
  471- print "<h3>$text{'2500'}</h3>\n", $cust{'glob_header_e'}, "</div>\n";
  472- if ( $cust{'prof_c02'} ) {
  473- print "<div class='prof_c02'>\n", $cust{'prof_c02'}, "</div>\n";
  474- }
  475- unless ($SingleMsgWrapNoUse) {
  476- print "<div id='msg_wrap'>\n", $cust{'msg_wrap_s'}, "\n";
  477- }
  478- print "<div class='prof_userln'>\n$cust{'prof_userln_s'}\n";
  479- print "<div id='prof_poster'>\n", $cust{'prof_poster_s'}, $name, $cust{'prof_poster_e'}, "</div>\n";
  480- if ( $AdminRun
  481-      && (    ( $remoteuser && ( $remoteuser ne $poster ) )
  482-           || ( $DisplayIPs && $ipaddress ) )
  483-     )
  484- {
  485- print $text{'2520'}, " $text{'1519'}<br>\n"
  486-     if ( $profmod eq 'Yes' );
  487- if ( $remoteuser && ( $remoteuser ne $poster ) ) {
  488- print "<span id=\"prof_remote\">", "('REMOTE_USER' = $remoteuser)</span>\n ";
  489- }
  490- if ( $DisplayIPs && $ipaddress ) {
  491- print "<span id=\"prof_remote\">($ipaddress)</span> ";
  492- }
  493- }
  494- if ( $DisplayProfileEmail && $email ) {
  495- print "<span id='prof_email'><<a href='";
  496- if ($BlindEmail) {
  497- 
  498- print $DestinationURL, $BBSquery, 'md', $QS2, $QueryMode{'bem'}, $QS1, 'id', $QS2, $verified_ref->{'id'}, "'>", $text{'1050'};
  499- 
  500- }
  501- else {
  502- print 'mailto:', $email, "'>", $email;
  503- }
  504- print "</a>></span><br>\n";
  505- }
  506- if ( !$BlogView ) {
  507- print "<span id='prof_msgcnt'>$text{'2501'} ($boardname): ", "<span class='strong'>", &commas($PosterCount), "</span>";
  508- unless ( $PosterCount = 0 ) {
  509- print "</span><br>\n", "<span id='prof_msgcnt'>$text{'2502'}: <a href='", $DestinationURL, $BBSquery, 'md' . $QS2 . 'read' . $QS1 . 'id' . $QS2 . $LastPost, "'$BBStarget>", &PrintDate($LastDate), "</a>";
  510- }
  511- print "</span>\n";
  512- }
  513- print $cust{'prof_userln_e'}, "</div>\n";
  514- print "<div id=\"prof_text\">\n$cust{'prof_text_s'} $MessageOpenCode\n";
  515- print $line;
  516- }
  517- else {
  518- print $line;
  519- }
  520- }
  521- print $MessageCloseCode, $cust{'prof_text_e'}, "</div>\n";
  522- if ($image_url) {
  523- my $image = $image_url;
  524- $image =~ s/.*\/([^\/])/$1/gi;
  525- if ( -e "$UserProfilePicsDir/$image" ) {
  526- $image_url = "$UserProfilePicsURL/$image";
  527- }
  528- print "<div id='prof_image'>\n", $cust{'prof_image_s'}, "\n<IMG SRC='$image_url' ALT=''>\n", $cust{'prof_image_e'}, "</div>\n";
  529- }
  530- if ($linkurl) {
  531- print "<div id='prof_link'>\n", $cust{'prof_link_s'}, "<a href='$linkurl' target='_blank'>", $linkname, "</a>\n", $cust{'prof_link_e'}, "</div>\n";
  532- }
  533- unless ($SingleMsgWrapNoUse) { print $cust{'msg_wrap_e'}, "</div>\n"; }
  534- if ( $cust{'prof_c03'} ) {
  535- print "<div class=\"prof_c03\">\n", $cust{'prof_c03'}, "</div>\n";
  536- }
  537- &Footer( $MessageFooterFile, "credits" );
  538- } ## end sub UserProfile
  539- 
  540- sub EditProfile {
  541- require 'webbbs_share.pl';
  542- $SpellCheckerMeta = 1;
  543- $ProfileCheck     = "";
  544- my $fullname = '';
  545- if (    ( ( $main::tbb->{'get'}->{'md'} eq 'profileedit' ) || ( $main::tbb->{'get'}->{'md'} eq 'login_profileedit' ) )
  546-      && ( $main::tbb->{'get'}->{'id'} ) )
  547- {
  548- $ProfileCheck = $main::tbb->{'get'}->{'id'};
  549- }
  550- elsif (    ( $main::tbb->{'get'}->{'md'} eq 'manage' )
  551-         && ( $main::tbb->{'post'}->{'tp'} eq 'profile' )
  552-         && ( $main::tbb->{'post'}->{'id'} ) )
  553- {
  554- $ProfileCheck = $main::tbb->{'post'}->{'id'};
  555- }
  556- elsif ( $FORM{'loginname'} ) {
  557- $ProfileCheck = $fullname = $FORM{'loginname'};
  558- $Cookies{'name'} = $Cookies{'password'} = '';
  559- }
  560- elsif ( $Cookies{'name'} ) {
  561- $ProfileCheck = $fullname = $Cookies{'name'};
  562- }
  563- else {
  564- &profile_login;
  565- exit;
  566- }
  567- my $login_ok   = 0;
  568- my $check_pw   = $FORM{'loginpw'} || $Cookies{'password'} || '';
  569- my $crypted_pw = crypt( $check_pw, "aa" );
  570- $ProfileCheck =~ s/[^\w\.\-\']/\+/g;
  571- $ProfileCheck =~ tr/A-Z/a-z/;
  572- my $file        = "$UserProfileDir/$ProfileCheck.txt";
  573- my $profiledata = '';
  574- if ( -s $file ) {
  575- $profiledata = $read5x->read_profile($file);
  576- if ( $crypted_pw eq $profiledata->{'password'} ) {
  577- $login_ok = 1;
  578- }
  579- if (    ($fullname)
  580-      && ( $fullname ne $profiledata->{'name'} ) )
  581- {
  582- $login_ok = 0;
  583- }
  584- }
  585- elsif ( $FORM{'loginname'} || $Cookies{'name'} ) {
  586- $login_ok = 1;
  587- }
  588- if ($AdminRun) {
  589- $login_ok = 1;
  590- }
  591- unless ($login_ok) {
  592- &profile_login;
  593- exit;
  594- }
  595- $Cookies{'name'} = $profiledata->{'name'}
  596-     || $FORM{'loginname'}
  597-     || $Cookies{'name'};
  598- if ( $profiledata->{'image_url'} ) {
  599- ( $profiledata->{'image_url'}, undef ) = &find_pics_location( $profiledata->{'image_url'}, 'ProfilePics' );
  600- }
  601- &Header( $text{'2503'}, $MessageHeaderFile );
  602- ( $main::navbar_top, $main::navbar_bottom ) = $main::tbb->{'tbb_html'}->get_navbar_HTML( 'sub_navbar' => 'profile' );
  603- unless ($TopNavbarNoPrint) {
  604- print "<div id='nb_top'>\n" . $main::navbar_top . "</div>\n";
  605- }
  606- if ( $cust{'prof_c11'} ) {
  607- print "<div id=\"prof_c11\">\n", $cust{'prof_c11'}, "</div>\n";
  608- }
  609- if ($printboardname) {
  610- print "<div id='glob_header'>\n", $cust{'glob_header_s'};
  611- print "<h2>$boardname</h2>\n";
  612- print "$cust{'glob_header_e'}</div>\n";
  613- }
  614- if ( $cust{'prof_c12'} ) {
  615- print "<div id=\"prof_c12\">\n" . $cust{'prof_c12'} . "</div>\n";
  616- }
  617- print "<div id=\"prof_form\">\n", $cust{'prof_form_s'};
  618- print "<p>$text{'2550'}";
  619- print "</p>\n";
  620- print "<FORM ENCTYPE=\"multipart/form-data\" METHOD='POST' ";
  621- print "NAME=\"message\" ACTION=\"$DestinationURL$BBSquery";
  622- print 'md' . $QS2 . "$QueryMode{'profilesave'}\" target=\"_self\">\n";
  623- if ( $profiledata->{'ipaddress'} ) {
  624- print "<INPUT TYPE='HIDDEN' NAME=\"ipaddress\" ";
  625- print "VALUE=\"" . $profiledata->{'ipaddress'} . "\">\n";
  626- }
  627- if ( $profiledata->{'remoteuser'} ) {
  628- print "<INPUT TYPE='HIDDEN' NAME=\"remote\" ";
  629- print "VALUE=\"" . $profiledata->{'remoteuser'} . "\">\n";
  630- }
  631- print "<table $tablespec><tr id='prf_01'>\n";
  632- print "<th colspan='2'>";
  633- if ($AdminRun) {
  634- print $text{'2531'};
  635- print "<p><span class=\"strong\">$Cookies{'name'}</span>";
  636- if (    ( $profiledata->{'remoteuser'} && ( $profiledata->{'remoteuser'} ne $poster ) )
  637-      || ( $DisplayIPs && $profiledata->{'ipaddress'} ) )
  638- {
  639- if ( $profiledata->{'remoteuser'}
  640-      && ( $profiledata->{'remoteuser'} ne $poster ) )
  641- {
  642- print " ('REMOTE_USER' = " . $profiledata->{'remoteuser'};
  643- }
  644- if ( $DisplayIPs && $profiledata->{'ipaddress'} ) {
  645- print " (" . $profiledata->{'ipaddress'} . ")";
  646- }
  647- }
  648- print "</p>";
  649- }
  650- else {
  651- print $text{'2503'};
  652- }
  653- print "</th></tr><tr id='prf_02'>";
  654- print "<td align='right'>";
  655- print "$text{'1510'}</td>";
  656- print "<td>";
  657- if ( !($AdminRun) && $LockRemoteUser && $ENV{'REMOTE_USER'} ) {
  658- print "<INPUT TYPE='HIDDEN' NAME=\"name\" ";
  659- print " VALUE=\"$ENV{'REMOTE_USER'}\">";
  660- print "<span class=\"strong\">$ENV{'REMOTE_USER'}</span>";
  661- }
  662- else {
  663- print "<INPUT TYPE='TEXT' NAME=\"name\" ";
  664- print "SIZE='$InputLength' MAXLENGTH='$MaxInputLength'";
  665- if ( $Cookies{'name'} ) { print " VALUE=\"$Cookies{'name'}\""; }
  666- print ">";
  667- }
  668- print "</td></tr><tr id='prf_03'>\n";
  669- print "<td align='right'>";
  670- print "$text{'1511'}";
  671- print "</td><td>";
  672- 
  673- if ( $RequireProfileEmail && $profiledata->{'email'} ) {
  674- print $profiledata->{'email'};
  675- print " " . $cust{'prof_form_11'};
  676- }
  677- else {
  678- my $input_email = $profiledata->{'email'} || $Cookies{'email'} || '';
  679- print "<INPUT TYPE='TEXT' NAME=\"email\" SIZE='$InputLength' MAXLENGTH='100'";
  680- print " VALUE=\"" . $input_email . "\">";
  681- if ($RequireProfileEmail) {
  682- print "</td></tr><tr id='prf_04'>\n";
  683- print "<td align='right'>";
  684- print "$text{'2521'}";
  685- print "</td><td>";
  686- print "<INPUT TYPE='TEXT' NAME=\"email_2\" SIZE='$InputLength' MAXLENGTH='100'";
  687- print " VALUE=\"" . $input_email . "\">";
  688- 
  689- }
  690- }
  691- print "</td></tr><tr id='prf_05'>\n";
  692- print "<td colspan='2'>";
  693- print "<span class=\"strong\">$text{'2518'}:</span>";
  694- print "<br>\n<TEXTAREA COLS='$InputColumns' ROWS='$InputRows' ";
  695- print "NAME=\"body\">";
  696- $body = $profiledata->{'text'};
  697- if (%SmileyCode) {
  698- foreach $key ( keys %SmileyCode ) {
  699- $key2 = $SmileyCode{$key};
  700- $key2 =~ s/([\[\]\(\)\\\*\+\?\\\|])/\\$1/g;
  701- $body =~ s/$key2/$key/g;
  702- }
  703- }
  704- if (%FormatCode) {
  705- require 'webbbs_share.pl';
  706- $quotedtext = decode_BB_code( $quotedtext, \%FormatCode );
  707- }
  708- $body =~ s/\n/ /g;
  709- $body =~ s/<P>/\n\n/g;
  710- $body =~ s/<BR>/\n/g;
  711- $body =~ s/^\n*//g;
  712- 
  713- $body =~ s/\& /\&\; /g;
  714- $body =~ s/"/\"\;/g;
  715- $body =~ s/</\<\;/g;
  716- $body =~ s/>/\>\;/g;
  717- print "$body\n";
  718- print "</TEXTAREA></td></tr>\n";
  719- 
  720- if ($AllowProfileURLs) {
  721- print "<tr id='prf_06'><td align='right'>";
  722- print "$text{'1515'}</td>";
  723- print "<td><INPUT TYPE='TEXT' ";
  724- print "NAME=\"url\" SIZE='$InputLength' MAXLENGTH='250'";
  725- if ( $profiledata->{'linkurl'} ) {
  726- print " VALUE=\"" . $profiledata->{'linkurl'} . "\"";
  727- }
  728- elsif ( $Cookies{'linkurl'} ) {
  729- print " VALUE=\"$Cookies{'linkurl'}\"";
  730- }
  731- else { print " VALUE=\"http://\""; }
  732- print "></td></tr><tr id='prf_07'>\n";
  733- print "<td align='right'>";
  734- print "$text{'1516'}</td>";
  735- print "<td><INPUT TYPE='TEXT' ";
  736- print "NAME=\"url_title\" SIZE='$InputLength' MAXLENGTH='$MaxInputLength'";
  737- if ( $profiledata->{'linkname'} ) {
  738- print " VALUE=\"" . $profiledata->{'linkname'} . "\"";
  739- }
  740- elsif ( $Cookies{'linkname'} ) {
  741- print " VALUE=\"$Cookies{'linkname'}\"";
  742- }
  743- print "></td></tr>\n";
  744- }
  745- if ($AllowProfilePics) {
  746- print "<tr id='prf_08'><td></td>\n", "<td>", $text{'1501'}, "</td>\n", "    </tr><tr id='prf_09'>\n", "<td align='right'>", $text{'1517'}, "</td>\n", "<td><INPUT TYPE='TEXT' ", "NAME='imageurl' SIZE='$InputLength' MAXLENGTH='250' VALUE='";
  747- if ( $profiledata->{'image_url'} ) {
  748- print $profiledata->{'image_url'};
  749- }
  750- elsif ( $Cookies{'imageurl'} ) { print "$Cookies{'imageurl'}"; }
  751- else                           { print "http://"; }
  752- print "'></td>\n", "    </tr>\n";
  753- if ($UserProfilePicsURL) {
  754- print "<tr id='prf_10'><td></td>\n", "<td>", $text{'1507'}, "</td>\n", "    </tr><tr id='prf_11'>\n", "<td align='right'>", $text{'2505'}, "</td>\n", "<td>", "<INPUT TYPE='FILE' NAME='profilegraphic' SIZE='$InputLength'>", "</td>\n", "    </tr>\n";
  755- }
  756- }
  757- if ( $AdminRun && $profiledata->{'image_url'} ) {
  758- print "<tr id='prf_12'><td colspan='2' class=\"center\">";
  759- print "<IMG SRC=\"" . $profiledata->{'image_url'} . "\" ALT=\"\">\n";
  760- print "</td></tr>\n";
  761- }
  762- if (    $AdminRun
  763-      || ( $RequireProfileEmail && $profiledata->{'email'} )
  764-      || ( !$RequireProfileEmail ) )
  765- {
  766- $PassBoxSize = int( $InputLength / 3 );
  767- unless ($AdminRun) {
  768- print "<tr id='prf_13'><td align='right'>";
  769- print "$text{'0205'}</td>";
  770- print "<td><INPUT TYPE='PASSWORD' NAME=\"password\"";
  771- if ($check_pw) { print " VALUE=\"$check_pw\""; }
  772- print " SIZE='$PassBoxSize' maxlength='10'>\n";
  773- print " " . $cust{'prof_form_10'};
  774- print "</td></tr>\n";
  775- }
  776- print "<tr id='prf_14'><td align='right'>";
  777- print "$text{'0208'}</td>";
  778- print "<td><INPUT TYPE='PASSWORD' NAME=\"newpass1\"";
  779- print " SIZE='$PassBoxSize' maxlength='8'> <INPUT TYPE='PASSWORD' NAME=\"newpass2\"";
  780- print " SIZE='$PassBoxSize' maxlength='8'>";
  781- print "</td></tr>\n";
  782- if ($UseCookies) {
  783- print "<tr id='prf_15'><td align='right'>";
  784- print "$text{'6720'}</td>";
  785- print "<td>";
  786- print "<label><INPUT TYPE='RADIO' NAME=\"CookiePW\" ";
  787- print "VALUE=\"Yes\"";
  788- if ($check_pw) { print " CHECKED"; }
  789- print "> $text{'1519'}</label> ";
  790- print "<label><INPUT TYPE='RADIO' NAME=\"CookiePW\" ";
  791- print "VALUE=\"No\"";
  792- unless ($check_pw) { print " CHECKED"; }
  793- print "> $text{'1520'}</label>";
  794- print "</td></tr>\n";
  795- }
  796- }
  797- if ($AdminRun) {
  798- unless ( $profiledata->{'profmod'} ) {
  799- $profiledata->{'profmod'} = ($Moderated) ? 'Yes' : 'No';
  800- }
  801- print "<tr id='prf_16'><td align='right'>";
  802- print "$text{'2520'}</td>";
  803- print "<td>";
  804- print "<label><INPUT TYPE='RADIO' NAME=\"ProfMod\" ";
  805- print "VALUE=\"Yes\"";
  806- if ( $profiledata->{'profmod'} eq "Yes" ) { print " CHECKED"; }
  807- print "> $text{'1519'}</label> ";
  808- print "<label><INPUT TYPE='RADIO' NAME=\"ProfMod\" ";
  809- print "VALUE=\"No\"";
  810- if ( $profiledata->{'profmod'} eq "No" ) { print " CHECKED"; }
  811- print "> $text{'1520'}</label>";
  812- print "</td></tr>\n";
  813- }
  814- print "<tr id='prf_17'><td colspan='2' class='misc_msgform_b'>";
  815- if ($SpellCheckURL) {
  816- print "<button class='button' type='button' onClick='spellcheck_sendtext(\"message\", \"body\", \"$spellcheck_popup_width\", \"$spellcheck_popup_height\", \"$spellcheck_popup_top\", \"$spellcheck_popup_left\")'>\n", "$text{'1552'}</button>\n";
  817- }
  818- print "<INPUT TYPE='SUBMIT' class='button' NAME=\"Post\" ";
  819- print "VALUE=\"$text{'2507'}\"> ";
  820- unless ( !($AdminRun) && $RequireProfileEmail ) {
  821- print "<INPUT TYPE='SUBMIT' class='button' NAME=\"Delete\" ";
  822- print "VALUE=\"$text{'2504'}\"></td>";
  823- }
  824- print "</tr>\n</table>\n</FORM>\n";
  825- if ($SpellCheckURL) {
  826- print "<form name='send' action='$SpellCheckURL' method='POST' target='SpellChecker'>\n", "<input type='hidden' name='checkme'>\n", "<input type='hidden' name='form'>\n", "<input type='hidden' name='field'>\n", "<input type='hidden' name='spell' value='check'>\n", "</form>\n";
  827- }
  828- print $cust{'prof_form_e'}, "</div>\n";
  829- if ( $cust{'prof_c13'} ) {
  830- print "<div id=\"prof_c13\">\n", $cust{'prof_c13'}, "</div>\n";
  831- }
  832- &Footer( $MessageFooterFile, "credits" );
  833- } ## end sub EditProfile
  834- 
  835- sub CheckPassword {
  836- unless ($name) { &Error( "9610", "9611" ); }
  837- $profilename = $name;
  838- $profilename =~ s/[^\w\.\-\']/\+/g;
  839- $profilename =~ tr/A-Z/a-z/;
  840- if ( !($AdminRun) && $RequireProfileEmail ) {
  841- unless ( -e "$UserProfileDir/$profilename.txt" ) {
  842- return;
  843- }
  844- }
  845- $CheckPass = $FORM{'oldpassword'} ? $FORM{'oldpassword'} : $FORM{'password'};
  846- unless ($CheckPass) {
  847- &Error( "9610", "9611" ) unless ($AdminRun);
  848- }
  849- $newpassword = crypt( $CheckPass, "aa" );
  850- if ( -e "$UserProfileDir/$profilename.txt" ) {
  851- $PassCheck   = 0;
  852- $oldpassword = "";
  853- open( FILE, "$UserProfileDir/$profilename.txt" );
  854- @message = <FILE>;
  855- close(FILE);
  856- foreach $line (@message) {
  857- if ( $line =~ /^PASSWORD>(.*)/i ) {
  858- $oldpassword = $1;
  859- last;
  860- }
  861- }
  862- if ($oldpassword) {
  863- if ( $newpassword eq $oldpassword ) {
  864- $PassCheck = 1;
  865- }
  866- }
  867- 
  868- }
  869- if ( $FORM{'oldpassword'} ) {
  870- $newpassword = crypt( $FORM{'password'}, "aa" );
  871- }
  872- } ## end sub CheckPassword
  873- 
  874- sub SaveProfile {
  875- require 'webbbs_share.pl';
  876- &CheckPassword;
  877- if ($ResolveIPs) {
  878- if ( ( $ENV{'REMOTE_ADDR'} =~ /\d+\.\d+\.\d+\.\d+/ )
  879-      && ( !( $ENV{'REMOTE_HOST'} )
  880-           || ( $ENV{'REMOTE_HOST'} =~ /\d+\.\d+\.\d+\.\d+/ ) )
  881-     )
  882- {
  883- @domainbytes = split( /\./, $ENV{'REMOTE_ADDR'} );
  884- $packaddr = pack( "C4", @domainbytes );
  885- $resolvedip = ( gethostbyaddr( $packaddr, 2 ) )[0];
  886- unless ( $resolvedip =~ /^[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})$/ ) {
  887- $resolvedip = "";
  888- }
  889- if ($resolvedip) {
  890- $ENV{'REMOTE_HOST'} = $resolvedip;
  891- }
  892- }
  893- }
  894- else {
  895- $ENV{'REMOTE_HOST'} = "";
  896- }
  897- unless ( $ENV{'REMOTE_HOST'} ) {
  898- $ENV{'REMOTE_HOST'} = $ENV{'REMOTE_ADDR'};
  899- }
  900- if ( $BannedIPsFile && ( $BanLevel != 1 ) ) {
  901- open( BANNED, "$BannedIPsFile" );
  902- @bannedips = <BANNED>;
  903- chomp(@bannedips);
  904- close(BANNED);
  905- foreach $bannedip (@bannedips) {
  906- $bannedip =~ s/^([^\s]*)\s.*$/$1/g;
  907- next if ( length($bannedip) < 2 );
  908- if (    ( $ENV{'REMOTE_HOST'} =~ /$bannedip/i )
  909-      || ( $ENV{'REMOTE_ADDR'} =~ /$bannedip/i ) )
  910- {
  911- &Error( "9520", "9521" );
  912- }
  913- }
  914- undef @bannedips;
  915- }
  916- if ($NaughtyFlag) {
  917- &Error( "9512", "9513" );
  918- }
  919- unless ($AdminRun) {
  920- $FORM{'ProfMod'} = "";
  921- if ( -e "$UserProfileDir/$profilename.txt" ) {
  922- open( FILE, "$UserProfileDir/$profilename.txt" );
  923- @message = <FILE>;
  924- close(FILE);
  925- foreach $line (@message) {
  926- if ( $line =~ /^EMAIL>(.*)/i ) {
  927- $oldemail = $1;
  928- }
  929- elsif ( $line =~ /^MODERATED>(.*)/i ) {
  930- $FORM{'ProfMod'} = $1;
  931- if ($EditedProfilesModerated) { $FORM{'ProfMod'} = 'Yes';
  932- }
  933- last;
  934- }
  935- }
  936- }
  937- if ( !$FORM{'ProfMod'} ) {
  938- $FORM{'ProfMod'} = 'No';
  939- if ( ($NewProfilesModerated) || ( ( !defined $NewProfilesModerated ) && ($Moderated) ) ) {
  940- $FORM{'ProfMod'} = 'Yes';
  941- }
  942- }
  943- 
  944- if ( $email && ( $oldemail ne $email ) ) {
  945- opendir( PROFILES, $UserProfileDir );
  946- @profiles = readdir(PROFILES);
  947- closedir(PROFILES);
  948- foreach $profile (@profiles) {
  949- unless ( $profile =~ /^.*\.txt$/ ) { next; }
  950- open( FILE, "$UserProfileDir/$profile" );
  951- @message = <FILE>;
  952- close(FILE);
  953- $profilenamecheck  = "";
  954- $profileemailcheck = "";
  955- foreach $line (@message) {
  956- if ( $line =~ /^NAME>(.*)/i ) { $profilenamecheck = $1; }
  957- elsif ( $line =~ /^EMAIL>(.*)/i ) {
  958- $profileemailcheck = $1;
  959- last;
  960- }
  961- }
  962- if ( $profileemailcheck eq $email ) {
  963- &Error( "9516", "9517", $profilenamecheck );
  964- }
  965- }
  966- undef @profiles;
  967- }
  968- 
  969- if ($RequireProfileEmail) {
  970- if ($oldemail) {
  971- $email = $oldemail;
  972- }
  973- elsif (    ( !$oldemail )
  974-         && ( $email ne $FORM{'email_2'} ) )
  975- {
  976- &Error( "9518", "9519" );
  977- }
  978- else {
  979- $oldpassword = "";
  980- $newpassword = "";
  981- $newpass     = "";
  982- srand();
  983- $passwordlength = int( rand(4) ) + 7;
  984- foreach $key ( 1 .. $passwordlength ) {
  985- $char = int( rand(26) );
  986- $char += 65;
  987- $char = chr($char);
  988- $newpass .= $char;
  989- }
  990- $newpassword = crypt( $newpass, "aa" );
  991- $MailPassword = 1;
  992- }
  993- }
  994- }
  995- 
  996- my $ban_result = $tbb->{'db'}->verify_filters( 'type'     => 'bannedEmails',
  997-                                                'to_check' => $email, );
  998- if ( $ban_result != 0 ) {
  999- &Error( "9514", "40030" );
 1000- }
 1001- 
 1002- if ( $RequireProfileEmail && !($email) ) {
 1003- &Error( "9514", "9515" );
 1004- }
 1005- my $check_imaurl = $FORM{'imageurl'};
 1006- $check_imaurl =~ s/^(http)?:?(\/)*//gi;
 1007- $check_imaurl =~ s/\s+//g;
 1008- if (    ($check_imaurl)
 1009-      && ( $check_imaurl !~ /\.(gif|jpg|jpeg|png)$/i ) )
 1010- {
 1011- &Error( "9656", "9657" );
 1012- exit;
 1013- }
 1014- if ( $FORM{'ProfileGraphic'} ) {
 1015- if    ( $PicType eq "GIF" ) { $picname = "$profilename.gif"; }
 1016- elsif ( $PicType eq "JPG" ) { $picname = "$profilename.jpg"; }
 1017- elsif ( $PicType eq "PNG" ) { $picname = "$profilename.png"; }
 1018- else { &Error( "9650", "9651" ); }
 1019- if ( length( $FORM{'ProfileGraphic'} ) > ( $MaxGraphicSize * 1024 ) ) {
 1020- &Error( "9652", "9653" );
 1021- }
 1022- unless ( open( GRAPHIC, ">$UserProfilePicsDir/$picname" ) ) {
 1023- &Error( "9654", "9655" );
 1024- }
 1025- binmode GRAPHIC;
 1026- print GRAPHIC $FORM{'ProfileGraphic'};
 1027- close(GRAPHIC);
 1028- $image_url = "$UserProfilePicsURL/$picname";
 1029- }
 1030- my $file = "$UserProfileDir/$profilename.txt";
 1031- $profiledata = $read5x->read_profile($file);
 1032- my ( $prof_image_url, $prof_image_file ) = &find_pics_location( $profiledata->{'image_url'}, 'ProfilePics' );
 1033- if ( $prof_image_url ne $image_url ) { unlink $prof_image_file; }
 1034- open( FILE, ">$UserProfileDir/$profilename.txt" )
 1035-     || &Error( "9110", "9112" );
 1036- print FILE "NAME>$name\n";
 1037- print FILE "EMAIL>$email\n";
 1038- if ( $AdminRun && !( $FORM{'newpass1'} ) ) {
 1039- print FILE "PASSWORD>$oldpassword\n";
 1040- }
 1041- else { print FILE "PASSWORD>$newpassword\n"; }
 1042- if ($AdminRun) {
 1043- print FILE "IP_ADDRESS>$FORM{'ipaddress'}\n";
 1044- if ( $FORM{'remote'} ) {
 1045- print FILE "<!--$FORM{'remote'}-->\n";
 1046- }
 1047- }
 1048- else {
 1049- print FILE "IP_ADDRESS>$ENV{'REMOTE_HOST'}\n";
 1050- if ( $ENV{'REMOTE_USER'} ) {
 1051- print FILE "<!--$ENV{'REMOTE_USER'}-->\n";
 1052- }
 1053- }
 1054- print FILE "IMAGE>$image_url\n";
 1055- print FILE "LINKNAME>$message_url_title\n";
 1056- print FILE "LINKURL>$message_url\n";
 1057- print FILE "MODERATED>$FORM{'ProfMod'}\n";
 1058- print FILE "$FORM{'body'}\n";
 1059- close(FILE);
 1060- $UserProfile    = $profilename;
 1061- $ReturnFromSave = 1;
 1062- &UserProfile;
 1063- } ## end sub SaveProfile
 1064- 
 1065- sub DeleteProfile {
 1066- require 'webbbs_share.pl';
 1067- &CheckPassword;
 1068- my $file = "$UserProfileDir/$profilename.txt";
 1069- $profiledata = $read5x->read_profile($file);
 1070- unlink $file;
 1071- my ( undef, $prof_image ) = &find_pics_location( $profiledata->{'image_url'}, 'ProfilePics' );
 1072- if ($prof_image) { unlink $prof_image; }
 1073- unlink "$UserProfilePicsDir/$profilename.gif";
 1074- unlink "$UserProfilePicsDir/$profilename.jpg";
 1075- unlink "$UserProfilePicsDir/$profilename.png";
 1076- &Header( $text{'2600'}, $MessageHeaderFile, "refresh" );
 1077- &Header2("refresh");
 1078- print "<h3>$text{'2600'}</h3>\n";
 1079- print $cust{'glob_header_e'} . "\n</div>\n";
 1080- print "<div id=\"glob_msg\">\n" . $cust{'prof_msg_s'};
 1081- print "<p>$text{'2601'}</p>\n";
 1082- print $cust{'prof_msg_e'} . "\n</div>\n";
 1083- &Footer( $MessageFooterFile, "return", "refresh" );
 1084- } ## end sub DeleteProfile
 1085- 
 1086- sub SetCookieData {
 1087- &GetCookie($boardname);
 1088- unless ( $FORM{'password'} ) { $FORM{'password'} = $Cookies{'password'}; }
 1089- if ( ( $main::tbb->{'get'}->{'md'} ne 'profilesave' )
 1090-      || $FORM{'Delete'} )
 1091- {
 1092- return;
 1093- }
 1094- $listtype = $Cookies{'listtype'};
 1095- $listtime = $Cookies{'listtime'};
 1096- unless ( $Cookies{'lastvisit'} ) {
 1097- $Cookies{'lastvisit'}   = $lastvisit = $todaydate;
 1098- $Cookies{'lastmessage'} = $lastseen  = $lastmessage;
 1099- $Cookies{'thisvisit'}   = $thisvisit = $todaydate;
 1100- $Cookies{'thismessage'} = $thisseen  = $lastmessage;
 1101- }
 1102- if ( $Cookies{'timestamp'}
 1103-      && ( ( $time - $Cookies{'timestamp'} ) > $SessionTime ) )
 1104- {
 1105- $Cookies{'lastvisit'}   = $lastvisit = $Cookies{'thisvisit'};
 1106- $Cookies{'lastmessage'} = $lastseen  = $Cookies{'thismessage'};
 1107- $Cookies{'thisvisit'}   = $thisvisit = $todaydate;
 1108- $Cookies{'thismessage'} = $thisseen  = $lastmessage;
 1109- }
 1110- else {
 1111- $lastvisit = $Cookies{'lastvisit'};
 1112- $lastseen  = $Cookies{'lastmessage'};
 1113- $thisvisit = $Cookies{'thisvisit'};
 1114- $thisseen  = $Cookies{'thismessage'};
 1115- }
 1116- &WriteCookie;
 1117- } ## end sub SetCookieData
 1118- 
 1119- sub profile_login {
 1120- my $loginname = $FORM{'loginname'} || $Cookies{'name'} || '';
 1121- &Header( $text{'2532'}, $MessageHeaderFile, undef, undef );
 1122- ( $main::navbar_top, $main::navbar_bottom ) = $main::tbb->{'tbb_html'}->get_navbar_HTML( 'sub_navbar' => 'profile' );
 1123- unless ($TopNavbarNoPrint) {
 1124- print "<div id='nb_top'>\n" . $main::navbar_top . "</div>\n";
 1125- }
 1126- print "<div id='prof_login'>\n", "<h2>$text{'2532'}</h2>\n";
 1127- if ( $FORM{'loginname'} || $FORM{'loginpw'} ) {
 1128- print "<h3>$text{'9120'}</h3>\n<p>$text{'9121'}<br/> </p>\n";
 1129- }
 1130- else {
 1131- print "<p>$text{'2533'}<br/> </p>\n";
 1132- }
 1133- my $actionurl = $DestinationURL . $BBSquery . 'md' . $QS2 . $QueryMode{'profileedit'};
 1134- print <<"EOF";
 1135- <form method='post' action='$actionurl' name='login' target='_self'>
 1136- <table class='w80'>
 1137-     <TR>
 1138- <td ALIGN='RIGHT' width='40%'>$text{'1510'}</td>
 1139- <TD><INPUT TYPE='TEXT' NAME='loginname' SIZE='25' MAXLENGTH='50' VALUE='$loginname'></TD>
 1140-     </TR><TR>
 1141- <td ALIGN='RIGHT' width='40%'>$text{'0205'}</td>
 1142- <TD><INPUT TYPE='PASSWORD' NAME='loginpw' VALUE='' SIZE='25'>$cust{'prof_login_1'}</TD>
 1143-     </TR><TR>
 1144- <td COLSPAN='2' class='misc_msgform_b'>
 1145- <input TYPE='SUBMIT' class='button' name='submit' value='$text{'2531'}'></td>
 1146-     </TR>
 1147- </TABLE>
 1148- </form>
 1149- EOF
 1150- print "</div>\n";
 1151- &Footer( $FooterFile, 'credits', undef );
 1152- } ## end sub profile_login
 1153- 
 1154- 1;