<?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>danielmorlock.de</title>
	<atom:link href="http://www.danielmorlock.de/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.danielmorlock.de</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 06 Dec 2009 18:45:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Segmentation fault</title>
		<link>http://www.danielmorlock.de/?p=71</link>
		<comments>http://www.danielmorlock.de/?p=71#comments</comments>
		<pubDate>Thu, 22 Oct 2009 10:48:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.danielmorlock.de/?p=71</guid>
		<description><![CDATA[I experienced that sometimes, web applications partly break with the following apache error log: [Thu Oct 22 11:54:39 2009] [notice] child pid 17157 exit signal Segmentation fault (11) [Thu Oct 22 12:00:06 2009] [notice] child pid 17158 exit signal Segmentation &#8230; <a href="http://www.danielmorlock.de/?p=71">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I experienced that sometimes, web applications partly break with the following apache error log:</p>
<pre name="code" class="html">[Thu Oct 22 11:54:39 2009] [notice] child pid 17157 exit signal Segmentation fault (11)
[Thu Oct 22 12:00:06 2009] [notice] child pid 17158 exit signal Segmentation fault (11)
[Thu Oct 22 12:02:47 2009] [notice] child pid 17191 exit signal Segmentation fault (11)
[Thu Oct 22 12:02:47 2009] [notice] child pid 17343 exit signal Segmentation fault (11)</pre>
<p>Whenever that error occurred, the server response is empty. In my case, that issue mostly happens in ajax requests where the server response should be some XML snippets. But if the segfault occurs, the XML snippet is empty &#8211; the onliest hint I get is the log entry in /var/log/apache/error.log.<br />
First thing I tried is to debug applications using Zend Debugger, but if the debugger was enabled and I step through the application, the error did not happen and the request finishes correctly. Because Google did not lead to an answer, I sat down and tried until I was able to reproduce the error with a simple PHP script:</p>
<pre name="code" class="php">
session_start();
class A
{
    public function __construct()
    {
        echo "A::__construct()";
    }

    public function __destruct()
    {
        $_SESSION["MyObject"] = $this;
        echo "A::__destruct()";
    }

    public function __toString()
    {
        return "CLASS_A";
    }
}
new A();
</pre>
<p>First time I called this script via web browser all things are good. But the second time, I get an segmentation fault error in the apache log and the browser just displays nothing. Reason for that is that I try to store the current object in the session variable. When I do this the very first time, it work&#8217;s because <em>$_SESSION["MyObject"]</em> is not defined. But for any further call, <em>$_SESSION["MyObject"]</em> is defined with the current object and it will be undefined in order to assign the new value. Thus <em>A::__destruct()</em> is called a second time, where <em>$_SESSION["MyObject"]</em> will be re-defined again. This results in a endless loop and ends up in a segmentation fault of the currently used worker thread of the apache webserver.<br />
Note that in PHP 5.2 (and earlier?), there&#8217;s a <a href="http://bugs.php.net/bug.php?id=15522">Bug</a> which causes a segmentation fault whenever a PHP function is called recursively more than a definit times. I tried to reproduced and got a segmentation fault after about 900000 recursions.<br />
To do things right, we should check <em>$_SESSION["MyObject"]</em> whether it contains the current object. Only if <em>$_SESSION["MyObject"]</em> contains another object than the current, we can safely define another value!</p>
<pre name="code" class="php">
session_start();
class A
{
    public function __construct()
    {
        echo "A::__construct()";
    }

    public function __destruct()
    {
        if($this !== $_SESSION["MyObject"])
             $_SESSION["MyObject"] = $this;
        echo "A::__destruct()";
    }

    public function __toString()
    {
        return "CLASS_A";
    }
}
new A();
</pre>
<p>Storing objects in session variables brings another issue: The destructor of each object stored in the session is called each time, the current script ends. But the constructor is never called, because the initialized object already exists in the session. In order to avoid the destructor call, I recommend to serialize the object by using <a href="http://php.net/manual/de/function.serialize.php">serialize()</a> before storing it in the session:</p>
<pre name="code" class="php">
session_start();
class A
{
    public function __construct()
    {
        echo "A::__construct()";
    }

    public function __destruct()
    {
        $_SESSION["MyObject"] = serialize($this);
        echo "A::__destruct()";
    }

    public function __toString()
    {
        return "CLASS_A";
    }
}
new A();
</pre>
<p>In order to access the serialized object, you should unserialize the object first by using <a href="http://php.net/manual/de/function.unserialize.php">unserialize()</a>. Please note, that no every object property can be serialized and should be handled separately. You can use PHP&#8217;s magic methods like <a href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep">__sleep()</a> or <a href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep">__wakeup()</a> to handle those properties.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielmorlock.de/?feed=rss2&amp;p=71</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Import Events into Google Calendar</title>
		<link>http://www.danielmorlock.de/?p=57</link>
		<comments>http://www.danielmorlock.de/?p=57#comments</comments>
		<pubDate>Wed, 09 Sep 2009 16:28:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Volleyball]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.danielmorlock.de/?p=57</guid>
		<description><![CDATA[This is a wrapper class for some Google calendar import methods. Frequently I get a list with lots of dates I&#8217;ve to add to the Google calendar. To bad that there is no calendar import function for the Google calendar. &#8230; <a href="http://www.danielmorlock.de/?p=57">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a wrapper class for some Google calendar import methods. Frequently I get a list with lots of dates I&#8217;ve to add to the Google calendar. To bad that there is no calendar import function for the Google calendar. But fortunately, Zend provides a nice PHP framework for this task. Let&#8217;s have a look how to add calendar events by using this framework:</p>
<p><strong>Requirements</strong></p>
<p>My wrapper uses parts of the Zend framework. If you use gentoo just let portage do that task: <em><strong>emerge -av dev-php5/ZendFramework</strong></em>.<br />
I&#8217;m sure that other distributions also maintain packages for that framework. If not, you&#8217;ve to install the Zend Framework by hand like desribed <a href="http://framework.zend.com/">here</a>.</p>
<p>You need at least a running PHP interpreter (here: <em><strong>dev-lang/php-5.2.10</strong></em>).</p>
<p><strong>Parsing Data</strong></p>
<p>Before we create an event, we&#8217;ve to organize data. This is done by creating corresponding objects:</p>
<pre class="php:nogutter:nocontrols">$Match = new Match();
$Match-&gt;Number = 4265;
$Match-&gt;Location = "Hagwaldhalle Pfinztal, Ortsteil Kleinsteinbach";
$Match-&gt;Team = "VSG Kleinsteinbach";
$Match-&gt;Opponent = "TuS KA/Rüppurr II";
$Match-&gt;Date = new DateTime("06.03.2010 15:00");</pre>
<p>Note, that you can use the static method <em><strong>Match::Parse($Path)</strong></em> in order to parse a data resource (given by $Path) with the following format:</p>
<pre class="ror:nogutter:nocontrols">4201 TuS Durmersheim III - TV Liedolsheim        03.10.2009 (15:00) Gymnasiumshalle Durmersheim
4202 TuS Durmersheim III - VSG Kleinsteinbach
4203 SG Hilpertsau/Au - TSV Ubstadt              03.10.2009 (15:00) Ebersteinhalle Obertsrot
4204 SG Hilpertsau/Au - SC Wettersbach</pre>
<p>You can find a sample data file <a href="http://code.google.com/p/matchimport/source/browse/trunk/VSG-2009.db">here</a>.</p>
<p><strong>Importing Data</strong></p>
<p>Last step is to import the objects to your Google calendar. Check your Google calendar settings in order to get your private calendar ID (must be somewhat with @group.calendar.google.com as prefix).</p>
<p>Now, we have to login to the Google service. This can be done by <strong><em>Match::Login($Username,$Password)</em></strong>. This method might throw exceptions on failures, so make sure you catch them in an appropriate way.</p>
<p>Finally you can create a calendar entry from a Match object by <em><strong>Match-&gt;Create($Feed)</strong></em>. Where $Feed is the URL to your private Google calendar: <em><strong>http://www.google.com/calendar/feeds/ID@group.calendar.google.com/private/full</strong></em>.</p>
<p><strong>Source &amp; Example</strong></p>
<p>You can checkout the latest version from Google code:<br />
<strong><em>svn checkout http://matchimport.googlecode.com/svn/trunk/ matchimport-read-only</em></strong>.<br />
There&#8217;s an example script <a href="http://code.google.com/p/matchimport/source/browse/trunk/run.php">run.php</a> which contains the basic steps to import a Match schedule.</p>
<p>By default, the duration of a match is set to 100 mins and there&#8217;s a 20 min break between two matches. Further, a reminder is set which reminds the Google calendar user by SMS two days before the match starts.</p>
<p>The source is under Free BDS license, so feel free to modify the code.<br />
Visit the <a href="http://code.google.com/p/matchimport">Google code project</a> for more details.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielmorlock.de/?feed=rss2&amp;p=57</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Both ondblclick &amp; onclick Handlers</title>
		<link>http://www.danielmorlock.de/?p=29</link>
		<comments>http://www.danielmorlock.de/?p=29#comments</comments>
		<pubDate>Fri, 12 Jun 2009 12:14:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Handler]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[onclick]]></category>
		<category><![CDATA[ondblclick]]></category>

		<guid isPermaLink="false">http://comserver.bigfatservers.com/wordpress/?p=29</guid>
		<description><![CDATA[var dblclick = false;function MethodA(){setTimeout(function(){if(dblclick == true){return;}alert('MethodA');},250);}function MethodB(){dblclick = true;alert('MethodB');setTimeout(function(){dblclick = false;},250);} Back from hell after long I post a workaround for the ondblclick and onclick javascript issue: It&#8217;s not possible to define both handlers so that the onclick handler &#8230; <a href="http://www.danielmorlock.de/?p=29">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript">var dblclick = false;function MethodA(){setTimeout(function(){if(dblclick == true){return;}alert('MethodA');},250);}function MethodB(){dblclick = true;alert('MethodB');setTimeout(function(){dblclick = false;},250);}</script></p>
<p>Back from hell after long I post a workaround for the ondblclick and onclick javascript issue:<br />
<strong>It&#8217;s not possible to define both handlers so that the onclick handler won&#8217;t get active on a doubleclick:</strong></p>
<pre name="code" class="html">
&lt;input type="button"
            value="Example"
            onclick="MethodA();"
            ondblclick="MethodB();" />
</pre>
<input type="button" value="Example" onclick="alert('MethodA');" ondblclick="alert('MethodB');" />
<div>&nbsp;</div>
<p>A possible workaround is to use a semaphore-like global variable (here: dblclick). This is set to true whenever the doubleclick handler is performed.<br />
Further we delay the single click handler for some miliseconds (here: 250) and check against the dblclick semaphore until continue.</p>
<pre name="code" class="jscript">
var dblclick = false;
function MethodA()
{
     setTimeout(function()
     {
          if(dblclick == true)
               return;

          alert('MethodA');
     },250);
}
function MethodB()
{
     dblclick = true;
     alert('MethodB');
     setTimeout(function()
     {
          dblclick = false;
     },250);
}</pre>
<input type="button" value="Example" onclick="MethodA();" ondblclick="MethodB();" />
<div>&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.danielmorlock.de/?feed=rss2&amp;p=29</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fvwm Configuration</title>
		<link>http://www.danielmorlock.de/?p=12</link>
		<comments>http://www.danielmorlock.de/?p=12#comments</comments>
		<pubDate>Wed, 21 Nov 2007 00:26:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FVWM]]></category>

		<guid isPermaLink="false">http://comserver.bigfatservers.com/wordpress/?p=12</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="Fvwm Pager" src="http://danielmorlock.de/wp-content/uploads/2007/07/pager1.jpg" alt="Fvwm Pager" width="397" height="388" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielmorlock.de/?feed=rss2&amp;p=12</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Booting Gentoo from USB Hard Disk</title>
		<link>http://www.danielmorlock.de/?p=15</link>
		<comments>http://www.danielmorlock.de/?p=15#comments</comments>
		<pubDate>Sun, 19 Aug 2007 22:23:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Gentoo]]></category>

		<guid isPermaLink="false">http://comserver.bigfatservers.com/wordpress/?p=15</guid>
		<description><![CDATA[I installed my Gentoo on my internal hard disk. Due to mobility I think about moving my system to a portable USB hard disk. The first idea was to use an initial ram disk image to load the USB drivers &#8230; <a href="http://www.danielmorlock.de/?p=15">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I installed my <b>Gentoo</b> on my internal hard disk. Due to mobility I think about moving my system to a portable USB hard disk. The first idea was to use an initial ram disk image to load the USB drivers and load the main system. I read some things about  creating an inital ram disk image (<b>initrd</b>) by using <b>mkinitrd</b> and come to the end, that there has to be a solution which is more easier than using an initrd.</p>
<blockquote><p>The main problem when booting from USB is the following: First of all, the BIOS is setting up its USB drivers to load the kernel into the RAM. After this step, the BIOS makes the kernel booting. When the kernel is booting, it unloads the BIOS USB drivers to load the kernel specific USB drivers. There is some time between unload the BIOS drivers and loading the kernel drivers where no USB driver is active &#8211; without an USB driver, the kernel cannot access the root filesystem and panics.</p></blockquote>
<p>The solution is to delay the kernel boot process until the kernel USB drivers are loaded and the kernel can access the root filesystem. I found the <strong>rootdelay</strong> boot parameter in my current kernel documentation:</p>
<blockquote><p><code> rootdelay = [KNL] Delay (in seconds) to pause before attempting<br />
 to mount the root filesystem</code></p></blockquote>
<p>So booting your linux distribution from an USB disk is quiet easy:</p>
<ul>
<li>Just append the rootdelay parameter to your boot loader configuration (in my case, this is <b>grub</b>):<br />
<blockquote><p><code># 2.6.22-suspend2-r1<br />
title 2.6.22-suspend2-r1<br />
root (hd0,1)<br />
kernel /boot/vmlinuz-2.6.22-suspend2-r1 root=/dev/sdb2 video=vesafb-tng:mtrr,ywrap resume2=swap:/dev/sdb5 rootdelay=5</code>
</p></blockquote>
</li>
<li>When you boot your system from USB, you have to think about changing device names. If your device was at /dev/hda, the USB device will be at /dev/sda. So you have to figure out your USB device name, adjust the fstab configuration and the root kernel parameter in your grub configuration.</li>
<li>Finally you have to make sure, that you build-in the needed USB drivers into your kernel. So I set the following options in my kernel configuration:<br />
<blockquote><p><code>Device Drivers  ---><br />
     USB support  ---><br />
          < *> Support for Host-side USB<br />
           [*]   USB device filesystem<br />
          < *>   EHCI HCD (USB 2.0) support<br />
           [*]     Full speed ISO transactions (EXPERIMENTAL)<br />
           [*]     Root Hub Transaction Translators (EXPERIMENTAL)<br />
           [*]     Improved Transaction Translator scheduling (EXPERIMENTAL)<br />
          < *>   UHCI HCD (most Intel and VIA) support<br />
          < *> USB Mass Storage support</code></p></blockquote>
</li>
<li>
It depends on your architecture whether you have to build-in EHCI, OHCI or UHCI. Just use <b>lspci</b> to detect you requirements. In my case I got the following output:<br />
<blockquote><p><code>ws1 linux # lspci | grep -i UHCI<br />
00:1d.0 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI #1 (rev 01)<br />
00:1d.1 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI #2 (rev 01)<br />
00:1d.2 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI #3 (rev 01)<br />
00:1d.3 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI #4 (rev 01)<br />
ws1 linux # lspci | grep -i OHCI<br />
ws1 linux # lspci | grep -i EHCI<br />
00:1d.7 USB Controller: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller (rev 01)<br />
ws1 linux #</code>
</p></blockquote>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.danielmorlock.de/?feed=rss2&amp;p=15</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Burning CD/DVD using the Shell</title>
		<link>http://www.danielmorlock.de/?p=11</link>
		<comments>http://www.danielmorlock.de/?p=11#comments</comments>
		<pubDate>Sat, 19 May 2007 10:09:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Gentoo]]></category>

		<guid isPermaLink="false">http://comserver.bigfatservers.com/wordpress/?p=11</guid>
		<description><![CDATA[It&#8217;s not very difficult to write CD/DVD&#8217;s from the linux shell. Here&#8217;s is a short summary how to burn CD/DVD&#8217;s using mkisofs and cdrecord. First of all, you have to create an ISO image, which you can write onto CD/DVD. &#8230; <a href="http://www.danielmorlock.de/?p=11">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not very difficult to write CD/DVD&#8217;s from the linux shell. Here&#8217;s is a short summary how to burn CD/DVD&#8217;s using <em>mkisofs</em> and <em>cdrecord.</em></p>
<p>First of all, you have to create an ISO image, which you can write onto CD/DVD. I&#8217;m using <em>mkisofs</em> for this job:</p>
<pre><code>mkisofs -J -v -r -o /tmp/myimage.iso /folder/to/burn</code></pre>
<ul>
<li>-v Verbose execution</li>
<li>-J Generate Joliet directory records in addition to regular iso9660 file names. (Windows compatibility)</li>
<li>-r Adapt file mode bits</li>
<li>-i Defines ouput image</li>
</ul>
<p>After you created an ISO image, you can burn the image onto CD/DVD using <em>cdrecord</em></p>
<pre><code>cdrecord -v -eject -driveropts=burnfree -dao dev=/dev/hdc /tmp/myimage.iso</code></pre>
<ul>
<li>-v Increment the verbose level</li>
<li>-eject Eject the CD/DVD after process has finished</li>
<li>-driveropts=burnfree Turn on support for buffer underrun free writing</li>
<li>-dao Write your CD/DVD in Disk At Once Mode</li>
<li>-dev Define the device</li>
</ul>
<p>That&#8217;s it &#8211; with increased verbose level, you can watch the process of your burn job.<br />
Alternatively, you can create the image and burn the CD/DVD on the fly using linux pipes:</p>
<pre><code>mkisofs -r /folder/to/burn | cdrecord -v -eject -driveropts=burnfree  dev=/dev/hdc -</code></pre>
<p>In this case, <em>mkisofs</em> prints the image data to stdout. We catch this and redirect the image data directly to cdrecord. Note, that if <em>mkisofs</em> fails creating the image completely, <em>cdrecord</em> might rubish your CD/DVD.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielmorlock.de/?feed=rss2&amp;p=11</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DigitalProductID Decode Algorithm</title>
		<link>http://www.danielmorlock.de/?p=10</link>
		<comments>http://www.danielmorlock.de/?p=10#comments</comments>
		<pubDate>Thu, 19 Apr 2007 21:35:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://comserver.bigfatservers.com/wordpress/?p=10</guid>
		<description><![CDATA[Every licence key, you give for Microsoft software, creates a DigitalProductID in the Windows registry. E.g. you find the digital product id for your Microsoft Windows in your registry: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion The following algorithm shows you howto decode the digital &#8230; <a href="http://www.danielmorlock.de/?p=10">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Every licence key, you give for Microsoft software, creates a DigitalProductID in the Windows registry. E.g. you find the digital product id for your Microsoft Windows in your registry: <strong>HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion</strong></p>
<p>The following algorithm shows you howto decode the digital product id to fetch your raw product key. If you loose your product key, this should help you to get it back without spending money. <em>Please use this knowledge only for legal use! </em>This is the onliest limitation to the following algorithm:</p>
<pre name="code" class="csharp">
/* Digit Array */
Char[] Digits = {'B', 'C', 'D', 'F', 'G', 'H', 'J','K', 'M', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9'};
Char[] DecodedKey = new Char[25];
System.Byte[] BinaryKey = {0x7f, 0x6a, 0x51, 0x4c, 0x8e, 0x5a, 0x91, 0x56, 0xea, 0x34, 0x77, 0x1a, 0xb7, 0xf2, 0x02}; // Not really a working key <img src='http://www.danielmorlock.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
int StartOffset = 0x34;
int i, j, k;
String Result = "";
for (i = DecodedKey.Length-1; i &gt;= 0; i --)
{
     k = 0;
     for (j = BinaryKey.Length-1; j &gt;= 0; j--)
     {
          k = (k &lt;&lt; <img src='http://www.danielmorlock.de/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> + BinaryKey[j];
          BinaryKey[j] = (System.Byte)(k / 24);
          k = k % 24;
     }
     DecodedKey[i] = Digits[k];
}</pre>
<p>You got the raw decoded key in the <strong>Result</strong> variable. After decoding, you have to format the product key e.g. adding &#8220;-&#8221; after every 5th char and so on. I used <em>Microsoft .NET Framework </em>and <em>C#</em> to access the registry and decode the byte progression.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielmorlock.de/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gentoo, Gnome &amp; Vmware Trouble</title>
		<link>http://www.danielmorlock.de/?p=9</link>
		<comments>http://www.danielmorlock.de/?p=9#comments</comments>
		<pubDate>Wed, 28 Mar 2007 08:02:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[VMWare]]></category>

		<guid isPermaLink="false">http://comserver.bigfatservers.com/wordpress/?p=9</guid>
		<description><![CDATA[After another world-update (Vmware Workstation 5.5.3 build-34685, D-Bus Message Bus Daemon 1.0.2) I got the following errors when I try to start vmware: &#160; workstation1@ws1 /usr/local/bin $ /opt/vmware/workstation/bin/vmware /opt/vmware/workstation/lib/bin/vmware: /opt/vmware/workstation/lib/lib/libpng12.so.0/libpng12.so.0: no version information available (required by /usr/lib/libcairo.so.2) process 1777: Attempt &#8230; <a href="http://www.danielmorlock.de/?p=9">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After another world-update (Vmware Workstation 5.5.3 build-34685, D-Bus Message Bus Daemon 1.0.2)  I got the following errors when I try to start vmware:</p>
<p align="left">&nbsp;</p>
<pre lang="bash">workstation1@ws1 /usr/local/bin $ /opt/vmware/workstation/bin/vmware
/opt/vmware/workstation/lib/bin/vmware: /opt/vmware/workstation/lib/lib/libpng12.so.0/libpng12.so.0: no version information available (required by /usr/lib/libcairo.so.2)
process 1777: Attempt to remove filter function 0xb6c80c20 user data 0x8805038, but no such filter has been added
D-Bus not built with -rdynamic so unable to print a backtrace
/opt/vmware/workstation/lib/bin/vmware: /opt/vmware/workstation/lib/lib/libpng12.so.0/libpng12.so.0: no version information available (required by /usr/lib/libcairo.so.2)
/opt/vmware/workstation/lib/bin/vmware: /opt/vmware/workstation/lib/lib/libpng12.so.0/libpng12.so.0: no version information available (required by /usr/lib/libcairo.so.2)
process 1788: Attempt to remove filter function 0xb7006c20 user data 0x8806c80, but no such filter has been added
D-Bus not built with -rdynamic so unable to print a backtrace
workstation1@ws1 /usr/local/bin $</pre>
<p>It seems that there is a problem with the gnome dbus daemon running in background. There are several workarounds at web on vmware and gentoo pages which propose either to change soft-links linking corresponding libraries or start vmware with changed library dependings.<br />
My workaround is quiet easy: Just stop the dbus daemon before starting vmware:</p>
<pre lang="bash">workstation1@ws1 /usr/local/bin $ cat /usr/local/bin/vmware
#!/bin/bash
sudo /etc/init.d/dbus stop
/opt/vmware/workstation/bin/vmware
sudo /etc/init.d/dbus start
workstation1@ws1 /usr/local/bin $</pre>
<p>This will prevent you from changing any software preferences and is likely to be removed easily when this dbus vmware bug is hopefully fixed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielmorlock.de/?feed=rss2&amp;p=9</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Upload Script with Progress Bar</title>
		<link>http://www.danielmorlock.de/?p=7</link>
		<comments>http://www.danielmorlock.de/?p=7#comments</comments>
		<pubDate>Tue, 27 Feb 2007 23:55:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://comserver.bigfatservers.com/wordpress/?p=7</guid>
		<description><![CDATA[Introduction If you want to upload some files through a web interface using PHP, you might use a classic POST method to push the data to the action script. If you choose your file and submit the HTML form, the &#8230; <a href="http://www.danielmorlock.de/?p=7">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<blockquote><p>If you want to upload some files through a web interface using PHP, you might use a classic POST method to push the data to the action script. If you choose your file and submit the HTML form, the file is transfered to the server and moved into a temporary file. Further your action script can examine the file and copy it to a specific location.<br />
This method works fine, but I has one essential disadvantage: The file has to be transfered completely before you can examine the filetype, filesize and other file information. Further when transfering the file, you have no information about the transfer status. Assume, you want to upload a huge file. After you submit the upload form, you&#8217;ll wait several minutes without any information.<br />
I found a solution which is working quiet well. I will post some examples and will desribe basic ideas about upload files using CGI PHP. Maybe you want to use this information to build your own upload script.</p></blockquote>
<p><strong>Using CGI </strong><strong>PHP</strong></p>
<blockquote><p>There are different possibilities, you can run PHP. In general, PHP runs as module, e.g. in a <a href="http://www.apache.org">apache web server</a>.  But there is another interesting method to run PHP. If you run a PHP script as CGI program, a new process is forked and the PHP interpreter is loaded into this process. This method allows us to run several PHP scripts concurrently.<br />
Imagine, that we have a PHP script to transfer the file and periodically write out the size of transfered data into a temporary state file. Further another script exists to read out the state file information, calculate the percentage of transfered data and displays a cute progress bar. Now we can use the concurrency described above to let the two scripts run concurrently. So you see, the main idea is to separate the upload and the statistic script. While the upload script transfers data, the statistic script will show the progress bar.</p></blockquote>
<p><strong>Filetransfer Management</strong></p>
<blockquote><p>The idea of transfering is quit easy: We read a data package of a couple of bytes (e.g. 1024 bytes), examine it and save it in a temporary file. After we reach the end of file (eof), we move the temporary file to the destination file. You can get an idea of this transfer from the following code example:</p>
<pre name="code" class="php">
#!/usr/bin/php
< ?PHP
// If the file size is too huge for uploading ...
if($_ENV['CONTENT_LENGTH'] > (1024^2) * 10)
{
     echo "Location: http://meinedomain.de/error.html\n\n";
     die(0);
}
$bytesTransfered = 0;
while(!feof(STDIN))
{
     $buffer = fread(STDIN,1024);
     $bytesTransfered += strlen($buffer);
     file_put_contents("/tmp/upload",$buffer,FILE_APPEND);
}
die(0);
?>
</pre>
<p>Note, that this script run as CGI program, like I desribed above.</p>
<p>As you see, I periodically read 1024 bytes from STDIN. This wrapps the input stream e.g. coming from a HTML input form. Let&#8217;s have a look at the input stream layout.<br />
Further you are able, to validate the content length by using <em>$_ENV['CONTENT_LENGTH']</em> at the beginning of the upload script, like I did on line 4.
</p></blockquote>
<p><strong>Stream Data</strong></p>
<blockquote><p>If you look at the uploaded file, you will see something like the following snippet I got after uploading a jpeg file:<br />
<code style="text-align:left;">-----------------------------1951833994121914805585029106<br />
Content-Disposition: form-data; name="datei"; filename="sysarc.jpg"<br />
Content-Type: image/jpeg<br />
some binary or ASCII code<br />
-----------------------------1951833994121914805585029106--</code><br />
As you see, we got the basic information <em>Content-Disposition</em> and <em>Content-Type</em> at the beginning of the file stream. So the idea is to parse the first lines of an incoming transfer until the header is completely transfered. Further one can examine the header information and perhaps, you can stop the file transfer, e.g. if someone wants to upload a forbidden content type.<br />
To sum up, we have an upload control script, which can hand over essential information (filetype, filename, filesize, transfered bytes) to another statistic script. It&#8217;s your turn to create a statistic script which analysis this information.
</p></blockquote>
<p><strong>Avoid Javascript</strong></p>
<blockquote><p>
Now, you know the basic ideas about uploading files with pure PHP. You don&#8217;t need further client-side scripting languages like <em>Javascript</em> to use the upload script. Think about multiple frames (I know, that&#8217;s very old-school, but I found no other possibility). If your are using two frames, one frame can show the upload form and can call the upload script while the other frame can show the statistic page all the time. The statistic page refreshes itself every few seconds using the following html meta tag:</p>
<p><code style="text-align:left;">&lt;meta http-equiv="refresh" content="5; URL=http://meinedomain.de/statistic.php"&gt;</code></p>
<p>If an upload begins, the upload script hands over upload information to the statistic script which creates an upload progress bar.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.danielmorlock.de/?feed=rss2&amp;p=7</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
