<?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>iTeamWork &#187; H.Grafe</title>
	<atom:link href="http://iteamwork.de/author/hg4de/feed" rel="self" type="application/rss+xml" />
	<link>http://iteamwork.de</link>
	<description>Coding Tipps</description>
	<lastBuildDate>Thu, 06 Oct 2011 17:38:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Wie man schnellen Code schreibt</title>
		<link>http://iteamwork.de/wie-man-schnellen-code-schreibt.html</link>
		<comments>http://iteamwork.de/wie-man-schnellen-code-schreibt.html#comments</comments>
		<pubDate>Tue, 05 Apr 2011 22:41:35 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Programmierung]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=114</guid>
		<description><![CDATA[Ein Interessanter Artikel zum Thema wie man schnellen Code schreibt. Sehr zu empfehlen: How to write fast code]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fwie-man-schnellen-code-schreibt.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fwie-man-schnellen-code-schreibt.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Ein Interessanter Artikel zum Thema wie man schnellen Code schreibt. Sehr zu empfehlen: <a href="http://asserttrue.blogspot.com/2009/03/how-to-write-fast-code.html">How to write fast code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/wie-man-schnellen-code-schreibt.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PHP] Prüfen ob Interface implementiert wurde</title>
		<link>http://iteamwork.de/php-prufen-ob-interface-implementiert-wurde.html</link>
		<comments>http://iteamwork.de/php-prufen-ob-interface-implementiert-wurde.html#comments</comments>
		<pubDate>Wed, 31 Mar 2010 23:29:04 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[implementiert]]></category>
		<category><![CDATA[instanceof]]></category>
		<category><![CDATA[interface]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=74</guid>
		<description><![CDATA[Wie kann man überprüfen ob eine Klasse ein Interface implementiert?]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fphp-prufen-ob-interface-implementiert-wurde.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fphp-prufen-ob-interface-implementiert-wurde.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Vor kurzem habe ich gezeigt wie man ein Interface erstellt und dieses Implementiert. Nun ist es durchaus von Interesse zu prüfen ob eine Klasse dieses Interface implementiert hat. Dies geht wie folgt:<br />
<span id="more-74"></span></p>
<blockquote><p>$p=new klasseMitInterface($db);<br />
if ($p instanceof  Plugin2)<br />
{<br />
//Interface implementiert<br />
}<br />
else<br />
{<br />
//leider nein<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/php-prufen-ob-interface-implementiert-wurde.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PHP] Interfaces implementieren</title>
		<link>http://iteamwork.de/php-interfaces-implementieren.html</link>
		<comments>http://iteamwork.de/php-interfaces-implementieren.html#comments</comments>
		<pubDate>Fri, 19 Mar 2010 23:26:02 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[implementieren]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[Klasse]]></category>
		<category><![CDATA[Vererbung]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=67</guid>
		<description><![CDATA[Was sind interfaces und wie benutzt man sie?]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fphp-interfaces-implementieren.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fphp-interfaces-implementieren.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Interfaces definieren eine Schnittstelle nach Außen. Durch Sie ist sichergestellt das bestimmte Funktionen vorhanden sind und exakt so aussehen wie sie definiert wurden.</p>
<p>In PHP wird ein Interface wie folgt definiert:</p>
<blockquote><p>interface Plugin<br />
{<br />
public function __construct($db);<br />
public function start();<br />
}</p></blockquote>
<p>Hier wird definiert das die Klasse welches das Interface implementiert einen Konstruktor haben muss der als Parameter eine Variable nimmt. Außerdem muss eine Methode vorhanden sein die start heißt und keine Parameter benötigt.</p>
<p>Implementiert wird das ganze wie folgt:</p>
<p><span id="more-67"></span></p>
<blockquote><p>class Ueberweisung implements Plugin<br />
{</p>
<p>function __construct($db)<br />
{<br />
//&#8230;<br />
}<br />
function start()<br />
{<br />
//&#8230;<br />
}<br />
}</p></blockquote>
<p>Nur wenn alle Funktionen implemtiert wirden funktioniert dies. Ansonsten gibt der PHP Interpretor eine Error Meldung.</p>
<p>Es ist auch möglich das ein Interface von einem anderen erbt.</p>
<blockquote><p>interface Plugin2 extends Plugin<br />
{<br />
public function machwas();<br />
}</p></blockquote>
<p>Eine Klasse die jetzt Plugin2 implementiert muss nun alle Methoden von Plugin und Plugin2 bereitstellen.</p>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/php-interfaces-implementieren.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[TRICKS] Schneller navigieren in PHPMyAdmin</title>
		<link>http://iteamwork.de/schneller-navigieren-in-phpmyadmin.html</link>
		<comments>http://iteamwork.de/schneller-navigieren-in-phpmyadmin.html#comments</comments>
		<pubDate>Sat, 20 Feb 2010 23:39:20 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=65</guid>
		<description><![CDATA[In PHPMyAdmin gibt es die Möglichkeit, links in der Zeile mit den Tabellennamen dem Symbol einen anderen Link zuzuweisen als dem Text.  So kann man z.B. über das Symbol die Daten anzeigen lassen und über den Namen die Struktur. Dies spart im normalen Arbeitsablauf normalerweise viel Zeit. Dazu muss in der config.inc.php nur folgendes Ergänzt [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fschneller-navigieren-in-phpmyadmin.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fschneller-navigieren-in-phpmyadmin.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In PHPMyAdmin gibt es die Möglichkeit, links in der Zeile mit den Tabellennamen dem Symbol einen anderen Link zuzuweisen als dem Text.  So kann man z.B. über das Symbol die Daten anzeigen lassen und über den Namen die Struktur.</p>
<p>Dies spart im normalen Arbeitsablauf normalerweise viel Zeit.</p>
<p>Dazu muss in der config.inc.php nur folgendes Ergänzt werden:</p>
<div class="codesnip-container" >$cfg['LeftDefaultTabTable']=&#8217;sql.php&#8217;;<br />
$cfg['DefaultTabTable']=&#8217;tbl_structure.php&#8217;;</div>
<p>Der erste Wert ändert den Link des Symbols, der zweite den des Textes.</p>
<p>Mögliche Werte sind:  &#8220;tbl_structure.php&#8221;,         &#8220;tbl_sql.php&#8221;, &#8220;tbl_select.php&#8221;,         &#8220;tbl_change.php&#8221; und &#8220;sql.php&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/schneller-navigieren-in-phpmyadmin.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[SQL] Spaltennamen auslesen</title>
		<link>http://iteamwork.de/sql-spaltennamen-auslesen.html</link>
		<comments>http://iteamwork.de/sql-spaltennamen-auslesen.html#comments</comments>
		<pubDate>Sun, 03 Jan 2010 16:15:49 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=62</guid>
		<description><![CDATA[Manchmal kommt es vor, das man die Spaltennamen einer Tabelle auslesen will. Im Prinzip ganz einfach, wenn man weiß wie es geht: MS Sql: SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &#8216;foo&#8217; My Sql: SHOW COLUMNS FROM foo; Oracle: SELECT column_name FROM all_tab_columns WHERE table_name= &#8216;foo&#8217;;]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fsql-spaltennamen-auslesen.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fsql-spaltennamen-auslesen.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Manchmal kommt es vor, das man die Spaltennamen einer Tabelle auslesen will.</p>
<p>Im Prinzip ganz einfach, wenn man weiß wie es geht:</p>
<p><span id="more-62"></span>MS Sql:</p>
<blockquote>
<div>
<div><span>SELECT</span> column_name <span>FROM</span> INFORMATION_SCHEMA.<span>COLUMNS</span> <span>WHERE</span> TABLE_NAME = <span>&#8216;foo&#8217;</span></div>
</div>
</blockquote>
<div><span>My Sql:</span></div>
<blockquote>
<div>SHOW COLUMNS FROM foo;</div>
</blockquote>
<div>Oracle:</div>
<blockquote>
<div>SELECT column_name FROM all_tab_columns WHERE table_name= &#8216;foo&#8217;;</div>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/sql-spaltennamen-auslesen.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[SQL] mysqldump: Couldn&#8217;t execute &#8216;show fields from `table`&#8217;: Can&#8217;t create/write to file &#8216;/tmp/#sql_735_0.MYI&#8217;</title>
		<link>http://iteamwork.de/mysqldump-couldnt-execute-show-fields-from-table-cant-createwrite-to-file-tmpsql_735_0myi.html</link>
		<comments>http://iteamwork.de/mysqldump-couldnt-execute-show-fields-from-table-cant-createwrite-to-file-tmpsql_735_0myi.html#comments</comments>
		<pubDate>Tue, 14 Apr 2009 15:45:56 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tricks]]></category>
		<category><![CDATA[ausführrechte]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[execute]]></category>
		<category><![CDATA[leserechte]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[rechte]]></category>
		<category><![CDATA[schreibrechte]]></category>
		<category><![CDATA[show]]></category>
		<category><![CDATA[tmp]]></category>
		<category><![CDATA[write]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=23</guid>
		<description><![CDATA[Folgende Fehlermeldung habe ich heute bekommen: mysqldump: Couldn&#8217;t execute &#8216;show fields from `table`&#8217;: Can&#8217;t create/write to file &#8216;/tmp/#sql_735_0.MYI&#8217; Nachdem ich lange gegrübelt habe, was ich überhaupt geändert habe, ist mir eingefallen das ich die Rechte des /tmp Verzeichnisses auf 666 geändert habe (read + write für jeden). Dies ist zwar kein Grund, das man da [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fmysqldump-couldnt-execute-show-fields-from-table-cant-createwrite-to-file-tmpsql_735_0myi.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fmysqldump-couldnt-execute-show-fields-from-table-cant-createwrite-to-file-tmpsql_735_0myi.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Folgende Fehlermeldung habe ich heute bekommen:</p>
<blockquote><p>mysqldump: Couldn&#8217;t execute &#8216;show fields from `table`&#8217;: Can&#8217;t create/write to file &#8216;/tmp/#sql_735_0.MYI&#8217;</p></blockquote>
<p><span id="more-23"></span></p>
<p>Nachdem ich lange gegrübelt habe, was ich überhaupt geändert habe, ist mir eingefallen das ich die Rechte des /tmp Verzeichnisses auf 666 geändert habe (read + write für jeden). Dies ist zwar kein Grund, das man da nicht mehr reinschreiben kann, aber scheinbar benötigt mysql für diverse Befehle auch ausführ (x) Rechte auf dem tmp Ordner.</p>
<p>Also abhilfe für das Problem: dem /tmp Ordner wieder x Rechte geben (nicht zu empfehlen) oder das tmp Verzeichnis vom MySQL Server in der my.cnf umlegen.</p>
<p>Und schon klappt es auch wieder mit dem Show Befehl.</p>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/mysqldump-couldnt-execute-show-fields-from-table-cant-createwrite-to-file-tmpsql_735_0myi.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[APACHE] pcfg_openfile: unable to check htaccess file</title>
		<link>http://iteamwork.de/pcfg_openfile-unable-to-check-htaccess-file.html</link>
		<comments>http://iteamwork.de/pcfg_openfile-unable-to-check-htaccess-file.html#comments</comments>
		<pubDate>Thu, 05 Feb 2009 16:27:24 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[denied]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[pcfg_openfile]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[readable]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=22</guid>
		<description><![CDATA[(13)Permission denied: /var/www/webxx/html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable Ich wusste, das ich den Fehler schonmal hatte. Doch woran lag das nochmal? Richtig, der Webserver kann nicht auf das Verzeichnis zugreifen. In Verbindung mit suPHP ist der Webserver in der Kategorie &#8220;Other&#8221; so das auch other leserechte aufs Document Root braucht: [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fpcfg_openfile-unable-to-check-htaccess-file.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fpcfg_openfile-unable-to-check-htaccess-file.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<blockquote><p>(13)Permission denied: /var/www/webxx/html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable</p></blockquote>
<p>Ich wusste, das ich den Fehler schonmal hatte. Doch woran lag das nochmal?</p>
<p>Richtig, der Webserver kann nicht auf das Verzeichnis zugreifen.</p>
<p>In Verbindung mit suPHP ist der Webserver in der Kategorie &#8220;Other&#8221; so das auch other leserechte aufs Document Root braucht:</p>
<blockquote><p>chmod o+r /var/www/webx/html</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/pcfg_openfile-unable-to-check-htaccess-file.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[SQL] IP Adressen speichern</title>
		<link>http://iteamwork.de/ip-adressen-speichern.html</link>
		<comments>http://iteamwork.de/ip-adressen-speichern.html#comments</comments>
		<pubDate>Thu, 16 Oct 2008 19:33:21 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[adressen]]></category>
		<category><![CDATA[inet_aton]]></category>
		<category><![CDATA[inet_ntoa]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[speichern]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=21</guid>
		<description><![CDATA[Oft werden IP Adressen in einer Datenbank als Varchar(15) gespeichert. Doch das braucht 16 Byte pro Adresse. Wenn man sie als Int wert speichern würde, würde man nur 4 Byte brauchen. Das ist eine Ersparnis von 75%! Außerdem hat das den weiteren Vorteil, das man in den IP Adressen gut suchen kann. Also speichern wir [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fip-adressen-speichern.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fip-adressen-speichern.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Oft werden IP Adressen in einer Datenbank als Varchar(15) gespeichert. Doch das braucht 16 Byte pro Adresse. Wenn man sie als Int wert speichern würde, würde man nur 4 Byte brauchen. Das ist eine Ersparnis von 75%!</p>
<p>Außerdem hat das den weiteren Vorteil, das man in den IP Adressen gut suchen kann.</p>
<p>Also speichern wir sie doch in Zukunft als Int:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">INSERT</span> <span class="kw1">INTO</span> <span class="sy0">&#8230;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span>INET_ATON<span class="br0">&#40;</span><span class="st0">&quot;127.0.0.1&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
</div>
<p>zurückrechnen lässt es sich mit:</p>
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1">INET_NTOA<span class="br0">&#40;</span>feldname<span class="br0">&#41;</span></div>
</li>
</ol>
</div>
</div>
<p>Eigentlich ganz einfach und 75% Platz gespart <img src='http://iteamwork.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Und wir können nun mit dem kleiner und größer Operator ganz einfach auf bestimmte IP Bereiche testen z.B. um diese zu filtern.</p>
<p>Erklärung warum das so ist:</p>
<p>IP-Adresse: 127.0.0.1<br />
-&gt; IP in Hex: 0x7F.0&#215;00.0&#215;00.0×01<br />
-&gt; Punkte entfernen: 0x7F000001<br />
-&gt; Dezimal: 2130706433</p>
<p>Das lässt sich natürlich auch wieder zurückrechnen <img src='http://iteamwork.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/ip-adressen-speichern.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PHP] Javascript und CSS Dateien komprimieren</title>
		<link>http://iteamwork.de/javascript-und-css-dateien-komprimieren.html</link>
		<comments>http://iteamwork.de/javascript-und-css-dateien-komprimieren.html#comments</comments>
		<pubDate>Tue, 05 Aug 2008 10:44:39 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Snippets]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[komprimieren]]></category>
		<category><![CDATA[optimieren]]></category>
		<category><![CDATA[platz sparen]]></category>
		<category><![CDATA[stylesheets]]></category>
		<category><![CDATA[verkleinern]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=20</guid>
		<description><![CDATA[Relativ viel Performance kostet es, mehrere Javascript und/oder Stylesheet Dateien einzubinden. Zwar geht die Abarbeitung relativ fix dank keep-alive aber dennoch kostet es Zeit. Bestimmte Javascript Bibiotheken bestehen ja schonmal locker aus 10 Dateien. Daher kann es sinnvoll sein, mehrere Dateien in einer Zusammenzufassen. Weiterhin ist so die Möglichkeit gegeben, evtl noch etwas nachzubearbeiten um [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fjavascript-und-css-dateien-komprimieren.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fjavascript-und-css-dateien-komprimieren.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Relativ viel Performance kostet es, mehrere Javascript und/oder Stylesheet Dateien einzubinden. Zwar geht die Abarbeitung relativ fix dank keep-alive aber dennoch kostet es Zeit. Bestimmte Javascript Bibiotheken bestehen ja schonmal locker aus 10 Dateien.</p>
<p>Daher kann es sinnvoll sein, mehrere Dateien in einer Zusammenzufassen.</p>
<p>Weiterhin ist so die Möglichkeit gegeben, evtl noch etwas nachzubearbeiten um weitere Dateigröße einzusparen.</p>
<p>Besonders User mit langsammen Verbindungen würden dies dankbar annehmen.</p>
<p><span id="more-20"></span></p>
<p>Nehmen wir also an, wir nutzen folgende beiden Dateien:</p>
<blockquote><p>&lt;script src=&#8221;script/script1.js&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;<br />
&lt;script src=&#8221;script/script2.js&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;</p></blockquote>
<p>dann ersetzen wir das durch:</p>
<blockquote><p>&lt;script src=&#8221;javascript.php&#8221; type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;</p></blockquote>
<p>Dieses müssen wir dann nur noch wie folgt anlegen:</p>
<blockquote><p>&lt;?php<br />
header(‘Content-type: application/javascript’); //Typ setzen<br />
//Dateien ausgeben<br />
require_once(’script/script1.js’);<br />
require_once(’script/script2.js’);<br />
?&gt;</p></blockquote>
<p>Das wars auch schon. Nun werden beide Dateien in einer ausgegeben. Dabei muss lediglich drauf geachtet werden das alles mit einem Semikolon abgeschlossen wird (auch die letzte Zeile der einzelnen Dateien!)</p>
<p>Der obrige Code kann noch weiter optimiert werden. Zuerst einmal könnten wir dem Browser sagen, das er die Script Datei Cachen soll, so muss sie lediglich einmal übertragen werden:</p>
<blockquote><p>header (&#8220;cache-control: must-revalidate; max-age: 2592000&#8243;);<br />
header (&#8220;expires: &#8221; . gmdate (&#8220;D, d M Y H:i:s&#8221;, time() + 2592000) . &#8221; GMT&#8221;);</p></blockquote>
<p>zweitens:<br />
es könnten alle Zeilenumbrüche entfernt , kommentare gefiltert und doppelte Leerzeichen durch einzelne ersetzt werden. Bei Dateien mit mehreren (tausend) Zeilen lässt sich so nochmal (ordentlich) Platz gespart werden:</p>
<blockquote><p>function verkleiner($data) {<br />
// Kommentare entfernen<br />
$data = preg_replace(‘!/\*[^*]*\*+([^/][^*]*\*+)*/!’, ”, $data);<br />
// Zeilenumbruch und Tab entfernen<br />
$data = str_replace(array(&#8220;\r\n&#8221;, &#8220;\r&#8221;, &#8220;\n&#8221;, &#8220;\t&#8221;), ”, $data);<br />
//Doppelte Leerzeichen entfernen<br />
$data = preg_replace(‘/\s\s+/’, ‘ ‘, $data);<br />
return $data;<br />
}</p></blockquote>
<p>und drittens können wir zusätzlich noch evtl verfügbare Komprimierungstechniken benutzen:</p>
<blockquote><p>header(‘Content-Length: ‘ . strlen($data));<br />
if (stripos($_SERVER["HTTP_ACCEPT_ENCODING"],‘x-gzip’) !== false) {<br />
header(&#8220;Content-encoding:x-gzip&#8221;);<br />
$data = gzencode($data);<br />
}<br />
elseif (stripos($_SERVER["HTTP_ACCEPT_ENCODING"],‘gzip’) !== false) {<br />
header(&#8220;Content-encoding:gzip&#8221;);<br />
$data = gzencode($data);<br />
}<br />
elseif (stripos($_SERVER["HTTP_ACCEPT_ENCODING"],‘deflate’) !== false) {<br />
header(&#8220;Content-encoding:deflate&#8221;);<br />
$data = gzdeflate($data);<br />
}</p></blockquote>
<p>Somit sieht die verkleiner funktion insgesammt wie folgt aus:</p>
<blockquote><p>function verkleiner($data) {<br />
// Kommentare entfernen<br />
$data = preg_replace(‘!/\*[^*]*\*+([^/][^*]*\*+)*/!’, ”, $data);<br />
// Zeilenumbruch und Tab entfernen<br />
$data = str_replace(array(&#8220;\r\n&#8221;, &#8220;\r&#8221;, &#8220;\n&#8221;, &#8220;\t&#8221;), ”, $data);<br />
//Doppelte Leerzeichen entfernen<br />
$data = preg_replace(‘/\s\s+/’, ‘ ‘, $data);<br />
header(‘Content-Length: ‘ . strlen($data));<br />
if (stripos($_SERVER["HTTP_ACCEPT_ENCODING"],‘x-gzip’) !== false) {<br />
header(&#8220;Content-encoding:x-gzip&#8221;);<br />
$data = gzencode($data);<br />
}<br />
elseif (stripos($_SERVER["HTTP_ACCEPT_ENCODING"],‘gzip’) !== false) {<br />
header(&#8220;Content-encoding:gzip&#8221;);<br />
$data = gzencode($data);<br />
}<br />
elseif (stripos($_SERVER["HTTP_ACCEPT_ENCODING"],‘deflate’) !== false) {<br />
header(&#8220;Content-encoding:deflate&#8221;);<br />
$data = gzdeflate($data);<br />
}<br />
return $data;<br />
}</p></blockquote>
<p>Jetzt müssen wir nur noch die Javascript Dateien anders einlesen so das wir sie bearbeiten können und das ganze sieht wie folgt aus:</p>
<blockquote><p>&lt;?php<br />
function verkleiner($data) {<br />
// Kommentare entfernen<br />
$data = preg_replace(‘!/\*[^*]*\*+([^/][^*]*\*+)*/!’, ”, $data);<br />
// Zeilenumbruch und Tab entfernen<br />
$data = str_replace(array(&#8220;\r\n&#8221;, &#8220;\r&#8221;, &#8220;\n&#8221;, &#8220;\t&#8221;), ”, $data);<br />
//Doppelte Leerzeichen entfernen<br />
$data = preg_replace(‘/\s\s+/’, ‘ ‘, $data);<br />
header(‘Content-Length: ‘ . strlen($data));<br />
if (stripos($_SERVER["HTTP_ACCEPT_ENCODING"],‘x-gzip’) !== false) {<br />
header(&#8220;Content-encoding:x-gzip&#8221;);<br />
$data = gzencode($data);<br />
}<br />
elseif (stripos($_SERVER["HTTP_ACCEPT_ENCODING"],‘gzip’) !== false) {<br />
header(&#8220;Content-encoding:gzip&#8221;);<br />
$data = gzencode($data);<br />
}<br />
elseif (stripos($_SERVER["HTTP_ACCEPT_ENCODING"],‘deflate’) !== false) {<br />
header(&#8220;Content-encoding:deflate&#8221;);<br />
$data = gzdeflate($data);<br />
}<br />
return $data;<br />
}<br />
header(‘Content-type: application/javascript’); //Typ setzen<br />
header (&#8220;cache-control: must-revalidate; max-age: 2592000&#8243;); //Caching<br />
header (&#8220;expires: &#8221; . gmdate (&#8220;D, d M Y H:i:s&#8221;, time() + 2592000) . &#8221; GMT&#8221;);<br />
$text=file_get_contents(’script/script1.js’);<br />
$text.=file_get_contents(’script/script2.js’);<br />
echo verkleiner($text);<br />
?&gt;</p></blockquote>
<p>Dies funktioniert natürlich auch mit CSS Dateien. HTML Seiten sollte man so nicht ausliefern da die Formatierung für bestimmte Elemente (z.B. pre) zerstört werden würde.<br />
Ich weise allerdings nochmal darauf hin, das die Javascript Dateien sauber geschrieben sein müssen und  auch die letzte Klasse in einer Datei mit einem Semikolon beendet werden muss!</p>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/javascript-und-css-dateien-komprimieren.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML Wissenstest</title>
		<link>http://iteamwork.de/html-wissenstest.html</link>
		<comments>http://iteamwork.de/html-wissenstest.html#comments</comments>
		<pubDate>Sat, 21 Jun 2008 09:09:26 +0000</pubDate>
		<dc:creator>H.Grafe</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[elemente]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://iteamwork.de/?p=15</guid>
		<description><![CDATA[Do you speak HTML? Ja? Und wieviele HTML Elemente kannst du in 5 Minuten nennen? Finde es herraus: http://www.oneplusyou.com/bb/html_quiz]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fiteamwork.de%2Fhtml-wissenstest.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fiteamwork.de%2Fhtml-wissenstest.html&amp;source=okriz&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Do you speak HTML? Ja? Und wieviele HTML Elemente kannst du in 5 Minuten nennen?</p>
<p>Finde es herraus: <a href="http://www.oneplusyou.com/bb/html_quiz" target="_blank">http://www.oneplusyou.com/bb/html_quiz</a></p>
]]></content:encoded>
			<wfw:commentRss>http://iteamwork.de/html-wissenstest.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

