<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Albertech.net &#187; uptime</title>
	<atom:link href="http://albertech.net/tag/uptime/feed/" rel="self" type="application/rss+xml" />
	<link>http://albertech.net</link>
	<description>Tips, Tricks, and Reviews in Linux, Apache, MySQL, PHP</description>
	<lastBuildDate>Fri, 03 Sep 2010 17:40:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP Uptime check</title>
		<link>http://albertech.net/2008/11/php-uptime-check/</link>
		<comments>http://albertech.net/2008/11/php-uptime-check/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 21:49:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[uptime]]></category>

		<guid isPermaLink="false">http://albertech.net/?p=38</guid>
		<description><![CDATA[I found a useful script in PHP that can be used for checking uptime of a server. It can be useful for checking when the servers have a such a significant load that pages can't be displayed. The benefit or running it locally is that I can configure the script to perform failover functionality if necessary. Online uptime services are good too, but most of them aren't free. Maybe I should force the server to show a <a href="http://www.urbandictionary.com/define.php?term=failwhale">failwhale</a> when the site gets too busy...  j/k :D

Here's the link to the script.
<a href="http://www.programmingtalk.com/showthread.php?t=34999">http://www.programmingtalk.com/showthread.php?t=34999</a>

<code>
<?php 

// the URL you want to ... ]]></description>
			<content:encoded><![CDATA[<p>I found a useful script in PHP that can be used for checking uptime of a server. It can be useful for checking when the servers have a such a significant load that pages can&#8217;t be displayed. The benefit or running it locally is that I can configure the script to perform failover functionality if necessary. Online uptime services are good too, but most of them aren&#8217;t free. Maybe I should force the server to show a <a href="http://www.urbandictionary.com/define.php?term=failwhale">failwhale</a> when the site gets too busy&#8230;  j/k <img src='http://albertech.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Here&#8217;s the link to the script.<br />
<a href="http://www.programmingtalk.com/showthread.php?t=34999">http://www.programmingtalk.com/showthread.php?t=34999</a></p>
<p><code><br />
<?php </p>
<p>// the URL you want to keep tabs on<br />
$url = 'http://www.somewebsite.com'; </p>
<p>// if not available, send email<br />
if ( url_exists( $url ) === FALSE )<br />
{<br />
    $to   = 'my@email.com';<br />
    $subj = $url . ' is down!';<br />
    $msg  = $url . ' was tested at ' . date( 'Y-m-d H:i:s' ) . ' and was inaccessible.';<br />
    @mail( $to, $subj, $msg );<br />
} </p>
<p>/**<br />
 * url_exists()<br />
 * Checks for the validity of a given URL<br />
 *<br />
 * @param string The http[s] URL you're checking for<br />
 * @return bool TRUE if online; FALSE if not; NULL if not an http(s):// URL<br />
 */<br />
function url_exists( $strURL = NULL )<br />
{<br />
    if ( !preg_match( '/^http(s?):\/\//i', $strURL, $m ) )<br />
        return NULL;<br />
    @$ch = curl_init();<br />
    curl_setopt( $ch, CURLOPT_URL, $strURL );<br />
    curl_setopt( $ch, CURLOPT_BINARYTRANSFER, 1 );<br />
    curl_setopt( $ch, CURLOPT_HEADERFUNCTION, 'curlHeaderCallback' );<br />
    curl_setopt( $ch, CURLOPT_FAILONERROR, 1 );<br />
    curl_setopt( $ch, CURLOPT_TIMEOUT, 5 );<br />
    // https?<br />
    if ( $m[1] == 's' )<br />
        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );<br />
    @curl_exec( $ch );<br />
    $intReturnCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );<br />
    curl_close( $ch );<br />
    return ( $intReturnCode == 200 OR $intReturnCode == 302 OR $intReturnCode == 304 ) ? TRUE : FALSE;<br />
} </p>
<p>?><br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://albertech.net/2008/11/php-uptime-check/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
