title: Quick way to find out if website is down or up?
body: <p>Using my <strong>wordpress functions.php</strong> file to check if every image displayed is up and running or down. I think what I want to do is to break this functions code (below) into two.</p>
  
  <p><strong>function 1</strong>: check if mirror1.com is up (instead of checking every image in loop). insert if/then statement depending on http status of mirror1.com. (<strong>if mirror1.com is down, then use mirror2.com</strong>) -- pass that into $mirror_website</p>
  
  <p><strong>function 2:</strong> simply pass in $mirror_website.. (the front end has <strong><code>&lt;img src="&lt;?php echo $mirror_website; ?&gt;/image.png"&gt;</code></strong> )</p>
  
  <p>The code below works, but it's checking EVERY simple image and slows down the site.</p>
  
  <pre><code>function amazons3acctreplaceto() {
  $url = 'http://www.mirror1.com';
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_NOBODY, true);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
      curl_exec($ch);
      $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
      curl_close($ch);
      if (200==$retcode) {
         $as3replaceto = "www.mirror1.com"; // All's well
      } else {
         $as3replaceto = "www.mirror2.com";  // not so much
      }
  </code></pre>