Simple script i wrote

  • monitorporn
  • Born
  • Born
  • monitorporn
  • Posts: 1

Post 3+ Months Ago

The other day i needed to figure out a way to check to see if a certain site is responding by checking it via its ip ..
This is what i tossed together. I hope it is found useful by atleast one reader



Code: [ Select ]
<?php
    $sites_ip = "76.73.74.98"; // Sites ip
    $port = 80; //port to get to that site
    if(@fsockopen($sites_ip, $port)) // check the site and add @ so if the site is not responding we wont get a nasty error
    {
   
    header("Location: http://$sites_ip"); //if site is running go ahead and redirect to it
    }
    else
    {
   
    print "I cant send you to $sites_ip IS NOT RESPONDING!";    // if site is not responding go ahead and print the sites ip and tell the users its not responding
   
    }
   
?>
  1. <?php
  2.     $sites_ip = "76.73.74.98"; // Sites ip
  3.     $port = 80; //port to get to that site
  4.     if(@fsockopen($sites_ip, $port)) // check the site and add @ so if the site is not responding we wont get a nasty error
  5.     {
  6.    
  7.     header("Location: http://$sites_ip"); //if site is running go ahead and redirect to it
  8.     }
  9.     else
  10.     {
  11.    
  12.     print "I cant send you to $sites_ip IS NOT RESPONDING!";    // if site is not responding go ahead and print the sites ip and tell the users its not responding
  13.    
  14.     }
  15.    
  16. ?>


Regards Brent Moeller AKA Unknown And MonitorPorn
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Not certain I understand the purpose.

Quote:
//if site is running go ahead and redirect to it


Well, the server of the IP in the example you gave is up and running, however, if you go to that IP it 404's and doesn't direct you to the actual site home page. I'm assuming it would do that with a lot of domains running on a shared server that all share the same IP and use an internal redirect based on the domain name. I guess that's why I don't understand what value your script has.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: ScottG and 122 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.