<?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>Ryan Byrd&#039;s Tech Ramblings</title>
	<atom:link href="http://www.ryanbyrd.net/techramble/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ryanbyrd.net/techramble</link>
	<description>The Second Best Blog in Utah</description>
	<lastBuildDate>Tue, 31 Aug 2010 19:34:26 +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>Remote Terminal Data Pushes (okay, okay&#8211; polling)</title>
		<link>http://www.ryanbyrd.net/techramble/2010/08/31/remote-terminal-data-pushes-okay-okay-polling/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/08/31/remote-terminal-data-pushes-okay-okay-polling/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 19:34:26 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=306</guid>
		<description><![CDATA[Maybe you have a giant warehouse and you&#8217;d like some large LCD monitors around the shipping lines which have the orders listed for all to see. You&#8217;d like these LCDs to update frequently and to be specific to each shipping line. What to do? Well, there is meta-refresh every second, but that&#8217;s flickery and lame. [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe you have a giant warehouse and you&#8217;d like some large LCD monitors around the shipping lines which have the orders listed for all to see. You&#8217;d like these LCDs to update frequently and to be specific to each shipping line.</p>
<p>What to do? Well, there is meta-refresh every second, but that&#8217;s flickery and lame. Let&#8217;s get the javascript prototype library to update divs based on the location selected in a dropdown list:</p>
<pre class="html4strict html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>LCD Terminal Somewhere<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span>
                var url = 'get_content.php';
                var pars = 'location=1';
                var myAjax = new Ajax.PeriodicalUpdater(
                        'placeholder',
                        url,
                        {
                                method: 'post',  //use post or IE will cache(with get)
                                parameters: pars,
                                frequency: 2
                        });
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/h2.html"><span style="color: #000000; font-weight: bold;">h2</span></a>&gt;</span>Terminal Display<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/h2.html"><span style="color: #000000; font-weight: bold;">h2</span></a>&gt;&lt;<a href="http://december.com/html/4/element/i.html"><span style="color: #000000; font-weight: bold;">i</span></a>&gt;</span>(content refreshes every two seconds)<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/i.html"><span style="color: #000000; font-weight: bold;">i</span></a>&gt;&lt;<a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">br</span></a> <span style="color: #66cc66;">/</span>&gt;</span>
   <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;placeholder&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width:600px; height: 300px; border-width: .1em;border-style: solid;border-color: #000;&quot;</span>&gt;</span>Lorum Ipsum<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">div</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myLocation&quot;</span>&gt;</span>Change Location: <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;&lt;<a href="http://december.com/html/4/element/select.html"><span style="color: #000000; font-weight: bold;">select</span></a> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myLocation&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myLocation&quot;</span> <span style="color: #000066;">onchange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pars='location='+this.options[this.selectedIndex].value; myAjax.options.parameters = pars.toQueryParams();&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">option</span></a> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span>&gt;</span>Line 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">option</span></a> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span>&gt;</span>Lines 2 and 3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">option</span></a> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span>&gt;</span>Reception<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">option</span></a> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span>&gt;</span>Break Room<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">option</span></a>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/select.html"><span style="color: #000000; font-weight: bold;">select</span></a>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></pre>
<p>And here is get_content.php</p>
<pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'location'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span>
	        <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;h2&gt;Some custom data for Line 1&lt;/h2&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
	        <span style="color: #b1b100;">break</span>;
        <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">:</span>
	        <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;h2&gt;Custom datagrid for Lines 2 and 3&lt;/h2&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
	        <span style="color: #b1b100;">break</span>;
        <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">:</span>
	        <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;h2&gt;This would be displayed on the receptionist LCD&lt;/h2&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
	        <span style="color: #b1b100;">break</span>;
        <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">:</span>
	        <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;h2&gt;Content for the break room&lt;/h2&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
	        <span style="color: #b1b100;">break</span>;
<span style="color: #009900;">&#125;</span>
<a href="http://www.php.net/print"><span style="color: #990000;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;p&gt;&lt;p&gt;&lt;div align=<span style="color: #000099; font-weight: bold;">\&quot;</span>right<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;Last Updated: &quot;</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/print"><span style="color: #990000;">print</span></a> <a href="http://www.php.net/strftime"><span style="color: #990000;">strftime</span></a><span style="color: #009900;">&#40;</span><span style="">'%c'</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/print"><span style="color: #990000;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span>;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/08/31/remote-terminal-data-pushes-okay-okay-polling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP ping and DNS lookup</title>
		<link>http://www.ryanbyrd.net/techramble/2010/08/25/php-ping-and-dns-lookup/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/08/25/php-ping-and-dns-lookup/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 23:02:08 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=301</guid>
		<description><![CDATA[here&#8217;s a handy utility script so you can check pings and DNS from a remote server though a web browser &#60;html&#62; &#60;body&#62; &#60;form action=&#34;ping.php&#34;&#62; IP address&#60;input type=&#34;input&#34; name=&#34;ipaddr&#34; /&#62; or hostname&#60;input type=&#34;input&#34; name=&#34;host&#34; /&#62; &#60;input type=&#34;submit&#34; /&#62; &#60;/form&#62; &#60;?php function ping&#40;$host&#41; &#123; exec&#40;sprintf&#40;'ping -c 1 -W 5 %s', escapeshellarg&#40;$host&#41;&#41;, $res, $rval&#41;; return $res; &#125; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>here&#8217;s a handy utility script so you can check pings and DNS from a remote server though a web browser</p>
<pre class="php php" style="font-family:monospace;">&lt;html&gt;
&lt;body&gt;
&lt;form action=&quot;ping.php&quot;&gt;
IP address&lt;input type=&quot;input&quot; name=&quot;ipaddr&quot; /&gt;
or
hostname&lt;input type=&quot;input&quot; name=&quot;host&quot; /&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> ping<span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <a href="http://www.php.net/exec"><span style="color: #990000;">exec</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/sprintf"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span><span style="">'ping -c 1 -W 5 %s'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/escapeshellarg"><span style="color: #990000;">escapeshellarg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$res</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rval</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$res</span>;
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'ipaddr'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'ipaddr'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">!=</span><span style="">''</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/^(<span style="color: #000099; font-weight: bold;">\d</span>{1,3})<span style="color: #000099; font-weight: bold;">\.</span>(<span style="color: #000099; font-weight: bold;">\d</span>{1,3})<span style="color: #000099; font-weight: bold;">\.</span>(<span style="color: #000099; font-weight: bold;">\d</span>{1,3})<span style="color: #000099; font-weight: bold;">\.</span>(<span style="color: #000099; font-weight: bold;">\d</span>{1,3})$/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'ipaddr'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;pre&gt;&quot;</span><span style="color: #009900;">&#41;</span>;print_r<span style="color: #009900;">&#40;</span>ping<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'ipaddr'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/pre&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ip address not valid&quot;</span><span style="color: #009900;">&#41;</span>;<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">!=</span><span style="">''</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span><span style="">'/^([a-z0-9][a-z0-9-]{0,62}\.)+([a-z]{2,4})$/'</span><span style="color: #339933;">,</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> dns_get_record<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;
                <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;pre&gt;&quot;</span><span style="color: #009900;">&#41;</span>;print_r<span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span>;echo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/pre&gt;&quot;</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;host name not valid&quot;</span><span style="color: #009900;">&#41;</span>;<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/08/25/php-ping-and-dns-lookup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BASH script to check URL for changes</title>
		<link>http://www.ryanbyrd.net/techramble/2010/08/16/bash-script-to-check-url-for-changes/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/08/16/bash-script-to-check-url-for-changes/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 20:00:14 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=296</guid>
		<description><![CDATA[Here&#8217;s a quick script I coded this morning to check a URL/URLs for changes and alert you #!/bin/bash HASHFILE=&#34;hashes.txt&#34; URLFILE=&#34;urls.txt&#34; EMAILADDRESS=&#34;name@example.com&#34; if &#91; -z &#34;$1&#34; &#93; then echo &#34;Usage: `basename $0` [TRAIN&#124;CHECK]&#34; echo &#34;Create a file called urls.txt with URLS to check&#34; exit 1 fi if &#91;&#91; &#34;${1}&#34; == &#34;CHECK&#34; &#93;&#93; then echo &#34;CHECKING&#34; if [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick script I coded this morning to check a URL/URLs for changes and alert you</p>
<pre class="bash bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">HASHFILE</span>=<span style="color: #ff0000;">&quot;hashes.txt&quot;</span>
<span style="color: #007800;">URLFILE</span>=<span style="color: #ff0000;">&quot;urls.txt&quot;</span>
<span style="color: #007800;">EMAILADDRESS</span>=<span style="color: #ff0000;">&quot;name@example.com&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: `basename $0` [TRAIN|CHECK]&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Create a file called urls.txt with URLS to check&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;${1}&quot;</span> == <span style="color: #ff0000;">&quot;CHECK&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;CHECKING&quot;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$HASHFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hash file exists. Parsing&quot;</span>
                <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line; <span style="color: #000000; font-weight: bold;">do</span>
                        <span style="color: #007800;">URL</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$line</span> |<span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
                        <span style="color: #007800;">HASH</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$line</span> |<span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #000000; font-weight: bold;">`</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Checking $URL&quot;</span>
                        <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #007800;">$URL</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
                        <span style="color: #007800;">FILENAME</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$URL</span><span style="color: #000000; font-weight: bold;">`</span>
                        <span style="color: #007800;">HASHVALUE</span>=<span style="color: #000000; font-weight: bold;">`</span>md5sum <span style="color: #007800;">$FILENAME</span>|<span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
                        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;${HASHVALUE}&quot;</span> == <span style="color: #ff0000;">&quot;${HASH}&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;NOTICE: hasn't changed&quot;</span>
                        <span style="color: #000000; font-weight: bold;">else</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ALERT: [$URL] CHANGED from [$HASH] to [$HASHVALUE]&quot;</span>
                                <span style="color: #007800;">PREFIX</span>=<span style="color: #ff0000;">&quot;BLOCK_&quot;</span>
                                <span style="color: #007800;">BLOCKFILE</span>=<span style="color: #007800;">$PREFIX</span><span style="color: #007800;">$FILENAME</span>
                                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$BLOCKFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
                                <span style="color: #000000; font-weight: bold;">then</span>
                                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;BLOCK FILE EXISTS. NOT EMAILING&quot;</span>
                                <span style="color: #000000; font-weight: bold;">else</span>
                                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;NO BLOCK FILE, EMAILING ALERT. WRITING BLOCK FILE&quot;</span>
                                        mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;ALERT: [$URL] CHANGED from [$HASH] to [$HASHVALUE]&quot;</span> <span style="color: #007800;">$EMAILADDRESS</span> <span style="color: #000000; font-weight: bold;">&lt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
                                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;$URL changed. alerted&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$BLOCKFILE</span>
                                <span style="color: #000000; font-weight: bold;">fi</span>
                        <span style="color: #000000; font-weight: bold;">fi</span>
                        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$FILENAME</span>
                <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$HASHFILE</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: no hash file exists. Exiting&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;TRAINING&quot;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$URLFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;URL file exists. Parsing&quot;</span>
                <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$HASHFILE</span>
                <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #007800;">$HASHFILE</span>
                <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line; <span style="color: #000000; font-weight: bold;">do</span>
                        <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #007800;">$line</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
                        <span style="color: #007800;">FILENAME</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$line</span><span style="color: #000000; font-weight: bold;">`</span>
                        <span style="color: #007800;">HASHVALUE</span>=<span style="color: #000000; font-weight: bold;">`</span>md5sum <span style="color: #007800;">$FILENAME</span>|<span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;$line $HASHVALUE&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$HASHFILE</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;added $line to hash file&quot;</span>
                          <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$FILENAME</span>
                <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #007800;">$URLFILE</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: no url file exists. Exiting&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/08/16/bash-script-to-check-url-for-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date Interval Calculation Function</title>
		<link>http://www.ryanbyrd.net/techramble/2010/08/03/date-interval-calculation-function/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/08/03/date-interval-calculation-function/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 05:12:24 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=290</guid>
		<description><![CDATA[You&#8217;d like to email someone seven times, every other day starting today. How do you get those dates? function calculateIntervalDates&#40;$startDate, $interval, $count&#41; &#123; $intervalArray=array&#40;'Daily'=&#62;1,'Every-other-day'=&#62;2,'Weekly'=&#62;7, 'Twice-monthly'=&#62;15, 'Monthly'=&#62;30&#41;; $daysToAdd=$intervalArray&#91;$interval&#93;; for&#40;$x=0;$x&#60;$count;$x++&#41; &#123; $intervalDateArray&#91;&#93;= date&#40;&#34;m/d/Y&#34;, strtotime&#40;&#34;$startDate + &#34;.$daysToAdd*$x.&#34; days&#34;&#41;&#41;; &#125; return $intervalDateArray; &#125; &#160; print_r&#40;calculateIntervalDates&#40;&#34;08/03/2010&#34;,'Every-other-day',7&#41;&#41;; which outputs Array &#40; &#91;0&#93; =&#62; 08/03/2010 &#91;1&#93; =&#62; 08/05/2010 &#91;2&#93; =&#62; 08/07/2010 &#91;3&#93; [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;d like to email someone seven times, every other day starting today. How do you get those dates?</p>
<pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> calculateIntervalDates<span style="color: #009900;">&#40;</span><span style="color: #000088;">$startDate</span><span style="color: #339933;">,</span> <span style="color: #000088;">$interval</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$intervalArray</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="">'Daily'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="">'Every-other-day'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="">'Weekly'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span> <span style="">'Twice-monthly'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">15</span><span style="color: #339933;">,</span> <span style="">'Monthly'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #000088;">$daysToAdd</span><span style="color: #339933;">=</span><span style="color: #000088;">$intervalArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$interval</span><span style="color: #009900;">&#93;</span>;
        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$count</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$intervalDateArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;m/d/Y&quot;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/strtotime"><span style="color: #990000;">strtotime</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;$startDate + &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$daysToAdd</span><span style="color: #339933;">*</span><span style="color: #000088;">$x</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; days&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$intervalDateArray</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span>calculateIntervalDates<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;08/03/2010&quot;</span><span style="color: #339933;">,</span><span style="">'Every-other-day'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;</pre>
<p>which outputs</p>
<pre class="bash bash" style="font-family:monospace;">Array
<span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span>0<span style="color: #7a0874; font-weight: bold;">&#93;</span> =<span style="color: #000000; font-weight: bold;">&gt;</span> 08<span style="color: #000000; font-weight: bold;">/</span>03<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> =<span style="color: #000000; font-weight: bold;">&gt;</span> 08<span style="color: #000000; font-weight: bold;">/</span>05<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> =<span style="color: #000000; font-weight: bold;">&gt;</span> 08<span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> =<span style="color: #000000; font-weight: bold;">&gt;</span> 08<span style="color: #000000; font-weight: bold;">/</span>09<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> =<span style="color: #000000; font-weight: bold;">&gt;</span> 08<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">11</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> =<span style="color: #000000; font-weight: bold;">&gt;</span> 08<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">13</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> =<span style="color: #000000; font-weight: bold;">&gt;</span> 08<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">15</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span>
<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre>
<p>I recognize the monthly is an approximate and that I could do better by having a special case for that, but, it&#8217;s close enough.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/08/03/date-interval-calculation-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting User-Agent Header in Selenium</title>
		<link>http://www.ryanbyrd.net/techramble/2010/08/02/setting-user-agent-header-in-selenium/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/08/02/setting-user-agent-header-in-selenium/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 18:40:18 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=284</guid>
		<description><![CDATA[If you Google &#8220;setting the Selenium User-Agent header&#8221; you get a whole bunch of crapola. Specifically, Selenium folks want you to use web drivers, which is stupid because the whole point is that you want to be able to record tests in the Selenium Firefox plugin and then run them with Selenium RC. (setting the [...]]]></description>
			<content:encoded><![CDATA[<p>If you Google &#8220;setting the Selenium User-Agent header&#8221; you get a whole bunch of crapola. Specifically, Selenium folks want you to use web drivers, which is stupid because the whole point is that you want to be able to record tests in the Selenium Firefox plugin and then run them with Selenium RC. <em>(setting the user-agent is useful when trying to filter out tests from live traffic</em>)</p>
<p>Anyway, the solution is to create a Firefox profile with the user-agent string already set. Be sure to modify the profile to clear cookies and cache on exit, to not prompt for updates or add-ons etc. </p>
<p>First, start Firefox in profile editor mode:</p>
<pre class="bash bash" style="font-family:monospace;">firefox.exe <span style="color: #660033;">-ProfileManager</span> <span style="color: #660033;">-no-remote</span></pre>
<p>Go ahead and create a new profile and then start Firefox with that profile and make you customizations (set the user-agent, etc). Then launch selenium like this:</p>
<pre class="bash bash" style="font-family:monospace;">java <span style="color: #660033;">-jar</span> selenium-server.jar <span style="color: #660033;">-firefoxProfileTemplate</span> <span style="color: #ff0000;">&quot;your profile directory goes here&quot;</span></pre>
<p>Here is some test code to see if you&#8217;ve succeeded:</p>
<pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span> <span style="">'PHPUnit/Extensions/SeleniumTestCase.php'</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> testuagent <span style="color: #000000; font-weight: bold;">extends</span> PHPUnit_Extensions_SeleniumTestCase
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">function</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBrowser</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;*firefox&quot;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBrowserUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.iopus.com/&quot;</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> testMyTestCase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">open</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/imacros/demo/v5/user-agent.htm&quot;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;30000&quot;</span><span style="color: #009900;">&#41;</span>;
    <a href="http://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>useful links:</p>
<p>http://johnbokma.com/mexit/2004/04/24/changinguseragent.html</p>
<p>http://girliemangalo.wordpress.com/2009/02/05/creating-firefox-profile-for-your-selenium-rc-tests/</p>
<p>http://www.iopus.com/imacros/demo/v5/user-agent.htm</p>
<p>http://support.mozilla.com/en-US/kb/How+to+clear+the+cache</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/08/02/setting-user-agent-header-in-selenium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hip, Hip Array</title>
		<link>http://www.ryanbyrd.net/techramble/2010/07/31/hip-hip-array/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/07/31/hip-hip-array/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 05:40:50 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=279</guid>
		<description><![CDATA[I couldn&#8217;t resist&#8230; src: http://www.neatoshop.com/product/Hip-Hip-Array]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t resist&#8230;<br />
<a href="http://www.ryanbyrd.net/techramble/wp-content/uploads/2010/07/hip-hip-array.jpg"><img src="http://www.ryanbyrd.net/techramble/wp-content/uploads/2010/07/hip-hip-array.jpg" alt="" title="hip-hip-array" width="500" height="399" class="alignnone size-full wp-image-280" /></a></p>
<p>src: http://www.neatoshop.com/product/Hip-Hip-Array</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/07/31/hip-hip-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selenium, Nagios and Magento&#8211; together at last!</title>
		<link>http://www.ryanbyrd.net/techramble/2010/07/29/selenium-nagios-and-magento-together-at-last/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/07/29/selenium-nagios-and-magento-together-at-last/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 16:51:26 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=273</guid>
		<description><![CDATA[Now that I have a server running selenium tests against a magento-powered ecommerce site and logging those tests to a file, we need to integrate with nagios. First, I installed openSSH on that windows server (via copssh), and copied over the nagios user public key to authorized_keys. Then I wrote this nagios script: #! /usr/bin/php [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I have a server running selenium tests against a magento-powered ecommerce site and logging those tests to a file, we need to integrate with nagios. First, I installed openSSH on that windows server (via <a href="http://www.itefix.no/i2/copssh" target="_blank">copssh</a>), and copied over the nagios user public key to authorized_keys. Then I wrote this nagios script:</p>
<pre class="php php" style="font-family:monospace;">#! /usr/bin/php -q
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<a href="http://www.php.net/ini_set"><span style="color: #990000;">ini_set</span></a><span style="color: #009900;">&#40;</span> <span style="">'max_execution_time'</span><span style="color: #339933;">,</span> <span style="">'55'</span> <span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/ini_set"><span style="color: #990000;">ini_set</span></a><span style="color: #009900;">&#40;</span> <span style="">'display_errors'</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span>;
&nbsp;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;STATUS_OK&quot;</span><span style="color: #339933;">,</span>       <span style="color:#800080;">0</span> <span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;STATUS_WARNING&quot;</span><span style="color: #339933;">,</span>  <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;STATUS_CRITICAL&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;STATUS_UNKNOWN&quot;</span><span style="color: #339933;">,</span>  <span style="color: #cc66cc;">3</span> <span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$execCommand</span><span style="color: #339933;">=</span><span style="">'ssh WINDOWS_SERVER_IP_GOES_HERE -l nagiosremote &quot;tail -n 1 selenium.txt&quot;'</span>;
<a href="http://www.php.net/exec"><span style="color: #990000;">exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$execCommand</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span><span style="color: #000088;">$date</span><span style="color: #339933;">,</span><span style="color: #000088;">$time</span><span style="color: #339933;">,</span><span style="color: #000088;">$status</span><span style="color: #339933;">,</span><span style="color: #000088;">$avg</span><span style="color: #339933;">,</span><span style="color: #000088;">$std</span><span style="color: #339933;">,</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">,</span><span style="color: #000088;">$flagCnt</span><span style="color: #339933;">,</span><span style="color: #000088;">$statCnt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><a href="http://www.php.net/split"><span style="color: #990000;">split</span></a><span style="color: #009900;">&#40;</span><span style="">','</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color:#800080;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">,</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">===</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>||<span style="color: #009900;">&#40;</span><a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">,</span><span style="">'ERROR'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!==</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ERROR: $status $FLAG<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span>;
        <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span> STATUS_CRITICAL <span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
        <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;OK: time $time, status $status, avg $avg, std $std, FLAG $FLAG, flagCnt $flagCnt, statCnt $statCnt<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span>;
        <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span> STATUS_OK <span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre>
<p>Then I defined a check_command, a host, a host_group and a service in nagios and we&#8217;re in business!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/07/29/selenium-nagios-and-magento-together-at-last/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Selenium RC Runner Script (updated)</title>
		<link>http://www.ryanbyrd.net/techramble/2010/07/27/quick-selenium-rc-runner-script/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/07/27/quick-selenium-rc-runner-script/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 22:31:10 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=265</guid>
		<description><![CDATA[define&#40;'BADWEIGHT',10&#41;; define&#40;'GOODWEIGHT',1&#41;; define&#40;'BADMULTIPLIER',150&#41;; define&#40;'BADTIMEOUT',10&#41;; define&#40;'SLOWDEVIATIONS',2&#41;; $filename = 'C:\Program Files\ICW\home\nagiosremote\selenium.txt'; &#160; $execCommand=&#34;phpunit.bat selenium.php&#34;; $trial=0; function logToFile&#40;$somecontent&#41; &#123; global $filename; if &#40;is_writable&#40;$filename&#41;&#41; &#123; if &#40;!$handle = fopen&#40;$filename, 'a'&#41;&#41; &#123; echo &#34;Cannot open file ($filename)&#34;; exit; &#125; if &#40;fwrite&#40;$handle, $somecontent&#41; === FALSE&#41; &#123; echo &#34;Cannot write to file ($filename)&#34;; exit; &#125; fclose&#40;$handle&#41;; &#125; else &#123; echo &#34;The file [...]]]></description>
			<content:encoded><![CDATA[<pre class="php php" style="font-family:monospace;"><a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'BADWEIGHT'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'GOODWEIGHT'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'BADMULTIPLIER'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">150</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'BADTIMEOUT'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="">'SLOWDEVIATIONS'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="">'C:\Program Files\ICW\home\nagiosremote\selenium.txt'</span>;
&nbsp;
<span style="color: #000088;">$execCommand</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;phpunit.bat selenium.php&quot;</span>;
<span style="color: #000088;">$trial</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
<span style="color: #000000; font-weight: bold;">function</span> logToFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$somecontent</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<a href="http://www.php.net/global"><span style="color: #990000;">global</span></a> <span style="color: #000088;">$filename</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_writable"><span style="color: #990000;">is_writable</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span> <span style="">'a'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			 <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> <span style="color: #0000ff;">&quot;Cannot open file ($filename)&quot;</span>;
			 <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a>;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$somecontent</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> <span style="color: #0000ff;">&quot;Cannot write to file ($filename)&quot;</span>;
			<a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a>;
		<span style="color: #009900;">&#125;</span>
		<a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a> <span style="color: #0000ff;">&quot;The file $filename is not writable&quot;</span>;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sd_square<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mean</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <a href="http://www.php.net/pow"><span style="color: #990000;">pow</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$mean</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>; <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sd<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">return</span> <a href="http://www.php.net/sqrt"><span style="color: #990000;">sqrt</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_sum"><span style="color: #990000;">array_sum</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_map"><span style="color: #990000;">array_map</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sd_square&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array_fill"><span style="color: #990000;">array_fill</span></a><span style="color: #009900;">&#40;</span><span style="color:#800080;">0</span><span style="color: #339933;">,</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_sum"><span style="color: #990000;">array_sum</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getStats<span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$trial</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$sum</span><span style="color: #339933;">+=</span><span style="color: #000088;">$trial</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span>;
		<span style="color: #000088;">$timeArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$trial</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$counter</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span>?<a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span>;
	<span style="color: #000088;">$average</span><span style="color: #339933;">=</span><a href="http://www.php.net/sprintf"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;%.2f&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$sum</span><span style="color: #339933;">/</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trials</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$stdDev</span><span style="color: #339933;">=</span><a href="http://www.php.net/sprintf"><span style="color: #990000;">sprintf</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;%.2f&quot;</span><span style="color: #339933;">,</span>sd<span style="color: #009900;">&#40;</span><span style="color: #000088;">$timeArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$stdDev</span><span style="color: #339933;">=</span><span style="color:#800080;">0.00</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$average</span><span style="color: #339933;">,</span><span style="color: #000088;">$stdDev</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> stripOutliers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$times</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$noOutlierArray</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$avg</span><span style="color: #339933;">,</span><span style="color: #000088;">$stDev</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span>getStats<span style="color: #009900;">&#40;</span><span style="color: #000088;">$times</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$times</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&lt;=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$avg</span><span style="color: #339933;">+</span><span style="color: #000088;">$stDev</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$noOutlierArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span>;
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$noOutlierArray</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
<span style="color: #000088;">$statCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$output</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	<a href="http://www.php.net/exec"><span style="color: #990000;">exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$execCommand</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #000088;">$time</span><span style="color: #339933;">=</span><a href="http://www.php.net/intval"><span style="color: #990000;">intval</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>; <span style="color: #666666; font-style: italic;">//parse seconds</span>
	<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">,</span><span style="color: #000088;">$hud</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><a href="http://www.php.net/split"><span style="color: #990000;">split</span></a><span style="color: #009900;">&#40;</span><span style="">' '</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>; <span style="color: #666666; font-style: italic;">//parse status</span>
	<span style="color: #000088;">$status</span><span style="color: #339933;">=</span><a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">!=</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$status</span><span style="color: #339933;">=</span><a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$output</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
		<span style="color: #000088;">$statCnt</span><span style="color: #339933;">+=</span>BADWEIGHT;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$statCnt</span><span style="color: #339933;">-=</span>GOODWEIGHT;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$resultArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$trial</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="">'time'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$time</span>;
	<span style="color: #000088;">$resultArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$trial</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="">'status'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$status</span>;
&nbsp;
	<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$avg</span><span style="color: #339933;">,</span><span style="color: #000088;">$stDev</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span>getStats<span style="color: #009900;">&#40;</span>stripOutliers<span style="color: #009900;">&#40;</span><span style="color: #000088;">$resultArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$time</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$avg</span><span style="color: #339933;">+</span>SLOWDEVIATIONS<span style="color: #339933;">*</span><span style="color: #000088;">$stDev</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>?<span style="color: #0000ff;">&quot;SLOW&quot;</span><span style="color: #339933;">:</span><span style="">'OK'</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">!=</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'WARNING! Bad Status '</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">==</span><span style="">'SLOW'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">+=</span>BADWEIGHT;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">-=</span>GOODWEIGHT;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$flagCnt</span><span style="color: #339933;">&lt;=</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$flagCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$statCnt</span><span style="color: #339933;">&lt;=</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$statCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$flagCnt</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>BADWEIGHT<span style="color: #339933;">*</span>BADMULTIPLIER<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'ERROR! TOO MANY SLOW TRANSACTIONS'</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$statCnt</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>BADWEIGHT<span style="color: #339933;">*</span>BADMULTIPLIER<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'ERROR! TOO MANY TRANSACTION FAILURES'</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">==</span><span style="">'ERROR! TOO MANY TRANSACTION FAILURES'</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #000088;">$status</span><span style="color: #339933;">==</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'OK'</span>;<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">==</span><span style="">'ERROR! TOO MANY SLOW TRANSACTIONS'</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #000088;">$status</span><span style="color: #339933;">==</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">=</span><span style="">'OK'</span>;<span style="color: #000088;">$flagCnt</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$lineItem</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${trial},&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="">'d/m/Y H:i:s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,$time sec,$status,Avg:$avg,StdDev:$stDev,$FLAG,$flagCnt,$statCnt<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
	<a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#41;</span>;
	logToFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$lineItem</span><span style="color: #009900;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$FLAG</span><span style="color: #339933;">!=</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span>||<span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #339933;">!=</span><span style="">'OK'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span>BADTIMEOUT<span style="color: #009900;">&#41;</span>;
	<span style="color: #000088;">$trial</span>++;
<span style="color: #009900;">&#125;</span></pre>
<p>which will produce a text file like this:</p>
<pre class="bash bash" style="font-family:monospace;">C:\xampp\php<span style="color: #000000; font-weight: bold;">&gt;</span>php runTests.php
0,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:06:01,<span style="color: #000000;">34</span> sec,OK,Avg:<span style="color: #000000;">34.00</span>,StdDev:0,OK,0,0
<span style="color: #000000;">1</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:06:<span style="color: #000000;">20</span>,<span style="color: #000000;">19</span> sec,OK,Avg:<span style="color: #000000;">26.50</span>,StdDev:<span style="color: #000000;">10.61</span>,OK,0,0
<span style="color: #000000;">2</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:06:<span style="color: #000000;">39</span>,<span style="color: #000000;">19</span> sec,OK,Avg:<span style="color: #000000;">19.00</span>,StdDev:<span style="color: #000000;">0.00</span>,OK,0,0
<span style="color: #000000;">3</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:06:<span style="color: #000000;">58</span>,<span style="color: #000000;">18</span> sec,OK,Avg:<span style="color: #000000;">18.67</span>,StdDev:<span style="color: #000000;">0.58</span>,OK,0,0
<span style="color: #000000;">4</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:07:<span style="color: #000000;">17</span>,<span style="color: #000000;">18</span> sec,OK,Avg:<span style="color: #000000;">18.50</span>,StdDev:<span style="color: #000000;">0.58</span>,OK,0,0
<span style="color: #000000;">5</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:07:<span style="color: #000000;">36</span>,<span style="color: #000000;">19</span> sec,OK,Avg:<span style="color: #000000;">18.60</span>,StdDev:<span style="color: #000000;">0.55</span>,OK,0,0
<span style="color: #000000;">6</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:07:<span style="color: #000000;">55</span>,<span style="color: #000000;">18</span> sec,OK,Avg:<span style="color: #000000;">18.50</span>,StdDev:<span style="color: #000000;">0.55</span>,OK,0,0
<span style="color: #000000;">7</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:08:<span style="color: #000000;">14</span>,<span style="color: #000000;">18</span> sec,OK,Avg:<span style="color: #000000;">18.43</span>,StdDev:<span style="color: #000000;">0.53</span>,OK,0,0
<span style="color: #000000;">8</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:08:<span style="color: #000000;">38</span>,<span style="color: #000000;">24</span> sec,OK,Avg:<span style="color: #000000;">19.12</span>,StdDev:<span style="color: #000000;">2.03</span>,SLOW,<span style="color: #000000;">10</span>,0
<span style="color: #000000;">9</span>,<span style="color: #000000;">29</span><span style="color: #000000; font-weight: bold;">/</span>07<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span> <span style="color: #000000;">12</span>:09:<span style="color: #000000;">12</span>,<span style="color: #000000;">24</span> sec,OK,Avg:<span style="color: #000000;">19.67</span>,StdDev:<span style="color: #000000;">2.50</span>,OK,<span style="color: #000000;">9</span>,0</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/07/27/quick-selenium-rc-runner-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Magento Sites with Selenium</title>
		<link>http://www.ryanbyrd.net/techramble/2010/07/21/testing-magento-sites-with-selenium/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/07/21/testing-magento-sites-with-selenium/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 19:08:29 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=259</guid>
		<description><![CDATA[So you installed the Selenium IDE firefox plugin and you recorded a check-out transaction of your Magento-powered ecommerce site. Then you save as a php file and fire up your Selenium RC server and run the script. It gets to the checkout page and &#8230; Nothing. What&#8217;s wrong? What&#8217;s wrong is that you&#8217;ve submitted too [...]]]></description>
			<content:encoded><![CDATA[<p>So you installed the Selenium IDE firefox plugin and you recorded a check-out transaction of your Magento-powered ecommerce site. Then you save as a php file and fire up your Selenium RC server and run the script. It gets to the checkout page and &#8230; Nothing. What&#8217;s wrong?</p>
<p>What&#8217;s wrong is that you&#8217;ve submitted too quickly. You need to do some checking with xpath ids for the &#8220;updating totals&#8221; div before you can click submit. Here&#8217;s a working Selenium Magento script for your reference:</p>
<pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span> <span style="">'PHPUnit/Extensions/SeleniumTestCase.php'</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Example <span style="color: #000000; font-weight: bold;">extends</span> PHPUnit_Extensions_SeleniumTestCase
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">function</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBrowser</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;*chrome&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBrowserUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.example.com&quot;</span><span style="color: #009900;">&#41;</span>;
 <span style="color: #009900;">&#125;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> testMyTestCase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;">//$this-&gt;maxRunningTime= 30; //(this is a special function I implemented)</span>
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">open</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">click</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//ul[@id='nav']/li[1]/ul/li[1]/a/span&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;30000&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">click</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//img[@alt='ADD TO CART']&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;30000&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">click</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//div[2]/div[1]/ul/li/a/img&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;30000&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;billing:email&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;test@example.com&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;billing:firstname&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;test&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;billing:lastname&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;test&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;billing:telephone&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;8015551212&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;billing:street1&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;100 Main Street&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;billing:city&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Salt Lake City&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;billing:region_id&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;label=Utah&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;billing:postcode&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;84116&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">click</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//*[@id=<span style="color: #000099; font-weight: bold;">\&quot;</span>billing:street1<span style="color: #000099; font-weight: bold;">\&quot;</span>]&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$second</span> <span style="color: #339933;">=</span> <span style="color:#800080;">0</span>; ; <span style="color: #000088;">$second</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$second</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">break</span>;
       try <span style="color: #009900;">&#123;</span>
           <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isElementPresent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//span[@id='billing-please-wait' and contains(@style,'display: none')]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">break</span>;
       <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
       <a href="http://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$second</span> <span style="color: #339933;">=</span> <span style="color:#800080;">0</span>; ; <span style="color: #000088;">$second</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$second</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">break</span>;
       try <span style="color: #009900;">&#123;</span>
           <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isElementPresent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//span[@id='billing-please-wait' and contains(@style,'display: none')]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">break</span>;
       <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
       <a href="http://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;merchant_cc_number&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;511111111111111&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">click</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;advice-validate-cc-number-merchant_cc_number&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;merchant_cc_number&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;4111111111111111&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;merchant_expiration&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;label=01 - January&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;merchant_expiration_yr&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;label=2016&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;merchant_cc_cid&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;432&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">click</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//*[@id=<span style="color: #000099; font-weight: bold;">\&quot;</span>submit-order-button<span style="color: #000099; font-weight: bold;">\&quot;</span>]&quot;</span><span style="color: #009900;">&#41;</span>;
   <a href="http://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">click</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//*[@id=<span style="color: #000099; font-weight: bold;">\&quot;</span>submit-order-button<span style="color: #000099; font-weight: bold;">\&quot;</span>]&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;30000&quot;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>;
   try <span style="color: #009900;">&#123;</span>
       <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assertTrue</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isTextPresent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Thank you for your purchase!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>PHPUnit_Framework_AssertionFailedError <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <a href="http://www.php.net/array_push"><span style="color: #990000;">array_push</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">verificationErrors</span><span style="color: #339933;">,</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
   <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
<p>Here is the <a href="http://www.ryanbyrd.net/techramble/2009/10/07/automated-qa-testing-with-selenium/" target="_blank">Selenium timeout/maxRunningTime modification code</a> explained.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/07/21/testing-magento-sites-with-selenium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Disaster Recovery VirtualHosts</title>
		<link>http://www.ryanbyrd.net/techramble/2010/07/06/testing-disaster-recovery-virtualhosts/</link>
		<comments>http://www.ryanbyrd.net/techramble/2010/07/06/testing-disaster-recovery-virtualhosts/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 22:05:38 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=254</guid>
		<description><![CDATA[Maybe you have a bunch of high-volume sites and you want them never to go down? You could get a couple dedicated servers and install Apache and your sites on them. If ever your main server goes down, your plan could be to switch the DNS for your sites over to these DR servers. How [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe you have a bunch of high-volume sites and you want them never to go down? You could get a couple dedicated servers and install Apache and your sites on them. If ever your main server goes down, your plan could be to switch the DNS for your sites over to these DR servers. </p>
<p>How do you test that your sites (set up with VirtualHosts) on these servers work, BEFORE you have to switch them over?</p>
<p>Well, you&#8217;d add the new IPs to your local hosts file and test it. But what if you wanted on going tests, maybe with Selenium? Well, you could use a proxy and add the lines to the proxy&#8217;s /etc/hosts UNLESS you needed to test the same site on multiple servers. If that was your scenario, you could do the following:</p>
<p>1. install glypeproxy ( http://www.glype.com/ ) which is free for non-commercial use<br />
2. in browse.php, after require &#8216;includes/init.php&#8217;; add:</p>
<pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'hostHack'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$goto</span><span style="color: #339933;">=</span><a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/rawurlencode"><span style="color: #990000;">rawurlencode</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/base64_encode"><span style="color: #990000;">base64_encode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curURL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$sessionfixurl</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://YOURURLHERE/hosthack.php?goto=$goto&quot;</span>;
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: $sessionfixurl&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre>
<p>3. add a new file called hosthack.php:</p>
<pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'goto'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$goto</span><span style="color: #339933;">=</span><a href="http://www.php.net/base64_decode"><span style="color: #990000;">base64_decode</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/rawurldecode"><span style="color: #990000;">rawurldecode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'goto'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span><span style="color: #000088;">$proxyip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;hostHack=true&amp;hostHackIP=&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$goto</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'hostHack'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">true</span>;
<span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'hostHackIP'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$proxyip</span>;
<span style="color: #009900;">&#125;</span>
<a href="http://www.php.net/session_name"><span style="color: #990000;">session_name</span></a><span style="color: #009900;">&#40;</span><span style="">'s'</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/session_start"><span style="color: #990000;">session_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$_SESSION</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="">'hostHack'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'hostHack'</span><span style="color: #009900;">&#93;</span>;
<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="">'hostHackIP'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'hostHackIP'</span><span style="color: #009900;">&#93;</span>;
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="">'goto'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$proxyip</span><span style="color: #339933;">!=</span><span style="">''</span><span style="color: #009900;">&#41;</span>
<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: $url&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre>
<p>4. in includes/settings.php add (after stripObjects):</p>
<pre class="php php" style="font-family:monospace;"><span style="">'hostHack'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="">'Host Hack'</span><span style="color: #339933;">,</span>
                        <span style="">'default'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">,</span>
                        <span style="">'desc'</span> <span style="color: #339933;">=&gt;</span> <span style="">'use a proxy IP for the host name'</span><span style="color: #009900;">&#41;</span></pre>
<p>5. in themes/default/main.php add this javascript code:</p>
<pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> xmlHttp <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span>;
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> updateLocationFirst<span style="color: #009900;">&#40;</span>pointer<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
hostHack<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hostHack'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">checked</span>;
hostHackIP<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hostHackIP'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span>;
xmlHttp <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
url<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://YOURURLHERE/hosthack.php?hostHack=&quot;</span><span style="color: #339933;">+</span>hostHack<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&amp;hostHackIP=&quot;</span><span style="color: #339933;">+</span>hostHackIP;
xmlHttp.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span> url<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span>;
xmlHttp.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000066; font-weight: bold;">return</span> updateLocation<span style="color: #009900;">&#40;</span>pointer<span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre>
<p>6. in that same file, modify the onsubmit to be:<br />
<code><br />
return updateLocationFirst(this);<br />
</code><br />
7. in that same file, right after foreach ( $toShow as $option ), add:</p>
<pre class="php php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$option</span><span style="color: #009900;">&#91;</span><span style="">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="">'hostHack'</span><span style="color: #009900;">&#41;</span> <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;input name=hostHackIP type=text id=<span style="color: #000099; font-weight: bold;">\&quot;</span>hostHackIP<span style="color: #000099; font-weight: bold;">\&quot;</span>/&gt;&quot;</span><span style="color: #009900;">&#41;</span>;</pre>
<p>8. oh, and in browse, right before curl_setopt_array, add:</p>
<pre class="php php" style="font-family:monospace;"><span style="color: #000088;">$port</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;80&quot;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">URL</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;https&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!==</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$port</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;443&quot;</span>;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="">'hostHack'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&amp;&amp;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="">'hostHackIP'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">curlOptions</span><span style="color: #009900;">&#91;</span>CURLOPT_PROXY<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="">'hostHackIP'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;:$port&quot;</span>;
<span style="color: #009900;">&#125;</span></pre>
<p>And there you have it. Now the options box will present a hosthack option (what some call the process of overriding DNS by adding a line to /etc/hosts, or in our case, using the proxy method of php&#8217;s curl) alongside a box for an IP. If you want to send a hosthacked proxed link, simply postfix &#038;hostHack=true&#038;hostHackIP=THEIP to the end of your glype encoded URL</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanbyrd.net/techramble/2010/07/06/testing-disaster-recovery-virtualhosts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
