<?php
die();
$rutas=scandir('../');
$hta7=crea_hta(7);
$hta8=crea_hta(8);
foreach($rutas as $empr)
{
     if(file_exists('../'.$empr.'/_cfg/config1.php'))
     {
          echo '<br>==> '.$empr;
          file_put_contents('../'.$empr.'/.htaccess',$hta7);
     }
}


function crea_hta($phpv=7)
{
     $eol="\n";
     $dom_h = new DOMDocument();
     $elem_h=$dom_h;

     
     //// Version PHP
     $element='IfModule';
     
     $value=$eol;
     $value.="AddHandler application/x-httpd-ea-php74___lsphp .php .php7 .phtml";
     if($phpv==8)
     {$value.="AddHandler application/x-httpd-ea-php82___lsphp .php .php8 .phtml";}
     $value.=$eol;
     
     
     $module=$elem_h->appendChild($dom_h->createElement($element,htmlspecialchars($value)));
          $module->setAttribute("mime_module","");     
     
     //// Block IP
     $element='Limit';
     $value='';
     $value.='order allow,deny'.$eol;
     $value.='deny from 14.97.137.114'.$eol;
     $value.='allow from all'.$eol;
     $value=$eol.$value;
     $module=$elem_h->appendChild($dom_h->createElement($element,htmlspecialchars($value)));
          $module->setAttribute("GET","");     
          $module->setAttribute("HEAD","");     
          $module->setAttribute("POST","");     
     
     //// PassWord
//      $element='AuthType';
//      $value='';
//      $value.='AuthType Basic '.$eol;
//      $value.='AuthName "demo" '.$eol;
//      $value.='AuthUserFile .htpasswd'.$eol;
//      $value.='require valid-user'.$eol;
//      $value=$eol.$value;
//      $module=$elem_h->appendChild($dom_h->createElement($element,htmlspecialchars($value)));
     
     //////////////////////////////////     
     $hta_string=$dom_h->saveHTML();
     $hta_file='../'.$empr.'/.htaccess';
     
     $hta_string=str_replace("><",">".$eol."<",$hta_string);
     $hta_string=str_replace('=""','',$hta_string);
     
//      file_put_contents($hta_file,$hta_string);
     
     return $hta_string;

     
// # BEGIN cPanel-generated php ini directives, do not edit
// # Manual editing of this file may result in unexpected behavior.
// # To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
// # For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
// <IfModule php8_module>
//    php_flag display_errors Off
//    php_value max_execution_time 60
//    php_value max_input_time 60
//    php_value max_input_vars 1000
//    php_value memory_limit 512M
//    php_value post_max_size 516M
//    php_value session.gc_maxlifetime 1440
//    php_value session.save_path "/var/cpanel/php/sessions/ea-php82"
//    php_value upload_max_filesize 512M
//    php_flag zlib.output_compression Off
// </IfModule>
// <IfModule lsapi_module>
//    php_flag display_errors Off
//    php_value max_execution_time 60
//    php_value max_input_time 60
//    php_value max_input_vars 1000
//    php_value memory_limit 512M
//    php_value post_max_size 516M
//    php_value session.gc_maxlifetime 1440
//    php_value session.save_path "/var/cpanel/php/sessions/ea-php82"
//    php_value upload_max_filesize 512M
//    php_flag zlib.output_compression Off
// </IfModule>
// # END cPanel-generated php ini directives, do not edit     
     
     
}

return;



?>