<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Webtubes &#187; Programmierung</title>
	<atom:link href="http://www.webtubes.de/category/programmierung/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webtubes.de</link>
	<description>Web Development aus meiner Sicht</description>
	<lastBuildDate>Thu, 15 Dec 2011 21:02:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Yii Framework &#8211; das PHP Framework meiner Wahl</title>
		<link>http://www.webtubes.de/programmierung/php/yii-framework-das-php-framework-meiner-wahl/</link>
		<comments>http://www.webtubes.de/programmierung/php/yii-framework-das-php-framework-meiner-wahl/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 17:20:26 +0000</pubDate>
		<dc:creator>Robert Bernhard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Yii Framework]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.webtubes.de/?p=407</guid>
		<description><![CDATA[Irgendwann stand oder steht wohl jeder PHP-Entwickler einmal vor dem Problem der Auswahl eines geeigneten PHP Frameworks. Bis vor einigen Monaten habe ich mich primär mit selbst erstellten Frameworks herum geschlagen. Nicht das die Frameworks schlecht waren, jedoch verspürte ich mehr und mehr den Drang, bekannte PHP-Frameworks kennen zu lernen. Dies ist nicht zuletzt dem Umstand [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.webtubes.de/programmierung/php/yii-framework-das-php-framework-meiner-wahl/"><img class="aligncenter size-full wp-image-419" title="Yii Framework" src="http://www.webtubes.de/wp-content/uploads/yii.png" alt="" width="580" height="126" /></a></p>
<p>Irgendwann stand oder steht wohl jeder PHP-Entwickler einmal vor dem Problem der Auswahl eines geeigneten PHP Frameworks. Bis vor einigen Monaten habe ich mich primär mit selbst erstellten Frameworks herum geschlagen. Nicht das die Frameworks schlecht waren, jedoch verspürte ich mehr und mehr den Drang, bekannte PHP-Frameworks kennen zu lernen. Dies ist nicht zuletzt dem Umstand geschuldet, dass am Markt befindliche Ressourcen nicht kompatibel zu selbst erstellten Frameworks sind (der Aufwand und somit die Kosten sind zu hoch).</p>
<p><a href="http://framework.zend.com/"><img class="alignright size-full wp-image-422" title="Zend Framework" src="http://www.webtubes.de/wp-content/uploads/PoweredBy_ZF_4LightBG.png" alt="" width="127" height="25" /></a>So fiel meine Wahl zunächst auf ZEND Framework – das Flaggschiff unter den PHP Frameworks. ZEND ist ein sehr mächtiges aber leider auch ein unterirdisch performantes Framework. Die eigenartige auf Grund von PHP Abwärtskompatibilität angewendete Namespace-Implementierung mit Unterstrichen sowie die Komplexität des ZEND-Monsters haben mich jedoch zunehmend abgeschreckt. Mit ZEND gehen viele Dinge, wirklich sehr viele, aber in der Regel brauche ich diese Dinge nicht. Insofern bestand tief in mir der Wunsch nach einem schlankeren, Ressourcen schonendem und gut dokumentierten Framework Ausschau zu halten. Das Framework sollte zudem einfach konfigurierbar und modular verwendbar sein. Die Möglichkeit Extensions zur Erweiterung des Frameworks einzubinden, setze ich als gegeben voraus.</p>
<p><span id="more-407"></span></p>
<p>Folgende Komponenten sollte das Framework unbedingt an Board haben:</p>
<ul>
<li>MVC</li>
<li>modular erweiterbar (Module)</li>
<li>i18n (Mehrsprachigkeit)</li>
<li>einfache Konfiguration</li>
<li>ORM einfach austauschbar (falls erforderlich)</li>
<li>gut aufgestellte Community (wichtig für Extensions und Support)</li>
<li>gute Dokumentation (sowie im Code als auch im User Guide)</li>
<li>Access Control &amp; Rights Management</li>
<li>Unit Tests</li>
<li>gute Erweiterbarkeit und somit Flexibilität in jeglicher Hinsicht</li>
<li>Benutzer definiertes URL-Design (Routing)</li>
</ul>
<p><a href="http://www.yiiframework.com/"><img class="size-medium wp-image-419 alignright" style="border-style: initial; border-color: initial;" title="Yii Framework" src="http://www.webtubes.de/wp-content/uploads/yii-300x64.png" alt="" width="300" height="64" /></a></p>
<p>Sicherlich erfüllen sehr viele PHP-Frameworks oben genannte Ansprüche, allerdings wollte ich nach ZEND einem noch jungen Projekt meine Aufmerksamkeit schenken. So viel mein Blick eher zufällig als gezielt auf Yii. Angestachelt durch den <a title="Yii Performance Vergleich" href="http://www.yiiframework.com/performance/">Yii Performance Vergleich</a> mit diversen anderen Frameworks begann ich mich also in Yii einzulesen. Die ersten Tests verliefen zügig und funktionierten ohne Wehwechen – das kannte ich von ZEND auch anders. Module funktionieren von Haus aus, ohne das ich mich in Konfigurationsdateien tot wuseln muss. Selbst Module in Modulen in Modulen … funktionieren ohne groß Schnickschnack veranstalten zu müssen. Das hat mich dann doch sehr beeindruckt.</p>
<p>Das implementierte ORM (AR) ist sehr leistungsfähig, jedoch wie ich finde für Cloud Entwicklung nur bedingt geeignet. Das Problem des ORM ist schlichtweg, dass aus dem Code kein Datenbankschema generiert werden kann (zumindest nicht von Haus aus). Abgesehen davon beherrscht das ORM jedoch alles, was die tägliche Entwicklung benötigt. Mit Dcotrine2ORM, einer Extension zum Implementierung von Doctrine 2.0 in Yii, gibt es die für mich bessere Alternative, die sich ohne Probleme einbinden und nutzen lässt und diesen Missstand behebt.</p>
<p>Nun kann man denken was man will, die Leistungsfähigkeit und Performance eines Frameworks ist lediglich in einem realen Projekt sinnvoll einschätzbar. Von “Hello World” Tests halte ich persönlich nicht viel. Es gilt also ein Exempel zu statuieren, um über zuvor genannte Punkte eine gute Aussage treffen zu können. Ein Vergleich zu anderen Frameworks ist dadurch jedoch auch nur bedingt möglich.</p>
<p>Wie es der Zufall so will, holte ich also eine meiner Ideen aus der Schublade und begann zusammen einem Freund daraus ein Konzept zusammen zu tragen – zunächst alles ohne Yii <img src='http://www.webtubes.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Nachdem wir festgestellt hatten, dass sich die Idee umzusetzen lohnt, haben wir sämtliche erforderliche Seiten und Masken als Prototypen Sketches entworfen und von meinem Designer auf Basis dieser Grundlage ein Layout erstellen lassen. Kosten für weitere Dienstleistungen haben wir im Budget natürlich einfließen lassen, denn wenn man etwas macht dann richtig (-&gt; no money no honey).  genug gesülzt…</p>
<p>Die Landingpage zur Registrierung, zum Login, Passwort zurück setzen etc. ist fertig gestellt und ich erlaube mir an dieser Stelle ein Zwischenfazit. Die Entwicklung mit dem Yii Framework macht einem erfahrenen Entwickler wie mir nicht zuletzt wegen der ausgezeichneten Dokumentation sehr viel Spaß. Das Framework erweist sich als sehr gelungen und flexibel erweiterbar. Komponenten und Erweiterungen lassen sich nach Bedarf sehr trivial ein- beziehungsweise abschalten.</p>
<p>Mit einem Speicherverbrauch (LAMP, inklusive Doctrine, i18n, Verwendung von Modulen, APC=on) von 3,5-5,5 MB pro Request für die bisher entstandenen nicht sonderlich komplexen Seiten ist Yii in meinen Augen sehr Ressourcen schonend. Zum (ungleichen) Vergleich – eine WordPress Installation benötigt ohne Zusatzfeatures 14 MB. Mit einigen Plugins sind 32 MB schnell geknackt. Ein Drupal langt mit 15-40MB ebenfalls üppig zu. Zu bedenken ist, dass unter anderem der Arbeitsspeicher die Anzahl synchroner Requests begrenzt. Wenn das System zum Beispiel 30GB für Apache-Prozesse einräumt (entspricht Anzahl Apache max. Connections multipliziert mit PHP memory_limit) komme ich mit meinem Messergebnis auf 30*1024 / 5,5 = 5.585 maximale mögliche Connections zur gleichen Zeit – das ist verglichen mit WordPress (14 MB, 2.194) oder Drupal (20 MB, 1.536) sehr viel. Dieser Wert ist rein rechnerisch zu betrachten und nicht praxistauglich. Hier spielen noch andere Faktoren (IO, Datenbank Connections, etc.) eine Rolle. Allerdings zeigt der Vergleich durchaus auf, dass Ressourcen für andere wichtige Dinge aufgespart werden.</p>
<p>Warum ich meine jungfräuliche Yii-Applikation mit WordPress/Drupal vergleiche? Weil beide geläufige und zuhauf eingesetzte Softwares sind und jeder diese Softwares kennt. Wie bereits geschrieben ist der Vergleich sehr ungleich. Meine Yii Applikation ist natürlich lange nicht so funktionell wie ein WordPress oder ein Drupal. Wenn ich allerdings bedenke, dass Doctrine schon eine fette Sau ist und die Messergebnisse im Debug Modus zu Stande kommen (Logging, Debug Toolbar, etc.), so kommt mir der Speicherverbrauch doch sehr niedrig vor.</p>
<p>Ich nehme dieses erste Posting zum Yii Framework zum Anlass, weiter über meine Erfahrungen mit dem Yii Framework zu berichten.</p>
<p>Stay tuned!</p>
<p>Links:<br />
<a href="http://www.yiiframework.com/">http://www.yiiframework.com</a> - Yii Framework<br />
<a href="http://framework.zend.com/">http://framework.zend.com/</a> - Zend Framework</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webtubes.de/programmierung/php/yii-framework-das-php-framework-meiner-wahl/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; Update mittels JOIN</title>
		<link>http://www.webtubes.de/programmierung/sql/mysql-update-mittels-join/</link>
		<comments>http://www.webtubes.de/programmierung/sql/mysql-update-mittels-join/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 20:07:09 +0000</pubDate>
		<dc:creator>Robert Bernhard</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.webtubes.de/?p=120</guid>
		<description><![CDATA[Nicht selten ist es beim Aktualisieren von Datensätzen notwendig, die Bedingung für in Frage kommende Datensätze bei der Update-Anweisung einzufügen. Wer keine Kenntnis darüber besitzt, wird eine zweite Abfrage vorschalten und das Ergebnis in der eigentlichen Update-Anweisung verwerten. Dabei ist das Updaten von Datensätzen mittels bei MySQL sehr trivial. Folgende Abfrage aktualisiert alle Datensätze von [...]]]></description>
			<content:encoded><![CDATA[<p>Nicht selten ist es beim Aktualisieren von Datensätzen notwendig, die Bedingung für in Frage kommende Datensätze bei der Update-Anweisung einzufügen. Wer keine Kenntnis darüber besitzt, wird eine zweite Abfrage vorschalten und das Ergebnis in der eigentlichen Update-Anweisung verwerten.</p>
<p>Dabei ist das Updaten von Datensätzen mittels bei MySQL sehr trivial. Folgende Abfrage aktualisiert alle Datensätze von tabelle1 (aktiv wird auf 1 gesetzt) welche in tabelle2 existieren.</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Mysql: Update mittels Join</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="sql" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">UPDATE</span> 	tabelle1 <span style="color: #993333; font-weight: bold;">AS</span> a</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">JOIN</span> 	tabelle2 <span style="color: #993333; font-weight: bold;">AS</span> b</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">ON</span> 	a<span style="color: #66cc66;">.</span>id <span style="color: #66cc66;">=</span> b<span style="color: #66cc66;">.</span>id</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">SET</span> 	a<span style="color: #66cc66;">.</span>aktiv<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span></div></li></ol></pre></div></div>
<p>Folgende Abfrage setzt das Flag &#8220;aktiv&#8221; in beiden Tabellen bei Datensätzen, die in beiden Tabellen vorkommen.<br />
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Quelltext</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">UPDATE		tabelle1 AS a</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">JOIN		tabelle2 AS b</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		ON a.<span style="color: #0066ee;">id</span> <span style="color: #339933;">=</span> b.<span style="color: #0066ee;">id</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000066; font-weight: bold;">SET</span>		a.<span style="color: #0066ee;">aktiv</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		b.<span style="color: #0066ee;">aktiv</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span></div></li></ol></pre></div></div></p>
<p>Die Verknüpfung der Tabellen ist beliebig erweiterbar. Selbst Subselects oder Derived Tables sind kein Problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webtubes.de/programmierung/sql/mysql-update-mittels-join/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; Löschen mittels JOIN</title>
		<link>http://www.webtubes.de/programmierung/sql/mysql-loschen-mittels-join/</link>
		<comments>http://www.webtubes.de/programmierung/sql/mysql-loschen-mittels-join/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 19:53:03 +0000</pubDate>
		<dc:creator>Robert Bernhard</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.webtubes.de/?p=249</guid>
		<description><![CDATA[Unter Umständen ist bei dem Löschen von Datensätzen ein JOIN notwendig. Das Löschen von Datensätzen unter Verwendung eines JOINS unter MySQL ist dabei relativ einfach. Folgende Operation löscht den Datensatz auf lediglich aus Tabelle 1. Gelöscht werden Datensätze von tabelle1 bei welchen die Bedingungen tabelle1.id = tabelle2.id erfüllt. Folgende Abfrage löscht Einträge aus beiden Tabellen. [...]]]></description>
			<content:encoded><![CDATA[<p>Unter Umständen ist bei dem Löschen von Datensätzen ein JOIN notwendig. Das Löschen von Datensätzen unter Verwendung eines JOINS unter MySQL ist dabei relativ einfach.</p>
<p>Folgende Operation löscht den Datensatz auf lediglich aus Tabelle 1. Gelöscht werden Datensätze von tabelle1 bei welchen die Bedingungen tabelle1.id = tabelle2.id erfüllt.<br />
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Mysql: Löschen mittels Join</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="sql" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">DELETE</span> 	del</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">FROM</span> 	tabelle1 <span style="color: #993333; font-weight: bold;">AS</span> del</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">JOIN</span> 	tabelle2 <span style="color: #993333; font-weight: bold;">AS</span> sel</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">ON</span> 	del<span style="color: #66cc66;">.</span>id <span style="color: #66cc66;">=</span> sel<span style="color: #66cc66;">.</span>id</div></li></ol></pre></div></div><br />
Folgende Abfrage löscht Einträge aus beiden Tabellen. Gelöscht werden Datensätze von tabelle1 und tabelle2 bei welchen die Bedingungen tabelle1.id = tabelle2.id erfüllt.<br />
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Mysql: Löschen mittels Join 2</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="sql" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">DELETE</span> 	del<span style="color: #66cc66;">,</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	sel</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">FROM</span> 	tabelle1 <span style="color: #993333; font-weight: bold;">AS</span> del</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">JOIN</span> 	tabelle2 <span style="color: #993333; font-weight: bold;">AS</span> sel</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">ON</span> 	del<span style="color: #66cc66;">.</span>id <span style="color: #66cc66;">=</span> sel<span style="color: #66cc66;">.</span>id</div></li></ol></pre></div></div><br />
Die Verknüpfung der Tabellen mittels JOIN ist beliebig (auch mit LEFT JOIN) erweiterbar.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webtubes.de/programmierung/sql/mysql-loschen-mittels-join/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anzahl betroffener Datensätze unter Verwendung von Limit ermitteln (MySQL)</title>
		<link>http://www.webtubes.de/programmierung/sql/anzahl-betroffener-datensatze-unter-verwendung-von-limit-ermitteln-mysql/</link>
		<comments>http://www.webtubes.de/programmierung/sql/anzahl-betroffener-datensatze-unter-verwendung-von-limit-ermitteln-mysql/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 15:00:54 +0000</pubDate>
		<dc:creator>Robert Bernhard</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.webtubes.de/?p=121</guid>
		<description><![CDATA[Sicherlich standet ihr auch schon einmal vor dem Problem, die Ergebnismenge einer SQL Abfrage einschränken zu müssen. Soweit ist alles unkritisch. Wird nun beispielsweise für eine Seitenauswahl (pagination 1, 2, 3, &#8230; etc.) die Gesamtanzahl der Datensätze benötigt, ist eine weitere Abfrage erforderlich, welche ohne Limit die Ergebnisse zählt (COUNT). Bei einfachen Abfragen ist diese [...]]]></description>
			<content:encoded><![CDATA[<p>Sicherlich standet ihr auch schon einmal vor dem Problem, die Ergebnismenge einer SQL Abfrage einschränken zu müssen. Soweit ist alles unkritisch. Wird nun beispielsweise für eine Seitenauswahl (pagination 1, 2, 3, &#8230; etc.) die Gesamtanzahl der Datensätze benötigt, ist eine weitere Abfrage erforderlich, welche ohne Limit die Ergebnisse zählt (<em>COUNT</em>).<br />
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">SQL</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="sql" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">SELECT</span> COUNT<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">FROM</span> tabelle <span style="color: #993333; font-weight: bold;">WHERE</span> feld <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'suchwort'</span></div></li></ol></pre></div></div><br />
Bei einfachen Abfragen ist diese Art des &#8220;countens&#8221; von Datensätzen kein Problem. Sind die Abfragen jedoch komplexer, so ist zum Zählen von Datensätzen die SQL Abfrage doch sehr oft um zu formulieren.</p>
<p>Die Lösung des Problems bietet MySQL selbst mit dem Befehl <em>SQL_CALC_FOUND_ROWS</em>.<br />
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">SQL</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="sql" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">SELECT</span> 	SQL_CALC_FOUND_ROWS</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	spalte1<span style="color: #66cc66;">,</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	spalte2</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">FROM</span> 	tabelle</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">WHERE</span> 	feld <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'suchwort'</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">LIMIT</span> 	<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">10</span></div></li></ol></pre></div></div><br />
<em>SQL_CALC_FOUND_ROWS</em> wird einfach vor die zu selektierenden Spalten gesetzt (Achtung ohne Komma) und wirkt sich abgesehen von der minimal schlechteren Performance zunächst nicht aus. Das Resultset besteht aus maximal 10 Datensätzen und  kann wie gehabt gefetcht werden. Durch eine weitere SQL Abfrage mit dem Befehl<em> FOUND_ROWS</em> wird anschließend die Anzahl aller gefundenen Datensätze ohne die Limitierung abgefragt.<br />
<div id="wpshdo_7" class="wp-synhighlighter-outer"><div id="wpshdt_7" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_7"></a><a id="wpshat_7" class="wp-synhighlighter-title" href="#codesyntax_7"  onClick="javascript:wpsh_toggleBlock(7)" title="Click to show/hide code block">SQL</a></td><td align="right"><a href="#codesyntax_7" onClick="javascript:wpsh_code(7)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_print(7)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_7" class="wp-synhighlighter-inner" style="display: block;"><pre class="sql" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333; font-weight: bold;">SELECT</span> FOUND_ROWS<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div></li></ol></pre></div></div><br />
Diese Abfrage gibt genau einen Record (Datensatz) mit einem Tupel zurück und enthält die Anzahl gefundener Datensätze ohne Limitierung. Neben des Vorteils, dass die Abfrage nicht für das Zählen der Einträge umgeschrieben werden muss, ergibt sich oftmals jedoch ein minimaler Performancenachteil. Hier gilt es zwischen Komfort und Performance abzuwägen.</p>
<p>Mehr Informationen über <em>SQL_CALC_FOUND_ROWS</em> und <em>FOUND_ROWS</em> findet ihr in der offiziellen <a href="http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_found-rows">MySQL-Dokumentation</a>.</p>
<p>Ein PHP Beispiel findet ihr im kompletten Beitrag.<span id="more-121"></span></p>
<p><strong>PHP-Beispiel:</strong></p>
<div id="wpshdo_8" class="wp-synhighlighter-outer"><div id="wpshdt_8" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_8"></a><a id="wpshat_8" class="wp-synhighlighter-title" href="#codesyntax_8"  onClick="javascript:wpsh_toggleBlock(8)" title="Click to show/hide code block">PHP Beispiel</a></td><td align="right"><a href="#codesyntax_8" onClick="javascript:wpsh_code(8)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_print(8)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_8" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">	SELECT 	SQL_CALC_FOUND_ROWS</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">		feld1,</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">		feld2,</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">		feld3</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">	FROM 	tabelle</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">	WHERE 	feld1 LIKE 'suchwort'</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">LIMIT 	0, 10</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0000ff;">&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/list"><span style="color: #990000;">list</span></a> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$feld1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$feld2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$feld3</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_row"><span style="color: #990000;">mysql_fetch_row</span></a> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$feld1</span> <span style="color: #006699; font-weight: bold;">$feld2</span> <span style="color: #006699; font-weight: bold;">$feld3</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://www.php.net/mysql_free_result"><span style="color: #990000;">mysql_free_result</span></a> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT FOUND_ROWS()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://www.php.net/list"><span style="color: #990000;">list</span></a> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$cnt</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_row"><span style="color: #990000;">mysql_fetch_row</span></a> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><a href="http://www.php.net/mysql_free_result"><span style="color: #990000;">mysql_free_result</span></a> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Datensätze insgesamt: <span style="color: #006699; font-weight: bold;">$cnt</span>&quot;</span><span style="color: #339933;">;</span></div></li></ol></pre></div></div>
<p id="__mce">
]]></content:encoded>
			<wfw:commentRss>http://www.webtubes.de/programmierung/sql/anzahl-betroffener-datensatze-unter-verwendung-von-limit-ermitteln-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fake Google-Bots mittels .htaccess aussperren</title>
		<link>http://www.webtubes.de/programmierung/fake-google-bots-mittels-htaccess-aussperren/</link>
		<comments>http://www.webtubes.de/programmierung/fake-google-bots-mittels-htaccess-aussperren/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 14:43:53 +0000</pubDate>
		<dc:creator>Robert Bernhard</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Bots]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.webtubes.de/?p=114</guid>
		<description><![CDATA[Dass neugierige Dritte eigene Projekte analysieren (Konkurrenzanalyse) ist ja nicht neu. Immer häufiger treffe ich in letzter Zeit beim Stöbern durch meine Logs auf manipulierte Header. Grundsätzlich spricht ja nichts dagegen, sich bei anderen etwas abzugucken. Wenn jedoch der User Agent absichtlich in der Form manipuliert wird, dass sich der Analysator als Googlebot ausgibt, hört [...]]]></description>
			<content:encoded><![CDATA[<p>Dass neugierige Dritte eigene Projekte analysieren (Konkurrenzanalyse) ist ja nicht neu. Immer häufiger treffe ich in letzter Zeit beim Stöbern durch meine Logs auf manipulierte Header. Grundsätzlich spricht ja nichts dagegen, sich bei anderen etwas abzugucken. Wenn jedoch der User Agent absichtlich in der Form manipuliert wird, dass sich der Analysator als Googlebot ausgibt, hört mein Verständnis auf.</p>
<p>Wie ein Fake Google Bot mittels .htaccess ausgesperrt wird, möchte ich euch nun kurz aufzeigen. Zuvor möchte ich jedoch auch davor warnen &#8211; es wird niemals eine zu 100 Prozent vollständige Liste aller Google IP Adressen geben. Nahezu täglich erweitert Google die eigenen Serverfarmen und somit auch die Anzahl der im Netz befindlichen Crawler (Bots). Jeder neuer Crawler hat eine eigene und unter Umständen euch nicht bekannte IP-Adresse. Die Folge kann sein, dass ihr ungewollter Weise Google aussperrt und das ist nicht Sinn der Sache.</p>
<p>Gut fangen wir an &#8211; zunächst benötigen wir eine Liste der Googlebot IP Adressen. Derartige Listen lassen sich bei Google finden. Falls nicht bereits vorhanden, legen wir nun im Root-Verzeichnis der zu schützenden Webseite eine .htaccess Datei mit folgendem Inhalt an (falls bereits angelegt, überspringen).</p>
<pre lang="text">RewriteEngine On</pre>
<p>Nun sind mittels der angelegten .htaccess Datei noch die IP Adressen des die Webseite aufrufenden Benutzers gegen seinen User Agent zu prüfen. Kommt im User Agent &#8220;googlebot&#8221; vor und die IP Adresse ist in unserer Liste nicht vorhanden, wird der Besucher kurzer Hand ausgesperrt (nix nada niente).</p>
<pre lang="text">RewriteEngine On

# ACHTUNG!!! Die IP Adressen sind nur exemplarisch
# und gehören nicht zu Google
RewriteCond %{HTTP_USER_AGENT} googlebot
RewriteCond %{REMOTE_ADDR} !^1.1.1.1 [OR] # IP Adresse 1
RewriteCond %{REMOTE_ADDR} !^2.2.2.2 [OR] # IP Adresse 2
RewriteCond %{REMOTE_ADDR} !^2.2.3. [OR] # IP Bereich 2.2.3.1 - 2.2.3.255
RewriteRule ^.* - [F]</pre>
<p>Das war es dann auch schon. Fake Google Bots sind ab sofort ausgesperrt. Bitte achtet unbedingt auf die Aktualität eurer Ip Adressen Liste! Wer eine halbwegs aktuelle Liste von Google IP Adressen findet, kann sie gerne in einem Kommentar bekannt geben.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webtubes.de/programmierung/fake-google-bots-mittels-htaccess-aussperren/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regulärer Ausdruck zum Verlinken von Bildern für Lightbox/Slimbox</title>
		<link>http://www.webtubes.de/programmierung/php/regularer-ausdruck-zum-verlinken-von-bildern-fur-lightboxslimbox/</link>
		<comments>http://www.webtubes.de/programmierung/php/regularer-ausdruck-zum-verlinken-von-bildern-fur-lightboxslimbox/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 12:00:50 +0000</pubDate>
		<dc:creator>Robert Bernhard</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.webtubes.de/?p=87</guid>
		<description><![CDATA[Es kommt immer wieder mal vor, dass man vor die Aufgabe gestellt wird, einen in der Datenbank abgelegten Quelltext für die Ausgabe vor zu bereiten. Nicht zuletzt peppen Plugins wie Lightbox oder Slimbox ein eingestaubtes CMS System mächtig auf, in dem Bilder in einer sehr schönen Optik vergrößert angezeigt werden können. Bevor man sich nun [...]]]></description>
			<content:encoded><![CDATA[<p>Es kommt immer wieder mal vor, dass man vor die Aufgabe gestellt wird, einen in der Datenbank abgelegten Quelltext für die Ausgabe vor zu bereiten. Nicht zuletzt peppen Plugins wie <a href="http://www.lokeshdhakar.com/projects/lightbox2/">Lightbox</a> oder <a href="http://www.digitalia.be/software/slimbox">Slimbox</a> ein eingestaubtes CMS System mächtig auf, in dem Bilder in einer sehr schönen Optik vergrößert angezeigt werden können.</p>
<p>Bevor man sich nun die Arbeit macht, jedes im Quellcode eingebettetes Bild (&lt;img src=&#8221;" &#8230; &gt;) an das auserwählte Plugin anzupassen, macht ein regulärer Ausdruck hier viel mehr Sinn.</p>
<p>Beim Einsatz von PHP genügt folgender regulärer Ausdruck, um alle Bilder eines Quelltextes für Lightbox beziehungsweise Slimbox anzupassen:<br />
<div id="wpshdo_9" class="wp-synhighlighter-outer"><div id="wpshdt_9" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_9"></a><a id="wpshat_9" class="wp-synhighlighter-title" href="#codesyntax_9"  onClick="javascript:wpsh_toggleBlock(9)" title="Click to show/hide code block">PHP-Snippet</a></td><td align="right"><a href="#codesyntax_9" onClick="javascript:wpsh_code(9)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_print(9)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_9" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a> <span style="color: #009900;">&#40;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0000ff;">&quot;#()#siU&quot;</span><span style="color: #339933;">,</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$1</span>&quot;</span><span style="color: #339933;">,</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #000088;">$str</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li></ol></pre></div></div><br />
Einfach aber gut stimmts?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webtubes.de/programmierung/php/regularer-ausdruck-zum-verlinken-von-bildern-fur-lightboxslimbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Übersichtliche Quelltexte unabhängig von der Programmiersprache</title>
		<link>http://www.webtubes.de/programmierung/php/ubersichtliche-quelltexten-unabhangig-von-der-programmiersprache/</link>
		<comments>http://www.webtubes.de/programmierung/php/ubersichtliche-quelltexten-unabhangig-von-der-programmiersprache/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 23:51:12 +0000</pubDate>
		<dc:creator>Robert Bernhard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Quelltext]]></category>

		<guid isPermaLink="false">http://www.webtubes.de/?p=46</guid>
		<description><![CDATA[Als langjähriger Entwickler schlägt man sich bei einem Blick auf den eigenen Quellcode von früheren Zeiten doch sehr oft die Hände über dem Kopf zusammen &#8220;Wer soll das bitte lesen? Wo sind alle die Kommentare abgeblieben? Für was steht gleich die Variable $a2?&#8221;. Gerade heute habe ich wieder über fremden Quellcode schauen müssen und dachte [...]]]></description>
			<content:encoded><![CDATA[<p>Als langjähriger Entwickler schlägt man sich bei einem Blick auf den eigenen Quellcode von früheren Zeiten doch sehr oft die Hände über dem Kopf zusammen &#8220;Wer soll das bitte lesen? Wo sind alle die Kommentare abgeblieben? Für was steht gleich die Variable $a2?&#8221;. Gerade heute habe ich wieder über fremden Quellcode schauen müssen und dachte mir, dass dies ein guter Anlass für ein solches Posting wäre.<span id="more-46"></span></p>
<h3>Worauf kommt es bei einem guten Quelltext an?</h3>
<p>Nun zunächst einmal sollte das Dokument möglichst nicht mehrere 1000 Zeilen groß sein. Quelltexte dieser Größe lassen sich nur schwer überblicken. Mehrere kleine Dokumente lassen sich. Nach meiner Erfahrung in Hinsicht auf Teamarbeit und Dokumentation hat es sich oft gezeigt, dass sich das Aufdröseln unterm Strich gelohnt hat. Allerdings trifft das nicht immer zu!</p>
<h3>Sinnvolle Benennung von Variablen</h3>
<p>Weiterhin sollte ein Programmierer sich bei der Benennung von Variablen lieber 10 Minuten zeit nehmen, anstatt die Programmierung mit Sinn entleerten Variablen Bezeichnungen fort zu setzen. Nehmen wir zum Beispiel an, eine Variable für die Gesamtsumme eines Warenkorbes deklariert werden muss.<br />
<div id="wpshdo_10" class="wp-synhighlighter-outer"><div id="wpshdt_10" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_10"></a><a id="wpshat_10" class="wp-synhighlighter-title" href="#codesyntax_10"  onClick="javascript:wpsh_toggleBlock(10)" title="Click to show/hide code block">PHP-Snippet</a></td><td align="right"><a href="#codesyntax_10" onClick="javascript:wpsh_code(10)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_print(10)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_10" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color:#800080;">999999.99</span><span style="color: #339933;">;</span></div></li></ol></pre></div></div><br />
Ok b wie Basket klingt ok oder? Nein das geht absolut gar nicht! Denken Sie sich mal in die Situation hinein, Sie müssten Ihren Quelltext in 2 oder 3 Jahren überarbeiten. Prost Mahlzeit! $b ist einfach nur Sinn entleert.</p>
<p>Nehmen wir uns doch etwas mehr Zeit bei der Findung des Variablennamens:<br />
Welchen Wert enthält die Variable? Die Gesamtsumme aller Waren im Warenkorbes&#8230;<br />
Inklusive oder exklusive Mehrwertsteuer? inklusive Mehrwertsteuer&#8230;</p>
<p>Demzufolge ist es doch ein Einfaches die Variable schlüssig zu benennen oder?<br />
<div id="wpshdo_11" class="wp-synhighlighter-outer"><div id="wpshdt_11" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_11"></a><a id="wpshat_11" class="wp-synhighlighter-title" href="#codesyntax_11"  onClick="javascript:wpsh_toggleBlock(11)" title="Click to show/hide code block">sprechende Variablennamen</a></td><td align="right"><a href="#codesyntax_11" onClick="javascript:wpsh_code(11)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_11" onClick="javascript:wpsh_print(11)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_11" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$basketSumBrutto</span> <span style="color: #339933;">=</span> <span style="color:#800080;">999999.99</span><span style="color: #339933;">;</span></div></li></ol></pre></div></div><br />
Den Sinn dieser Variable hat man immer sofort vor Augen stimmts? Die einzige  Art von Variablen, die möglichst kurz benannt werden sollten, sind Zählvariablen.</p>
<h3>Einrückung Einrückung und nochmal Einrückung</h3>
<p>In vielen Programmiersprachen hat es sich durchgesetzt, mittels Tabulator einzurücken. Das hat den Vorteil, dass ein TAB vom Programmierer in der Regel in seiner Entwicklungsumgebung frei konfigurierbar ist. So kann ein TAB bei einem Programmierer, welche auf Quetschkommode steht, 2 Leerzeichen entsprechen und bei den meisten anderen wird der TAB genau 4 Leerzeichen entsprechen. Es ist jedoch zu beachten, dass <span style="text-decoration: line-through;">der Editor</span> die Entwicklungsumgebung die Tabs beim Speichern nicht in Leerzeichen konvertiert. Denn das wäre dann fatal! Einige Unix Programmierer werden mich jetzt schlagen, aber ich lege mich nachfolgend auf die Einrückung mittels TAB fest.</p>
<p>Betrachten wir uns folgendes Snippet:<br />
<div id="wpshdo_12" class="wp-synhighlighter-outer"><div id="wpshdt_12" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_12"></a><a id="wpshat_12" class="wp-synhighlighter-title" href="#codesyntax_12"  onClick="javascript:wpsh_toggleBlock(12)" title="Click to show/hide code block">unübersichtlicher Quellcode</a></td><td align="right"><a href="#codesyntax_12" onClick="javascript:wpsh_code(12)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_12" onClick="javascript:wpsh_print(12)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_12" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$sprache</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;deutsch&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$vorname</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Max&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$nachname</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Mustermann&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$strasse</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Musterstraße&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$hausnr</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$plz</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;01234&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$ort</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Musterstadt&quot;</span><span style="color: #339933;">;</span></div></li></ol></pre></div></div><br />
Auf den ersten Blick sieht das fast ok aus, aber das geht viel besser und übersichtlicher:</p>
<div id="wpshdo_13" class="wp-synhighlighter-outer"><div id="wpshdt_13" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_13"></a><a id="wpshat_13" class="wp-synhighlighter-title" href="#codesyntax_13"  onClick="javascript:wpsh_toggleBlock(13)" title="Click to show/hide code block">übersichtlicher Quellcode</a></td><td align="right"><a href="#codesyntax_13" onClick="javascript:wpsh_code(13)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_13" onClick="javascript:wpsh_print(13)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_13" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$sprache</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;deutsch&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$vorname</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Max&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$nachname</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Mustermann&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$strasse</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Musterstraße&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$hausnr</span>	  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$plz</span>	  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;01234&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$ort</span>	  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Musterstadt&quot;</span><span style="color: #339933;">;</span></div></li></ol></pre></div></div>
<p>Und was liest sich jetzt besser? Klar macht es etwas Arbeit, den Code wie eben gezeigt etwas schöner zu gestalten, aber eins ist sicher: Nachfolgend über den Code blickende Dritte haben sehr viel mehr Vergnügen beim Lesen. Und auch der Autor des Quelltextes wird selbst nach Jahren noch sagen &#8211; super übersichtlich! Für Entwickler, die innerhalb eines größeren Teams arbeiten, sollte dieser Stil zu guten Pflicht gehören.</p>
<h3>Kommentare</h3>
<p>Mit dem Kommentaren haben es die wenigsten Programmierer. Die meisten setzen der Einfachheit gar keine Kommentare. Autsch! Viele Programmierer, die dann doch Kommentare setzen, meinen es mit dem Kommentieren aber leider zu gut. Zum Beispiel sind solche Kommentare hier völliger Blödsinn und können getrost weg gelassen werden.<br />
<div id="wpshdo_14" class="wp-synhighlighter-outer"><div id="wpshdt_14" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_14"></a><a id="wpshat_14" class="wp-synhighlighter-title" href="#codesyntax_14"  onClick="javascript:wpsh_toggleBlock(14)" title="Click to show/hide code block">unsinnige Kommentare</a></td><td align="right"><a href="#codesyntax_14" onClick="javascript:wpsh_code(14)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_14" onClick="javascript:wpsh_print(14)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_14" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Sprache des Clienten</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$sprache</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;deutsch&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Vorname des Clienten</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$vorname</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Max&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Nachname des Clienten</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$nachname</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Mustermann&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Straße des Clienten</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$strasse</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Musterstraße&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Hausnummer des Clienten</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$hausnr</span>      <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Postleitzahl des Clienten</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$plz</span>      <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;01234&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Ort des Clienten</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$ort</span>      <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Musterstadt&quot;</span><span style="color: #339933;">;</span></div></li></ol></pre></div></div><br />
Hallo? Davon ausgehend, dass wir inzwischen Variablen sinnvoll benennen, sind diese Kommentare doch wirklich absolut überflüssig. Zumal diese Kommentare den gesamten Variablenblock zerstören. Wenn man hier schon unbedingt kommentieren möchte, dann empfehle ich maximal einen Kommentar oberhalb dieses thematisch zusammen gehörigen Blockes. Wie gesagt wenn überhaupt!</p>
<div id="wpshdo_15" class="wp-synhighlighter-outer"><div id="wpshdt_15" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_15"></a><a id="wpshat_15" class="wp-synhighlighter-title" href="#codesyntax_15"  onClick="javascript:wpsh_toggleBlock(15)" title="Click to show/hide code block">Kommentar für gesamten Block</a></td><td align="right"><a href="#codesyntax_15" onClick="javascript:wpsh_code(15)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_15" onClick="javascript:wpsh_print(15)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_15" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Clientendaten für Musterdatensatz</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$sprache</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;deutsch&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$vorname</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Max&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$nachname</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Mustermann&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$strasse</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Musterstraße&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$hausnr</span>	  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$plz</span>	  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;01234&quot;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$ort</span>	  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Musterstadt&quot;</span><span style="color: #339933;">;</span></div></li></ol></pre></div></div>
<p><strong>Doch wo machen Kommentare eigentlich Sinn?</strong></p>
<p>Ganz einfach. Kommentare sollten Codestrukturen beschreiben, die nicht selbsterklärend sind. Das können zum Beispiel Funktionen, Klassen oder größere Codeblöcke sein. Hier bietet es sich jedoch an, die Kommentare zu konsolidieren beziehungsweise zu bündeln (der Code und der Kommentar sind examplarisch zu sehen).<br />
<div id="wpshdo_16" class="wp-synhighlighter-outer"><div id="wpshdt_16" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_16"></a><a id="wpshat_16" class="wp-synhighlighter-title" href="#codesyntax_16"  onClick="javascript:wpsh_toggleBlock(16)" title="Click to show/hide code block">Beispiel sinnvoller Kommentare</a></td><td align="right"><a href="#codesyntax_16" onClick="javascript:wpsh_code(16)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_16" onClick="javascript:wpsh_print(16)" title="Print code"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.webtubes.de/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_16" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Berechnung der Gesamtsumme aller Waren innerhalb des Warenkorbs</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// Die Beträge in Array $basketItems liegen netto vor! Das Array</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// $basketItems enhält folgende Struktur:</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">// 	[][item] =&gt;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">//		[</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">//			[id] 	=&gt; int,</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">//			[menge] =&gt; int,</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">//			[preis] =&gt; double</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #666666; font-style: italic;">//		]</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$basketSumNetto</span>  <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$basketSumBrutto</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$basketItems</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$item_x</span><span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$basketSumNetto</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$item_x</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'menge'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$item_x</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'preis'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000088;">$basketSumBrutto</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$basketSumNetto</span> <span style="color: #339933;">*</span> <span style="color:#800080;">1.19</span><span style="color: #339933;">;</span></div></li></ol></pre></div></div><br />
Bei Klassen beziehungsweise Methoden bietet es sich an auf standardisierte Techniken zur Dokumentation zurück zu greifen.</p>
<ul>
<li><a href="http://www.phpdoc.org/" target="_blank">PHPDoc für PHP</a></li>
<li><a href="http://java.sun.com/j2se/javadoc/writingdoccomments/" target="_blank">Javadoc für Java</a></li>
<li><a href="http://www.ruby-doc.org/" target="_blank">Rubydoc für Ruby</a></li>
<li><a href="http://effbot.org/zone/pythondoc.htm" target="_blank">PythonDoc für Python</a></li>
</ul>
<p>Es gibt quasi für nahezu jede Programmiersprache ein passendes Pendant. Der Vorteil dieser Tools ist neben der Standardisierung die entstehende Quelltext Dokumentation in Form einer übersichtlichen Ansammlung von sämtlichen dokumentierten Quellcode. <a href="http://manual.phpdoc.org/HTMLframesConverter/default/" target="_blank">Beispiel für PHPDoc</a></p>
<h3>Was wir gelernt haben</h3>
<p>Es ist nicht entscheidend, eine Quellcode möglichst schnell zu programmieren, sondern möglichst gut lesbar, dokumentiert, durchdacht und fehlerfrei. Die Zeit, die man zur Optimierung des Quelltextes verwendet, spart man sich später beim Debugging oder bei anstehenden Erweiterungen am Quelltext. Man sollte sich als Programmierer einen programmierten Quellcode nach etwas längerer Zeit mit etwas Abstand nochmals ansehen und nach dokumentieren. Das Problem ist nämlich eine Betriebsblindheit. Seinen eigenen Quellcode kennt man zum Zeitpunkt des Schreibens immer. Daher erscheinen viele Dinge logisch, sind es jedoch ganz und gar nicht.</p>
<p>Ich habe mir all diese kleinen Dinge in einem tollen Team angelernt. Natürlich sollten beim gemeinsamen Arbeiten innerhalb eines Teams viele weitere kleine Details schriftlich fixiert und als Style Guide oder wie auch immer man dieses Dokument bezeichnen mag zur Verfügung gestellt werden. Ansatzpunkte könnten hier sein:</p>
<ul>
<li>Variablen Buckelschreibweise oder Unterstrichschreibweise</li>
<li>Festlegung der zu verwendenden Kommentarsyntax (z.B. PHPDoc)</li>
<li> Codestruktur (z.B. oben Logik unten Ausgabe)</li>
<li>Instanzen von Objekten mit großen ANfangsbuchstaben</li>
</ul>
<p>Ein Brainstorming innerhalb eines lockeren Teammeetings wird noch viele weitere Punkte auf die Liste bringen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webtubes.de/programmierung/php/ubersichtliche-quelltexten-unabhangig-von-der-programmiersprache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Permanent Redirect &#8211; wie leite ich einen Link dauerhaft um?</title>
		<link>http://www.webtubes.de/programmierung/mod-rewrite/permanent-redirect-wie-leite-ich-einen-link-dauerhaft-um/</link>
		<comments>http://www.webtubes.de/programmierung/mod-rewrite/permanent-redirect-wie-leite-ich-einen-link-dauerhaft-um/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 18:32:12 +0000</pubDate>
		<dc:creator>Robert Bernhard</dc:creator>
				<category><![CDATA[Link Rewriting]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.schulungs-kurse.de/?p=16</guid>
		<description><![CDATA[Eins möchte ich euch schon einmal vorweg nehmen &#8211; vergesst META REFRESH und Javscript Aufrufe ala location.href=&#8221;bla.html&#8221;. Für eine dauerhafte Umleitung sind diese Methoden nicht der richtige Weg. Permanent Redirect bedeutet, dass eine Internetseite für den Browser und Suchmaschinen -  vor allem Suchmaschinen sind da richtig geil drauf &#8211; eindeutig erkennbar dauerhaft auf eine andere [...]]]></description>
			<content:encoded><![CDATA[<p>Eins möchte ich euch schon einmal vorweg nehmen &#8211; vergesst <em>META REFRESH</em> und Javscript Aufrufe ala <em>location.href=&#8221;bla.html&#8221;</em>. Für eine dauerhafte Umleitung sind diese Methoden nicht der richtige Weg. Permanent Redirect bedeutet, dass eine Internetseite für den Browser und Suchmaschinen -  vor allem Suchmaschinen sind da richtig geil drauf &#8211; eindeutig erkennbar dauerhaft auf eine andere Internetseite umgeleitet wird. Als Erkennungsmerkmal wird beim Aufruf einer permanent umzuleitenden Seite anstatt des normalen Header</p>
<blockquote><p>HTTP/1.x 200 OK</p></blockquote>
<p>der Header</p>
<blockquote><p>HTTP/1.x 301 Moved Permanently<strong><em> </em></strong></p></blockquote>
<p>gesendet wird. Und genau diese Modifikation des Header können <em>META REFRESH</em> und Javascript <em>location.href=&#8221;bla.html&#8221;</em> nicht. Soweit so gut&#8230;</p>
<p>Oftmals spricht man der Kürze wegen auch von einem <strong>301 Redirect</strong> &#8230; <a title="Wikipedia unser guter alter Freund hilft doch gerne" href="http://de.wikipedia.org/wiki/Hypertext_Transfer_Protocol#HTTP-Statuscodes" target="_blank">mehr über Header</a> kann man bei Wikipedia nachlesen. Das dauerhafte Umleiten von Links kann aus verschiedensten Beweggründen wichtig sein. Einer der Gründe ist das Vermeiden von Duplicate Content, ein anderer könnte eine veränderte Internetadresse sein, &#8230;. es gibt sicherlich 1000 Weitere Gründe.</p>
<p>Wie man nun einen Permanent Redirect realisiert und was es dabei zu beachten gibt, habe ich nachfolgend <span style="text-decoration: line-through;">kurz</span> zusammen gefasst.<span id="more-16"></span></p>
<h3>Wie wird ein Permanent Redirect realisiert?</h3>
<p>Kommen wir nun zum eigentlich wichtigen. Zunächst einmal muss sicher gestellt sein, dass man auf dem eigenen Webspace <strong> .htaccess Dateien</strong> verwenden kann und das Modul <strong>mod_rewrite</strong> aktiviert ist. Dies ist in der Regel der Fall. Andernfalls ist der Kurs an dieser Stelle <span style="text-decoration: line-through;">zu Ende</span> lediglich informativer Natur.</p>
<p>Sofern noch keine .htaccess Datei auf dem Webspace angelegt ist, ist das jetzt zu tun. Im Kopf der Datei sollte dann folgendes stehen:</p>
<blockquote><p>RewriteEngine On<br />
RewriteBase /</p></blockquote>
<p>Diese HTACCESS Datei wird nun vom Webserver bei jedem Seitenaufruf geladen und konfiguriert diesen quasi nachträglich um. Die Direktive (so nennt man diese Eigenschaften) <em>RewriteEngine </em>weist den Webserver mit dem Wert <em>On</em> an, das Modul mod_rewrite zu aktivieren. <em>RewriteBase </em>ist der relative Startpfad der Webseite (für http://www.schulungs-kurse.de demnach ein einfacher Slash oder liegt die HTACCESS Datei in einem Unterverzeichnis /meinUnterverzeichnis &#8211; immer relativ von der Domain gesehen).</p>
<p>Der 301 Redirect für einen Aufruf einer Webseite <strong>ohne www</strong> auf die gleiche Seite aber <strong>mit www</strong> könnte so aussehen:</p>
<blockquote><p>RewriteCond %{HTTP_HOST} !^www\.webtubes\.de$<br />
RewriteRule ^(.*)$ http://www.webtubes.de/$1 [L,R=301]</p></blockquote>
<p>Kopiert meine Domain http://webtubes.de (ohne www) einfach in ein neues Fensterchen und drückt ENTER. Anschließend wird im Browser die Seite mit www angezeigt. Das Besondere an dieser Umleitung ist, dass aufgerufene Pfade und angehangene <span style="text-decoration: line-through;">Query Strings</span> Parameter an die neue Seite übergeben werden. Ein Aufruf der Seite</p>
<blockquote><p><em>http://</em>webtubes<em>.de/bla/huhu.php?q=1</em></p></blockquote>
<p>wird also nach <em></em></p>
<blockquote><p><em>http://www.</em>webtubes<em>.de/bla/huhu.php?q=1</em></p></blockquote>
<p>permanent umgeleitet &#8211; probiert es ruhig aus (euch grinst ein 404 Error an, da die Zielseite natürlich nicht existiert).</p>
<h3>Wichtige Tipps und Beispiele</h3>
<ol>
<li>Sollen <span style="text-decoration: line-through;">Query Strings</span> Parameter nicht an die Zielseite angehängt werden, ist an die Zielseite ein <em>Fragezeichen (?) </em>anzuhängen<br />
<blockquote><p>RewriteRule ^(.*)$ http://www.webtubes.de/$1<strong>?</strong> [L,R=301]</p></blockquote>
</li>
<li>Soll der aufgerufene Pfad beziehungsweise die aufgerufene Datei nicht an die neue Seite angehängt werden, ist die Variable <em>$1</em> zu entfernen<br />
<blockquote><p>RewriteRule ^.*$ http://www.webtubes.de/ [L,R=301]</p></blockquote>
</li>
<li>Soll nur eine bestimmte Seite umgeleitet werden und nicht blind links alle Seiten, ist die Regel durch <span style="text-decoration: line-through;">Conditions</span> Bedingungen zu erweitern<br />
<blockquote><p># bitte nur doofe-seite.html umleiten ok?<br />
RewriteCond %{REQUEST_URI} ^doofe-seite\.html$<br />
RewriteRule ^.*$ http://www.webtubes.de/ [L,R=301]<br />
# &#8230; Yes sir</p></blockquote>
</li>
<li>Sollen bestimmt Seiten von der Umleitung ausgeschlossen werden &#8211; also entgegen gesetzt zu Tip 3 &#8211; ist die Regel ebenfalls durch <span style="text-decoration: line-through;">Conditions</span> Bedingungen zu erweitern<br />
<blockquote><p># ALLES, aber bitte nicht meine-beste-seite.html umleiten ok?<br />
RewriteCond %{REQUEST_URI} !^meine-beste-seite\.html$<br />
RewriteRule ^.*$ http://www.webtubes.de/ [L,R=301]<br />
# &#8230; alles klar Capitano</p></blockquote>
<p>Man beachte bei dieser Regel das <em>Ausrufezeichen (!)</em> in der Bedingung, welches die Bedingung im Grunde einfach rum dreht: wenn Seite <strong>nicht </strong>meine-beste-seite.html mittels 301 Redirect umleiten&#8230;</li>
</ol>
<h3>Anmerkungen</h3>
<p>Für das permanente Umleiten gibt es weitere Schreibweisen, die jedoch nur auf einem anderen Weg nach Rom führen.  Sollte ich etwas vergessen haben, werde ich diesen Beitrag ergänzen.</p>
<h3>Fazit</h3>
<p>Das  dauerhafte Umleiten eines Links ist total einfach, vorausgesetzt die Grundlagen werden beherrscht.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webtubes.de/programmierung/mod-rewrite/permanent-redirect-wie-leite-ich-einen-link-dauerhaft-um/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 2.416 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-01-19 11:36:07 -->

