<?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>var/log</title>
	<atom:link href="http://www.varslashlog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.varslashlog.com</link>
	<description>Yet another weblog</description>
	<lastBuildDate>Sat, 12 Sep 2009 13:34:27 +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>How to stop spam without captcha or javascript</title>
		<link>http://www.varslashlog.com/2009/06/03/how-to-stop-spam-without-pictures-or-javascript/</link>
		<comments>http://www.varslashlog.com/2009/06/03/how-to-stop-spam-without-pictures-or-javascript/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 00:15:46 +0000</pubDate>
		<dc:creator>AHSauge</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Antispam]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[Header]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[picture]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[spambot]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=169</guid>
		<description><![CDATA[This time I&#8217;m going to put up a really bold statement. I believe it&#8217;s currently possible to fight spam on the web without pictures, javascript or anything else that might compromise usability. Sounds quite impossible and too good to be true, right? Well, it might not be that far fetched as it seems. Please read [...]]]></description>
			<content:encoded><![CDATA[<p>This time I&#8217;m going to put up a really bold statement. I believe it&#8217;s currently possible to fight spam on the web without pictures, javascript or anything else that might compromise usability. Sounds quite impossible and too good to be true, right? Well, it might not be that far fetched as it seems. Please read on and I&#8217;ll explain why.<span id="more-169"></span></p>
<p>We&#8217;ve all seen it, <a title="Article on wikipedia about captcha" href="http://en.wikipedia.org/wiki/Captcha">captcha</a> or pictures that protects alot of web-forms against those nasty spam-bots while at the same time blissfully destroying the usability of the web (<a href="http://www.johnmwillis.com/other/top-10-worst-captchas/">10 &#8220;good&#8221; examples</a>). While a lot of attempts have been made to make it more usable for more people (pictures aren&#8217;t exactly user-friendly for blind people &#8230;), it still boils down to some requirements either for the browser (e.g. javascript) or the user (typing into an input field). While requiring the browser to support something isn&#8217;t that bad, requiring the user to do something definitely isn&#8217;t usability at it&#8217;s best. Wouldn&#8217;t it be nice to just instant see whether or not the current request is made from a bot or a browser? Well, you might be able &#8230;</p>
<p>For the last two weeks I&#8217;ve created my personal pet project logging spam attempts in some scripts running at <a href="http://www.ascdevel.com">Ascended Development</a>. After more than 300 attempts and above 100 unique spam-bots (or IPs anyway), the results shock me &#8230; a lot. The spam-bots that has visited the site is incredible stupid. In simplest terms they don&#8217;t even seem to be able to handle cookies (e.g. thereby also session in PHP), little less the pictures or javascript. The most ridiculous thing is that they actually do send data in the antispam input field. The problem is that it&#8217;s 2 to 4 times longer than the number of characters in the picture, and yes, it didn&#8217;t supply the cookie for the session meaning it wouldn&#8217;t succeed even if the wild guess was right.</p>
<p>So what can we do without requiring user input or javascript? Certainly not add a hidden input field in the form and hope that the bot add something to it. All bots (yeah, actually every single one of them) either provide the default value or didn&#8217;t provide the field at all. Actually out of the 300 attempts only 50 didn&#8217;t provide the field, and a massive 250 attempts had the default value. None tried any other values, and it seems that those that didn&#8217;t provide the field tried again with the default value. Simply put, a hidden field don&#8217;t work, at least not on those bots visiting our site at the logged locations.</p>
<p>So here&#8217;s the trick: Simply read the HTTP-headers. Has to be too good to be true? Well, the log is equally clear on this matter too. None of the bots provided the fields Accept-Language and Accept-Encoding, both of which quite frankly any decent browser sends out these days (Opera, Firefox, Konqueror, Chrome, Safari and even IE). Even lynx, a text browser, does send these headers, and I tested it with a two year old release. It does make sense if you think about it. The browsers will add the Accept-Language so pages can be correctly localized and Accept-Encoding so that compression can be used. Both things is benefitial to the user, and therefor present despite both being optional. The spambots on the other hand seem to be using libaries like libcurl to build their HTTP-client, and by default these libraries don&#8217;t seem add Accept-Language or Accept-Encoding. Add the fact that few, if any, sort spam-bots from browsers this way, and we can see that it&#8217;s not really such a surprise after all.</p>
<p>This isn&#8217;t without it&#8217;s flaws though. I&#8217;ve only encountered simple, general spam-bots and not the ones attacking widespread software like phpBB or vBulletin. Also, the site isn&#8217;t subject to targeted attacks. That been said, I wouldn&#8217;t be surprised if they too fail to provide these HTTP-headers, and for the time being I&#8217;m quite confident that this method is about as efficient, or better, than the current widespread method of using pictures. It should also continue to be that way until this type of checking is more widely used. So until then, I believe this is a good way to avoid spam in you web applications:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_ACCEPT_ENCODING'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">||</span>
    <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_ACCEPT_LANGUAGE'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Spambot'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Browser'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>If only this was working against email spam too &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2009/06/03/how-to-stop-spam-without-pictures-or-javascript/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to use Unicode/UTF-8 in PHP properly (part 1)</title>
		<link>http://www.varslashlog.com/2009/02/09/how-to-use-unicodeutf-8-in-php-properly-part-1/</link>
		<comments>http://www.varslashlog.com/2009/02/09/how-to-use-unicodeutf-8-in-php-properly-part-1/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 01:45:13 +0000</pubDate>
		<dc:creator>AHSauge</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[iconv]]></category>
		<category><![CDATA[mbstring]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Unicode]]></category>
		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=119</guid>
		<description><![CDATA[I&#8217;ve previous been writing about why PHP and Unicode/UTF-8 is a bad combination. Even though UTF-8 in PHP should (for now) be avoided, it is sometimes a necessity to use it. As UTF-8 can be quite problematic for some people to use, I thought I this time should write about how to actually use it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve <a title="Why PHP and Unicode/UTF-8 is a bad combination" href="http://www.varslashlog.com/2008/10/27/why-php-and-unicode-is-a-bad-combination/">previous</a> been writing about why PHP and Unicode/UTF-8 is a bad combination. Even though UTF-8 in PHP should (for now) be avoided, it <em>is</em> sometimes a necessity to use it. As UTF-8 can be quite problematic for some people to use, I thought I this time should write about how to actually use it properly. In this first part I&#8217;ll deal with the basic handling of UTF-8 in PHP using the PHP extensions mbstring and/or iconv.</p>
<p><span id="more-119"></span></p>
<h4>The basic facts</h4>
<p>The key element when using a multibyte character set in PHP is to know exactly what you&#8217;re doing. If you don&#8217;t, you can easily end up with partially corrupted text and wrong results. The one big reason for this is the fact that PHP by default does not support anything other than byte-sized character set. In fact, strictly speaking, PHP doesn&#8217;t really know what a character set is. All it sees are bytes, not characters. This means that every string-function in PHP works on the assumption that a byte is a character. When dealing with for instance UTF-8 this is no longer true. The result is that strlen reports the number of bytes in the string, not the number of characters. Similarly, strpos will give you the position in bytes, not characters, and many of the other string-functions have similar problems. So what to do?</p>
<p>First off, a very handy fact about UTF-8 is it&#8217;s ASCII-compatible (7bit ASCII that is), meaning these characters are binary represented as 0xxx xxxx (where x are ASCII bits). Another handy fact about valid UTF-8 strings is that any encoded Unicode character has a unique byte sequence, meaning it can&#8217;t be confused with a part of another character. This means that if you encounter a byte 00100000 (20 hex or 32 dec) it can not be anything other than a space character, or else it&#8217;s not a valid UTF-8 string.  For those interested in how this is archived, here&#8217;s the binary representation of UTF-8 characters (skip if you&#8217;re not into that type of stuff ;o)</p>
<blockquote>
<pre>1 byte:  0xxx xxxx
2 bytes: 110x xxxx 10xx xxxx
3 bytes: 1110 xxxx 10xx xxxx 10xx xxxx
4 bytes: 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx</pre>
</blockquote>
<p>Well, enough with talk about UTF-8 in general. Here&#8217;s a step-by-step guild how to use UTF-8 in PHP.</p>
<h4>1.  Find you what you have available</h4>
<p>If you&#8217;re going to use UTF-8 in PHP you&#8217;ll first need to find you what&#8217;s available to you. Ideally you should have the PHP extension <a title="link to the PHP manual for mbstring" href="http://www.php.net/mbstring">mbstring</a> install and it should <span style="text-decoration: underline;">not</span> be set to overload str-functions. With mbstring you&#8217;ll have a set of functions that are multibyte aware. If you don&#8217;t have mbstring available, check for <a title="Link to PHP manual for iconv" href="http://www.php.net/iconv">iconv</a> (also an PHP extension). In PHP 5 and later this extension will give you some very simple functions to work with (strlen, strpos, strrpos, substr and validation). If you have neither mbstring nor iconv available at your host (I&#8217;m assuming that you&#8217;re going to run something in a hosted server), you should strongly consider change host and/or your need for Unicode/UTF-8, as you&#8217;re going to have to make some native functions that works properly on UTF-8 encoded strings. For the sake of simplicity, I&#8217;m going to assume you have mbstring or iconv installed.</p>
<h4>2. Store your files as UTF-8</h4>
<p>This should be somewhat obvious. If you&#8217;re going to use UTF-8, you should store your files as it too. The simple reason is that any strings you have stored in your scripts will be UTF-8 too, and should be outputed properly given you&#8217;ve done everything else correct.</p>
<h4>3. Define input and output as UTF-8</h4>
<p>This is quite depending on what you&#8217;re doing, but chances are that you&#8217;re dealing with the HTTP-protocol and HTML. If so you have to add the following function call before any output (if you&#8217;re not using output buffering).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-Type: text/html; charset=utf-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>and add the following to the head-part of your HTML-document</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span>Content-<span style="color: #000066;">Type</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span>&gt;</span></pre></div></div>

<p>This will state that any output is html and UTF-8. If you&#8217;re not dealing with html, just replace text/html with whatever you&#8217;re using (and proably drop the meta tag too). This should also ensure that input from most browsers is UTF-8, but to be really sure it might be a good idea to add the attribute accept-charset to any forms you might have, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">accept-charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- Input stuff here --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p>This attribute can also be used with a comma-separated list of character set your script accept. To keep it simple you should just use UTF-8 as the only accepted &#8220;character set&#8221; (strictly speaking, UTF-8 is an encoding of the Unicode character set, and not a charset by itself).</p>
<p>If you don&#8217;t have control over the input, for instance RSS feed from 3. party server, transform it to Unicode and encode to UTF-8. This can be done like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//mbstring</span>
<span style="color: #000088;">$UTF8string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_convert_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'other charset'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// or call</span>
<span style="color: #990000;">mb_internal_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// once to use UTF-8 as default and and drop last parameter like this:</span>
<span style="color: #000088;">$UTF8string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_convert_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'other charset'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//iconv</span>
<span style="color: #000088;">$UTF8string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">iconv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'other charset'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'UTF-8'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Consult the PHP manual for supported character sets.</p>
<h4>4. Validate your input</h4>
<p>I can not stress this point enough. Check that your input actually is UTF-8, or the multibyte aware functions might not work as expected. Also, if not validated, those who view or store your data might get security problems like SQL-injection (though it would be their fault it&#8217;s happening &#8230;). This can be done as follows for mbstring:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//last parameter can still be dropped as showed in last example</span>
<span style="color: #000088;">$validUTF8</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_check_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//will give true if valid, false if not</span></pre></div></div>

<p>for iconv you&#8217;ll have to go for a bit more dirty solution</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> validateUTF8_iconv<span style="color: #009900;">&#40;</span><span style="color: #000088;">$before</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$after</span> <span style="color: #339933;">=</span> <span style="color: #990000;">iconv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'UTF-8'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'UTF-8'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$before</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$before</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$after</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The reason this works is because any non-valid characters are removed or changed, and thus the strings will not be equal anymore.</p>
<h4>5. Store your data correct</h4>
<p>Now this is really a pit a lot of people fall into. Storing UTF-8 on disc is no problem, and is done just as before. Storing data in a database however, is in the case of MySQL definitely <em>not</em> as before. First of you&#8217;ll need MySQL 4.1 or later as the versions before don&#8217;t support what we&#8217;re about to do. The big problem with PHP and MySQL is that the connection is by default set to latin1, also known as ISO-8859-1, and a lot of people then actually store there data as a UTF-8-transformed ISO-8859-1. That is, MySQL thinks your input is ISO-8859-1 and then  convert it to Unicode and encode it as UTF-8. This will lead to problems when you view your data in for instance phpMyAdmin which connects to MySQL the proper way when dealing with UTF-8. The correct way to connect to MySQL is now</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$link</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql_user'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql_password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SET NAMES 'utf8' COLLATE 'utf8_general_ci'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The difference is the second line which states what charset is being used for further talk on the connection. The collate part can be dropped if you&#8217;re using the default one (utf8_general_ci). In addition to this, the table and fields should be defined with collation utf8_[something] and to save space don&#8217;t use char-fields as they will use 3x number of characters you define. Instead you should use varchar. Please also note that MySQL only supports Unicode 3.0, that is 2 byte Unicode up to code-point FFFE (<a title="Byte Order Mark" href="http://en.wikipedia.org/wiki/Byte_Order_Mark">BOM</a>) or 3 byte UTF-8. If you need any code-points above that, you&#8217;re unfortunately in for some trouble &#8230;</p>
<p>This is however only the case of MySQL. For other database systems you should check what is the default charset and how to change it. The documentation/manual of the system is a good place to start to find this type of information.</p>
<h4>6. Functions operating on UTF-8</h4>
<p>The points above should make sure that you&#8217;re using UTF-8. The last thing is that you have to remember that any str-functions might not work correctly. Try to use str-functions defined in mbstring or iconv (see documentation). Some functions do however work as expected. Strcmp does only a binary compare and still works, strcasecmp however don&#8217;t. Str_replace will also work on valid UTF-8 strings as any given character has a unique byte sequence, but the case-less version str_ireplace don&#8217;t. In general any str-function that is not case-less and don&#8217;t need to operate on the number of characters in the string, should work just fine as long as any input to the function is valid UTF-8.</p>
<p>There are also some functions that are not part of mbstring or iconv that do support UTF-8. Htmlspecialchars, htmlentities and preg_* (with u modifier) are examples of this. There are also functions that operate on a purley binary level without any regards to charset. Examples of this is the md5 and sha1 functions.</p>
<p>That concludes this part of the howto. You should now be able to use UTF-8 the right way. If you have any questions, please leave a comment and I&#8217;ll happily answer. The next part will hopefully deal with some common pitfalls and how to debug and solve them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2009/02/09/how-to-use-unicodeutf-8-in-php-properly-part-1/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Busting &#8220;echo is faster than print&#8221;</title>
		<link>http://www.varslashlog.com/2008/11/05/busting-echo-is-faster-than-print/</link>
		<comments>http://www.varslashlog.com/2008/11/05/busting-echo-is-faster-than-print/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 23:17:09 +0000</pubDate>
		<dc:creator>AHSauge</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[echo]]></category>
		<category><![CDATA[echo or print]]></category>
		<category><![CDATA[echo vs print]]></category>
		<category><![CDATA[print]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=89</guid>
		<description><![CDATA[I&#8217;ve previously been talking about premature optimization. Today I thought I should illustrate how ridicules some of the stuff is by busting &#8220;echo is faster than print&#8221;. There&#8217;s a lot of people calming that this is true (1, 2, 3, 4 and a lot of others). Now to be clear, they are somewhat right about [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve previously been talking about <a title="Premature optimization is bad" href="http://www.varslashlog.com/2008/11/01/premature-optimization-is-bad/" target="_blank">premature optimization</a>. Today I thought I should illustrate how ridicules some of the stuff is by busting &#8220;echo is faster than print&#8221;. There&#8217;s a lot of people calming that this is true (<a href="http://elliottback.com/wp/php-performance-echo-print/trackback/" target="_blank">1</a>, <a href="http://reinholdweber.com/?p=3" target="_blank">2</a>, <a href="http://www.chazzuka.com/blog/wp-trackback.php?p=163" target="_blank">3</a>, <a href="http://hmvrulz.wordpress.com/2008/09/23/20-php-optimization-tips-make-it-faster/" target="_blank">4</a> and <a title="Search result for 'echo is faster than print'" href="http://www.google.no/search?q=echo+is+faster+than+print" target="_blank">a lot of others</a>). Now to be clear, they are somewhat right about this. Echo <em>is</em> really faster than print, which it really should due to the fact that echo don&#8217;t return anything while print does. The problem and my point here however, is how much this difference really is. The answer is so tiny that you can forget actually measuring it in a real world application. There&#8217;s why:<span id="more-89"></span><br />
First off, the code I&#8217;ve been using is</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_fill</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1000000</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$end</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$end</span><span style="color: #339933;">-</span><span style="color: #000088;">$start</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">ob_end_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>and</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_fill</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$start</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1000000</span><span style="color: #339933;">;</span> <span style="color: #000088;">$j</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$end</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$end</span><span style="color: #339933;">-</span><span style="color: #000088;">$start</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">ob_end_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$res</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>As you can see I&#8217;ve tried to make this as simple as possible. I&#8217;ve used output buffer to remove the huge variables also known as browser and network (yes, they&#8217;re really a bottleneck here, trust me or try comparing firefox with lynx). Testing was done in the 64bit version of Fedora 9 (which is a linux distro) with PHP 5.2.6 on an AMD Athlon 64 X2 4600 (dual core CPU running at standard 2.4GHz).</p>
<p>Running this gives me an average of 0.333 seconds for echo and 0.346 seconds for print. Doing some calculation you&#8217;ll see that the average difference between each echo and print is 13ns or 0.000000013 seconds. Even though this is a 3.8% difference, it&#8217;s not even a millionth of a second, but 13 billionth! Hardly any difference if you ask me. I know, it&#8217;s just testing with a single, silly punctuation mark. To prevent people from going &#8220;There must be a bigger difference with a longer string!&#8221;, I ran the test with the first paragraph of lorem ipsum.</p>
<blockquote><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc luctus arcu vehicula est. Donec facilisis iaculis magna. Mauris neque dui, varius in, fermentum id, scelerisque et, massa. Nam ac velit nec odio molestie pellentesque. Nulla dolor mauris, tempus ultrices, cursus in, ultrices sollicitudin, orci. Sed at ligula. Sed id erat id nisl molestie tempus. Vestibulum nibh dolor, vulputate nec, dictum non, sollicitudin nec, nibh. Sed vitae diam eget felis dignissim tempor. Aenean vel risus. Integer consectetuer nibh. Ut eu nunc. Donec at sapien.</p>
</blockquote>
<p>This is 551 characters, which should satisfy most people. Results? 0.987 seconds for echo and 1.014 seconds for print, meaning echo is 2.6% faster. Again, hardly any difference as this is 27ns or 0.000000027 seconds. Conclusion: Myth busted! You&#8217;ll have to do a ridicules amount of outputing to make any actual difference.</p>
<p>PS: If you run this on your own computer, I would love to hear about your results (including type of CPU, OS and PHP version). Remember this though: Please bar in mind that you&#8217;ll have to disable any CPU-throttling and run it in separate files to get accurate results.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2008/11/05/busting-echo-is-faster-than-print/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Premature optimization is bad</title>
		<link>http://www.varslashlog.com/2008/11/01/premature-optimization-is-bad/</link>
		<comments>http://www.varslashlog.com/2008/11/01/premature-optimization-is-bad/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 00:45:15 +0000</pubDate>
		<dc:creator>AHSauge</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[premature optimization]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=76</guid>
		<description><![CDATA[Donald Knuth once wrote that &#8220;premature optimization is the root of all evil&#8221;. I have to agree with him on that. One thing I&#8217;ve been dying to write about is the massive amount of crappy PHP optimization tips found on the net. Two examples of such is Reinhold Weber&#8217;s 40 Tips for optimizing your php [...]]]></description>
			<content:encoded><![CDATA[<p>Donald Knuth once wrote that &#8220;premature optimization is the root of all evil&#8221;. I have to agree with him on that. One thing I&#8217;ve been dying to write about is the massive amount of crappy PHP optimization tips found on the net. Two examples of such is Reinhold Weber&#8217;s <a title="40 Tips for optimizing your php code" href="http://reinholdweber.com/?p=3" target="_blank">40 Tips for optimizing your php code</a> and chazzuka&#8217;s <a href="http://www.chazzuka.com/blog/?p=163" target="_blank">63+ best practice to optimize PHP code performances</a>. They <em>do</em> both have some good tips here and there, but in general this is just stupid tips, or more precise, premature optimization. There are reasons why such tips are bad.<span id="more-76"></span></p>
<p>First of all, most of these tips are undocumented and presented as obvious facts. This makes them hard to disprove or confirm as the reality is a bit different and more complicated than what these people tend to think. A good example of such a clam is &#8220;a foreach-loop is faster than a for-loop&#8221; or vica versa. I&#8217;ve tested this a couple of times, and though I get a consistent result in favor of for-loop, just changing the platform from Linux to Windows seems to reverse the result. This displays a major problem. Even the slightest difference in OS, software version, hardware etc. can change the results significantly. This is never mentioned by people presenting optimization &#8220;tips&#8221;.</p>
<p>Second, even though the result is correct, it&#8217;s often pointless to actually make the change because you&#8217;ll never actually save considerable amount of time. Let&#8217;s look at the first point in both my links.</p>
<blockquote><p>If a method can be static, declare it static. Speed improvement is by a factor of 4.</p></blockquote>
<p>Sounds good, doesn&#8217;t it? Speed improvements by a factor of 4! That must be significant, right? No, not necessarily. It can very well be an improvement by a factor of 4 (even though my testing seem to show about equal speed), but that&#8217;s only as significant as the time it initially takes. If one execution takes, say 1µs, saving 0.75µs isn&#8217;t that significant (µs = microsecond = 10^-6 s = 0.000001) considering the function itself might using 100µs on each execution. This is very often the case when these people present their &#8220;tips&#8221; if they&#8217;re actually correct on what&#8217;s the faster part.</p>
<p>Third, with the previous stuff in mind. Even if the clam is correct and even if there is some performance to be gained, is it worth it? Not necessarily. There are several things to keep in mind here. Primarily optimization degrades readability, and there&#8217;s also the issue of someone actually have to make these changes. Is it really that worth it if you have to spend an hour changing alot of code just to have a cumulative saving of about 1ms? I don&#8217;t think so &#8230;</p>
<p>The final nail in the coffin for these &#8220;tips&#8221; is the fact that it&#8217;s never ever tested with any load. Load is important as that&#8217;s the reality. It doesn&#8217;t matter if solution A is x times faster than solution B saving y amount of seconds, if solution A hits a bottleneck when it&#8217;s run in 10 parallel requests making it much slower than solution B under the same conditions. Here&#8217;s where real optimization come in handy. Caching stuff, using a PHP accelerator, having a thought through algorithm, actually knowing what&#8217;s the perfomance hit and so on is always going to beat these type of lists hands down anytime. That&#8217;s the reality of optimization, not whether or not you use single or double quotes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2008/11/01/premature-optimization-is-bad/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Remember to backup</title>
		<link>http://www.varslashlog.com/2008/10/31/remember-to-backup/</link>
		<comments>http://www.varslashlog.com/2008/10/31/remember-to-backup/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 22:28:56 +0000</pubDate>
		<dc:creator>Aleks</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[system crash]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=72</guid>
		<description><![CDATA[What we all know is the backup is for whimps. This song might show the importace of taking backup to not make a system admin more depressed.
]]></description>
			<content:encoded><![CDATA[<p>What we all know is the backup is for whimps. This song might show the importace of taking backup to not make a system admin more depressed.</p>
<a href="http://www.varslashlog.com/2008/10/31/remember-to-backup/"><p><em>Click here to view the embedded video.</em></p></a>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2008/10/31/remember-to-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to setup subdomains in apache</title>
		<link>http://www.varslashlog.com/2008/10/31/how-to-setup-subdomains-in-apache/</link>
		<comments>http://www.varslashlog.com/2008/10/31/how-to-setup-subdomains-in-apache/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 14:31:07 +0000</pubDate>
		<dc:creator>Aleks</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[subdomain]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=61</guid>
		<description><![CDATA[It&#8217;s not difficult to run a website without using expensive applications like plesk. It&#8217;s really not that difficult to setup a subdomain or site yourself. Here I will show an easy method of setting up subdomains. Though this might not be a perfect way of doing it. At least it easy, and you have the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not difficult to run a website without using expensive applications like plesk. It&#8217;s really not that difficult to setup a subdomain or site yourself. Here I will show an easy method of setting up subdomains. Though this might not be a perfect way of doing it. At least it easy, and you have the site up and running in 5 minutes.<span id="more-61"></span>If we do this guide by setup the site for example.tld and one subdomain, admin. The DNS records did I show how to setup in <a title="How to setup DNS in BIND" href="http://www.varslashlog.com/2008/10/30/how-to-setup-dns-in-bind/">this guide about how to setup DNS in BIND.</a></p>
<p>We start by setting up the paths to our new domin. It might be a good idea to put new domains in the home directory. Though you are free to put them where you want.</p>
<p>I personally use the home directory, and will base my short guide on doing so.</p>
<p>Start by creating the domain as a folder in the home directory.</p>
<blockquote><p># mkdir /home/example.tld</p></blockquote>
<p>Next give apache owner rights over the folder</p>
<blockquote><p># chown apache:apache /home/example.tld</p></blockquote>
<p>Change the directory to the example.tld.</p>
<blockquote><p># cd /home/example.tld</p></blockquote>
<p>We want to make two directories, one to store our web page to example.tld, and one to store subdomains.</p>
<blockquote><p># mkdir htdocs<br />
# mkdir subdomains<br />
# chown apache:apache htdocs<br />
# chown apache:apache subdomains</p></blockquote>
<p>Since we are going to add one subdomain, we will add our subdomain &#8220;admin&#8221; to our subdomain folder.</p>
<blockquote><p># mkdir subdomains/admin<br />
# chown apache:apache subdomains/admin</p></blockquote>
<p>And at last create a htdocs folder in the admin subdomain folder.</p>
<blockquote><p># mkdir subdomins/admin/htdocs<br />
# chown  apache:apache subdomains/admin/htdocs</p></blockquote>
<p>We are almoust ready now. Put your web page files into the htdocs folders, or just create a dummy index.html with &#8220;Hello World&#8221; or something. If you get many folders and files and need th change the owner on all you can run this command to change all files and dirs to the apache user and group.</p>
<blockquote><p># chown apache:apache -R /home/example.tld</p></blockquote>
<p>Now we are ready to edit the apache configuration.</p>
<p>Open the configuration file (you need to be root or have sudo privileges)</p>
<blockquote><p>#vi /etc/httpd/conf/httpd.conf</p></blockquote>
<p>Go to the end of the configuration file and go into insert mode. Add two virtual hosts in this file at the far end.</p>
<p>First Add the virtual host if it&#8217;s not present</p>
<blockquote><p>NameVirtualHost *:80</p></blockquote>
<p>Then add the virtual host for the main domain, example.tld</p>
<blockquote><p>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /home/example.tld/htdocs<br />
ServerName example.tld<br />
&lt;Directory &#8220;/home/example.tld/htdocs&#8221;&gt;<br />
allow from all<br />
Options +Indexes<br />
&lt;/Directory&gt;<br />
&lt;/VirtualHost&gt;</p></blockquote>
<p>Next add the virtual host for the subdomain. Repeat this one for every subdomain you want</p>
<blockquote><p>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /home/example.tld/subdomains/admin/htdocs<br />
ServerName admin.example.tld<br />
&lt;Directory &#8220;/home/example.tld/subdomains/admin/htdocs&#8221;&gt;<br />
allow from all<br />
Options +Indexes<br />
&lt;/Directory&gt;</p></blockquote>
<p>Save the configuration and restart apache</p>
<blockquote><p># service httpd restart</p></blockquote>
<p>Finished!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2008/10/31/how-to-setup-subdomains-in-apache/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>EA gets criminal (update: or maybe not &#8230;)</title>
		<link>http://www.varslashlog.com/2008/10/30/ea-gets-criminal/</link>
		<comments>http://www.varslashlog.com/2008/10/30/ea-gets-criminal/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 23:22:55 +0000</pubDate>
		<dc:creator>AHSauge</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[EA]]></category>
		<category><![CDATA[Red Alert 3]]></category>
		<category><![CDATA[Spore]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=57</guid>
		<description><![CDATA[Just as I thought EA couldn&#8217;t get any more worse then what we&#8217;ve seen with Spore, I read this Norwegian article about EA and it&#8217;s alleged new policy. For the non-Norwegian readers, this article basically talks about a post in the EA forum by a EA-employee
Well, its actually going to be a bit nastier for [...]]]></description>
			<content:encoded><![CDATA[<p>Just as I thought EA couldn&#8217;t get any more worse then what we&#8217;ve seen with Spore, I read <a title="Article about EAs alleged new policy" href="http://www.dagbladet.no/art/forum/spill/3590788/" target="_blank">this</a> Norwegian article about EA and it&#8217;s alleged new policy. For the non-Norwegian readers, this article basically talks about <a href="http://forums.ea.com/mboards/message.jspa?messageID=4344364#4344364" target="_blank">a post in the EA forum</a> by a EA-employee</p>
<blockquote><p>Well, its actually going to be a bit nastier for those who get banned.</p>
<p>Your forum account will be directly tied to your Master EA Account, so if we ban you on the forums, you would be banned from the game as well since the login process is the same. And you&#8217;d actually be banned from your other EA games as well since its all tied to your account. So if you have SPORE and Red Alert 3 and you get yourself banned on our forums or in-game, well, your SPORE account would be banned to. It&#8217;s all one in the same, so I strongly reccommend people play nice and act mature.</p></blockquote>
<p>Now this is really crazy! Apparently, if EA don&#8217;t like what you do on their forum or anywhere else for that matter, you&#8217;ll be locked out of your own games! If this is really true, then I&#8217;ve never ever seen such a distasteful treatment of customers in my entire life. True, the victims here are most likely not mom&#8217;s angel, but they&#8217;ve still got rights, and this isn&#8217;t mentioned in the <a href="http://terms.ea.com/" target="_blank">TOS</a>. Not that I&#8217;m a lawyer or anything, but I think it&#8217;s illegal to steal, and if EA regards piracy as stealing, then this is definitely stealing too! So congrats EA, you just became a thief!</p>
<p>Update:  Thankfully, it <a href="http://forums.ea.com/mboards/thread.jspa?threadID=457006&amp;tstart=0" target="_blank">turns out</a> that this is just a misunderstanding. EA will NOT ban you from you game.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2008/10/30/ea-gets-criminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to setup DNS in BIND</title>
		<link>http://www.varslashlog.com/2008/10/30/how-to-setup-dns-in-bind/</link>
		<comments>http://www.varslashlog.com/2008/10/30/how-to-setup-dns-in-bind/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 14:58:47 +0000</pubDate>
		<dc:creator>Aleks</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[subdomain]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=45</guid>
		<description><![CDATA[This might be a beginners topic for most of the people out there, but the dns setup can be a bit confusing. This is just a short guide for how to setup an easy setup. Nothing complicated, and no fancy-pancy setup. This example will show how to setup an domain example.tld with three sub domains [...]]]></description>
			<content:encoded><![CDATA[<p>This might be a beginners topic for most of the people out there, but the dns setup can be a bit confusing. This is just a short guide for how to setup an easy setup. Nothing complicated, and no fancy-pancy setup. This example will show how to setup an domain example.tld with three sub domains and mail.<span id="more-45"></span></p>
<p>I know subdomains can be setup as wildcards, CNAME and A-records, but right now I use A-record for the subdomains.  To just get it going we will consentrate of just getting it working with the following configuration.</p>
<blockquote><p>Domain: example.tld<br />
Subdomains: mail, admin, mysql<br />
IP: 1.2.3.4</p></blockquote>
<p>Now we will start by adding the domain to the named.conf &#8211; Though it might not be present at this path you might need to search for it. (Using for example webmin would help you show all configuration files).</p>
<blockquote><p># vi /etc/named.conf</p></blockquote>
<p>Add a new zone to named.conf</p>
<blockquote><p>zone &#8220;example.tld&#8221; {<br />
type master;<br />
file &#8220;/var/named/example.tld.hosts&#8221;;<br />
};</p></blockquote>
<p>Save the configuration</p>
<blockquote><p>Push escape, then : x</p></blockquote>
<p>The next step is creating the DNS records.  Add a new file to bind.</p>
<blockquote><p># vi /var/named/example.tld.hosts</p></blockquote>
<p>In this file you will create your DNS-records.</p>
<blockquote><p>$ttl 15m ; TTL Might be smart to have at 15 minutes until your conf are ok<br />
example.tld.	IN	SOA	ns.example.tld. user.example.tld. (<br />
123456789 ;An unique number<br />
86000 ;Refresh rate in seconds<br />
7200 ;Update Retry in seconds<br />
3600000 ;Expiry in seconds<br />
600 ; minimum in seconds<br />
)</p>
<p>example.tld.	IN	NS	ns.example.tld.<br />
example.tld.   IN      A    1.2.3.4<br />
www.example.tld.    IN    CNAME example.tld<br />
mail IN A 1.2.3.4<br />
admin IN A 1.2.3.4<br />
mysql IN A 1.2.3.4<br />
mail.example.tld.	IN	MX	1 example.tld.</p></blockquote>
<p>Now save the file and restart BIND</p>
<blockquote><p># service bind restart</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2008/10/30/how-to-setup-dns-in-bind/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Innovative Microsoft shows new Windows</title>
		<link>http://www.varslashlog.com/2008/10/29/innovative-microsoft-shows-new-windows/</link>
		<comments>http://www.varslashlog.com/2008/10/29/innovative-microsoft-shows-new-windows/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 23:55:03 +0000</pubDate>
		<dc:creator>AHSauge</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[KDE]]></category>
		<category><![CDATA[KDE 4]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=39</guid>
		<description><![CDATA[As we all know, Microsoft is a very innovative company. They proved that by making Windows VistaX, and today they&#8217;ve proven it yet again by showing off their new OS, Windows KDE. Just take a look:

Seriously, my first impression was &#8220;KDE on Vista&#8221;. This is the same copycat behavour we&#8217;ve seen before from the Redmond-area. [...]]]></description>
			<content:encoded><![CDATA[<p>As we all know, Microsoft is a very innovative company. They proved that by making Windows VistaX, and today they&#8217;ve proven it yet again by showing off their new OS, Windows KDE. Just take a look:<span id="more-39"></span></p>
<p style="text-align: left;"><a href="http://www.varslashlog.com/wp-content/uploads/2008/10/windows7.png" rel="lightbox[39]"><img class="size-medium wp-image-40 aligncenter" title="Windows 7" src="http://www.varslashlog.com/wp-content/uploads/2008/10/windows7-300x225.png" alt="" width="300" height="225" /></a></p>
<p style="text-align: left;">Seriously, my first impression was &#8220;KDE on Vista&#8221;. This is the same copycat behavour we&#8217;ve seen before from the Redmond-area. For instance, that taskbar looks quite like that in KDE 4, and MS have been &#8220;creative&#8221; enought to let those widg &#8230; oh sorry, I of course mean gadgets, float on the desktop instead of beeing confined to the sidebar. &#8220;New!&#8221; Riiiiiight &#8230; Then there&#8217;s the new Explorer, which has it&#8217;s resemblance of Dolphin.</p>
<p style="text-align: center"><a href="http://www.varslashlog.com/wp-content/uploads/2008/10/windows7explorer.png" rel="lightbox[39]"><img class="alignnone size-medium wp-image-42" title="Windows 7 Explorer" src="http://www.varslashlog.com/wp-content/uploads/2008/10/windows7explorer-300x207.png" alt="" width="300" height="207" /></a></p>
<p style="text-align: left">I&#8217;m all aware of the fact that MS, Apple, KDE etc. are all sort of stealing ideas from each other, but everyone except MS actually does bring something new to the table now and then. When the heck i MS going to do that? When is MS actually going to be innovative instead of constantly being a copycat ending up with a bad copy? Gotta wonder &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2008/10/29/innovative-microsoft-shows-new-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Trac setup with subdomain in a plesk environment</title>
		<link>http://www.varslashlog.com/2008/10/28/trac-setup-with-subdomain-in-a-plesk-environment/</link>
		<comments>http://www.varslashlog.com/2008/10/28/trac-setup-with-subdomain-in-a-plesk-environment/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 11:19:39 +0000</pubDate>
		<dc:creator>Aleks</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[configurating]]></category>
		<category><![CDATA[nix]]></category>
		<category><![CDATA[plesk]]></category>
		<category><![CDATA[subdomain]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://www.varslashlog.com/?p=31</guid>
		<description><![CDATA[One thing I&#8217;ve noticed about tutorials regarding the config of apache towards trac in a plesk environment are rather lacking. I&#8217;ll use this short guide to show an easy method of adding the plesk interface as a python module of apache.
The installation of trac is an easy if you got the correct access. Anyhow will [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I&#8217;ve noticed about tutorials regarding the config of apache towards trac in a plesk environment are rather lacking. I&#8217;ll use this short guide to show an easy method of adding the plesk interface as a python module of apache.<span id="more-31"></span></p>
<p>The installation of trac is an easy if you got the correct access. Anyhow will I not go through the install process in this guide, but you can find a tutorial on doing that at the trac home page.</p>
<p>When you got plesk installed you should have  you subdomains as virtual hosts. This should be installed automatic from your plesk admin panel.</p>
<p>Lets say your site is named example.tld and your subdomain named trac.</p>
<blockquote><p>Site name: example.tld<br />
Sub domain: trac</p></blockquote>
<p>Now log into a SSH client and navigate to the trac subdomain folder</p>
<p># cd /var/www/vhosts/example.tld/subdomains/trac/</p>
<p>As we just can&#8217;t put the project files from trac into the htdocs folder just make a project in this folder so you got a sub folder &#8220;project&#8221; in the trac directory (or another place).</p>
<p>When you&#8217;ve got your project folder in place you are ready to setup the trac for your subdomain. In the subdomain folder locate the folder &#8220;conf&#8221;. This folder will locate a file that extend the apache configuration, vhost.conf &#8211; If not, vi will create it</p>
<blockquote><p>#vi vhost.conf</p></blockquote>
<p>Not much configuration necessary here. Add this information (replace the example.tld and path with your environment. And myproject with your project folder for the www-path)</p>
<blockquote><p>&lt;Location /myproject&gt;<br />
SetHandler mod_python<br />
PythonInterpreter main_interpreter<br />
PythonHandler trac.web.modpython_frontend<br />
PythonOption TracEnv /var/www/vhosts/example.tld/subdomains/trac/project/<br />
PythonOption TracUriRoot /myproject<br />
SetEnv PYTHON_EGG_CACHE /tmp/cache<br />
&lt;/Location&gt;</p></blockquote>
<p>Now restart the apache web server and you are good to go</p>
<blockquote><p>#service httpd restart<br />
or<br />
#/etc/rc.d/httpd (or apache) restart</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.varslashlog.com/2008/10/28/trac-setup-with-subdomain-in-a-plesk-environment/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
