F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Admin\RegistrationLog.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Admin\RegistrationLog.pm
############################################################################### ###############################################################################
# RegistrationLog.pl                                                          # # RegistrationLog.pm                                                          #
  # $Date: 01.05.16 $                                                           #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5.2                                                  # # Version:        YaBB 2.6.12                                                 #
# Packaged:       October 21, 2012                                            # # Packaged:       January 5, 2016                                             #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
############################################################################### ###############################################################################
  use CGI::Carp qw(fatalsToBrowser);
  use English qw(-no_match_vars);
  our $VERSION = '2.6.12';
   
$registrationlogplver = 'YaBB 2.5.2 $Revision: 1.1 $'; $registrationlogpmver = 'YaBB 2.6.12 $Revision: 1710 $';
if ($action eq 'detailedversion') { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
&LoadLanguage('Register');  LoadLanguage('Register'); 
   
sub view_reglog { sub view_reglog {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   
   $yytitle = $prereg_txt{'15a'};    $yytitle = $prereg_txt{'15a'};
   
   if (-e "$vardir/registration.log") {    if ( -e "$vardir/registration.log" ) {
       fopen(LOGFILE, "$vardir/registration.log");         fopen( LOGFILE, "$vardir/registration.log" ); 
       @logentries = <LOGFILE>;        @logentries = <LOGFILE>;
       fclose(LOGFILE);        fclose(LOGFILE);
       @logentries = reverse @logentries;        @logentries = reverse @logentries;
   
       fopen(FILE, "$memberdir/memberlist.txt");         fopen( FILE, "$memberdir/memberlist.txt" ); 
       @memberlist = <FILE>;        @memberlist = <FILE>;
       fclose(FILE);        fclose(FILE);
   
       # If a pre-registration list exists load it        # If a pre-registration list exists load it
       if (-e "$memberdir/memberlist.inactive") {        if ( -e "$memberdir/memberlist.inactive" ) {
           fopen(INACT, "$memberdir/memberlist.inactive");             fopen( INACT, "$memberdir/memberlist.inactive" ); 
           @reglist = <INACT>;            @reglist = <INACT>;
           fclose(INACT);            fclose(INACT);
       }        }
       # grab pre regged user activationkey for admin activation  
       foreach (@reglist) {         # grab pre regged user activationkey for admin activation 
           (undef, $actcode, $regmember, undef) = split(/\|/, $_, 4);         foreach (@reglist) { 
           $actkey{$regmember} = $actcode;             ( undef, $actcode, $regmember, undef ) = split /\|/xsm, $_, 4; 
       }             $actkey{$regmember} = $actcode; 
   } else {         } 
       $servertime = $date;     } 
       push(@logentries, "$servertime|LD|$username|$username|$user_ip");     else { 
   }         $servertime = $date; 
   @memberlist = reverse @memberlist;         push @logentries, "$servertime|LD|$username|$username|$user_ip"; 
     }
   if (@logentries > 0) {     @memberlist = reverse @memberlist; 
       $logcount = @logentries;  
       my $newstart = $INFO{'newstart'} || 0;     if ( @logentries > 0 ) { 
         $logcount = @logentries;
       $postdisplaynum = 8;         my $newstart = $INFO{'newstart'} || 0; 
       $max = $logcount;  
       $newstart = (int($newstart / 25)) * 25;         $postdisplaynum = 8; 
       $tmpa = 1;         $max            = $logcount; 
       if ($newstart >= (($postdisplaynum - 1) * 25)) { $startpage = $newstart - (($postdisplaynum - 1) * 25); $tmpa = int( $startpage / 25 ) + 1; }         $newstart       = ( int( $newstart / 25 ) ) * 25; 
       if ($max >= $newstart + ($postdisplaynum * 25)) { $endpage = $newstart + ($postdisplaynum * 25); } else { $endpage = $max }         $tmpa           = 1; 
       if ($startpage > 0) { $pageindex = qq~<a href="$adminurl?action=$action;newstart=0" style="font-weight: normal;">1</a>&nbsp;...&nbsp;~; }         if ( $newstart >= ( ( $postdisplaynum - 1 ) * 25 ) ) { 
       if ($startpage == 25) { $pageindex = qq~<a href="$adminurl?action=$action;newstart=0" style="font-weight: normal;">1</a>&nbsp;~;}             $startpage = $newstart - ( ( $postdisplaynum - 1 ) * 25 ); 
       for ($counter = $startpage; $counter < $endpage; $counter += 25) {             $tmpa = int( $startpage / 25 ) + 1; 
           $pageindex .= $newstart == $counter ? qq~<b>$tmpa</b>&nbsp;~ : qq~<a href="$adminurl?action=$action;newstart=$counter" style="font-weight: normal;">$tmpa</a>&nbsp;~;         } 
           $tmpa++;         if ( $max >= $newstart + ( $postdisplaynum * 25 ) ) { 
       }             $endpage = $newstart + ( $postdisplaynum * 25 ); 
       $lastpn = int($logcount / 25) + 1;         } 
       $lastptn = ($lastpn - 1) * 25;         else { $endpage = $max } 
       if ($endpage < $max - (25) ) { $pageindexadd = qq~...&nbsp;~; }         if ( $startpage > 0 ) { 
       if ($endpage != $max) { $pageindexadd .= qq~<a href="$adminurl?action=$action;newstart=$lastptn">$lastpn</a>~; }             $pageindex = 
       $pageindex .= $pageindexadd;  qq~<a href="$adminurl?action=$action;newstart=0" class="norm">1</a>&nbsp;...&nbsp;~; 
         }
       $pageindex = qq~         if ( $startpage == 25 ) { 
           <tr>             $pageindex = 
               <td class="windowbg" colspan="4"><span class="small" style="float: left;">$admin_txt{'139'}: $pageindex</span></td>  qq~<a href="$adminurl?action=$action;newstart=0" class="norm">1</a>&nbsp;~; 
           </tr>         } 
       ~;         foreach my $counter ( $startpage .. ( $endpage - 1 ) ) { 
             if ( $counter % 25 == 0 ) {
       $numbegin = ($newstart + 1);                 $pageindex .= 
       $numend = ($newstart + 25);                   $newstart == $counter 
       if ($numend > $logcount) { $numend  = $logcount; }                   ? qq~<b>$tmpa</b>&nbsp;~ 
       if ($logcount == 0) { $numshow = ''; }                   : qq~<a href="$adminurl?action=$action;newstart=$counter" class="norm">$tmpa</a>&nbsp;~; 
       else { $numshow = qq~($numbegin - $numend)~; }                 $tmpa++; 
             }
       @logentries = splice(@logentries, $newstart, 25);         } 
   }         $lastpn  = int( $logcount / 25 ) + 1; 
         $lastptn = ( $lastpn - 1 ) * 25;
   foreach $logentry (@logentries) {         if ( $endpage < $max - (25) ) { $pageindexadd = q~...&nbsp;~; } 
       chomp $logentry;         if ( $endpage != $max ) { 
       my ($logtime, $status, $userid, $actid, $ipadd) = split(/\|/, $logentry);             $pageindexadd .= 
       if($do_scramble_id){  qq~<a href="$adminurl?action=$action;newstart=$lastptn">$lastpn</a>~; 
           $cryptactid = &cloak($actid);         } 
           $cryptuserid = &cloak($userid);         $pageindex .= $pageindexadd; 
       } else {  
           $cryptactid = $actid;  
           $cryptuserid = $userid;  
       }  
       if($userid ne $actid && $actid ne '') {  
           &LoadUser($actid);  
           $actadminlink = qq~ $prereg_txt{'by'} <a href="$scripturl?action=viewprofile;username=$cryptactid">${$uid.$actid}{'realname'}</a>~;  
       } else {  
           $actadminlink = '';  
       }  
       if ($status eq 'AA' && &LoadUser($userid)){  
           &LoadUser($userid);  
           $linkuserid = qq~$userid (<a href="$scripturl?action=viewprofile;username=$cryptuserid">${$uid.$userid}{'realname'}</a>)~;  
       } else {  
           $linkuserid = $userid;  
       }  
       $is_member = &check_member($userid);  
       if ($do_scramble_id){ $cryptid = &cloak($userid); } else { $cryptid = $userid; }  
       $reclogtime = &timeformat($logtime);  
       if ($status eq 'N' && $is_member == 0 && -e "$memberdir/$userid.pre") {  
           $delrecord = qq~<a href="$adminurl?action=del_regentry;username=$cryptid">$prereg_txt{'del'}</a>~;  
           $delrecord .= qq~<br /><a href="$adminurl?action=view_regentry;username=$cryptid~ . ($actkey{$userid} ne '' ? ";activationkey=$actkey{$userid};type=validate" : "") . qq~">$prereg_txt{'view'}</a>~;  
           $delrecord .= qq~<br /><a href="$scripturl?action=activate;username=$cryptid;activationkey=$actkey{$userid}">$prereg_txt{'act'}</a>~;  
       } elsif ($status eq 'W' && $is_member == 0 && -e "$memberdir/$userid.wait") {  
           $delrecord = qq~<a href="$adminurl?action=rej_regentry;username=$cryptid">$prereg_txt{'reject'}</a>~;  
           $delrecord .= qq~<br /><a href="$adminurl?action=view_regentry;username=$cryptid;type=approve">$prereg_txt{'view'}</a>~;  
           $delrecord .= qq~<br /><a href="$adminurl?action=apr_regentry;username=$cryptid">$prereg_txt{'apr'}</a>~;  
       } else {  
           $delrecord = '---';  
       }  
       $loglist .= qq~  
       <tr>  
       <td class="windowbg" width="20%" align="center">$reclogtime</td>  
       <td class="windowbg2" width="35%" align="center">$prereg_txt{$status}$actadminlink<br />IP: $ipadd</td>  
       <td class="windowbg" width="25%" align="center">$linkuserid</td>  
       <td class="windowbg2" width="20%" align="center">$delrecord</td>  
       </tr>~;  
   }  
   
   $yymain .= qq~  
   <script language="JavaScript1.2" src="$yyhtml_root/ubbc.js" type="text/javascript"></script>  
   <form name="reglog_form" action="$adminurl?action=clean_reglog" method="post" onsubmit="return submitproc();">  
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">  
   <table width="100%" cellspacing="1" cellpadding="4">  
   <tr valign="middle">  
       <td align="left" class="titlebg" colspan="4"><img src="$imagesdir/xx.gif" alt="" border="0" /> <b>$yytitle</b></td>  
   </tr>  
   <tr valign="middle">  
       <td align="left" class="windowbg2" colspan="4"><br />$prereg_txt{'20'}<br /><br /></td>  
   </tr>  
   $pageindex  
   <tr valign="middle">  
       <td align="center" class="catbg" width="20%"><b>$prereg_txt{'17'}</b></td>  
       <td align="center" class="catbg" width="35%"><b>$prereg_txt{'18'}</b></td>  
       <td align="center" class="catbg" width="25%"><b>$prereg_txt{'19'}</b></td>  
       <td align="center" class="catbg" width="20%"><b>$prereg_txt{'action'}</b></td>  
   </tr>  
   $loglist  
   </table>  
</div>  
   
<br />  
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">  
  <table width="100%" cellspacing="1" cellpadding="4">  
    <tr valign="middle">  
      <td align="center" class="catbg">  
        <input type="submit" value="$prereg_txt{'9'}" onclick="return confirm('$prereg_txt{'9'}');" class="button" />  
      </td>  
    </tr>  
  </table>  
</div>  
   
</form>         $pageindex = qq~<tr> 
                 <td class="windowbg" colspan="4"><span class="small" style="float: left;">$admin_txt{'139'}: $pageindex</span></td>
             </tr>~;
   
         $numbegin = ( $newstart + 1 );
         $numend   = ( $newstart + 25 );
         if   ( $numend > $logcount ) { $numend  = $logcount; }
         if   ( $logcount == 0 )      { $numshow = q{}; }
         else                         { $numshow = qq~($numbegin - $numend)~; }
   
         @logentries = splice @logentries, $newstart, 25;
     }
   
     foreach my $logentry (@logentries) {
         chomp $logentry;
         my ( $logtime, $status, $userid, $actid, $ipadd ) =
           split /\|/xsm, $logentry;
         if ($do_scramble_id) {
             $cryptactid  = cloak($actid);
             $cryptuserid = cloak($userid);
         }
         else {
             $cryptactid  = $actid;
             $cryptuserid = $userid;
         }
         if ( $userid ne $actid && $actid ne q{} ) {
             LoadUser($actid);
             $actadminlink =
  qq~ $prereg_txt{'by'} <a href="$scripturl?action=viewprofile;username=$cryptactid">${$uid.$actid}{'realname'}</a>~;
         }
         else {
             $actadminlink = q{};
         }
         if ( $status eq 'AA' && LoadUser($userid) ) {
             LoadUser($userid);
             $linkuserid =
  qq~$userid (<a href="$scripturl?action=viewprofile;username=$cryptuserid">${$uid.$userid}{'realname'}</a>)~;
         }
         else {
             $linkuserid = $userid;
         }
         $is_member = check_member($userid);
         if   ($do_scramble_id) { $cryptid = cloak($userid); }
         else                   { $cryptid = $userid; }
         $reclogtime = timeformat($logtime);
         if ( $status eq 'N' && $is_member == 0 && -e "$memberdir/$userid.pre" )
         {
             $delrecord =
  qq~<a href="$adminurl?action=del_regentry;username=$cryptid">$prereg_txt{'del'}</a>~;
             $delrecord .=
  qq~<br /><a href="$adminurl?action=view_regentry;username=$cryptid~
               . (
                 $actkey{$userid} ne q{}
                 ? ";activationkey=$actkey{$userid};type=validate" 
                 : q{}
               ) . qq~">$prereg_txt{'view'}</a>~;
             $delrecord .=
  qq~<br /><a href="$scripturl?action=activate;username=$cryptid;activationkey=$actkey{$userid}">$prereg_txt{'act'}</a>~;
         }
         elsif ($status eq 'W' 
             && $is_member == 0
             && -e "$memberdir/$userid.wait" )
         {
             $delrecord =
  qq~<a href="$adminurl?action=rej_regentry;username=$userid">$prereg_txt{'reject'}</a>~;
             $delrecord .=
  qq~<br /><a href="$adminurl?action=view_regentry;username=$cryptid;type=approve">$prereg_txt{'view'}</a>~;
             $delrecord .=
  qq~<br /><a href="$adminurl?action=apr_regentry;username=$userid">$prereg_txt{'apr'}</a>~;
         }
         else {
             $delrecord = '---';
         }
         my $lookupIP =
           ($ipLookup)
           ? qq~<a href="$scripturl?action=iplookup;ip=$ipadd">$ipadd</a>~
           : qq~$ipadd~;
         $loglist .= qq~<tr>
             <td class="windowbg center">$reclogtime</td>
             <td class="windowbg2 center">$prereg_txt{$status}$actadminlink<br />IP: $lookupIP - <a href="$adminurl?action=ipban_err;ban=$ipadd;lev=p;return=view_reglog">$admin_txt{'725f'}</a></td>
             <td class="windowbg center">$linkuserid</td>
             <td class="windowbg2 center">$delrecord</td>
         </tr>~;
     }
   
     $yymain .= qq~
     <script src="$yyhtml_root/ubbc.js" type="text/javascript"></script>
     <form name="reglog_form" action="$adminurl?action=clean_reglog" method="post" onsubmit="return submitproc();">
     <div class="bordercolor rightboxdiv">
         <table class="border-space pad-cell" style="margin-bottom: .5em;">
             <colgroup>
                 <col style="width: 20%" />
                 <col style="width: 35%" />
                 <col style="width: 25%" />
                 <col style="width: 20%" />
             </colgroup>
             <tr>
                 <td class="titlebg" colspan="4">$admin_img{'xx'} <b>$yytitle</b></td>
             </tr><tr>
                 <td class="windowbg2" colspan="4">
                     <div class="pad-more">$prereg_txt{'20'}</div>
                 </td>
             </tr>
             $pageindex
             <tr>
                 <td class="catbg center"><b>$prereg_txt{'17'}</b></td>
                 <td class="catbg center"><b>$prereg_txt{'18'}</b></td>
                 <td class="catbg center"><b>$prereg_txt{'19'}</b></td>
                 <td class="catbg center"><b>$prereg_txt{'action'}</b></td>
             </tr>
             $loglist
             </table>
         </div>
         <div class="bordercolor rightboxdiv">
             <table class="border-space pad-cell">
                 <tr>
                     <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'725e'}</th>
                 </tr><tr>
                     <td class="catbg center">
                         <input type="submit" value="$prereg_txt{'9'}" onclick="return confirm('$prereg_txt{'9'}');" class="button" />
                     </td>
                 </tr>
             </table>
             </div>
             </form>
~; ~;
   $action_area = 'view_reglog';    $action_area = 'view_reglog';
   &AdminTemplate;     AdminTemplate(); 
     return;
} }
   
sub check_member { sub check_member {
   my $is_member = 0;     my ($inp) = @_; 
   foreach $lstmember (@memberlist) {     my $is_member = 0; 
       chomp $lstmember;     foreach my $lstmember (@memberlist) { 
       ($listmember, undef) = split(/\t/, $lstmember, 2);         chomp $lstmember; 
       if ($_[0] eq $listmember) {         ( $listmember, undef ) = split /\t/xsm, $lstmember, 2; 
           $is_member = 1;         if ( $inp eq $listmember ) { 
           last;             $is_member = 1; 
       }             last; 
   }        }
   $is_member;     } 
     return $is_member;
} }
   
sub clean_reglog { sub clean_reglog {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   my (@outlist, @reglist, $reguser, $regstatus);     my (@outlist); 
   fopen(REG, "$vardir/registration.log", 1);     fopen( REG, "$vardir/registration.log", 1 ); 
   @reglist = <REG>;    my @reglist = <REG>;
   fclose(REG);    fclose(REG);
   ## depending on registration type only leave uncompleted entries in the log for completion and remove the failed or completed ones ##    ## depending on registration type only leave uncompleted entries in the log for completion and remove the failed or completed ones ##
   foreach (@reglist) {    foreach (@reglist) {
       (undef, $regstatus, $reguser, undef) = split(/\|/, $_);         my ( undef, $regstatus, $reguser, undef ) = split /\|/xsm, $_; 
       if (($regtype == 1 || $regtype == 2) && $regstatus eq "N" && -e "$memberdir/$reguser.pre") {         if (   ( $regtype == 1 || $regtype == 2 ) 
           push(@outlist, $_);             && $regstatus eq 'N' 
       }             && -e "$memberdir/$reguser.pre" ) 
       if ($regtype == 1 && $regstatus eq "W" && -e "$memberdir/$reguser.wait") {        {
           push(@outlist, $_);             push @outlist, $_; 
       }        }
   }         if (   $regtype == 1 
   fopen(REG, ">$vardir/registration.log", 1);             && $regstatus eq 'W' 
   print REG @outlist;             && -e "$memberdir/$reguser.wait" ) 
   fclose(REG);         { 
             push @outlist, $_;
   $yySetLocation = qq~$adminurl?action=view_reglog~;         } 
   &redirectexit;     } 
     fopen( REG, ">$vardir/registration.log", 1 );
     print {REG} @outlist or croak "$croak{'print'} REG";
     fclose(REG);
   
     $yySetLocation = qq~$adminurl?action=view_reglog~;
     redirectexit();
     return;
} }
   
sub kill_registration { sub kill_registration {
   &is_admin_or_gmod;     my ($inp) = @_; 
   my $changed;     is_admin_or_gmod(); 
   my $deluser = $_[0] || $INFO{'username'};     my $changed; 
   if ($do_scramble_id) { $deluser = &decloak($deluser); }     my $deluser = $inp || $INFO{'username'}; 
     if ($do_scramble_id) { $deluser = decloak($deluser); }
   fopen(INFILE, "$memberdir/memberlist.inactive");  
   @actlist = <INFILE>;     fopen( INFILE, "$memberdir/memberlist.inactive" ); 
   fclose(INFILE);     @actlist = <INFILE>; 
     fclose(INFILE);
   # check if user is in pre-registration and check activation key  
   foreach (@actlist) {     # check if user is in pre-registration and check activation key 
       ($regtime, undef, $regmember, undef) = split(/\|/, $_, 4);     foreach (@actlist) { 
       if ($deluser eq $regmember) {         ( $regtime, undef, $regmember, undef ) = split /\|/xsm, $_, 4; 
           $changed = 1;         if ( $deluser eq $regmember ) { 
           unlink "$memberdir/$regmember.pre";             $changed = 1; 
             unlink "$memberdir/$regmember.pre";
           # add entry to registration log  
           fopen(REG, ">>$vardir/registration.log", 1);             # add entry to registration log 
           print REG "$date|D|$regmember|$username|$user_ip\n";             fopen( REG, ">>$vardir/registration.log", 1 ); 
           fclose(REG);             print {REG} "$date|D|$regmember|$username|$user_ip\n" 
       } else {               or croak "$croak{'print'} REG"; 
           # update non activate user list             fclose(REG); 
           # write valid registration to the list again         } 
           push(@outlist, $_);         else { 
       }  
   }             # update non activate user list 
   if ($changed) {             # write valid registration to the list again 
       # re-open inactive list for update if changed             push @outlist, $_; 
       fopen(OUTFILE, ">$memberdir/memberlist.inactive", 1);         } 
       print OUTFILE @outlist;     } 
       fclose(OUTFILE);     if ($changed) { 
   }  
   $yySetLocation = qq~$adminurl?action=view_reglog~;         # re-open inactive list for update if changed 
   &redirectexit;         fopen( OUTFILE, ">$memberdir/memberlist.inactive", 1 ); 
         print {OUTFILE} @outlist or croak "$croak{'print'} OUTFILE";
         fclose(OUTFILE);
     }
     $yySetLocation = qq~$adminurl?action=view_reglog~;
     redirectexit();
     return;
} }
   
sub view_registration { sub view_registration {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   my $viewuser = $INFO{'username'} || $FORM{'username'};    my $viewuser = $INFO{'username'} || $FORM{'username'};
   my $readuser = $viewuser;    my $readuser = $viewuser;
   my $viewtype = $INFO{'type'};    my $viewtype = $INFO{'type'};
   my $actkey = $INFO{'activationkey'};    my $actkey   = $INFO{'activationkey'};
   if ($do_scramble_id) { $readuser = &decloak($viewuser); }    if ($do_scramble_id) { $readuser = decloak($viewuser); }
   &LoadUser($readuser);     LoadUser($readuser); 
   $yymain .= qq~    $yymain .= qq~
<form action="$adminurl?action=admin_descision;activationkey=$actkey" method="post" name="creator"> <form action="$adminurl?action=admin_descision;activationkey=$actkey" method="post" name="creator">
<input type="hidden" name="username" value="$viewuser" />  <div class="bordercolor rightboxdiv"> 
<table cellspacing="1" cellpadding="4" width="100%" align="center" class="bordercolor" border="0">  <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
<tr>     <colgroup> 
  <td colspan="2" class="catbg"><img src="$imagesdir/profile.gif" alt="" border="0" /> <b>$prereg_txt{'view'}</b>         <col style="width:320px" /> 
   <input type="hidden" name="type" value="$viewtype" />        <col style="width:auto" />
   <input type="hidden" name="activationkey" value="$actkey" />     </colgroup> 
 </td>     <tr> 
</tr><tr class="windowbg">         <td colspan="2" class="titlebg">$admin_img{'profile'} <b>$prereg_txt{'view'}</b> 
  <td width="320" align="left"><b>$prereg_txt{'apr_id'}: </b></td>             <input type="hidden" name="username" value="$viewuser" /> 
  <td align="left">$readuser</td>             <input type="hidden" name="type" value="$viewtype" /> 
</tr><tr class="windowbg">             <input type="hidden" name="activationkey" value="$actkey" /> 
  <td width="320" align="left"><b>$prereg_txt{'apr_name'}: </b></td>         </td> 
  <td align="left">${$uid.$readuser}{'realname'}</td>     </tr><tr class="windowbg"> 
         <td><b>$prereg_txt{'apr_id'}: </b></td>
         <td>$readuser</td>
     </tr><tr class="windowbg">
        <td><b>$prereg_txt{'apr_name'}: </b></td>
        <td>${$uid.$readuser}{'realname'}</td>
     </tr>~;
   
     if ( $viewtype eq 'validate' ) {
         $yymain .= qq~<tr class="windowbg">
         <td><b>$prereg_txt{'apr_email_invalid'}: </b></td>
         <td>${$uid.$readuser}{'email'}</td>
     </tr>~;
     }
     elsif ( $viewtype eq 'approve' ) {
         $yymain .= qq~<tr class="windowbg">
    <td><b>$prereg_txt{'apr_email_valid'}: </b></td>
    <td>${$uid.$readuser}{'email'}</td>
</tr>~; </tr>~;
     }
   
   if ($viewtype eq "validate"){     if ( $addmemgroup_enabled == 2 || $addmemgroup_enabled == 3 ) { 
       $yymain .= qq~<tr class="windowbg">         my @usergroup; 
  <td width="320" align="left"><b>$prereg_txt{'apr_email_invalid'}: </b></td>         foreach ( split /,/xsm, ${ $uid.$readuser }{'addgroups'} ) { 
  <td align="left">${$uid.$readuser}{'email'}</td>             push 
</tr>~;               @usergroup, 
   } elsif ($viewtype eq "approve"){               ( 
       $yymain .= qq~<tr class="windowbg">                 split /\|/xsm, 
  <td width="320" align="left"><b>$prereg_txt{'apr_email_valid'}: </b></td>                 $NoPost{ ${ $uid.$readuser }{'addgroups'} }, 2 
  <td align="left">${$uid.$readuser}{'email'}</td>               )[0]; 
</tr>~;         } 
   }         $yymain .= qq~<tr class="windowbg"> 
    <td><b>$register_txt{'765a'}:</b></td>
   if ($addmemgroup_enabled == 2 || $addmemgroup_enabled == 3) {    <td>~ . join( q{, }, @usergroup ) . q~</td> 
       my @usergroup;  
       foreach (split(/,/, ${$uid.$readuser}{'addgroups'})) {  
           push(@usergroup, (split(/\|/, $NoPost{${$uid.$readuser}{'addgroups'}}, 2))[0]);  
       }  
       $yymain .= qq~<tr class="windowbg">  
  <td width="320" align="left"><b>$register_txt{'765'}:</b></td>  
  <td align="left">~ . join(', ', @usergroup) . qq~</td>  
</tr>~; </tr>~;
   }    }
   
   $yymain .= qq~<tr class="windowbg">     my $lookupIP = 
  <td width="320" align="left"><b>$prereg_txt{'apr_language'}: </b></td>       ($ipLookup) 
  <td align="left">${$uid.$readuser}{'language'}</td>       ? qq~<a href="$scripturl?action=iplookup;ip=${$uid.$readuser}{'lastips'}">${$uid.$readuser}{'lastips'}</a>~ 
       : qq~${$uid.$readuser}{'lastips'}~;
   
     $yymain .= qq~<tr class="windowbg">
    <td><b>$prereg_txt{'apr_language'}: </b></td>
    <td>${$uid.$readuser}{'language'}</td>
</tr><tr class="windowbg"> </tr><tr class="windowbg">
  <td width="320" align="left"><b>$prereg_txt{'apr_ip'}: </b></td>   <td><b>$prereg_txt{'apr_ip'}: </b></td>
  <td align="left">${$uid.$readuser}{'lastips'}</td>    <td>$lookupIP (<a href="$adminurl?action=ipban_err;ban=${$uid.$readuser}{'lastips'};lev=p;return=view_reglog">$admin_txt{'725f'}</a>)</td> 
</tr>~; </tr>~;
   
   if ($regtype == 1){     if ( $regtype == 1 ) { 
       $yymain .= qq~<tr class="windowbg">        $yymain .= qq~<tr class="windowbg">
  <td width="320" align="left"><b>$prereg_txt{'apr_reason'}: </b></td>   <td><b>$prereg_txt{'apr_reason'}: </b></td>
  <td align="left">${$uid.$readuser}{'regreason'}</td>    <td>${$uid.$readuser}{'regreason'}</td> 
</tr>~; </tr>~;
   }    }
   if ($extendedprofiles) {    if ($extendedprofiles) {
       require "$sourcedir/ExtendedProfiles.pl";         require Admin::Settings_ExtendedProfiles; 
       $yymain .= &ext_viewprofile_r($readuser);         $yymain .= ext_viewprofile_r($readuser); 
   }    }
   
   if ($viewtype eq "approve"){     if ( $viewtype eq 'approve' ) { 
       $yymain .= qq~<tr>        $yymain .= qq~<tr>
  <td colspan="2" class="catbg"><img src="$imagesdir/profile.gif" alt="" border="0" /> <b>$prereg_txt{'apr_admin_reason_title'}</b></td>   <td colspan="2" class="titlebg">$admin_img{'profile'} <b>$prereg_txt{'apr_admin_reason_title'}</b></td>
</tr> </tr>
<tr class="windowbg"> <tr class="windowbg">
  <td width="320" align="left"><b>$prereg_txt{'apr_admin_reason'}: </b></td>   <td><b>$prereg_txt{'apr_admin_reason'}: </b></td>
  <td align="left"><textarea rows="4" cols="50" id="admin_reason" name="admin_reason">$admin_reason</textarea></td>   <td><textarea rows="4" cols="50" id="admin_reason" name="admin_reason">$admin_reason</textarea></td>
</tr> </tr>
<tr class="catbg">  </table> 
   <td height="30" valign="middle" align="center" colspan="2">  </div> 
   <input type="submit" name="moda" value="$prereg_txt{'apr_admin_reject'}" onclick="return confirm('$prereg_txt{'apr_admin_reject'} ?')" class="button" />  <div class="bordercolor rightboxdiv"> 
   <input type="submit" name="moda" value="$prereg_txt{'apr_admin_approve'}" onclick="return confirm('$prereg_txt{'apr_admin_approve'} ?')" class="button" />  <table class="border-space pad-cell"> 
   </td>     <tr> 
</tr>~;         <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'actions'}</th> 
     </tr><tr>
   } elsif ($viewtype eq "validate"){         <td class="catbg center"> 
       $yymain .= qq~<tr class="catbg">             <input type="submit" name="moda" value="$prereg_txt{'apr_admin_reject'}" onclick="return confirm('$prereg_txt{'apr_admin_reject'} ?')" class="button" /> 
   <td height="30" valign="middle" align="center" colspan="2">             <input type="submit" name="moda" value="$prereg_txt{'apr_admin_approve'}" onclick="return confirm('$prereg_txt{'apr_admin_approve'} ?')" class="button" /> 
   <input type="submit" name="moda" value="$prereg_txt{'apr_admin_delete'}" onclick="return confirm('$prereg_txt{'apr_admin_delete'} ?')" class="button" />         </td> 
   <input type="submit" name="moda" value="$prereg_txt{'apr_admin_validate'}" onclick="return confirm('$prereg_txt{'apr_admin_validate'} ?')" class="button" />     </tr> 
   </td>  </table> 
</tr>~;  </div>~; 
   }  
   
   $yymain .= qq~     } 
     elsif ( $viewtype eq 'validate' ) {
         $yymain .= qq~
  </table>
  </div>
  <div class="bordercolor rightboxdiv">
  <table class="border-space pad-cell">
     <tr>
         <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'actions'}</th>
     </tr><tr>
         <td class="catbg center">
             <input type="submit" name="moda" value="$prereg_txt{'apr_admin_delete'}" onclick="return confirm('$prereg_txt{'apr_admin_delete'} ?')" class="button" />
             <input type="submit" name="moda" value="$prereg_txt{'apr_admin_validate'}" onclick="return confirm('$prereg_txt{'apr_admin_validate'} ?')" class="button" />
         </td>
     </tr>
</table> </table>
  </div>~;
     }
   
     $yymain .= q~
</form>~; </form>~;
   
   $yytitle = "$prereg_txt{'view'}";    $yytitle = "$prereg_txt{'view'}";
   &AdminTemplate;     AdminTemplate(); 
     return;
} }
   
sub process_registration_review { sub process_registration_review {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   my $descuser  = $FORM{'username'};    my $descuser  = $FORM{'username'};
   my $desctype  = $FORM{'type'};    my $desctype  = $FORM{'type'};
   my $descision = $FORM{'moda'};    my $descision = $FORM{'moda'};
   my $actkey    = $FORM{'activationkey'};    my $actkey    = $FORM{'activationkey'};
   $admin_reason = $FORM{'admin_reason'};    $admin_reason = $FORM{'admin_reason'};
   if ($desctype eq "validate") {    if ( $desctype eq 'validate' ) {
       if ($descision eq $prereg_txt{'apr_admin_validate'}) {        if ( $descision eq $prereg_txt{'apr_admin_validate'} ) {
           require "$sourcedir/Register.pl";             require Sources::Register; 
           &user_activation($descuser,$actkey);             user_activation( $descuser, $actkey ); 
       } elsif ($descision eq $prereg_txt{'apr_admin_delete'}) {         } 
           &kill_registration($descuser);         elsif ( $descision eq $prereg_txt{'apr_admin_delete'} ) { 
       }             kill_registration($descuser); 
   } elsif ($desctype eq "approve") {         } 
       if ($descision eq $prereg_txt{'apr_admin_approve'}) {     } 
           &approve_registration($descuser);     elsif ( $desctype eq 'approve' ) { 
       } elsif ($descision eq $prereg_txt{'apr_admin_reject'}) {        if ( $descision eq $prereg_txt{'apr_admin_approve'} ) {
           &reject_registration($descuser);             approve_registration($descuser); 
       }        }
   }         elsif ( $descision eq $prereg_txt{'apr_admin_reject'} ) { 
             reject_registration($descuser);
         }
     }
     return;
} }
   
sub reject_registration { sub reject_registration {
   &is_admin_or_gmod;     my ($inp) = @_; 
   my $deluser = $_[0] || $INFO{'username'};     is_admin_or_gmod(); 
   if (!$admin_reason) { $admin_reason = $FORM{'admin_reason'}; }     my $deluser = $inp || $INFO{'username'}; 
   if ($do_scramble_id) { $deluser = &decloak($deluser); }    if ( !$admin_reason ) { $admin_reason = $FORM{'admin_reason'}; }
   
   if (-e "$memberdir/memberlist.approve" && $regtype == 1) {     if ($do_scramble_id)  { $deluser      = decloak($deluser); } 
       fopen(APR, "$memberdir/memberlist.approve");  
       @aprlist = <APR>;     if ( -e "$memberdir/memberlist.approve" && $regtype == 1 ) { 
       fclose(APR);         fopen( APR, "$memberdir/memberlist.approve" ); 
   }         @aprlist = <APR>; 
   # check if waiting user exists         fclose(APR); 
     }
   
     # check if waiting user exists
   if ( -e "$memberdir/$deluser.wait" ) {    if ( -e "$memberdir/$deluser.wait" ) {
       LoadUser($deluser);        LoadUser($deluser);
       ## send a rejection email ##        ## send a rejection email ##
       my $templanguage = $language;        my $templanguage = $language;
       $language = ${ $uid . $deluser }{'language'};        $language = ${ $uid . $deluser }{'language'};
       LoadLanguage('Email');        LoadLanguage('Email');
       require "$sourcedir/Mailer.pl";         require Sources::Mailer; 
       if ( $admin_reason ne q{} ) {        if ( $admin_reason ne q{} ) {
           $message = template_email(            $message = template_email(
               $reviewrejectedemail,                $reviewrejectedemail,
               {                {
                   'displayname' => ${ $uid . $deluser }{'realname'},                    'displayname' => ${ $uid . $deluser }{'realname'},
                   'username'    => $deluser,                    'username'    => $deluser,
                   'reviewer'    => ${ $uid . $username }{'realname'},                    'reviewer'    => ${ $uid . $username }{'realname'},
                   'reason'      => $admin_reason                    'reason'      => $admin_reason
               }                }
           );            );
       sendmail(            sendmail(
           ${ $uid . $deluser }{'email'},                ${ $uid . $deluser }{'email'},
           "$mailreg_txt{'apr_result_reject'} $mbname",                "$mailreg_txt{'apr_result_reject'} $mbname",
           $message, q{}, $emailcharset                $message, q{}, $emailcharset
       );            );
       }        }
       elsif ( $nomailspammer == 1 ) {        elsif ( $nomailspammer == 1 ) {
           $message = template_email(            $message = template_email(
               $instantrejectedemail,                $instantrejectedemail,
               {                {
                   'displayname' => ${ $uid . $deluser }{'realname'},                    'displayname' => ${ $uid . $deluser }{'realname'},
                   'username'    => $deluser,                    'username'    => $deluser,
                   'reviewer'    => ${ $uid . $username }{'realname'}                    'reviewer'    => ${ $uid . $username }{'realname'}
               }                }
           );            );
   
           sendmail(            sendmail(
               ${ $uid . $deluser }{'email'},                ${ $uid . $deluser }{'email'},
               "$mailreg_txt{'apr_result_reject'} $mbname",                "$mailreg_txt{'apr_result_reject'} $mbname",
               $message, q{}, $emailcharset                $message, q{}, $emailcharset
           );            );
       }        }
       $language = $templanguage;        $language = $templanguage;
   
         ## remove the registration data for the rejected user ##
         unlink "$memberdir/$deluser.wait";
         foreach (@aprlist) {
             ( undef, undef, $regmember, undef ) = split /\|/xsm, $_, 4;
             if ( $regmember ne $deluser ) {
                 push @aprchnglist, $_;
             }
         }
   
       ## remove the registration data for the rejected user ##         # update approval user list 
       unlink "$memberdir/$deluser.wait";         fopen( APR, ">$memberdir/memberlist.approve" ); 
       foreach (@aprlist) {         print {APR} @aprchnglist or croak "$croak{'print'} APR"; 
           (undef, undef, $regmember, undef) = split(/\|/, $_, 4);         fclose(APR); 
           if ($regmember ne $deluser) {  
               push(@aprchnglist, $_);         ## add entry to registration log ## 
           }         fopen( REG, ">>$vardir/registration.log", 1 ); 
       }         print {REG} "$date|AR|$deluser|$username|$user_ip\n" 
       # update approval user list           or croak "$croak{'print'} REG"; 
       fopen(APR, ">$memberdir/memberlist.approve");         fclose(REG); 
       print APR @aprchnglist;     } 
       fclose(APR);     $yySetLocation = qq~$adminurl?action=view_reglog~; 
     redirectexit();
       ## add entry to registration log ##     return; 
       fopen(REG, ">>$vardir/registration.log", 1);  
       print REG "$date|AR|$deluser|$username|$user_ip\n";  
       fclose(REG);  
   }  
   $yySetLocation = qq~$adminurl?action=view_reglog~;  
   &redirectexit;  
} }
   
sub approve_registration { sub approve_registration {
   &is_admin_or_gmod;     my ($inp) = @_; 
   my $apruser = $_[0] || $INFO{'username'};     is_admin_or_gmod(); 
   if (!$admin_reason) { $admin_reason = $FORM{'admin_reason'}; }     my $apruser = $inp || $INFO{'username'}; 
   if ($do_scramble_id) { $apruser = &decloak($apruser); }    if ( !$admin_reason ) { $admin_reason = $FORM{'admin_reason'}; }
   
   ## load the list with waiting approvals ##     if ($do_scramble_id)  { $apruser      = decloak($apruser); } 
   fopen(APR, "$memberdir/memberlist.approve");  
   @aprlist = <APR>;     ## load the list with waiting approvals ## 
   fclose(APR);     fopen( APR, "$memberdir/memberlist.approve" ); 
     @aprlist = <APR>;
   foreach (@aprlist) {     fclose(APR); 
       (undef, undef, $regmember, $regpassword) = split(/\|/, $_);  
       if ($regmember ne $apruser) {    foreach (@aprlist) {
           push(@aprchnglist, $_);         ( undef, undef, $regmember, $regpassword ) = split /\|/xsm, $_; 
       } else {        if ( $regmember ne $apruser ) {
           $foundmember = $regmember;             push @aprchnglist, $_; 
           $foundpassword = $regpassword;         } 
       }         else { 
   }             $foundmember   = $regmember; 
             $foundpassword = $regpassword;
   ## check if waiting user exists and was indeed in the waiting list ##         } 
   if (-e "$memberdir/$apruser.wait" && $foundmember ne "") {     } 
       &LoadUser($apruser);  
       # ckeck if email is allready in active use     ## check if waiting user exists and was indeed in the waiting list ## 
       if (lc ${$uid.$apruser}{'email'} eq lc &MemberIndex("check_exist", ${$uid.$apruser}{'email'})) {    if ( -e "$memberdir/$apruser.wait" && $foundmember ne q{} ) {
           $yymain .= qq~<font color="red"><b>$prereg_txt{'email_taken'} <i>${$uid.$apruser}{'email'}</i> ($prereg_txt{'35'}: $apruser)</b></font>~;         LoadUser($apruser); 
           &view_reglog;  
       }         # ckeck if email is already in active use 
         if (
       ## user is approved, so let him/her in ##             lc ${ $uid . $apruser }{'email'} eq 
       rename("$memberdir/$apruser.wait", "$memberdir/$apruser.vars");             lc MemberIndex( 'check_exist', ${ $uid . $apruser }{'email'} ) ) 
       &MemberIndex("add", $apruser);         { 
             $yymain .=
       ## send a approval email ##  qq~<span class="important"><b>$prereg_txt{'email_taken'} <i>${$uid.$apruser}{'email'}</i> ($prereg_txt{'35'}: $apruser)</b></span>~; 
       my $templanguage = $language;             view_reglog(); 
       $language = ${$uid.$apruser}{'language'};         } 
       &LoadLanguage('Email');  
       require "$sourcedir/Mailer.pl";  
       if ($emailpassword) {  
           if ($admin_reason ne "") {  
               $message = &template_email($pwreviewapprovedemail, {'displayname' => ${$uid.$apruser}{'realname'}, 'username' => $apruser, 'reviewer' => ${$uid.$username}{'realname'}, 'reason' => $admin_reason, 'password' => $foundpassword });  
           } else {  
               $message = &template_email($pwinstantapprovedemail, {'displayname' => ${$uid.$apruser}{'realname'}, 'username' => $apruser, 'reviewer' => ${$uid.$username}{'realname'}, 'password' => $foundpassword});  
           }  
       } else {  
           if ($admin_reason ne "") {  
               $message = &template_email($reviewapprovedemail, {'displayname' => ${$uid.$apruser}{'realname'}, 'username' => $apruser, 'reviewer' => ${$uid.$username}{'realname'}, 'reason' => $admin_reason });  
           } else {  
               $message = &template_email($instantapprovedemail, {'displayname' => ${$uid.$apruser}{'realname'}, 'username' => $apruser, 'reviewer' => ${$uid.$username}{'realname'}});  
           }  
       }  
       &sendmail(${$uid.$apruser}{'email'}, "$mailreg_txt{'apr_result_approved'} $mbname", $message,'',$emailcharset);  
       $language = $templanguage;  
   
       if ($send_welcomeim == 1) {  
           # new format msg file:  
           # messageid|(from)user|(touser(s))|(ccuser(s))|(bccuser(s))|subject|date|message|(parentmid)|reply#|ip|messagestatus|flags|storefolder|attachment  
           $messageid = $^T . $$;  
           fopen(INBOX, ">$memberdir/$apruser.msg");  
           print INBOX "$messageid|$sendname|$apruser|||$imsubject|$date|$imtext|$messageid|0|$ENV{'REMOTE_ADDR'}|s|u||\n";  
           fclose(INBOX);  
       }  
   
       # update approval user list  
       fopen(APR, ">$memberdir/memberlist.approve");  
       print APR @aprchnglist;  
       fclose(APR);  
   
       ## add entry to registration log ##  
       fopen(REG, ">>$vardir/registration.log", 1);  
       print REG "$date|AA|$apruser|$username|$user_ip\n";  
       fclose(REG);  
   }  
   $yySetLocation = qq~$adminurl?action=view_reglog~;  
   &redirectexit;  
}  
   
         ## user is approved, so let him/her in ##
         rename "$memberdir/$apruser.wait", "$memberdir/$apruser.vars";
         MemberIndex( 'add', $apruser );
   
         # update approval user list
         fopen( APR, ">$memberdir/memberlist.approve" );
         print {APR} @aprchnglist or croak "$croak{'print'} APR";
         fclose(APR);
   
         ## add entry to registration log ##
         fopen( REG, ">>$vardir/registration.log", 1 );
         print {REG} "$date|AA|$apruser|$username|$user_ip\n" 
           or croak "$croak{'print'} REG";
         fclose(REG);
   
         ## send a approval email ##
         my $templanguage = $language;
         $language = ${ $uid . $apruser }{'language'};
         LoadLanguage('Email');
         require Sources::Mailer;
         if ($emailpassword) {
             if ( $admin_reason ne q{} ) {
                 $message = template_email(
                     $pwreviewapprovedemail,
                     {
                         'displayname' => ${ $uid . $apruser }{'realname'},
                         'username'    => $apruser,
                         'reviewer'    => ${ $uid . $username }{'realname'},
                         'reason'      => $admin_reason,
                         'password'    => $foundpassword
                     }
                 );
             }
             else {
                 $message = template_email(
                     $pwinstantapprovedemail,
                     {
                         'displayname' => ${ $uid . $apruser }{'realname'},
                         'username'    => $apruser,
                         'reviewer'    => ${ $uid . $username }{'realname'},
                         'password'    => $foundpassword
                     }
                 );