<?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>PHP / MySQL / Linux Stories</title>
	<atom:link href="http://xfragger.de/feed" rel="self" type="application/rss+xml" />
	<link>http://xfragger.de</link>
	<description>Meine Erfahrungen in der Webentwicklerwelt</description>
	<lastBuildDate>Wed, 03 Nov 2010 06:35:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Developers Shame Day 2010</title>
		<link>http://xfragger.de/312/developers-shame-day-2010</link>
		<comments>http://xfragger.de/312/developers-shame-day-2010#comments</comments>
		<pubDate>Wed, 03 Nov 2010 06:35:10 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[developers shame day]]></category>
		<category><![CDATA[devshameday]]></category>

		<guid isPermaLink="false">http://xfragger.de/?p=312</guid>
		<description><![CDATA[PHP hates me Autor Nils nimmt am Developers-Shame-Day 2010 teil und ich dachte mir, ich suche auch mal in den Untiefen meines alten Codes nach einem Schmuckstück. Ursprünglich kam die Idee zum DevShameDay von &#8220;Cem, dem PHP-Hacker&#8220;. Leider ging in den Jahren einiges verloren, aber ich denke, dass hier ist schlecht genug, um sich dafür [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.phphatesme.com/blog/aktuelles/der-developers-shame-day/?utm_source=twitterfeed&#038;utm_medium=twitter&#038;utm_campaign=Feed:+PhpHatesMe-DerPhpBlog+(PHP+hates+me+-+Der+PHP+Blog)">PHP hates me</a> Autor <a href="http://www.phphatesme.com/blog/author/nils/">Nils</a> nimmt am  Developers-Shame-Day 2010 teil und ich dachte mir, ich suche auch mal in den Untiefen meines alten Codes nach einem Schmuckstück. Ursprünglich kam die Idee zum DevShameDay von &#8220;<a href="http://phphacker.net/2010/10/26/der-developers-shame-day/" rel="nofollow">Cem, dem PHP-Hacker</a>&#8220;.<br />
Leider ging in den Jahren einiges verloren, aber ich denke, dass hier ist schlecht genug, um sich dafür zu schämen.</p>
<p>Ich Schätze das ist um 2004 entstanden und lieferte Termine bzw. Events von einem bestimmten Tag, das ganze für einen Webkalender ala Google-Calendar. Was ich noch erwähnen sollte&#8230;. die Funktion wurde für jeden sichtbaren Kalendertag aufgerufen!</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">function</span> getevents<span style="color: #009900;">&#40;</span><span style="color: #000088;">$year</span><span style="color: #339933;">,</span><span style="color: #000088;">$month</span><span style="color: #339933;">,</span><span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$SELF</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$month</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$month</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'0'</span><span style="color: #339933;">.</span><span style="color: #000088;">$month</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$month</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'0'</span><span style="color: #339933;">.</span><span style="color: #000088;">$day</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$day</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$year</span>-<span style="color: #006699; font-weight: bold;">$month</span>-<span style="color: #006699; font-weight: bold;">$day</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$strx</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$month</span>-<span style="color: #006699; font-weight: bold;">$day</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;
           SELECT e.name as ename,
                                                e.description as edescr,
                                                e.id as eid,
                                                t.color as tcolor,
                                                e.time_start as time_start,
                                                e.time_end as time_end,
                                                e.remember as rem,
                                        e.date_start as date_start,
                                                e.date_end as date_end,
                                                t.description as tdescription,
                                                t.showtime as showtime
           FROM cal_entry e, cal_types t
           WHERE e.types_id = t.id
             AND (e.date_start &lt;= '<span style="color: #006699; font-weight: bold;">$str</span>'
                           AND ( e.date_end &gt;= '<span style="color: #006699; font-weight: bold;">$str</span>' AND e.date_end IS NOT NULL OR e.date_start = '<span style="color: #006699; font-weight: bold;">$str</span>' AND e.date_end IS NULL )
         OR(t.id = 1 AND right(e.date_start,5) = '<span style="color: #006699; font-weight: bold;">$strx</span>')
                         )
                        ORDER BY e.time_start, t.prio
         &quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$out</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;u&gt;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$SELF</span>?show=new&amp;date=<span style="color: #006699; font-weight: bold;">$year</span>-<span style="color: #006699; font-weight: bold;">$month</span>-<span style="color: #006699; font-weight: bold;">$day</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$day</span>.<span style="color: #006699; font-weight: bold;">$month</span>.&lt;/a&gt;&lt;/u&gt;&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$tmp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$SELF</span>?show=edit&amp;eid=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;eid&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;ym=<span style="color: #006699; font-weight: bold;">$year</span>-<span style="color: #006699; font-weight: bold;">$month</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
                 <span style="color: #000088;">$tmp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;font class=<span style="color: #000099; font-weight: bold;">\&quot;</span>entry<span style="color: #000099; font-weight: bold;">\&quot;</span> color=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;tcolor&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;li&gt;&quot;</span><span style="color: #339933;">;</span>
                 <span style="color: #000088;">$tmp</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ename&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                 <span style="color: #000088;">$starta</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_start&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000088;">$outstart</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$starta</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$starta</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$starta</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                 <span style="color: #000088;">$enda</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                 <span style="color: #000088;">$outend</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$enda</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$enda</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$enda</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                 <span style="color: #000088;">$divbody</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;table border=0 class=entry&gt;&lt;tr&gt;&quot;</span><span style="color: #339933;">;</span>
                 <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_start&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                   <span style="color: #000088;">$divbody</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td&gt;Von:&lt;/td&gt;&lt;td&gt;<span style="color: #006699; font-weight: bold;">$outstart</span>&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Bis:&lt;/td&gt;&lt;td&gt;<span style="color: #006699; font-weight: bold;">$outend</span>&lt;/td&gt;&lt;/tr&gt;&quot;</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: #000088;">$divbody</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;td&gt;Am:&lt;/td&gt;&lt;td&gt;<span style="color: #006699; font-weight: bold;">$outstart</span>&lt;/td&gt;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
                 <span style="color: #009900;">&#125;</span>
                 <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;showtime&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                     <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_start&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                       <span style="color: #000088;">$divbody</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&lt;td&gt;Von:&lt;/td&gt;&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_start&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Uhr&lt;/td&gt;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
                             <span style="color: #000088;">$divbody</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&lt;td&gt;Bis:&lt;/td&gt;&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_end&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Uhr&lt;/td&gt;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
                     <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_start&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_start&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$str</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_start&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                           <span style="color: #000088;">$divbody</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&lt;td&gt;Ab:&lt;/td&gt;&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_start&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Uhr&lt;/td&gt;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
                     <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_start&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$str</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                       <span style="color: #000088;">$divbody</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&lt;td&gt;Bis:&lt;/td&gt;&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_end&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Uhr&lt;/td&gt;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
                     <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_start&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;date_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_end&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                       <span style="color: #000088;">$divbody</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;tr&gt;&lt;td&gt;Ab:&lt;/td&gt;&lt;td&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;time_start&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Uhr&lt;/td&gt;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
                     <span style="color: #009900;">&#125;</span>
                 <span style="color: #009900;">&#125;</span>
                 <span style="color: #000088;">$rem</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;rem&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">&quot;&lt;font color=green&gt;EMail Erinnerung aktiv&lt;/font&gt;&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;&lt;font color=red&gt;EMail Erinnerung inaktiv&lt;/font&gt;&quot;</span><span style="color: #339933;">;</span>
                 <span style="color: #000088;">$divbody</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/table&gt;&quot;</span><span style="color: #339933;">;</span>
                 <span style="color: #666666; font-style: italic;">#$div = &quot;&lt;div title=\&quot;header=[&quot;.$row[&quot;ename&quot;].&quot;] body=[&quot;.$row[&quot;edescr&quot;].$divbody&quot;]\&quot;&gt;&quot;;
</span>                 <span style="color: #000088;">$div</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;div title=&quot;header=['</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ename&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'] body=['</span><span style="color: #339933;">.</span><span style="color: #990000;">nl2br</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;edescr&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$divbody</span><span style="color: #339933;">.</span><span style="color: #000088;">$rem</span><span style="color: #339933;">.</span><span style="color: #0000ff;">']&quot;&gt;'</span><span style="color: #339933;">;</span>
                 <span style="color: #000088;">$tmp</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/div&gt;&lt;/li&gt;&lt;/font&gt;&lt;/a&gt;&quot;</span><span style="color: #339933;">;</span>
                 <span style="color: #000088;">$out</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$div</span><span style="color: #339933;">.</span><span style="color: #000088;">$tmp</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$out</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/312/developers-shame-day-2010/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>lighttpd: Alle Subdomains auf www.domain.tld umleiten</title>
		<link>http://xfragger.de/298/lighttpd-alle-subdomains-auf-www-domain-tld-umleiten</link>
		<comments>http://xfragger.de/298/lighttpd-alle-subdomains-auf-www-domain-tld-umleiten#comments</comments>
		<pubDate>Tue, 24 Aug 2010 16:33:26 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Webserver]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[url.redirect]]></category>
		<category><![CDATA[www]]></category>

		<guid isPermaLink="false">http://xfragger.de/?p=298</guid>
		<description><![CDATA[Ich stand vor kurzem vor dem Problem, das alle Subdomains, die ein Benutzer eingeben könnte, auf www.example.com umleiten sollten. Aus Googlesicht ist das gut, weil so doppelter Inhalt vermieden wird und für den Benutzer ist es einfach schöner. Im Internet habe ich einige Beispiele gefunden, wie man www.example.com auf example.com und umgekehrt umleitet, aber keine [...]]]></description>
			<content:encoded><![CDATA[<p>Ich stand vor kurzem vor dem Problem, das alle Subdomains, die ein Benutzer eingeben könnte, auf www.example.com umleiten sollten.</p>
<p>Aus Googlesicht ist das gut, weil so doppelter Inhalt vermieden wird und für den Benutzer ist es einfach schöner.</p>
<p>Im Internet habe ich einige Beispiele gefunden, wie man www.example.com auf example.com und umgekehrt umleitet, aber keine generelle Lösung. Die Hostdefinition matcht *example.com und *.example.de, weitere sind ohne weiteres möglich.</p>
<p><span id="more-298"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$HTTP</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;host&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>~ <span style="color: #0000ff;">&quot;^(.*example\.(com|de)$&quot;</span> <span style="color: #009900;">&#123;</span>
        server<span style="color: #339933;">.</span>document<span style="color: #339933;">-</span>root <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/var/www/example.com&quot;</span>
        server<span style="color: #339933;">.</span>error<span style="color: #339933;">-</span>handler<span style="color: #339933;">-</span><span style="color: #cc66cc;">404</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/index.php&quot;</span>
&nbsp;
        <span style="color: #000088;">$HTTP</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;host&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!</span>~ <span style="color: #0000ff;">&quot;^(www\.(.*)\.(.*))$&quot;</span><span style="color: #009900;">&#123;</span>  <span style="color: #666666; font-style: italic;">#nur wenn es nicht schon www. ist
</span>                <span style="color: #000088;">$HTTP</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;host&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>~ <span style="color: #0000ff;">&quot;^(.*)\.(.*)\.(.*)$&quot;</span> <span style="color: #009900;">&#123;</span>   <span style="color: #666666; font-style: italic;">#falls es sich um xxx.*.* handelt
</span>                        url<span style="color: #339933;">.</span>redirect <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;.*&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;http://www.%2.%3&quot;</span> <span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000088;">$HTTP</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;host&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>~ <span style="color: #0000ff;">&quot;^([^.]*)\.([^.]*)$&quot;</span> <span style="color: #009900;">&#123;</span>    <span style="color: #666666; font-style: italic;">#falls es sich um *.* handelt (ohne Subdomain)
</span>                        url<span style="color: #339933;">.</span>redirect <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;.*&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;http://www.%1.%2&quot;</span> <span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Will man nun noch forum.example.de (nur die .de Variante) erlauben, muss man diese Expression &#8220;^(www\.(.*)\.(.*))$&#8221; auf &#8220;^(www\.(.*)|forum\.example\.de)$&#8221; abändern.</p>
]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/298/lighttpd-alle-subdomains-auf-www-domain-tld-umleiten/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML zu PDF umwandeln, endlich &#8220;einfach&#8221; (Plattformunabhängig)</title>
		<link>http://xfragger.de/286/html-zu-pdf-umwandeln-endlich-einfach-plattformunabhangig</link>
		<comments>http://xfragger.de/286/html-zu-pdf-umwandeln-endlich-einfach-plattformunabhangig#comments</comments>
		<pubDate>Sun, 01 Aug 2010 12:47:26 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[html2pdf pdf html koverter]]></category>

		<guid isPermaLink="false">http://xfragger.de/?p=286</guid>
		<description><![CDATA[Mal wieder auf der Suche nach einer sinnvollen HTML2PDF Lösung, bin ich auf wkhtmltopdf gestoßen. Das Tool nutzt Webkit im internen Backend und kann sogar CSS3 rendern. Die Installation unter MaxOSX und Linux ist absolut simpel: runterladen, ablegen, fertig. Unter Windows wird hier noch ein Installationsprozess durchgeführt, über den ich aktuell leider nichts sagen kann [...]]]></description>
			<content:encoded><![CDATA[<p>Mal wieder auf der Suche nach einer sinnvollen HTML2PDF Lösung, bin ich auf <a href="http://code.google.com/p/wkhtmltopdf/" target="_blank">wkhtmltopdf</a> gestoßen.</p>
<p>Das Tool nutzt <a href="http://webkit.org/" target="_blank">Webkit</a> im internen Backend und kann sogar CSS3 rendern. Die Installation unter MaxOSX und Linux ist absolut simpel: runterladen, ablegen, fertig. Unter Windows wird hier noch ein Installationsprozess durchgeführt, über den ich aktuell leider nichts sagen kann (bisher nicht getestet).</p>
<p>Um das Tool auf einer Webseite zu nutzen, habe ich mir ne kleine Klasse geschrieben, die HTML-Code als Input akzeptiert und mir den Pfad der fertigen PDF-Datei zurückliefert.</p>
<p><span id="more-286"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> HtmlToPdf <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">const</span> TMP <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/tmp/'</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">const</span> <span style="color: #990000;">EXEC</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/usr/local/bin/wkhtmltopdf-amd64'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//anpassen!</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$executable</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$htmlcode</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$tmphtmlfile</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$targetFilename</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'--ignore-load-errors'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Kommandozeilenoptionen für wkhtmltopdf</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$targetFilename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">targetFilename</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$targetFilename</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setHtmlCode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$htmlcode</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">htmlcode</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$htmlcode</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setTargetFilename<span style="color: #009900;">&#40;</span><span style="color: #000088;">$targetFilename</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">targetFilename</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$targetFilename</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> generate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createTempHtmlFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">convertHtmlfileToPdf</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">TMP</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">targetFilename</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createTempHtmlFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">tempnam</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">TMP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">File</span><span style="color: #339933;">::</span><span style="color: #004000;">move</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filename</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//nötig, damit die Datei als Input akzeptiert wird</span>
		<span style="color: #000088;">$filename</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'.html'</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">htmlcode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tmphtmlfile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$filename</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> convertHtmlfileToPdf<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">targetFilename</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">generateTargetFilename</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: #000088;">$cmd</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #990000;">EXEC</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tmphtmlfile</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">TMP</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">targetFilename</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">shell_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cmd</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">File</span><span style="color: #339933;">::</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tmphtmlfile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> generateTargetFilename<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">targetFilename</span> <span style="color: #339933;">=</span> uniqueid<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.pdf'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Und so nutzt man das Ganze:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$converter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HtmlToPdf<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'output.pdf'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$converter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setHtmlCode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$htmlcodeWithCSS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pdfFile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$converter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">generate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Sehr praktisch ist es, wenn man eine Templateengine (z.B. Smarty) nutzt, hier kann man erst den kompletten Code generieren und ihn dann via $smarty->fetch() in den Konverter übergeben. Über einen Parameter kann man dann noch dafür sorgen, dass der CSS Style nicht ausgelagert, sondern im head-Block ausgegeben wird, da das Tool sonst nicht damit klarkommt.</p>
]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/286/html-zu-pdf-umwandeln-endlich-einfach-plattformunabhangig/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP 5.3 DateTime Objekt &#8211; schwerwiegender Bug?</title>
		<link>http://xfragger.de/275/php-5-3-datetime-objekt-schwerwiegender-bug</link>
		<comments>http://xfragger.de/275/php-5-3-datetime-objekt-schwerwiegender-bug#comments</comments>
		<pubDate>Wed, 14 Jul 2010 20:14:29 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[zenddate]]></category>

		<guid isPermaLink="false">http://xfragger.de/?p=275</guid>
		<description><![CDATA[Eigentlich war ich ziemlich begeistert, vom DateTime Objekt. Endlich richtig einfach mit Daten umgehen und das auch noch inkl Zeitzonen etc. Seitdem ich allerdings mit einem Kollegen einen wirklich &#8220;krassen&#8221; Bug fand, bin ich nicht mehr so begeistert! Reproduzierbar ist er folgendermaßen: $from = new DateTime&#40;&#41;; $from-&#62;setTime&#40;0, 0, 0&#41;; $from-&#62;setISODate&#40;2010, 28, 1&#41;; //Montag der 28ten [...]]]></description>
			<content:encoded><![CDATA[<p>Eigentlich war ich ziemlich begeistert, vom <a href="http://de.php.net/manual/de/class.datetime.php" target="_blank">DateTime Objekt</a>. Endlich richtig einfach mit Daten umgehen und das auch noch inkl Zeitzonen etc.<br />
Seitdem ich allerdings mit einem Kollegen einen wirklich &#8220;krassen&#8221; Bug fand, bin ich nicht mehr so begeistert!</p>
<p>Reproduzierbar ist er folgendermaßen:<br />
<span id="more-275"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$from</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$from</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</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: #000088;">$from</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setISODate</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2010</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">28</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Montag der 28ten Woche 2010</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$from</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d.m.Y H:i'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//A</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$from</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTimestamp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//B</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d H:i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$from</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTimestamp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//C</span></pre></div></div>

<p>A: das ausgegeben Datum stimmt, es ist der 12.07.2010<br />
B: der Timestamp ist viel zu hoch: 1291849200<br />
C: der Beweis, der Timestamp gehört zum 29.05.2011 00:00</p>
<p>Wir haben lange versucht herauszufinden, warum dies passiert. Ein hässlicher Workaround ist dieser:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$from</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DateInterval<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'P0D'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Wir fügen also ein Interval von 0 Tagen (oder Stunden, Minuten etc) hinzu, wodurch sich eigentlich nichts ändern sollte. Danach stimmt das Ergebnis von ->getTimestamp() allerdings, nämlich 1278885600. </p>
<p>Nachdem wir absolut keinen Grund feststellen konnten, haben wir das Vertrauen verloren und nutzen seitdem <a href="http://zendframework.com/manual/de/zend.date.html" target="_blank">Zend_Date</a>, welches, meiner Meinung nach, besser und einfacher zu bedienen ist. Das ZendFramework ist sowieso schon im aktuellen Projekt eingebunden (nicht als Framework an sich, eher als Klassensammlung), als sprach es auch nicht dagegen, einen riesen Klotz an Dateien/Klassen zu integrieren, um nur eine Klasse zu nutzen.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWeek</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">28</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setYear</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2010</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWeekday</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setHour</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setMinute</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSecond</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTimestamp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Liefert das erwartete Ergebnis: 1278885600</p>
<p>Ist das nun wirklich ein riesen DateTime Bug oder liegt ein Denkfehler unsererseits vor?</p>
]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/275/php-5-3-datetime-objekt-schwerwiegender-bug/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Iterator oder IteratorAggregated Interface nutzen?</title>
		<link>http://xfragger.de/266/iterator-oder-iteratoraggregated-interface-nutzen</link>
		<comments>http://xfragger.de/266/iterator-oder-iteratoraggregated-interface-nutzen#comments</comments>
		<pubDate>Mon, 28 Jun 2010 20:30:56 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[arrayiterator]]></category>
		<category><![CDATA[iterator]]></category>
		<category><![CDATA[iteratoraggregate]]></category>
		<category><![CDATA[traversable]]></category>

		<guid isPermaLink="false">http://xfragger.de/?p=266</guid>
		<description><![CDATA[PHP bietet das Iterator Interface an, um Objekte direkt via foreach zu iterieren. class MyClass implements Interator &#123; private $array; &#125; &#160; $obj = new MyClass&#40;&#41;; foreach&#40;$obj as $key =&#62; $val&#41;&#123; ... &#125; Damit dieses Konstrukt funktioniert, benötigt die Klasse &#8220;MyClass&#8221; ein paar weitere Methoden und ein Attribut, welche vom Interface vorgeschrieben werden: public function [...]]]></description>
			<content:encoded><![CDATA[<p>PHP bietet das <a href="http://de.php.net/manual/de/class.iterator.php" target="_blank">Iterator</a> Interface an, um Objekte direkt via foreach zu iterieren.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MyClass implements Interator <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$array</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$obj</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #339933;">...</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><span id="more-266"></span><br />
Damit dieses Konstrukt funktioniert, benötigt die Klasse &#8220;MyClass&#8221; ein paar weitere Methoden und ein Attribut, welche vom Interface vorgeschrieben werden:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">rewind</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pointer</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">current</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pointer</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pointer</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pointer</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> valid<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pointer</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Nun geht das ganze aber auch viel einfacher und mit saubererem Code, mit dem <a href="http://de.php.net/manual/de/class.iteratoraggregate.php" target="_blank">IteratorAggregate</a> Interface und einem <a href="http://de.php.net/manual/de/spl.iterators.php" target="_blank">schon vorhandenem Iterator</a> (wie dem <a href="http://de.php.net/manual/de/class.arrayiterator.php" target="_blank">ArrayIterator</a>). Das Interface ist ziemlich Ähnlich und implementiert ebenfalls <a href="http://de.php.net/manual/de/class.traversable.php" target="_blank">Traversable</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MyClass implements IteratorAggregate <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$array</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getIterator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayIterator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$obj</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$obj</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #339933;">...</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/266/iterator-oder-iteratoraggregated-interface-nutzen/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress 3 MU auf lighttpd und das &#8220;langsame Bilder&#8221;-Problem</title>
		<link>http://xfragger.de/257/wordpress-3-mu-auf-lighttpd-und-das-langsame-bilder-problem</link>
		<comments>http://xfragger.de/257/wordpress-3-mu-auf-lighttpd-und-das-langsame-bilder-problem#comments</comments>
		<pubDate>Fri, 25 Jun 2010 19:32:54 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Webserver]]></category>
		<category><![CDATA[blogs.php]]></category>
		<category><![CDATA[langsam]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[ms-files.php]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress 3]]></category>
		<category><![CDATA[wordpress mu]]></category>

		<guid isPermaLink="false">http://xfragger.de/?p=257</guid>
		<description><![CDATA[Dieser und der ein oder andere Blog, welche hauptsächlich von meiner Frau betrieben werden, läuft nun auf WordPress 3, weil es mir auf den Geist ging immer x Blogs aktuell zu halten, laufen nun alle mit aktiviertem MU. Da auf meinem Websever lighttpd und nicht apache läuft, konnte ich mich nicht 100%ig an die Anleitung [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://xfragger.de/wp-content/uploads/2010/06/wordpress-300x299.png" rel="lightbox[257]"><img class="alignleft size-thumbnail wp-image-259" title="wordpress-300x299" src="http://xfragger.de/wp-content/uploads/2010/06/wordpress-300x299-150x150.png" alt="" width="150" height="150" /></a>Dieser und der ein oder andere Blog, welche hauptsächlich von meiner Frau betrieben werden, läuft nun auf WordPress 3, weil es mir auf den Geist ging immer x Blogs aktuell zu halten, laufen nun alle mit aktiviertem MU.</p>
<p>Da auf meinem Websever lighttpd und nicht apache läuft, konnte ich mich nicht 100%ig an die Anleitung auf der WP MU Seite halten.</p>
<p><span id="more-257"></span>In lighttpd gibt es kein .htaccess, also müssen die Rewriteregeln (ich nutze Subdomains, keine Unterverzeichnisse), in die lighttpd-config. Das ganze sieht so aus:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$HTTP</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;host&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>~ <span style="color: #0000ff;">&quot;^((.*).?example\.de)$&quot;</span> <span style="color: #009900;">&#123;</span>
  server<span style="color: #339933;">.</span>document<span style="color: #339933;">-</span>root <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/var/www/.../wp3/&quot;</span>
  server<span style="color: #339933;">.</span>error<span style="color: #339933;">-</span>handler<span style="color: #339933;">-</span><span style="color: #cc66cc;">404</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/index.php&quot;</span>  <span style="color: #666666; font-style: italic;">#hierdurch erspart man sich rewrite regeln für schöne permalinks
</span>  url<span style="color: #339933;">.</span>rewrite<span style="color: #339933;">-</span>once <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">&quot;^/(.*/)?files/$&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;/index.php&quot;</span><span style="color: #339933;">,</span>
   <span style="color: #0000ff;">&quot;^/(.*/)?files/(.*)&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;/wp-content/blogs.php?file=<span style="color: #006699; font-weight: bold;">$2</span>&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&quot;^/([_0-9a-zA-Z-]+/)?(wp-.*)&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$2</span>&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">&quot;^/([_0-9a-zA-Z-]+/)?(.*\.php)$&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$2</span>&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Der Rest lief einwandfrei nach offizieller Anleitung, da in einigen der anderen Blogs allerdings recht viele Bilder sind, viel mir sofort die mangelnde Performance diesbezüglich auf. Der Grund war schnell gefunden, gab es 40 Bilder auf einer Seite, bedeutete dies, aufgrund der zweiten Rewriteregel, jeweils einen Aufruf eines PHP Skriptes, welches einen ganzen Schweif an includes inkl. Datenbankverbindungen und Queries mit sich bringt.</p>
<p>Die Lösung war, mit ein wenig Linuxwissen, aber schnell gefunden: Symlinks für jeden einzelnen Blog. Erfordert zwar ein wenig mehr Verwaltungsaufwand, spart aber das Umleiten über ein PHP Skript, um Bilder anzuzeigen. Die Regel muss dann so aussehen:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #0000ff;">&quot;^/(.*/)?files/(.*)$&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;/wp-content/blogs.dir/%0/files/<span style="color: #006699; font-weight: bold;">$2</span>&quot;</span><span style="color: #339933;">,</span></pre></div></div>

<p>Das %0 funktioniert so nur, weil die Hostdefinition (Zeile 1 im oberen Code) als Pattern definiert ist!</p>
<p>Im, laut Anleitung angelegten, blogs.dir Verzeichnis müssen nun Symlinks angelegt werden:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">ln <span style="color: #339933;">-</span>s <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span>www<span style="color: #339933;">/.../</span>wp3<span style="color: #339933;">/</span>wp<span style="color: #339933;">-</span>content<span style="color: #339933;">/</span>blogs<span style="color: #339933;">.</span><span style="color: #990000;">dir</span><span style="color: #339933;">/</span><span style="color: #009900;">&#91;</span>BlogID<span style="color: #009900;">&#93;</span> <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span>www<span style="color: #339933;">/.../</span>wp3<span style="color: #339933;">/</span>wp<span style="color: #339933;">-</span>content<span style="color: #339933;">/</span>blogs<span style="color: #339933;">.</span><span style="color: #990000;">dir</span><span style="color: #339933;">/</span><span style="color: #009900;">&#91;</span>subdomain<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span>example<span style="color: #339933;">.</span>de</pre></div></div>

<p>Falls jemand eine elegantere Lösung kennt, als für jeden Blog einen Symlink anzulegen, als her damit!</p>
]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/257/wordpress-3-mu-auf-lighttpd-und-das-langsame-bilder-problem/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Performance Blog verlost 2 PHP Magazin Jahresabos</title>
		<link>http://xfragger.de/254/php-performance-blog-verlost-2-php-magazin-jahresabos</link>
		<comments>http://xfragger.de/254/php-performance-blog-verlost-2-php-magazin-jahresabos#comments</comments>
		<pubDate>Fri, 18 Jun 2010 18:31:43 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[gewinnspiel]]></category>
		<category><![CDATA[php magazin]]></category>

		<guid isPermaLink="false">http://blog.xfragger.de/?p=254</guid>
		<description><![CDATA[Ich denke der Titel sagt alles, hier die Teilnahmebedingungen http://phpperformance.de/php-magazin-abo-verlosung-gewinne-eines-von-zwei-jahresabos/]]></description>
			<content:encoded><![CDATA[<p>Ich denke der Titel sagt alles, hier die Teilnahmebedingungen<br />
<a href="http://phpperformance.de/php-magazin-abo-verlosung-gewinne-eines-von-zwei-jahresabos/">http://phpperformance.de/php-magazin-abo-verlosung-gewinne-eines-von-zwei-jahresabos/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/254/php-performance-blog-verlost-2-php-magazin-jahresabos/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL: Index über mehrere Spalten</title>
		<link>http://xfragger.de/246/mysql-index-uber-mehrere-spalten</link>
		<comments>http://xfragger.de/246/mysql-index-uber-mehrere-spalten#comments</comments>
		<pubDate>Wed, 21 Apr 2010 19:41:58 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[optimierung]]></category>
		<category><![CDATA[query optimierung]]></category>

		<guid isPermaLink="false">http://blog.xfragger.de/?p=246</guid>
		<description><![CDATA[Ich habe bereits mehrfach mitbekommen, dass anscheinend kaum jemand weiß, dass man Indizes auch über mehrere Spalten anlegen kann. Zuerst sollte erwähnt werden, dass MySQL im Normalfall pro Query nur EINEN pro Tabelle Index auf einmal nutzen kann (es gibt Ausnahmen, merged-index, aber nur unter bestimmten Umständen in bestimmten Queries). Ein Beispiel für den Einsatz [...]]]></description>
			<content:encoded><![CDATA[<p>Ich habe bereits mehrfach mitbekommen, dass anscheinend kaum jemand weiß, dass man Indizes auch über mehrere Spalten anlegen kann.</p>
<p>Zuerst sollte erwähnt werden, dass MySQL im Normalfall pro Query nur EINEN pro Tabelle Index auf einmal nutzen kann (es gibt Ausnahmen, merged-index, aber nur unter bestimmten Umständen in bestimmten Queries).</p>
<p>Ein Beispiel für den Einsatz eines Index über mehrere Spalten, wäre z.B. das folgende:</p>
<p><span id="more-246"></span>Eine Tabelle, in welcher Nachrichten zwischen Benutzern aufbewahrt werden, folgende Spalten sind vorhanden:</p>
<p>ID (int), receiverUserID(int), senderUserID(int), subject(varchar), text(text), time(int)</p>
<p>Wollen wir nun alle Nachrichten finden, die User 123 an User 234 geschickt hat und das Ergebnis noch nach Zeit sortieren, brauchen wir folgendes Query:</p>
<pre>
SELECT ID, subject, text, time
FROM message
WHERE receiverUserID = 234 AND senderUserID = 123
ORDER BY time ASC
</pre>
<p>Zuerst fällt auf, dass man die Nachrichten nach ID sortieren kann, was im Normalfall besser ist, als nach time, da wir davon ausgehen, dass die ID sich von Nachricht zu Nachricht um eins erhöht und die neusten somit die höchsten IDs haben.</p>
<p>Ohne das Wissen, dass es mehrspaltige Indizes gibt, würde man einen Index auf receiverUserID oder senderUserID legen, alternativ sogar beides, allerdings würde MySQL dann nur einen von beiden nutzen.<br />
Also legt man einen über beide an, was bei großen Datenmengen einen extremen Geschwindigkeitsschub bringen kann.</p>
<p>Um die Sortierung nun auch noch über den Index zu regeln, könnten man als dritte Spalte nun noch die ID in den Index aufnehmen, was allerdings nur sinnig ist, wenn man davon ausgeht, dass das Ergebnis wirklich viele Ergebnisse erzielen wird.</p>
]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/246/mysql-index-uber-mehrere-spalten/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>High Performance MySQL Konfiguration &#8211; my.cnf</title>
		<link>http://xfragger.de/243/high-performance-mysql-konfiguration-my-cnf</link>
		<comments>http://xfragger.de/243/high-performance-mysql-konfiguration-my-cnf#comments</comments>
		<pubDate>Fri, 02 Apr 2010 10:37:38 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[high performance]]></category>
		<category><![CDATA[konfiguration]]></category>
		<category><![CDATA[my.cnf]]></category>

		<guid isPermaLink="false">http://blog.xfragger.de/?p=243</guid>
		<description><![CDATA[Ich beschäftige mich aus beruflichen Gründen schon recht lange mit der Thematik und möchte das gesammelte Wissen nun mal niederschreiben. Es gibt definitiv keine Konfiguration, die allgemeingültig ist, aber ich versuche hiermit eine Hilfestellung zu geben, wie man die besten Werte für die eigenen Bedürfnisse findet. Nicht nur der Server spielt eine Rolle, auch die [...]]]></description>
			<content:encoded><![CDATA[<p>Ich beschäftige mich aus beruflichen Gründen schon recht lange mit der Thematik und möchte das gesammelte Wissen nun mal niederschreiben.</p>
<p>Es gibt definitiv keine Konfiguration, die allgemeingültig ist, aber ich versuche hiermit eine Hilfestellung zu geben, wie man die besten Werte für die eigenen Bedürfnisse findet.</p>
<p>Nicht nur der Server spielt eine Rolle, auch die Storage-Engine, um sich viel Stress zu ersparen, sollte man im vorraus planen, was man braucht und für welche Engine man sich entscheidet. Auch hier gibt es keine Universallösung, jede hat ihre Vor- und Nachteile, aber darauf will ich in diesem Eintrag nicht eingehen.</p>
<p>Da ich für das aktuell laufende Projekt nur InnoDB einsetze, beziehen sich die Ratschläge auf eine reine InnoDB Konfiguration und sollten ab MySQL Version 5.0 funktionieren.</p>
<p><span id="more-243"></span>&#8220;<strong>innodb_dirty_pages_pct</strong>&#8221;<br />
Gibt an, wie viele  InnoDB-Buffer-Pages im RAM vorhanden sein dürfen, ohne auf Festplatte geschrieben worden zu sein. Standard ist 90%, was für die meisten Umgebungen absolut OK sein sollte.</p>
<p>&#8220;<strong>thread_cache_size</strong>&#8221;<br />
Wie viele Threads dürfen sich im Cache befinden? Jede Verbindung zum Server braucht einen eigenen Thread, ist die Verbindung beendet, kann der Thread im Cache gelagert werden und steht der nächsten Verbindung zur Verfügung. Threads zu erstellen ist unnötiger Overhead, &#8220;SHOW GLOBAL STATUS&#8221; auf der MySQL Konsole gibt in der Variable &#8220;threads_created&#8221; aus, wie viele Threads erstellt werden. Dieser Wert sollte um maximal 10 pro Sekunde steigen, steigt er schneller, kann der Thread-cache vergrößert werden.</p>
<p>&#8220;<strong>table_definition_cache</strong>&#8221;<br />
Sollte größer oder gleich der Anzahl der vorhandenen Tabellen sein um unnötigen I/O Overhead zu ersparen.</p>
<p>&#8220;<strong>innodb_open_files</strong>&#8221;<br />
Sollte größer oder gleich der Anzahl der vorhandenen .ibd Dateien im MySQL-Datenverzeichnis sein (bei Debian meistens /var/lib/mysql).</p>
<p>&#8220;<strong>innodb_log_buffer_size</strong>&#8221;<br />
Die globale Variable &#8220;innodb_os_log_written&#8221; hilft hier bei der Ermittlung eines sinnvollen Wertes, der Wert sollte nicht zu schnell steigen, hier kann I/O Performance gewonnen werden.</p>
<p>&#8220;<strong>skip_name_resolve</strong>&#8221;<br />
Sollte aktiv sein, damit nicht für jeden Client 2 DNS-Lookups stattfinden, gleichzeitig bedeutet dies, dass Berechtigungen nur noch auf IP und nicht auf Hostnamen-Ebene verteilt werden können.</p>
<p>&#8220;<strong>innodb_flush_method</strong>&#8221;<br />
Falls ein Hardware-Raid mit ordentlichem Cache und Battery-Backup genutzt wird, sollte hier 0_direct eingestellt werden, um zu verhindern, dass OS-Buffer genutzt werden, welche das Logfile unbrauchbar machen könnten, wenn der Server abstürzt.</p>
<p>&#8220;<strong>innodb_flush_log_at_trx</strong>&#8221;<br />
Sollte auf 1 gestellt werden, damit jede beendete Transaktion sofort im Binarylog landet, um Datenverlust zu verhindern, falls der Server abstürzt. Der Wert 1 ist der beste Kompromiss zwischen Performance und Datensicherheit!</p>
<p>Diverse Key-Buffers und andere Caches (ausgenommen dem Query-Cache) können sehr klein gehalten werden (nicht abschalten, MySQL nutzt MyISAM für die Metatabellen). Hier würde nur sinnlos RAM belegt werden!</p>
<p>Auf Linux-Systemen sollte die <strong>swappiness</strong> noch auf 0 oder 1 gestellt werden, um zu verhindern, dass der Kernel MySQL Buffers in den SWAP-Space verschiebt, falls diese länger nicht genutzt werden. Swap-I/O ist weitaus schlimmer als normaler HDD-I/O, da MySQL &#8220;denkt&#8221; es würde mit schnellem RAM arbeiten, welcher in Wirklichkeit aber auf der HDD im Swap zu finden ist. Auf Debian-Systemen kann man diesen Wert mittels /etc/sysctl.conf setzen (vm.swappiness = 0) und danach &#8220;sysctl -p&#8221; ausführen.</p>
<p>Der restlich verfügbare Arbeitsspeicher sollte dem <strong>InnoDB-Buffer-Pool</strong> zur Verfügung gestellt werden, ist dieser groß genug, kann auf nahezu alle HDD-Leseabfragen verzichtet werden und es entsteht nahezu nur noch Schreib-I/O.</p>
<p>Es gibt noch weitere Einstellungen bezüglich des InnoDB-Tablespace und allgemeinen Einstellungen, falls hier noch Intresse besteht, hinterlasst nen Kommentar, werde dann versuchen zeitnah einen weiteren Beitrag zu schreiben.</p>
]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/243/high-performance-mysql-konfiguration-my-cnf/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Haystack und Needle vertauschen &#8211; Wer kennts nicht?</title>
		<link>http://xfragger.de/240/haystack-und-needle-vertauschen-wer-kennts-nicht</link>
		<comments>http://xfragger.de/240/haystack-und-needle-vertauschen-wer-kennts-nicht#comments</comments>
		<pubDate>Sat, 20 Mar 2010 11:06:46 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[haystack]]></category>
		<category><![CDATA[needle]]></category>

		<guid isPermaLink="false">http://blog.xfragger.de/?p=240</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://xfragger.de/wp-content/uploads/2010/03/nedle-und-haystack.jpg" rel="lightbox[240]"><img class="aligncenter size-full wp-image-241" src="http://xfragger.de/wp-content/uploads/2010/03/nedle-und-haystack.jpg" alt="" width="600" height="848" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://xfragger.de/240/haystack-und-needle-vertauschen-wer-kennts-nicht/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

