Advertisement
sorahx0

Allow IP

Aug 9th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. <?php
  2. echo " Seu Ip Atual : ";
  3. echo ($_SERVER['REMOTE_ADDR']);
  4. if( !empty($_GET["newip"]) ){
  5.  
  6.         $ip = trim($_GET["newip"]);
  7.         if( filter_var($ip, FILTER_VALIDATE_IP) ){
  8.  
  9.                 //RewriteCond %{REMOTE_ADDR} !^179\.108\.123\.250$
  10.                 $AddIp = "RewriteCond %{REMOTE_ADDR} !^".str_replace(".","\.",$ip)."$";
  11.                 $contentHtaccess = explode("\n", file_get_contents('../.htaccess'));
  12.                 $newContentHtaccess = [];
  13.                 foreach( $contentHtaccess as $indexFile => $valueFile){
  14.  
  15.                         if( strpos($valueFile, "#fim_listA_HGBLOCK") !== false ){
  16.  
  17.                                 $newContentHtaccess[] = $AddIp;
  18.                                 $newContentHtaccess[] = $valueFile;
  19.  
  20.                         }else{
  21.  
  22.                                 $newContentHtaccess[] = $valueFile;
  23.  
  24.                         }
  25.  
  26.                 }
  27.  
  28.                 rename("../.htaccess", "../.htaccess".date("dmYhis"));
  29.                 $fileNewHtaccess = fopen('../.htaccess', 'w');
  30.  
  31.                 foreach( $newContentHtaccess as $indexNFile => $valueNF ){
  32.  
  33.                         fwrite($fileNewHtaccess, $valueNF.PHP_EOL );
  34.  
  35.                 }
  36.  
  37.  
  38.  
  39.                 fclose($fileNewHtaccess);
  40.  
  41.         }else{
  42.  
  43.                 $error = "IP inválido";
  44.  
  45.         }
  46.  
  47. }else{
  48.  
  49.         $error = "Informar um IP Valido por favor";
  50. }
  51. ?>
  52. <form action="#" method="GET">
  53. <label>Liberar IP :  </label><input type="text" name="newip" id="newip" value="" placeholder="1.1.1.1"> <input type="submit" name="chargeform" id="chargeform" value="Liberar IP">
  54. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement