F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Admin\GuardianAdmin.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Admin\GuardianAdmin.pm
############################################################################### ###############################################################################
# GuardianAdmin.pl                                                            # # GuardianAdmin.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);
  our $VERSION = '2.6.12';
   
$guardianadminplver = 'YaBB 2.5.2 $Revision: 1.0 $'; $guardianadminpmver = 'YaBB 2.6.12 $Revision: 1710 $';
if ($action eq 'detailedversion') { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
&LoadLanguage('Guardian');  LoadLanguage('Guardian'); 
  $admin_images = "$yyhtml_root/Templates/Admin/default";
  $guardimg      = 'guardian.png';
   
sub setup_guardian { sub setup_guardian {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   
   # figure out what to print    # figure out what to print
   if ($use_guardian)            { $guardian_checked           = ' checked="checked" ' }    if ($use_guardian)      { $guardian_checked = ' checked="checked" ' }
   if ($use_htaccess)            { $htaccess_checked           = ' checked="checked" ' }    if ($use_htaccess)      { $htaccess_checked = ' checked="checked" ' }
   if ($disallow_proxy_on)       { $proxy_on_checked           = ' checked="checked" ' }    if ($disallow_proxy_on) { $proxy_on_checked = ' checked="checked" ' }
   if ($disallow_proxy_notify)   { $proxy_notify_checked       = ' checked="checked" ' }     if ($disallow_proxy_notify) { 
   if ($disallow_proxy_htaccess) { $proxy_htaccess_checked     = ' checked="checked" ' }         $proxy_notify_checked = ' checked="checked" '; 
   if ($referer_on)              { $referer_on_checked         = ' checked="checked" ' }    }
   if ($referer_notify)          { $referer_notify_checked     = ' checked="checked" ' }     if ($disallow_proxy_htaccess) { 
   if ($referer_htaccess)        { $referer_htaccess_checked   = ' checked="checked" ' }         $proxy_htaccess_checked = ' checked="checked" '; 
   if ($harvester_on)            { $harvester_on_checked       = ' checked="checked" ' }    }
   if ($harvester_notify)        { $harvester_notify_checked   = ' checked="checked" ' }    if ($referer_on)       { $referer_on_checked       = ' checked="checked" ' }
   if ($harvester_htaccess)      { $harvester_htaccess_checked = ' checked="checked" ' }    if ($referer_notify)   { $referer_notify_checked   = ' checked="checked" ' }
   if ($request_on)              { $request_on_checked         = ' checked="checked" ' }    if ($referer_htaccess) { $referer_htaccess_checked = ' checked="checked" ' }
   if ($request_notify)          { $request_notify_checked     = ' checked="checked" ' }    if ($harvester_on)     { $harvester_on_checked     = ' checked="checked" ' }
   if ($request_htaccess)        { $request_htaccess_checked   = ' checked="checked" ' }    if ($harvester_notify) { $harvester_notify_checked = ' checked="checked" ' }
   if ($string_on)               { $string_on_checked          = ' checked="checked" ' }     if ($harvester_htaccess) { 
   if ($string_notify)           { $string_notify_checked      = ' checked="checked" ' }         $harvester_htaccess_checked = ' checked="checked" '; 
   if ($string_htaccess)         { $string_htaccess_checked    = ' checked="checked" ' }    }
   if ($union_on)                { $union_on_checked           = ' checked="checked" ' }    if ($request_on)       { $request_on_checked       = ' checked="checked" ' }
   if ($union_notify)            { $union_notify_checked       = ' checked="checked" ' }    if ($request_notify)   { $request_notify_checked   = ' checked="checked" ' }
   if ($union_htaccess)          { $union_htaccess_checked     = ' checked="checked" ' }    if ($request_htaccess) { $request_htaccess_checked = ' checked="checked" ' }
   if ($clike_on)                { $clike_on_checked           = ' checked="checked" ' }    if ($string_on)        { $string_on_checked        = ' checked="checked" ' }
   if ($clike_notify)            { $clike_notify_checked       = ' checked="checked" ' }    if ($string_notify)    { $string_notify_checked    = ' checked="checked" ' }
   if ($clike_htaccess)          { $clike_htaccess_checked     = ' checked="checked" ' }    if ($string_htaccess)  { $string_htaccess_checked  = ' checked="checked" ' }
   if ($script_on)               { $script_on_checked          = ' checked="checked" ' }    if ($union_on)         { $union_on_checked         = ' checked="checked" ' }
   if ($script_notify)           { $script_notify_checked      = ' checked="checked" ' }    if ($union_notify)     { $union_notify_checked     = ' checked="checked" ' }
   if ($script_htaccess)         { $script_htaccess_checked    = ' checked="checked" ' }    if ($union_htaccess)   { $union_htaccess_checked   = ' checked="checked" ' }
     if ($clike_on)         { $clike_on_checked         = ' checked="checked" ' }
   ## make splits turn into linefeeds for the forms     if ($clike_notify)     { $clike_notify_checked     = ' checked="checked" ' } 
   chomp $banned_harvesters;     if ($clike_htaccess)   { $clike_htaccess_checked   = ' checked="checked" ' } 
   chomp $banned_referers;     if ($script_on)        { $script_on_checked        = ' checked="checked" ' } 
   chomp $banned_requests;     if ($script_notify)    { $script_notify_checked    = ' checked="checked" ' } 
   chomp $banned_strings;     if ($script_htaccess)  { $script_htaccess_checked  = ' checked="checked" ' } 
   chomp $whitelist;  
   $banned_harvesters =~ s~\|~\n~g;     ## make splits turn into linefeeds for the forms 
   $banned_referers   =~ s~\|~\n~g;     chomp $banned_harvesters; 
   $banned_requests   =~ s~\|~\n~g;     chomp $banned_referers; 
   $banned_strings    =~ s~\|~\n~g;     chomp $banned_requests; 
   $whitelist         =~ s~\|~\n~g;     chomp $banned_strings; 
   @access_denied = &update_htaccess("load");     chomp $whitelist; 
     $banned_harvesters =~ s/\|/\n/gxsm;
   foreach (@access_denied) {     $banned_referers   =~ s/\|/\n/gxsm; 
       chomp $_;     $banned_requests   =~ s/\|/\n/gxsm; 
       $acc_denied .= "$_\n";     $banned_strings    =~ s/\|/\n/gxsm; 
   }     $whitelist         =~ s/\|/\n/gxsm; 
     @access_denied = update_htaccess('load');
   $yymain .= qq~  
<form action="$adminurl?action=setup_guardian2" method="post" enctype="application/x-www-form-urlencoded">     foreach (@access_denied) { 
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">         chomp $_; 
  <table width="100%" cellspacing="1" cellpadding="4">         $acc_denied .= "$_\n"; 
    <tr valign="middle">     } 
      <td align="left" class="titlebg">  
        <img src="$imagesdir/guardian.gif" alt="" border="0" /> <b>$guardian_txt{'title'}</b>     $yymain .= qq~ 
      </td>  <form action="$adminurl?action=setup_guardian2" method="post" onsubmit="savealert()" enctype="application/x-www-form-urlencoded" accept-charset="$yymycharset"> 
    </tr>  <div class="bordercolor rightboxdiv"> 
    <tr valign="middle">     <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
      <td align="left" class="windowbg2"><br />         <tr> 
         $guardian_txt{'description'}<br /><br />             <td class="titlebg"> 
      </td>                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'title'}</b> 
    </tr>             </td> 
  </table>         </tr><tr> 
</div>             <td class="windowbg2"> 
                 <div class="pad-more">$guardian_txt{'description'}</div>
<br />             </td> 
         </tr>
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">     </table> 
  <table width="100%" cellspacing="1" cellpadding="4">  </div> 
    <tr valign="middle">  <div class="bordercolor rightboxdiv"> 
      <td align="left" class="titlebg">     <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
        <img src="$imagesdir/guardian_icon.gif" alt="" border="0" /> <b>$guardian_txt{'general'}</b>         <tr> 
      </td>             <td class="titlebg"> 
    </tr>                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'general'}</b> 
    <tr valign="middle">             </td> 
      <td align="left" class="windowbg2"><br />         </tr><tr> 
       <div class="setting_cell3">             <td class="windowbg2"> 
           <label for="use_guardian">$guardian_txt{'use_guardian'}</label>                 <div class="setting-cell3"> 
           <input type="checkbox" name="use_guardian" id="use_guardian" value="1"$guardian_checked />                     <label for="use_guardian">$guardian_txt{'use_guardian'}</label> 
       </div>                     <input type="checkbox" name="use_guardian" id="use_guardian" value="1"$guardian_checked /> 
       <br />                 </div> 
       <div class="setting_cell3">                 <div class="setting-cell3"> 
           <label for="use_htaccess">$guardian_txt{'use_htaccess'}                    <label for="use_htaccess">$guardian_txt{'use_htaccess'}
           <input type="checkbox" name="use_htaccess" id="use_htaccess" value="1"$htaccess_checked onmouseup="remove_htaccess();" /><br />$guardian_txt{'use_htaccess_support'}</label>                    <input type="checkbox" name="use_htaccess" id="use_htaccess" value="1"$htaccess_checked onmouseup="remove_htaccess();" /><br />$guardian_txt{'use_htaccess_support'}</label>
       </div>                </div>
       <script type="text/javascript" language="JavaScript">  <!--##Code removed##//--> 
        <!--                 <div class="setting-cell3"> 
           var old_htaccess = '';                     <label for="access_denied">$guardian_txt{'htaccess_list'}</label> 
           function remove_htaccess() {                 </div> 
               if (document.getElementById("use_htaccess").checked) {                 <div class="setting-cell4"> 
                   old_htaccess = document.getElementById("access_denied").value;                     <textarea cols="40" rows="8" name="access_denied" id="access_denied" style="width:98%">$acc_denied</textarea> 
                   document.getElementById("access_denied").value = '';                 </div> 
                   document.getElementById("access_denied").disabled = "disabled";             </td> 
               } else {         </tr> 
                   document.getElementById("access_denied").value = old_htaccess;     </table> 
                   document.getElementById("access_denied").disabled = "";  </div> 
               }  <div class="bordercolor rightboxdiv"> 
           }     <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
        // -->         <tr> 
       </script>             <td class="titlebg"> 
       <br />                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'proxy'}</b> 
       <div class="setting_cell3">             </td> 
           <label for="access_denied">$guardian_txt{'htaccess_list'}</label>         </tr><tr> 
       </div>             <td class="windowbg2"> 
       <div class="setting_cell4">                 <div class="setting-cell3"> 
           <textarea cols="40" rows="8" name="access_denied" id="access_denied" style="width:98%"~ . ($use_htaccess ? '' : ' disabled="disabled"') . qq~>$acc_denied</textarea>                     <label for="disallow_proxy_on">$guardian_txt{'proxy_on'}</label> 
       </div>                     <input type="checkbox" name="disallow_proxy_on" id="disallow_proxy_on" value="1"$proxy_on_checked /> 
      </td>                 </div> 
    </tr>                 <div class="setting-cell3"> 
  </table>                     <label for="whitelist">$guardian_txt{'white_list'}</label> 
</div>                </div>
                 <div class="setting-cell4">
<br />                     <textarea cols="40" rows="8" name="whitelist" id="whitelist" style="width:98%">$whitelist</textarea> 
                 </div>
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">                 <div class="setting-cell3"> 
  <table width="100%" cellspacing="1" cellpadding="4">                     <label for="disallow_proxy_notify">$guardian_txt{'notify'}</label> 
    <tr valign="middle">                     <input type="checkbox" name="disallow_proxy_notify" id="disallow_proxy_notify" value="1"$proxy_notify_checked /> 
      <td align="left" class="titlebg">                 </div> 
        <img src="$imagesdir/guardian_icon.gif" alt="" border="0" /> <b>$guardian_txt{'proxy'}</b>                 <div class="setting-cell3"> 
      </td>                     <label for="disallow_proxy_htaccess">$guardian_txt{'htaccess_add'} 
    </tr>                     <input type="checkbox" name="disallow_proxy_htaccess" id="disallow_proxy_htaccess" value="1"$proxy_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label> 
    <tr valign="middle">                 </div> 
      <td align="left" class="windowbg2"><br />             </td> 
        <div class="setting_cell3">         </tr> 
           <label for="disallow_proxy_on">$guardian_txt{'proxy_on'}</label>     </table> 
           <input type="checkbox" name="disallow_proxy_on" id="disallow_proxy_on" value="1"$proxy_on_checked />  </div> 
        </div>  <div class="bordercolor rightboxdiv"> 
      <br />     <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
        <div class="setting_cell3">         <tr> 
           <label for="whitelist">$guardian_txt{'white_list'}</label>             <td class="titlebg"> 
        </div>                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'referer'}</b> 
        <div class="setting_cell4">             </td> 
           <textarea cols="40" rows="8" name="whitelist" id="whitelist" style="width:98%">$whitelist</textarea>         </tr><tr> 
        </div>             <td class="windowbg2"> 
      <br />                 <div class="setting-cell3"> 
        <div class="setting_cell3">                     <label for="referer_on">$guardian_txt{'referer_on'}</label> 
           <label for="disallow_proxy_notify">$guardian_txt{'notify'}</label>                     <input type="checkbox" name="referer_on" id="referer_on" value="1"$referer_on_checked /> 
           <input type="checkbox" name="disallow_proxy_notify" id="disallow_proxy_notify" value="1"$proxy_notify_checked />                 </div> 
        </div>                 <div class="setting-cell3"> 
      <br />                     <label for="banned_referers">$guardian_txt{'referer_list'}</label> 
        <div class="setting_cell3">                 </div> 
           <label for="disallow_proxy_htaccess">$guardian_txt{'htaccess_add'}                 <div class="setting-cell4"> 
           <input type="checkbox" name="disallow_proxy_htaccess" id="disallow_proxy_htaccess" value="1"$proxy_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label>                     <textarea cols="40" rows="8" name="banned_referers" id="banned_referers" style="width:98%">$banned_referers</textarea> 
        </div>                </div>
      </td>                 <div class="setting-cell3"> 
    </tr>                     <label for="referer_notify">$guardian_txt{'notify'}</label> 
  </table>                     <input type="checkbox" name="referer_notify" id="referer_notify" value="1"$referer_notify_checked /> 
</div>                </div>
                 <div class="setting-cell3">
<br />                     <label for="referer_htaccess">$guardian_txt{'htaccess_add'} 
                     <input type="checkbox" name="referer_htaccess" id="referer_htaccess" value="1"$referer_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label>
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">                 </div> 
  <table width="100%" cellspacing="1" cellpadding="4">             </td> 
    <tr valign="middle">         </tr> 
      <td align="left" class="titlebg">     </table> 
        <img src="$imagesdir/guardian_icon.gif" alt="" border="0" /> <b>$guardian_txt{'referer'}</b>  </div> 
      </td>  <div class="bordercolor rightboxdiv"> 
    </tr>     <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
    <tr valign="middle">         <tr> 
      <td align="left" class="windowbg2"><br />             <td class="titlebg"> 
        <div class="setting_cell3">                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'harvester'}</b> 
           <label for="referer_on">$guardian_txt{'referer_on'}</label>             </td> 
           <input type="checkbox" name="referer_on" id="referer_on" value="1"$referer_on_checked />         </tr><tr> 
        </div>             <td class="windowbg2"> 
      <br />                 <div class="setting-cell3"> 
        <div class="setting_cell3">                     <label for="harvester_on">$guardian_txt{'harvester_on'}</label> 
           <label for="banned_referers">$guardian_txt{'referer_list'}</label>                     <input type="checkbox" name="harvester_on" id="harvester_on" value="1"$harvester_on_checked /> 
        </div>                </div>
        <div class="setting_cell4">                 <div class="setting-cell3"> 
           <textarea cols="40" rows="8" name="banned_referers" id="banned_referers" style="width:98%">$banned_referers</textarea>                     <label for="banned_harvesters">$guardian_txt{'harvester_list'}</label> 
        </div>                </div>
      <br />                 <div class="setting-cell4"> 
        <div class="setting_cell3">                     <textarea cols="40" rows="8" name="banned_harvesters" id="banned_harvesters" style="width:98%">$banned_harvesters</textarea> 
           <label for="referer_notify">$guardian_txt{'notify'}</label>                 </div> 
           <input type="checkbox" name="referer_notify" id="referer_notify" value="1"$referer_notify_checked />                 <div class="setting-cell3"> 
        </div>                     <label for="harvester_notify">$guardian_txt{'notify'}</label> 
      <br />                    <input type="checkbox" name="harvester_notify" id="harvester_notify" value="1"$harvester_notify_checked />
        <div class="setting_cell3">                 </div> 
           <label for="referer_htaccess">$guardian_txt{'htaccess_add'}                 <div class="setting-cell3"> 
           <input type="checkbox" name="referer_htaccess" id="referer_htaccess" value="1"$referer_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label>                     <label for="harvester_htaccess">$guardian_txt{'htaccess_add'} 
        </div>                     <input type="checkbox" name="harvester_htaccess" id="harvester_htaccess" value="1"$harvester_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label> 
      </td>                 </div> 
    </tr>             </td> 
  </table>         </tr> 
</div>     </table> 
  </div>
<br />  <div class="bordercolor rightboxdiv"> 
     <table class="border-space pad-cell" style="margin-bottom: .5em;">
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">         <tr> 
  <table width="100%" cellspacing="1" cellpadding="4">             <td class="titlebg"> 
    <tr valign="middle">                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'request'}</b> 
      <td align="left" class="titlebg">             </td> 
        <img src="$imagesdir/guardian_icon.gif" alt="" border="0" /> <b>$guardian_txt{'harvester'}</b>         </tr><tr> 
      </td>             <td class="windowbg2"> 
    </tr>                 <div class="setting-cell3"> 
    <tr valign="middle">                     <label for="request_on">$guardian_txt{'request_on'}</label> 
      <td align="left" class="windowbg2"><br />                    <input type="checkbox" name="request_on" id="request_on" value="1"$request_on_checked />
        <div class="setting_cell3">                 </div> 
           <label for="harvester_on">$guardian_txt{'harvester_on'}</label>                 <div class="setting-cell3"> 
           <input type="checkbox" name="harvester_on" id="harvester_on" value="1"$harvester_on_checked />                     <label for="banned_requests">$guardian_txt{'request_list'}</label> 
        </div>                </div>
      <br />                 <div class="setting-cell4"> 
        <div class="setting_cell3">                     <textarea cols="40" rows="8" name="banned_requests" id="banned_requests" style="width:98%">$banned_requests</textarea> 
           <label for="banned_harvesters">$guardian_txt{'harvester_list'}</label>                 </div> 
        </div>                 <div class="setting-cell3"> 
        <div class="setting_cell4">                     <label for="request_notify">$guardian_txt{'notify'}</label> 
           <textarea cols="40" rows="8" name="banned_harvesters" id="banned_harvesters" style="width:98%">$banned_harvesters</textarea>                     <input type="checkbox" name="request_notify" id="request_notify" value="1"$request_notify_checked /> 
        </div>                </div>
      <br />                 <div class="setting-cell3"> 
        <div class="setting_cell3">                     <label for="request_htaccess">$guardian_txt{'htaccess_add'} 
           <label for="harvester_notify">$guardian_txt{'notify'}</label>                     <input type="checkbox" name="request_htaccess" id="request_htaccess" value="1"$request_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label> 
           <input type="checkbox" name="harvester_notify" id="harvester_notify" value="1"$harvester_notify_checked />                 </div> 
        </div>             </td> 
      <br />         </tr> 
        <div class="setting_cell3">     </table> 
           <label for="harvester_htaccess">$guardian_txt{'htaccess_add'}  </div> 
           <input type="checkbox" name="harvester_htaccess" id="harvester_htaccess" value="1"$harvester_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label>  <div class="bordercolor rightboxdiv"> 
        </div>     <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
      </td>         <tr> 
    </tr>             <td class="titlebg"> 
  </table>                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'string'}</b> 
</div>             </td> 
         </tr><tr>
<br />             <td class="windowbg2"> 
                 <div class="setting-cell3">
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">                     <label for="string_on">$guardian_txt{'string_on'}</label> 
  <table width="100%" cellspacing="1" cellpadding="4">                     <input type="checkbox" name="string_on" id="string_on" value="1"$string_on_checked /> 
    <tr valign="middle">                 </div> 
      <td align="left" class="titlebg">                 <div class="setting-cell3"> 
        <img src="$imagesdir/guardian_icon.gif" alt="" border="0" /> <b>$guardian_txt{'request'}</b>                     <label for="banned_strings">$guardian_txt{'string_list'}</label> 
      </td>                 </div> 
    </tr>                 <div class="setting-cell4"> 
    <tr valign="middle">                     <textarea cols="40" rows="8" name="banned_strings" id="banned_strings" style="width:98%">$banned_strings</textarea> 
      <td align="left" class="windowbg2"><br />                 </div> 
        <div class="setting_cell3">                 <div class="setting-cell3"> 
           <label for="request_on">$guardian_txt{'request_on'}</label>                     <label for="string_notify">$guardian_txt{'notify'}</label> 
           <input type="checkbox" name="request_on" id="request_on" value="1"$request_on_checked />                    <input type="checkbox" name="string_notify" id="string_notify" value="1"$string_notify_checked />
        </div>                </div>
      <br />                 <div class="setting-cell3"> 
        <div class="setting_cell3">                     <label for="string_htaccess">$guardian_txt{'htaccess_add'} 
           <label for="banned_requests">$guardian_txt{'request_list'}</label>                     <input type="checkbox" name="string_htaccess" id="string_htaccess" value="1"$string_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label> 
        </div>                </div>
        <div class="setting_cell4">             </td> 
           <textarea cols="40" rows="8" name="banned_requests" id="banned_requests" style="width:98%">$banned_requests</textarea>         </tr> 
        </div>     </table> 
      <br />  </div> 
        <div class="setting_cell3">  <div class="bordercolor rightboxdiv"> 
           <label for="request_notify">$guardian_txt{'notify'}</label>     <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
           <input type="checkbox" name="request_notify" id="request_notify" value="1"$request_notify_checked />         <tr> 
        </div>             <td class="titlebg"> 
      <br />                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'script'}</b> 
        <div class="setting_cell3">             </td> 
           <label for="request_htaccess">$guardian_txt{'htaccess_add'}         </tr><tr> 
           <input type="checkbox" name="request_htaccess" id="request_htaccess" value="1"$request_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label>             <td class="windowbg2"> 
        </div>                 <div class="setting-cell3"> 
      </td>                     <label for="script_on">$guardian_txt{'script_on'}</label> 
    </tr>                     <input type="checkbox" name="script_on" id="script_on" value="1"$script_on_checked /> 
  </table>                 </div> 
</div>                 <div class="setting-cell3"> 
                     <label for="script_notify">$guardian_txt{'notify'}</label>
<br />                    <input type="checkbox" name="script_notify" id="script_notify" value="1"$script_notify_checked />
                 </div>
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">                 <div class="setting-cell3"> 
  <table width="100%" cellspacing="1" cellpadding="4">                     <label for="script_htaccess">$guardian_txt{'htaccess_add'} 
    <tr valign="middle">                     <input type="checkbox" name="script_htaccess" id="script_htaccess" value="1"$script_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label> 
      <td align="left" class="titlebg">                 </div> 
        <img src="$imagesdir/guardian_icon.gif" alt="" border="0" /> <b>$guardian_txt{'string'}</b>             </td> 
      </td>         </tr> 
    </tr>     </table> 
    <tr valign="middle">  </div> 
      <td align="left" class="windowbg2"><br />  <div class="bordercolor rightboxdiv"> 
        <div class="setting_cell3">     <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
           <label for="string_on">$guardian_txt{'string_on'}</label>         <tr> 
           <input type="checkbox" name="string_on" id="string_on" value="1"$string_on_checked />             <td class="titlebg"> 
        </div>                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'union'}</b> 
      <br />             </td> 
        <div class="setting_cell3">         </tr><tr> 
           <label for="banned_strings">$guardian_txt{'string_list'}</label>             <td class="windowbg2"> 
        </div>                 <div class="setting-cell3"> 
        <div class="setting_cell4">                     <label for="union_on">$guardian_txt{'union_on'}</label> 
           <textarea cols="40" rows="8" name="banned_strings" id="banned_strings" style="width:98%">$banned_strings</textarea>                     <input type="checkbox" name="union_on" id="union_on" value="1"$union_on_checked /> 
        </div>                </div>
      <br />                 <div class="setting-cell3"> 
        <div class="setting_cell3">                     <label for="union_notify">$guardian_txt{'notify'}</label> 
           <label for="string_notify">$guardian_txt{'notify'}</label>                     <input type="checkbox" name="union_notify" id="union_notify" value="1"$union_notify_checked /> 
           <input type="checkbox" name="string_notify" id="string_notify" value="1"$string_notify_checked />                 </div> 
        </div>                 <div class="setting-cell3"> 
      <br />                     <label for="union_htaccess">$guardian_txt{'htaccess_add'} 
        <div class="setting_cell3">                     <input type="checkbox" name="union_htaccess" id="union_htaccess" value="1"$union_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label> 
           <label for="string_htaccess">$guardian_txt{'htaccess_add'}                 </div> 
           <input type="checkbox" name="string_htaccess" id="string_htaccess" value="1"$string_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label>             </td> 
        </div>         </tr> 
      </td>     </table> 
    </tr>  </div> 
  </table>  <div class="bordercolor rightboxdiv"> 
</div>     <table class="border-space pad-cell" style="margin-bottom: .5em;"> 
         <tr>
<br />             <td class="titlebg"> 
                 <img src="$admin_images/$guardimg" alt="" /> <b>$guardian_txt{'clike'}</b>
<div class="bordercolor" style="padding: 0px; width: 99%; margin-left: 0px; margin-right: auto;">             </td> 
  <table width="100%" cellspacing="1" cellpadding="4">         </tr><tr> 
    <tr valign="middle">             <td class="windowbg2"> 
      <td align="left" class="titlebg">                 <div class="setting-cell3"> 
        <img src="$imagesdir/guardian_icon.gif" alt="" border="0" /> <b>$guardian_txt{'script'}</b>                     <label for="clike_on">$guardian_txt{'clike_on'}</label> 
      </td>                     <input type="checkbox" name="clike_on" id="clike_on" value="1"$clike_on_checked /> 
    </tr>                 </div> 
    <tr valign="middle">                 <div class="setting-cell3"> 
      <td align="left" class="windowbg2"><br />                     <label for="clike_notify">$guardian_txt{'notify'}</label> 
        <div class="setting_cell3">                     <input type="checkbox" name="clike_notify" id="clike_notify" value="1"$clike_notify_checked /> 
           <label for="script_on">$guardian_txt{'script_on'}</label>                 </div> 
           <input type="checkbox" name="script_on" id="script_on" value="1"$script_on_checked />                 <div class="setting-cell3"> 
        </div>                     <label for="clike_htaccess">$guardian_txt{'htaccess_add'} 
      <br />                     <input type="checkbox" name="clike_htaccess" id="clike_htaccess" value="1"$clike_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label> 
        <div class="setting_cell3">                 </div> 
           <label for="script_notify">$guardian_txt{'notify'}</label>             </td> 
           <input type="checkbox" name="script_notify" id="script_notify" value="1"$script_notify_checked />         </tr> 
        </div>     </table> 
      <br />  </div> 
        <div class="setting_cell3">  <div class="bordercolor rightboxdiv"> 
           <label for="script_htaccess">$guardian_txt{'htaccess_add'}  <table class="border-space pad-cell"> 
           <input type="checkbox" name="script_htaccess" id="script_htaccess" value="1"$script_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label>     <tr> 
        </div>         <th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th> 
      </td>     </tr><tr> 
    </tr>         <td class="catbg center"> 
  </table>             <input type="submit" value="$guardian_txt{'save'}" class="button" /> 
</div>         </td> 
     </tr>
<br />  </table> 
  </div>
<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">  
        <img src="$imagesdir/guardian_icon.gif" alt="" border="0" /> <b>$guardian_txt{'union'}</b>  
      </td>  
    </tr>  
    <tr valign="middle">  
      <td align="left" class="windowbg2"><br />  
        <div class="setting_cell3">  
           <label for="union_on">$guardian_txt{'union_on'}</label>  
           <input type="checkbox" name="union_on" id="union_on" value="1"$union_on_checked />  
        </div>  
      <br />  
        <div class="setting_cell3">  
           <label for="union_notify">$guardian_txt{'notify'}</label>  
           <input type="checkbox" name="union_notify" id="union_notify" value="1"$union_notify_checked />  
        </div>  
      <br />  
        <div class="setting_cell3">  
           <label for="union_htaccess">$guardian_txt{'htaccess_add'}  
           <input type="checkbox" name="union_htaccess" id="union_htaccess" value="1"$union_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label>  
        </div>  
      </td>  
    </tr>  
  </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="left" class="titlebg">  
        <img src="$imagesdir/guardian_icon.gif" alt="" border="0" /> <b>$guardian_txt{'clike'}</b>  
      </td>  
    </tr>  
    <tr valign="middle">  
      <td align="left" class="windowbg2"><br />  
        <div class="setting_cell3">  
           <label for="clike_on">$guardian_txt{'clike_on'}</label>  
           <input type="checkbox" name="clike_on" id="clike_on" value="1"$clike_on_checked />  
        </div>  
      <br />  
        <div class="setting_cell3">  
           <label for="clike_notify">$guardian_txt{'notify'}</label>  
           <input type="checkbox" name="clike_notify" id="clike_notify" value="1"$clike_notify_checked />  
        </div>  
      <br />  
        <div class="setting_cell3">  
           <label for="clike_htaccess">$guardian_txt{'htaccess_add'}  
           <input type="checkbox" name="clike_htaccess" id="clike_htaccess" value="1"$clike_htaccess_checked /><br />$guardian_txt{'htaccess_support'}</label>  
        </div>  
      </td>  
    </tr>  
  </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="$guardian_txt{'save'}" class="button" />  
      </td>  
    </tr>  
  </table>  
</div>  
</form> </form>
~; ~;
   $yytitle     = $guardian_txt{'setup'};    $yytitle     = $guardian_txt{'setup'};
   $action_area = "setup_guardian";     $action_area = 'setup_guardian'; 
   &AdminTemplate;     AdminTemplate(); 
     return;
} }
   
sub setup_guardian2 { sub setup_guardian2 {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
   my @onoff = qw/     my @onoff = qw{ 
     use_guardian use_htaccess disallow_proxy_on disallow_proxy_htaccess referer_on referer_htaccess harvester_on harvester_htaccess request_on request_htaccess string_on string_htaccess union_on union_htaccess clike_on clike_htaccess script_on script_htaccess disallow_proxy_notify referer_notify harvester_notify request_notify string_notify union_notify clike_notify script_notify/;       use_guardian use_htaccess disallow_proxy_on disallow_proxy_htaccess referer_on referer_htaccess harvester_on harvester_htaccess request_on request_htaccess string_on string_htaccess union_on union_htaccess clike_on clike_htaccess script_on script_htaccess disallow_proxy_notify referer_notify harvester_notify request_notify string_notify union_notify clike_notify script_notify}; 
   
   # Set as 0 or 1 if box was checked or not    # Set as 0 or 1 if box was checked or not
   my $fi;    my $fi;
   map { $fi = lc $_; ${$_} = $FORM{$fi} == 1 ? 1 : 0; } @onoff;    map { $fi = lc $_; ${$_} = $FORM{$fi} == 1 ? 1 : 0; } @onoff;
   
   $banned_harvesters = $FORM{'banned_harvesters'};    $banned_harvesters = $FORM{'banned_harvesters'};
   $banned_referers   = $FORM{'banned_referers'};    $banned_referers   = $FORM{'banned_referers'};
   $banned_requests   = $FORM{'banned_requests'};    $banned_requests   = $FORM{'banned_requests'};
   $banned_strings    = $FORM{'banned_strings'};    $banned_strings    = $FORM{'banned_strings'};
   $access_denied     = $FORM{'access_denied'};    $access_denied     = $FORM{'access_denied'};
   $whitelist         = $FORM{'whitelist'};    $whitelist         = $FORM{'whitelist'};
   chomp $banned_harvesters;    chomp $banned_harvesters;
   chomp $banned_referers;    chomp $banned_referers;
   chomp $banned_requests;    chomp $banned_requests;
   chomp $banned_strings;    chomp $banned_strings;
   chomp $whitelist;    chomp $whitelist;
   $banned_harvesters =~ s~\r~~g;     $banned_harvesters =~ s/\r//gxsm; 
   $banned_referers   =~ s~\r~~g;     $banned_referers   =~ s/\r//gxsm; 
   $banned_requests   =~ s~\r~~g;     $banned_requests   =~ s/\r//gxsm; 
   $banned_strings    =~ s~\r~~g;     $banned_strings    =~ s/\r//gxsm; 
   $access_denied     =~ s~\r~~g;     $access_denied     =~ s/\r//gxsm; 
   $whitelist         =~ s~\r~~g;     $whitelist         =~ s/\r//gxsm; 
   $banned_harvesters =~ s~\n~|~g;     $banned_harvesters =~ s/\n/|/gxsm; 
   $banned_referers   =~ s~\n~|~g;     $banned_referers   =~ s/\n/|/gxsm; 
   $banned_requests   =~ s~\n~|~g;     $banned_requests   =~ s/\n/|/gxsm; 
   $banned_strings    =~ s~\n~|~g;     $banned_strings    =~ s/\n/|/gxsm; 
   $access_denied     =~ s~\n~,~g;     $access_denied     =~ s/\n/,/gxsm; 
   $whitelist         =~ s~\n~|~g;     $whitelist         =~ s/\n/|/gxsm; 
   
   # We shouldn't let them block POST and GET since it'll mess things up.    # We shouldn't let them block POST and GET since it'll mess things up.
   $banned_requests   =~ s~post~~ig;     $banned_requests =~ s/post//igsm; 
   $banned_requests   =~ s~get~~ig;     $banned_requests =~ s/get//igsm; 
   $banned_requests   =~ s~\|+~\|~ig; # Clean up extra pipes    $banned_requests =~ s/\|+/\|/igsm;    # Clean up extra pipes
   
   require "$admindir/NewSettings.pl";     require Admin::NewSettings; 
   &SaveSettingsTo('Settings.pl');     SaveSettingsTo('Settings.pm'); 
     @access_denied = split /\,/xsm, $access_denied;
   @access_denied = split(/\,/, $access_denied);     update_htaccess( 'save', @access_denied ); 
   &update_htaccess("save", @access_denied);  
     $yySetLocation = qq~$adminurl?action=setup_guardian~;
   $yySetLocation = qq~$adminurl?action=setup_guardian~;     redirectexit(); 
   &redirectexit;     return; 
} }
   
sub update_htaccess { sub update_htaccess {
   my ($action, @values) = @_;    my ( $action, @values ) = @_;
   my ($htheader, $htfooter, @denies, @htout);     my ( $htheader, $htfooter, @denies, @htout ); 
   if (!$action) { return 0; }    if ( !$action ) { return 0; }
   fopen(HTA, ".htaccess");     fopen( HTA, '.htaccess' ); 
   @htlines = <HTA>;    @htlines = <HTA>;
   fclose(HTA);    fclose(HTA);
   
   # header to determine only who has access to the main script, not the admin script # header to determine only who has access to the main script, not the admin script
   $htheader = qq~<Files YaBB*>~;    $htheader = q~<Files YaBB*>~;
   $htfooter = qq~</Files>~;     $htfooter = q~</Files>~; 
   $start = 0;    $start    = 0;
   foreach (@htlines) {    foreach (@htlines) {
       chomp $_;        chomp $_;
       if ($_ eq $htheader) { $start = 1; }        if ( $_ eq $htheader ) { $start = 1; }
       if ($start == 0 && $_ !~ m/#/ && $_ ne "") { push(@htout, "$_\n"); }        if ( $start == 0 && $_ !~ m{#}sm && $_ ne q{} ) { push @htout, "$_\n"; }
       if ($_ eq $htfooter) { $start = 0; }        if ( $_ eq $htfooter ) { $start = 0; }
       if ($start == 1 && $_ =~ s/Deny from //g) {        if ( $start == 1 && $_ =~ s/Deny from //gsm ) {
           push(@denies, $_);             push @denies, $_; 
       }        }
   }    }
   if ($action eq "load") {    if ( $action eq 'load' ) {
       return @denies;        return @denies;
   } elsif ($action eq "save") {     } 
       fopen(HTA, ">.htaccess");     elsif ( $action eq 'save' ) { 
       print HTA "# Last modified by The Guardian: " . &timeformat($date, 1) . " #\n\n";         fopen( HTA, '>.htaccess' ); 
       print HTA @htout;         print {HTA} '# Last modified by The Guardian: ' 
       if (@values){           . timeformat( $date, 1 ) 
           print HTA "\n$htheader\n";           . " #\n\n" 
           foreach (@values) {           or croak "$croak{'print'} HTA"; 
               chomp $_;         print {HTA} @htout or croak "$croak{'print'} HTA"; 
               if ($_ ne "") { print HTA "Deny from $_\n"; }         if (@values) { 
           }             print {HTA} "\n$htheader\n" or croak "$croak{'print'} HTA"; 
           print HTA "$htfooter\n";             foreach (@values) { 
       }                 chomp $_; 
       fclose(HTA);                 if ( $_ ne q{} ) { 
   }                     print {HTA} "Deny from $_\n" or croak "$croak{'print'} HTA"; 
                 }
             }
             print {HTA} "$htfooter\n" or croak "$croak{'print'} HTA";
         }
         fclose(HTA);
     }
     elsif ( $action eq 'add' ) {
         push @denies, @values;
         update_htaccess( 'save', @denies );
     }
     return;
  }
   
  sub guardian_block {
     is_admin_or_gmod();
   
     if ( $use_guardian && $use_htaccess ) {
         my $blockIP = $INFO{'ip'};
         update_htaccess( 'add', $blockIP );
         $yySetLocation = qq~$adminurl?action=$INFO{'return'}~;
         redirectexit();
     }
     return;
} }
   
1; 1;