Facebook
From Speedy Camel, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 44
  1. <?php
  2. echo "Enter url :";
  3. $url = readline(">> ");
  4. // Validate url
  5. if(filter_var(gethostbyname($url), FILTER_VALIDATE_IP))
  6. {
  7.    echo("$url is a valid URL\n");
  8.    $myfile = fopen("/etc/hosts", "a") or die("Unable to open file!");
  9.    fwrite($myfile, "127.0.0.1 $url\n");  
  10.    fclose($myfile);
  11. } else {
  12.    echo("$url is not a valid URL\n");
  13. }