<?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; script</title>
	<atom:link href="http://albertech.net/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>http://albertech.net</link>
	<description>Tips, Tricks, and Reviews in Linux, Apache, MySQL, PHP</description>
	<lastBuildDate>Wed, 28 Jul 2010 16:09:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP: Display page render time</title>
		<link>http://albertech.net/2009/06/php-display-page-render-time/</link>
		<comments>http://albertech.net/2009/06/php-display-page-render-time/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 19:06:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[render time]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://albertech.net/?p=191</guid>
		<description><![CDATA[Here's what I currently use to determine how long it takes to generate a page in PHP. Its only 8 lines of code. ]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Falbertech.net%252F2009%252F06%252Fphp-display-page-render-time%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22PHP%3A%20Display%20page%20render%20time%22%20%7D);"></div>
<p>Here&#8217;s what I currently use to determine how long it takes to generate a page in PHP. Its only 4 lines of code.</p>
<p><strong>PHP 5</strong></p>
<p><code>$time_start = microtime(true);<br />
$time_end = microtime(true);<br />
$time = $time_end - $time_start;<br />
echo "Displaying the render time: $time seconds\n";</code></p>
<p><strong>PHP 4 Version: (8 lines)</strong></p>
<p>Put this at the top of the PHP script:<br />
<code><br />
$render_time_start = microtime_float();<br />
</code></p>
<p>Put this at the end of the script:<br />
<code><br />
$render_time_end = microtime_float();<br />
$render_time = $render_time_end - $render_time_start;<br />
echo $render_time;</code></p>
<p><code>function microtime_float(){<br />
list($usec, $sec) = explode(" ", microtime());<br />
return ((float)$usec + (float)$sec);<br />
}</code></p>

]]></content:encoded>
			<wfw:commentRss>http://albertech.net/2009/06/php-display-page-render-time/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<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[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Falbertech.net%252F2008%252F11%252Fphp-uptime-check%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22PHP%20Uptime%20check%22%20%7D);"></div>
<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>
