<?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>Adam Palmer, Linux, PHP Programmer, MySQL Developer, Website Security Consultant &#187; Technology</title>
	<atom:link href="http://www.adamsinfo.com/category/technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adamsinfo.com</link>
	<description>Adam Palmer MBCS CITP, Linux, PHP Programmer, MySQL Developer, Website Security Consultant</description>
	<lastBuildDate>Mon, 26 Jul 2010 22:16:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ethernet over mains power lines</title>
		<link>http://www.adamsinfo.com/ethernet-over-mains-power-lines/</link>
		<comments>http://www.adamsinfo.com/ethernet-over-mains-power-lines/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 22:14:36 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Internetworking & Routing]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[devolo]]></category>
		<category><![CDATA[ethernet]]></category>
		<category><![CDATA[LAN]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=951</guid>
		<description><![CDATA[I&#8217;ve been using a really clever device for the last few years that a lot of people seem to be unaware exists. It&#8217;s an ethernet over powerlines adapter &#8211; one such example is the Devolo dLAN. In a nutshell, you plug it into the mains, and connect the Ethernet socket to your network device. You [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using a really clever device for the last few years that a lot of people seem to be unaware exists. It&#8217;s an ethernet over powerlines adapter &#8211; one such example is the Devolo dLAN. In a nutshell, you plug it into the mains, and connect the Ethernet socket to your network device. You can then plug as many others as you like to various other powerpoints and extend your network wherever the power stretches. Devolo do ones that run up to 200mbit. It&#8217;s a theoretical maximum, although I&#8217;ve got 177mbit before which is impressive. It has a couple of downsides:</p>
<p>1. It won&#8217;t traverse 3 phase power. I&#8217;ve tried it, and I&#8217;ve ended up with a very weak/nonexistant signal which is probably more inductance than anything else.<br />
2. Obviously it doesn&#8217;t handle bad cables well &#8211; it doesn&#8217;t much like extension cables either.<br />
3. Different circuits work about as well as 3 phase power, the only signal you will get is probably inductance between the two circuits.</p>
<p>Some advantages:<br />
1. It travels pretty far. I&#8217;ve had over 150mbit between adapters at opposite ends of the house.<br />
2. No new cabling<br />
3. Fully supports standard Ethernet so all network protocols will work just fine over it.<br />
4. I love it</p>
<p>For anyone running a home or office network and not fortunate to have Ethernet points cabled in, I strongly recommend these devices, you&#8217;ll never know the difference.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/ethernet-over-mains-power-lines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirecting all HTML files to PHP files</title>
		<link>http://www.adamsinfo.com/redirecting-all-html-files-to-php-files/</link>
		<comments>http://www.adamsinfo.com/redirecting-all-html-files-to-php-files/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 22:03:50 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php programmer]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[rewritecond]]></category>
		<category><![CDATA[rewriteengine]]></category>
		<category><![CDATA[rewriterule]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=1048</guid>
		<description><![CDATA[Let&#8217;s say that you want to rename all your HTML files to PHP files to begin PHP Programming. However, you don&#8217;t want to lose all your inbound links to your HTML files. Here&#8217;s a quick and easy way to automatically convert all .html incoming addresses to .php files on your server, allowing you to switch [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say that you want to rename all your HTML files to PHP files to begin PHP Programming. However, you don&#8217;t want to lose all your inbound links to your HTML files. Here&#8217;s a quick and easy way to automatically convert all .html incoming addresses to .php files on your server, allowing you to switch to PHP and also keeping all your existing .html links working.</p>
<p>Create a .htaccess file, and enter:</p>
<p>RewriteEngine on<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteRule ^(.*)\.html $1.php [R=301,NC]</p>
<p>This creates a permanent working 301 redirect (Search Engine Friendly) to your new .PHP file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/redirecting-all-html-files-to-php-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing PHP variable data through POST</title>
		<link>http://www.adamsinfo.com/passing-php-variable-data-through-post/</link>
		<comments>http://www.adamsinfo.com/passing-php-variable-data-through-post/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 22:31:32 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[php programmer]]></category>
		<category><![CDATA[php variable]]></category>
		<category><![CDATA[post data]]></category>
		<category><![CDATA[serialize]]></category>
		<category><![CDATA[unserialize]]></category>
		<category><![CDATA[urlrawencode]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=1043</guid>
		<description><![CDATA[Recently, I was developing an API for a PHP application I&#8217;d built, to be utilized by other php programmers. Essentially, the php programmer passes a load of data to our API though a POST variable. This is as follows:
$api-&#62;process($to_process, $data, $opt1, $opt2);
$to_process is an array, as follows;
$to_process = Array( Array(&#8221;FOO&#8221;, &#8220;BAR&#8221;, 1, 2), Array(&#8221;BAR&#8221;, &#8220;FOO&#8221;, [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I was developing an API for a PHP application I&#8217;d built, to be utilized by other php programmers. Essentially, the php programmer passes a load of data to our API though a POST variable. This is as follows:</p>
<p>$api-&gt;process($to_process, $data, $opt1, $opt2);</p>
<p>$to_process is an array, as follows;</p>
<p>$to_process = Array( Array(&#8221;FOO&#8221;, &#8220;BAR&#8221;, 1, 2), Array(&#8221;BAR&#8221;, &#8220;FOO&#8221;, 5, 3), Array(&#8221;HELLO&#8221;, &#8220;World&#8221;, 9, 10) );</p>
<p>And $data is a ~5k string containing HTML code.</p>
<p>My best option so far, has been $data_array = Array(); $data_array[] = $to_process; $data_array[] = $code; $data_array[] = $opt1; $data_array[] = $opt2;</p>
<p>We can then send urlrawencode(serialize($data_array)); from our PHP script to the web API via curl through POST data. On the remote API server, we don&#8217;t need to use urlrawdecode() as the web server handles this for you. It&#8217;s also worth ensuring that magic_quotes_gpc is off. Simply, $data_array = unserialize($_POST['variable']); should do just fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/passing-php-variable-data-through-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSL increases confidence</title>
		<link>http://www.adamsinfo.com/ssl-increases-confidence/</link>
		<comments>http://www.adamsinfo.com/ssl-increases-confidence/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 21:25:58 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security Consultant]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[commerce]]></category>
		<category><![CDATA[purchases]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=1033</guid>
		<description><![CDATA[If you run a commerce website, you&#8217;ve probably heard about SSL certificates.  Depending upon the level of certificate that you have, they verify the validity of your domain, up to detailed information about your company.  An SSL certificate isn&#8217;t handy just for commerce sites, however.  It&#8217;s a vital website security component for [...]]]></description>
			<content:encoded><![CDATA[<p>If you run a commerce website, you&#8217;ve probably heard about SSL certificates.  Depending upon the level of certificate that you have, they verify the validity of your domain, up to detailed information about your company.  An SSL certificate isn&#8217;t handy just for commerce sites, however.  It&#8217;s a vital website security component for any site that deals with personal information of any sort.</p>
<p>These days, attacks on severs are commonplace, and website users are wary, especially when it comes to entering sensitive information.  That&#8217;s where an SSL certificate comes in handy.  It increases consumer confidence, and confidence of visitors in general.  It shows that you&#8217;re serious about what you&#8217;re doing.<br />
<span id="more-1033"></span><br />
An SSL certificate is really a must if you plan to accept any sort of sensitive data, including passwords, personal information, or payment credentials.  While it&#8217;s not a must to have an SSL certificate if you only have a message board on your site, you would be well advised to purchase one if you collect any sort of personal information, including real names and addresses.</p>
<p>An SSL certificate is really mandatory if you run a commerce website.  Credit card companies require this, and there are very few customers who are willing to enter payment or personal information without the blue or green bar, or the lock logo, depending upon the browser.</p>
<p>It&#8217;s quite easy to install an SSL certificate if you have a control panel of any sort, but the process is a little bit more involved if you do it in your SSH shell.  You will first need to enable the mod_ssl module in Apache.  It&#8217;s included in the default installation, but it is not enabled as a default.  The module requires the OpenSSL library.</p>
<p>As you can see, it&#8217;s a very involved process to install an SSL certificate if you don&#8217;t have a control panel.  It&#8217;s important that it be installed correctly, because there&#8217;s a certain chain to follow, and if link in the chain is broken, your certificate won&#8217;t validate, and even worse, your users could get an error message warning them about potential safety issues, which is not something that any webmaster wants.</p>
<p>If you are not comfortable with doing the process manually, have someone help you.  Even if you must pay for their services, it&#8217;s money well spent, because the increased sales or usage your site will get as a result will be the return on investment.</p>
<p>Sadly, an SSL certificate is something that many well-meaning webmasters or merchants neglect to get, and apart from violating the terms of the credit card companies&#8217; merchant agreements, it&#8217;s simply not good for business.</p>
<p>It would be well advised to use the https:// protocol for any section of your website that accepts a password, personal information, or payment information.  Doing so will make the experience far more pleasant for both yourself and your users or customers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/ssl-increases-confidence/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross Site Scripting XSS</title>
		<link>http://www.adamsinfo.com/cross-site-scripting-xss/</link>
		<comments>http://www.adamsinfo.com/cross-site-scripting-xss/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 17:59:38 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[cross site scripting]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[htmlentitie]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[strip_tags]]></category>
		<category><![CDATA[website security consultant]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=997</guid>
		<description><![CDATA[As a website security consultant, Cross Site Scripting or XSS vulnerabilities are something that I see just as often as the always popular SQL Injection attack.
Cross Site Scripting seems to have originally meant, placing some malicious code on your victim site, that would pull code (usually javascript, but sometimes vbscript) from another malicious domain. Each [...]]]></description>
			<content:encoded><![CDATA[<p>As a <a href="/website-security-consultant/">website security consultant</a>, Cross Site Scripting or XSS vulnerabilities are something that I see just as often as the always popular SQL Injection attack.</p>
<p>Cross Site Scripting seems to have originally meant, placing some malicious code on your victim site, that would pull code (usually javascript, but sometimes vbscript) from another malicious domain. Each client that visited the victim site, would end up unknowingly having 3rd party malicious script code executed on his own browser. Now, it has become a term used to describe any type of malicious scripting attack.</p>
<p>The first example is a simple one. Many sites allow user comments. A user could quite easily enter:<br />
This is my comment!&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
alert(&#8221;script!&#8221;);<br />
&lt;/script&gt;</p>
<p>Any user that hits this affected page, will now see a popup box with the text &#8220;script!&#8221;. The user could also just as easily have entered a script source of http://www.nastydomain.com/nastyscript.js which will be downloaded and executed.</p>
<p>The second option is to place some javascript code that steals the user&#8217;s cookies for that particular site, and then post them to a 3rd party site. His cookies may contain a login and password, or more likely a login hash. The attacker can then use these cookies to hijack the user&#8217;s session, and access possible sensitive areas of a site under that user&#8217;s account, as that hijacked user.</p>
<p>Fortunately the solution is simple. Either use htmlentities() to &#8216;escape&#8217; HTML entities, i.e. converting &lt;&#8217;s to &amp;lt; etc. Or, use strip_tags, to remove all HTML tag input.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/cross-site-scripting-xss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; Find Duplicates Only</title>
		<link>http://www.adamsinfo.com/mysql-find-duplicates-only/</link>
		<comments>http://www.adamsinfo.com/mysql-find-duplicates-only/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 18:12:21 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[distinct]]></category>
		<category><![CDATA[duplicate]]></category>
		<category><![CDATA[having]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[unique]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=989</guid>
		<description><![CDATA[Within MySQL, we may want to select duplicate records, instead of just selecting unique records. Assuming a table name of &#8216;table&#8217; and the field to check on being &#8216;field&#8217;;
To select UNIQUE rows only:
SELECT DISTINCT field FROM table;
To select DUPLICATE rows only:
SELECT field FROM table GROUP BY field HAVING ( COUNT(field) = 2 )
To select DUPLICATE, [...]]]></description>
			<content:encoded><![CDATA[<p>Within MySQL, we may want to select duplicate records, instead of just selecting unique records. Assuming a table name of &#8216;table&#8217; and the field to check on being &#8216;field&#8217;;</p>
<p>To select UNIQUE rows only:<br />
SELECT DISTINCT field FROM table;</p>
<p>To select DUPLICATE rows only:<br />
SELECT field FROM table GROUP BY field HAVING ( COUNT(field) = 2 )</p>
<p>To select DUPLICATE, TRIPLICATE or more rows only:<br />
SELECT field FROM table GROUP BY field HAVING ( COUNT(field) > 1 )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/mysql-find-duplicates-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP, MySQL and memcached</title>
		<link>http://www.adamsinfo.com/php-mysql-and-memcached/</link>
		<comments>http://www.adamsinfo.com/php-mysql-and-memcached/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 17:55:41 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=956</guid>
		<description><![CDATA[According to memcached is a distributed object memory caching system. It can be used to set and get data by keys by any application that supports sockets.
As a website security consultant I advise you to ensure that your memcache server runs on 127.0.0.1 only and that you secure your server. Anyone with access to the [...]]]></description>
			<content:encoded><![CDATA[<p>According to memcached is a distributed object memory caching system. It can be used to set and get data by keys by any application that supports sockets.</p>
<p>As a <a href="http://www.adamsinfo.com/website-security-consultant">website security consultant</a> I advise you to ensure that your memcache server runs on 127.0.0.1 only and that you secure your server. Anyone with access to the server can telnet to the server&#8217;s local interface and get/set your memcache data. </p>
<p>I&#8217;ve used memcached for a number of PHP/MySQL projects, where I want greater cache control on database queries, than just relying on MySQL&#8217;s inbuilt caching abilities.</p>
<p>Now, whilst memcached should not be used to mask bad database design and optimization, or badly written SQL queries, it can help dramatically with queries that simply take a long time and have already been optimized as far as possible.</p>
<p>Assume that you had a simple database query wrapper:<br />
<span id="more-956"></span><br />
function db_getrows($query)<br />
{</p>
<p style="padding-left: 30px;">$rows = Array();<br />
$resource = mysql_query($query);<br />
while ($rows[] = mysql_fetch_object($resource))<br />
{</p>
<p style="padding-left: 60px;">//do nothing</p>
<p style="padding-left: 30px;">}<br />
return $rows;</p>
<p>}</p>
<p>If you have no idea what queries are going to get passed to this, but simply want to cache all SELECT output, then modify as follows:</p>
<p>function db_getrows($query)<br />
{</p>
<p style="padding-left: 30px;">$rows = Array();<br />
//Get the MD5 hash of the query, which we can use to identify it:<br />
$hash = md5($query);<br />
$memcache_obj = memcache_connect(&#8221;localhost&#8221;, 11211); //connect to memcached<br />
$mem_get = memcache_get($memcache_obj, $hash); //If we had this query key stored in memcache, $mem_get will now contain the data, otherwise, it will be empty.</p>
<p style="padding-left: 30px;">if (empty($mem_get))<br />
{</p>
<p style="padding-left: 60px;">$resource = mysql_query($query);<br />
while ($rows[] = mysql_fetch_object($resource))<br />
{</p>
<p style="padding-left: 90px;">//do nothing</p>
<p style="padding-left: 60px;">}<br />
memcache_add($memcache_obj, $hash, serialize($rows), false, (60*60)); //add it to memcache for next time, have it expire in 1 hour (60*60 seconds)</p>
<p style="padding-left: 30px;">} else {</p>
<p style="padding-left: 60px;">$rows = unserialize($mem_get);</p>
<p style="padding-left: 30px;">}<br />
return $rows;</p>
<p>}</p>
<p>What will happen now, is that when a query is provided, we take the <a href="http://www.adamsinfo.com/creating-an-md5-on-linux-with-md5sum/">MD5 sum</a> of that query. We then check to see if we have that query response in memcache already. If so, great, unserialize it and return it. If not, run the query, get the data, and add it to memcache with an expiry time of 1 hour.</p>
<p>Any queries to memcache will of course bypass the database alltogether therefore alleviating the load. Your only consideration is what to cache and the expiry time. If you cache the output of a SELECT query on say, the number of posts on your forum, it may not just keep that out of date for an hour, but could infact cause erroneous data to be inserted by your forum into your database. In that case, you can take a look through the code and find any instances where your forum post count may be updated, and add memcache_delete($memcache_obj, &#8216;key_to_delete&#8217;, 10); which will automatically delete &#8216;key_to_delete&#8217; after 10 seconds.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/php-mysql-and-memcached/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Passing Variables By Reference and By Value</title>
		<link>http://www.adamsinfo.com/php-passing-variables-by-reference-and-by-value/</link>
		<comments>http://www.adamsinfo.com/php-passing-variables-by-reference-and-by-value/#comments</comments>
		<pubDate>Wed, 19 May 2010 16:08:02 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[by reference]]></category>
		<category><![CDATA[by value]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=979</guid>
		<description><![CDATA[By default in PHP, variables are passed around &#8216;by value&#8217;. i.e.
&#60;?php
function increment($i)
{
$i++;
return $i;
}
$a = 10;
$b = increment($a);
?&#62;
At this point, $a remains as 10, however $b is now 11. $b = increment(10); works just the same, and you can assign 10 back to the original variable with: $a = 10; $a = increment($a); This is called [...]]]></description>
			<content:encoded><![CDATA[<p>By default in PHP, variables are passed around &#8216;by value&#8217;. i.e.</p>
<p>&lt;?php<br />
function increment($i)<br />
{<br />
$i++;<br />
return $i;<br />
}</p>
<p>$a = 10;<br />
$b = increment($a);<br />
?&gt;</p>
<p>At this point, $a remains as 10, however $b is now 11. $b = increment(10); works just the same, and you can assign 10 back to the original variable with: $a = 10; $a = increment($a); This is called passing variables <strong>by value</strong>. i.e. I am passing the VALUE of $a to the increment() function.</p>
<p>We also have the option of passing variables by reference. For programmers that have worked with C before, this is a &#8216;pointer&#8217;.</p>
<p>&lt;?php<br />
function increment(&amp;$i)<br />
{<br />
$i++;<br />
return $i;<br />
}</p>
<p>$a = 10;<br />
increment($a);<br />
echo &#8220;a has now become: &#8221; . $a;<br />
?&gt;</p>
<p>In the case above, I am passing $a<strong> by reference</strong>.  i.e. the increment() function is operating on the variable $a rather than the value of the variable. Certain things that shouldn&#8217;t work get fixed by PHP, i.e. increment(&amp;$a). By the time the increment() function gets to it, it is actually passing the reference to the reference to the variable. Certain other things will fail entirely, i.e. increment(10); will give &#8220;Fatal error: Only variables can be passed by reference&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/php-passing-variables-by-reference-and-by-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Programmer &#8211; Remove characters from the end of a string</title>
		<link>http://www.adamsinfo.com/php-programmer-remove-characters-from-the-end-of-a-string/</link>
		<comments>http://www.adamsinfo.com/php-programmer-remove-characters-from-the-end-of-a-string/#comments</comments>
		<pubDate>Mon, 17 May 2010 23:36:49 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php programmer]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[strlen]]></category>
		<category><![CDATA[substr]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=975</guid>
		<description><![CDATA[&#60;?php
$s = &#8220;This is my string&#8221;;
$s = substr($s, 0, strlen($s)-2);
?&#62;
This trims 2 characters from $s, resulting in &#8220;This is my stri&#8221;;
]]></description>
			<content:encoded><![CDATA[<p>&lt;?php<br />
$s = &#8220;This is my string&#8221;;<br />
$s = substr($s, 0, strlen($s)-2);<br />
?&gt;</p>
<p>This trims 2 characters from $s, resulting in &#8220;This is my stri&#8221;;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/php-programmer-remove-characters-from-the-end-of-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Checking for Array Keys</title>
		<link>http://www.adamsinfo.com/php-checking-for-array-keys/</link>
		<comments>http://www.adamsinfo.com/php-checking-for-array-keys/#comments</comments>
		<pubDate>Thu, 13 May 2010 23:30:28 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[array_key_exists]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php programmer]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=972</guid>
		<description><![CDATA[As a PHP Programmer, I recently came up against an error while testing another developer&#8217;s code.. Within PHP, testing for the existance of the referring URL:
if (empty($_SERVER['HTTP_REFERER'])) will produce a notice:
Undefined index: HTTP_REFERER
The correct way to check for the existence of an array key is: if (array_key_exists(&#8221;HTTP_REFERER&#8221;, $_SERVER))


]]></description>
			<content:encoded><![CDATA[<p>As a PHP Programmer, I recently came up against an error while testing another developer&#8217;s code.. Within PHP, testing for the existance of the referring URL:</p>
<p><strong>if (empty($_SERVER['HTTP_REFERER'])) </strong>will produce a notice:<br />
Undefined index: HTTP_REFERER</p>
<p>The correct way to check for the existence of an array key is: <strong>if (array_key_exists(&#8221;HTTP_REFERER&#8221;, $_SERVER))</strong></p>
<p><strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/php-checking-for-array-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable recursion (public DNS) with Bind</title>
		<link>http://www.adamsinfo.com/disable-recursion-public-dns-with-bind/</link>
		<comments>http://www.adamsinfo.com/disable-recursion-public-dns-with-bind/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 23:34:03 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[named]]></category>
		<category><![CDATA[recursion]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=970</guid>
		<description><![CDATA[I&#8217;ve just set up two new nameservers, and after only a few weeks, I&#8217;ve noticed that random IP addresses are hitting my nameservers requesting DNS records for 3rd party domains. What&#8217;s worse is that my nameservers are responding with the results.
To disable this in bind, add the following to the &#8216;options&#8217; stanza within named.conf:
allow-recursion {&#8221;none&#8221;;};
recursion [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just set up two new nameservers, and after only a few weeks, I&#8217;ve noticed that random IP addresses are hitting my nameservers requesting DNS records for 3rd party domains. What&#8217;s worse is that my nameservers are responding with the results.</p>
<p>To disable this in bind, add the following to the &#8216;options&#8217; stanza within named.conf:</p>
<p>allow-recursion {&#8221;none&#8221;;};<br />
recursion no;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/disable-recursion-public-dns-with-bind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access denied for user &#8216;debian-sys-maint&#8217;@&#039;localhost&#8217;</title>
		<link>http://www.adamsinfo.com/access-denied-for-user-debian-sys-maintlocalhost/</link>
		<comments>http://www.adamsinfo.com/access-denied-for-user-debian-sys-maintlocalhost/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 21:55:32 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=967</guid>
		<description><![CDATA[Exporting all databases from a MySQL installation on Debian using &#8211;all-databases, and then importing them back into a new installation will overwrite your privileges table. Whilst this may be what you want, each MySQL installation on debian generates a unique /etc/mysql/debian.cnf which contains logon details for the &#8216;debian-sys-maint&#8217; system account. This account is used by [...]]]></description>
			<content:encoded><![CDATA[<p>Exporting all databases from a MySQL installation on Debian using &#8211;all-databases, and then importing them back into a new installation will overwrite your privileges table. Whilst this may be what you want, each MySQL installation on debian generates a unique /etc/mysql/debian.cnf which contains logon details for the &#8216;debian-sys-maint&#8217; system account. This account is used by the custom Debian scripts to deal with things such as checking for crashed tables.</p>
<p>After your export and import, you will likely end up with an error on your new installation:</p>
<p>&#8216;Access denied for user &#8216;debian-sys-maint&#8217;@'localhost&#8217;</p>
<p>The way to fix this, is to log in to MySQL as root, and issue:</p>
<p>GRANT ALL PRIVILEGES ON *.* TO &#8216;debian-sys-maint&#8217;@'localhost&#8217; IDENTIFIED  BY &#8216;xxxxx&#8217; WITH GRANT OPTION</p>
<p>Where &#8216;xxxxx&#8217; is the password found in your debian.cnf file.</p>
<p>Then issue: FLUSH PRIVILEGES; and restart MySQL</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/access-denied-for-user-debian-sys-maintlocalhost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Timing operations in PHP with microtime</title>
		<link>http://www.adamsinfo.com/timing-in-php-with-microtime/</link>
		<comments>http://www.adamsinfo.com/timing-in-php-with-microtime/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 16:34:29 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[epoch]]></category>
		<category><![CDATA[microtime]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=965</guid>
		<description><![CDATA[Within PHP, we have a function called microtime(bool $float).
When microtime() is called without any arguments it will return a string in the form of &#8220;microseconds seconds&#8221; i.e. &#8220;0.70801200 1271088014&#8243; which is the number of seconds and microseconds since the Unix Epoch (0:00:00 January 1, 1970 GMT).
When microtime is called with a &#8216;1&#8242;, i.e. &#60;? echo [...]]]></description>
			<content:encoded><![CDATA[<p>Within PHP, we have a function called <strong>microtime(bool $float)</strong>.</p>
<p>When microtime() is called without any arguments it will return a string in the form of &#8220;microseconds seconds&#8221; i.e. &#8220;0.70801200 1271088014&#8243; which is the number of seconds and microseconds since the Unix Epoch (0:00:00 January 1, 1970 GMT).</p>
<p>When microtime is called with a &#8216;1&#8242;, i.e. <strong>&lt;? echo microtime(1); ?&gt;</strong> it will return the number of microseconds alone which is going to be more useful for what we want to achieve, i.e. &#8220;1271088173.97&#8243;</p>
<p>So using this, we can now write a script that we want to time, for example:</p>
<p><strong>&lt;?php<br />
echo &#8220;Script Starting\n&#8221;;<br />
$start_time = microtime(1);<br />
for ($i = 0; $i &lt; 10000000; $i++)<br />
{<br />
//perform some calculation<br />
$n = $i%247;<br />
}<br />
$end_time = microtime(1);<br />
echo &#8220;Our script took: &#8221; . ($end_time &#8211; $start_time) . &#8221; to run\n&#8221;;<br />
?&gt;</strong></p>
<p>The output of this script is:</p>
<p>adam@vm1-webserver01:/tmp$ php ./t.php<br />
Script Starting<br />
Our script took: 1.45122814178 to run</p>
<p>Now you can add a $start_time = microtime(1); to the top of any script that you have, and a $end_time = microtime(1); echo $end_time-$start_time; to the end of any script that you have to time it, or alternatively just time certain portions to see where you can optimize things.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/timing-in-php-with-microtime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Communicating with the Twitter API via curl</title>
		<link>http://www.adamsinfo.com/communicating-with-the-twitter-api-via-curl/</link>
		<comments>http://www.adamsinfo.com/communicating-with-the-twitter-api-via-curl/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 18:35:01 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=958</guid>
		<description><![CDATA[Twitter provides an extensive API that allows developers to write interactive applications. Utilizing this API is deceptively simple, and here is an example with curl:
curl -u username:password http://api.twitter.com/1/statuses/friends_timeline.xml
Which will get the statuses of all your friends. You can of course use PHP&#8217;s curl library just as easily as the command line, and my next post [...]]]></description>
			<content:encoded><![CDATA[<p>Twitter provides an extensive API that allows developers to write interactive applications. Utilizing this API is deceptively simple, and here is an example with curl:</p>
<p>curl -u username:password http://api.twitter.com/1/statuses/friends_timeline.xml</p>
<p>Which will get the statuses of all your friends. You can of course use PHP&#8217;s curl library just as easily as the command line, and my next post will focus on using php5-curl</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/communicating-with-the-twitter-api-via-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UDP Tunneling to avoid hotspot or firewall restrictions</title>
		<link>http://www.adamsinfo.com/udp-tunneling-to-avoid-hotspot-or-firewall-restrictions/</link>
		<comments>http://www.adamsinfo.com/udp-tunneling-to-avoid-hotspot-or-firewall-restrictions/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 22:16:44 +0000</pubDate>
		<dc:creator>Adam Palmer</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security Consultant]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[53]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[hotspot]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[openvpn]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[transparent proxying]]></category>
		<category><![CDATA[udp]]></category>
		<category><![CDATA[udp tunneling]]></category>

		<guid isPermaLink="false">http://www.adamsinfo.com/?p=946</guid>
		<description><![CDATA[UDP tunneling is an attack that is often overlooked when manufacturers design wireless hotspot and other firewall/proxy based devices.
When you try and resolve a domain name, you make a request to a name server on UDP port 53. The way that a lot of wireless hotspot, firewalls and proxies work, is that your DNS request [...]]]></description>
			<content:encoded><![CDATA[<p>UDP tunneling is an attack that is often overlooked when manufacturers design wireless hotspot and other firewall/proxy based devices.</p>
<p>When you try and resolve a domain name, you make a request to a name server on UDP port 53. The way that a lot of wireless hotspot, firewalls and proxies work, is that your DNS request is allowed out, you get the IP for the machine you&#8217;re looking for, and then your request to the IP is redirected to the wireless hotspot login page, or through a web proxy server.</p>
<p>The problem is, that all port 53 UDP traffic is allowed out to anywhere, without any kind of authentication. You can therefore install <a href="http://www.adamsinfo.com/quick-linux-and-windows-openvpn-howto-and-tutorial-including-vpn-routing/">OpenVPN</a> on a remote server which by default listens in on UDP port 1194. You can change this with one configuration option to 53, and then edit your client config to connect to the server on port 53 instead. Often, other TCP/UDP ports might be allowed out, and ICMP is also sometimes a possibility. It is possible to easily tunnel your data out over TCP, UDP or ICMP as a worst case.</p>
<p>This type of attack worked on 5 out of 6 different wireless hotspot systems to gain access without authentication.</p>
<p>The one that it didn&#8217;t work on, captured all outbound 53 UDP requests, and silently redirected them to it&#8217;s own local DNS server. This is simple enough to do, so I&#8217;m not sure why more manufacturers haven&#8217;t done the same. Using iptables:</p>
<p>${IPTABLES} -t nat -A PREROUTING -i eth0 -p udp -m udp &#8211;dport 53 -j REDIRECT &#8211;to-port 53</p>
<p>These are the same type of rules used to configure <a href="http://www.adamsinfo.com/linux-squid-transparent-proxy/">transparent proxying for Squid</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adamsinfo.com/udp-tunneling-to-avoid-hotspot-or-firewall-restrictions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
