<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Agrafix Webdesign Blog &#187; PHP</title>
	<atom:link href="http://blog.agrafix.net/category/programmieren/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.agrafix.net</link>
	<description>Programmieren, Technik und Internet</description>
	<lastBuildDate>Wed, 25 Jan 2012 06:59:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ReTI IDE &amp; Simulator (Technische Informatik)</title>
		<link>http://blog.agrafix.net/2012/01/reti-ide-simulator-technische-informatik/</link>
		<comments>http://blog.agrafix.net/2012/01/reti-ide-simulator-technische-informatik/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 12:29:29 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projekte]]></category>
		<category><![CDATA[asm]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[prozessor]]></category>
		<category><![CDATA[reti]]></category>
		<category><![CDATA[simulator]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=533</guid>
		<description><![CDATA[Da ich aktuell an der Veranstaltung Technische Informatik an der Uni teilnehme war es im letzten Übungsblatt Aufgabe Programm-Code für einen einfachen Prozessor (ReTI oder auch RESA) zu schreiben. Das vorgeschlagene Tool dafür (Neumi) kann entsprechenden Programm-Code zwar super visualisieren, ist allerdings beim &#8220;coden&#8221; nicht sehr hilfreich da es kein vernünftiges Feedback bei Fehlern gibt [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2012/01/reti-ide-simulator-technische-informatik/' addthis:title='ReTI IDE &#38; Simulator (Technische Informatik) ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<em>Keine ähnlichen Beiträge vorhanden</em>]]></description>
			<content:encoded><![CDATA[<p>Da ich aktuell an der Veranstaltung Technische Informatik an der Uni teilnehme war es im letzten Übungsblatt Aufgabe Programm-Code für einen einfachen Prozessor (ReTI oder auch RESA) zu schreiben. Das vorgeschlagene Tool dafür (<a href="http://abs.informatik.uni-freiburg.de/teaching/Neumi/" title="Neumi">Neumi</a>) kann entsprechenden Programm-Code zwar super visualisieren, ist allerdings beim &#8220;coden&#8221; nicht sehr hilfreich da es kein vernünftiges Feedback bei Fehlern gibt und es auch keine gute Eingabemaske für den Code gibt. Deshalb hab ich mich hingesetzt und eine kleine HTML-JavaScript-IDE mit einer ReTI-Simulation in PHP zusammengebaut. Das ganze ist unter <a href="http://reti.agrafix.net/index.php" title="ReTI IDE &#038; Simulator">reti.agrafix.net</a> zu finden! Ich habe auch eine kleine Dokumentation dazu geschrieben, es sollte sich also alles von selbst erklären.<br />
Ein paar Worte vielleicht noch zur &#8220;Simulation&#8221;: Die Simulation ist eher ein Debugger, da der Code nicht assembliert sondern direkt interpretiert wird. Das ist notwendig um zielgenaues Feedback bei (Laufzeit-)Fehlern zu geben. Deshalb ist es nicht möglich auf Speicherzellen zuzugreifen, die Anweisungen/Befehle enthalten. (Mit dieser Einschränkung konnte man dennoch alle Aufgabenstellungen bis jetzt lösen <img src='http://blog.agrafix.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ) Solange man das also nicht benötigt, kann der Simulator den korrekten Endspeicherzustand berechnen.</p>
<p><a href="http://reti.agrafix.net/" title="ReTI IDE &#038; Simulator">Zur ReTI IDE &#038; Simulator</a></p>
<p>Für die HTML-JavaScript-IDE bzw. dessen Code-Editor habe ich übrigens auf das <a href="http://codemirror.net/" title="CodeMirror">CodeMirror 2</a> Framework gebaut. Super Framework, leider muss man erstmal ein bisschen Dokumentation lesen bis man damit zu guten Ergebnisen kommt!</p>
<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=533&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2012/01/reti-ide-simulator-technische-informatik/' addthis:title='ReTI IDE &amp; Simulator (Technische Informatik) ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><em>Keine ähnlichen Beiträge vorhanden</em></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2012/01/reti-ide-simulator-technische-informatik/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Poker Abstraktion</title>
		<link>http://blog.agrafix.net/2011/12/poker-abstraktion/</link>
		<comments>http://blog.agrafix.net/2011/12/poker-abstraktion/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 09:46:35 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[poker]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=501</guid>
		<description><![CDATA[Wie bereits angekündigt wird die nächste Version von Manager&#8217;s Life ein Casino in die Spielwelt integrieren. Dabei darf natürlich kein Multiplayer-Poker fehlen! Poker mit PHP umzusetzen ist eigentlich eine relativ einfache Sache &#8211; der schwierigere Teil ist das erkennen der Poker-Hände beim Showdown (Flush, Straight, Pair, &#8230;). Natürlich kann man einfach alle möglichen Hände hardcoden [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/12/poker-abstraktion/' addthis:title='Poker Abstraktion ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<em>Keine ähnlichen Beiträge vorhanden</em>]]></description>
			<content:encoded><![CDATA[<p>Wie bereits angekündigt wird die nächste Version von <a href="http://managerslife.de" title="Manager's Life" target="_blank">Manager&#8217;s Life</a> ein Casino in die Spielwelt integrieren. Dabei darf natürlich kein Multiplayer-Poker fehlen! </p>
<p>Poker mit PHP umzusetzen ist eigentlich eine relativ einfache Sache &#8211; der schwierigere Teil ist das erkennen der <a href="http://de.wikipedia.org/wiki/Hand_%28Poker%29" title="Hand (Poker)" target="_blank">Poker-Hände</a> beim Showdown (Flush, Straight, Pair, &#8230;). Natürlich kann man einfach alle möglichen Hände hardcoden und dann einfach eine nach der anderen Abarbeiten (siehe zB <a href="http://www.phpclasses.org/package/3149-PHP-Shuffle-and-evaluate-a-Poker-deck-of-cards.html" title="phppokerengine" target="_blank">phppokerengine</a>), das ist aber nicht besonderst elegant, performant oder erweiterbar. Außerdem ist es sehr unübersichtlich und fehleranfällig. Deshalb habe ich mir gedacht, man könnte alle möglichen Poker-Hände mit einer Abstraktions-Sprache definieren und diese dann mit entsprechendem Parser zu behandeln. </p>
<p>Zuerst zu meiner Sprache, die ich wie folgt definiert habe:</p>
<ul>
<li>Gleiche Zahlen stellen gleiche Karten-Werte dar</li>
<li>Gleiche Buchstaben stellen gleiche Farben dar</li>
<li>Ein Fragezeichen steht für eine beliebige Karte</li>
<li>Ein <strong>&gt;</strong> sagt, dass die nächste Karte direkt auf die vorherige folgen muss.</li>
<li>Ein <strong>[</strong> sagt, dass das nächste Zeichen kein Symbol, sondern kein expliziter Kartenwert ist</li>
<li><strong>{<em>x</em>}</strong> nach einem Symbol gibt an, wie oft es wiederholt wird</li>
</ul>
<p></p>
<p>Um das ganze zu konkretisieren habe ich nun alle Poker-Hände in meine Sprache übersetzt:</p>
<p><code>// pair (zB &hearts;A - &diams;A)<br />
1{2}</p>
<p>// two pair (zB &clubs;A - &diams;A - &spades;3 - &clubs;3)<br />
1{2}2{2}</p>
<p>// three of a kind (zB &clubs;A - &diams;A - &spades;A)<br />
1{3}</p>
<p>// straight (zB &clubs;K - &diams;Q - &spades;J - &clubs;10 - &clubs;9)<br />
?>?>?>?>?</p>
<p>// flush (zB &clubs;2 - &clubs;Q - &clubs;9 - &clubs;10 - &clubs;9)<br />
a{5}</p>
<p>// full house  (zB &clubs;K - &diams;K - &spades;Q - &clubs;Q - &clubs;Q)<br />
1{3}2{2}</p>
<p>// four of a kind  (zB &clubs;K - &diams;K - &spades;K - &clubs;K)<br />
1{4}</p>
<p>// straight flush  (zB &clubs;K - &clubs;Q - &clubs;J - &clubs;10 - &clubs;9)<br />
a>a>a>a>a</p>
<p>// royal flush (zB &clubs;A - &clubs;K - &clubs;Q - &clubs;J - &clubs;10)<br />
[a>a>a>a>a</code></p>
<p>Das Parsen und Verarbeiten ist zwar etwas trickreicher, aber machbar. Ich habe einen Quick-n-Dirty PHP-Prototypen gebaut &#8211; er funktioniert, ist allerdings nicht besonderst sauber geschrieben. Im Vergleich zu der Methode &#8220;alle-Möglichkeiten-hardcoren&#8221; entsteht übrigens noch ein weiterer Vorteil: Meine Klasse ist 7kB groß, die oben verlinkte 0,5 MB&#8230;</p>
<p>Die Verwendung der Klasse erfolgt so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// straight flush detector</span>
<span style="color: #000088;">$parser</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PokerParser<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a&gt;a&gt;a&gt;a&gt;a'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$hand</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'color'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'spades'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'card'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'k'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'color'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'spades'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'card'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'q'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'color'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'spades'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'card'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'j'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'color'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'spades'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'card'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'10'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'color'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'spades'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'card'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'9'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$parser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">check</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hand</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Deine Hand enthält ein Straight Flush!&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Kein Straight Flush vorhanden.&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Die Ausgabe sollte &#8220;Deine Hand enthält ein Straight Flush!&#8221; sein.</p>
<p>Die Klasse findet sich dort: <a href='http://blog.agrafix.net/wp-content/uploads/2011/12/PokerParser.class.php_.txt'>PokerParser.class.php</a></p>
<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=501&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/12/poker-abstraktion/' addthis:title='Poker Abstraktion ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><em>Keine ähnlichen Beiträge vorhanden</em></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2011/12/poker-abstraktion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RedBean PHP &#8211; Top oder Flop?</title>
		<link>http://blog.agrafix.net/2011/12/redbean-php-top-oder-flop/</link>
		<comments>http://blog.agrafix.net/2011/12/redbean-php-top-oder-flop/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 13:12:58 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[redbean]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=497</guid>
		<description><![CDATA[Eine Datenbank-Abstraktion mit ORM kann sehr praktisch sein und viel Arbeit sparen, vorallem wenn sie so funktioniert wie RedBean-PHP. Nun, wie funktioniert RedBean-PHP? Eigentlich relativ simpel. Anderst als bei sehr bekannten PHP-ORM-Libraries wie Doctrine oder Propel muss sich der Programmierer theoretisch gar nicht um das Layout der Datenbank kümmern. Er muss also keine Felder oder [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/12/redbean-php-top-oder-flop/' addthis:title='RedBean PHP &#8211; Top oder Flop? ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<em>Keine ähnlichen Beiträge vorhanden</em>]]></description>
			<content:encoded><![CDATA[<p>Eine Datenbank-Abstraktion mit <a href="http://de.wikipedia.org/wiki/Objektrelationale_Abbildung" title="ORM" target="_blank">ORM</a> kann sehr praktisch sein und viel Arbeit sparen, vorallem wenn sie so funktioniert wie <a href="http://redbeanphp.com/" title="RedBean PHP" target="_blank">RedBean-PHP</a>.<br />
Nun, wie funktioniert RedBean-PHP? Eigentlich relativ simpel. Anderst als bei sehr bekannten PHP-ORM-Libraries wie Doctrine oder Propel muss sich der Programmierer theoretisch gar nicht um das Layout der Datenbank kümmern. Er muss also keine Felder oder Relationen vor dem eigentlichen Programmieren definieren, sondern kann sie einfach verwenden, und RedBean-PHP kümmert sich um den Rest. Klingt ziemlich cool, oder? Hier mal ein Beispiel:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// RedBean-PHP besteht aus einer einzigen Datei</span>
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">&quot;rb.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Zur Datenbank verbinden:</span>
<span style="color: #666666; font-style: italic;">// derzeit wird SQLite, MySQL und PostgreSQL unterstützt</span>
R<span style="color: #339933;">::</span><span style="color: #004000;">setup</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql:host=localhost;dbname=redbeantest'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ein haus erstellen</span>
<span style="color: #000088;">$house</span> <span style="color: #339933;">=</span> R<span style="color: #339933;">::</span><span style="color: #004000;">dispense</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'house'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$house</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">color</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'blue'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$house</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">size</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">34</span><span style="color: #339933;">;</span>
R<span style="color: #339933;">::</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$house</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// in der db speichern</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// einen besitzer erstellen</span>
<span style="color: #000088;">$owner</span> <span style="color: #339933;">=</span> R<span style="color: #339933;">::</span><span style="color: #004000;">dispense</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'owner'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$owner</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Alex'</span><span style="color: #339933;">;</span>
R<span style="color: #339933;">::</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$owner</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// in der db speichern</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// das Haus gehört dem Besitzer</span>
<span style="color: #666666; font-style: italic;">// Many-to-Many Relation, da jeder Besitzer </span>
<span style="color: #666666; font-style: italic;">// viele Häuser haben kann und ein Haus </span>
<span style="color: #666666; font-style: italic;">// mehrere Besitzer</span>
R<span style="color: #339933;">::</span><span style="color: #004000;">associate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$owner</span><span style="color: #339933;">,</span> <span style="color: #000088;">$house</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// eine stadt erstellen</span>
<span style="color: #000088;">$city</span> <span style="color: #339933;">=</span> R<span style="color: #339933;">::</span><span style="color: #004000;">dispense</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'city'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$city</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Zauberstadt'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// eine One-to-Many Relation, da </span>
<span style="color: #666666; font-style: italic;">// jedes Haus nur zu einer Stadt </span>
<span style="color: #666666; font-style: italic;">// gehört</span>
<span style="color: #000088;">$city</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ownHouse</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$house</span><span style="color: #339933;">;</span> 
&nbsp;
R<span style="color: #339933;">::</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$city</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// speichern</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// jetzt laden wir mal ein paar sachen aus der DB</span>
<span style="color: #666666; font-style: italic;">// einen besitzer mit dem name Alex finden</span>
<span style="color: #000088;">$person</span> <span style="color: #339933;">=</span> R<span style="color: #339933;">::</span><span style="color: #004000;">findOne</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'owner'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' name = ?'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Alex'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// seine häuser finden</span>
<span style="color: #000088;">$houses</span> <span style="color: #339933;">=</span> R<span style="color: #339933;">::</span><span style="color: #004000;">related</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$person</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'house'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$houses</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// häuser dumpen</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// die häuser der stadt ausgeben</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$city</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ownHouse</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$house</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Haus Nummer <span style="color: #006699; font-weight: bold;">$key</span> ist &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$house</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">color</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Das ganze funktioniert, sobald es eine Datenbank &#8220;redbeantest&#8221; gibt. Es müssen keine Tabellen in der Datenbank erstellt werden, noch Forgein-Keys angelegt werden. (Weitere Beispiele und die Dokumentation sind auf der <a href="http://www.redbeanphp.com/" title="RedBean PHP" target="_blank">Webseite</a>.)</p>
<p>Alles wunderbar, allerdings kommt hier schon ein erstes Problem auf! RedBean PHP stellt nämlich alle Forgein-Keys und dessen Relations auf <em>ON UPDATE SET NULL, ON DELETE SET NULL</em>. Dieses Verhalten ist aber nicht immer gewünscht, das heißt hier muss man aufjedenfall noch nach RedBean-PHP aufräumen bevor die Software in Produktion gehen kann. Ein weiteres Problem ist, dass RedBean-PHP den Typ eines Datenbankfelds nur dann optimal wählt, wenn man es mit genügend Test-Daten füttert. Ansonsten ist auch hier ein nachträgliches Aufräumen nötig. Hier kann man sich also die Frage stellen &#8211; möchte ich lieber später meine Datenbank aufräumen müssen, oder sie direkt von Anfang an korrekt designen?</p>
<p>Ein zweites Problem von RedBean-PHP ist Performance. Das Framework macht, vorallem bei Relations, einfach viel zu viele Datenbank-Abfragen, die bei vielen Zugriffen zu hoher Datenbanklast führen können (Abhilfe schafft hier ein Caching System, allerdings ist das nur hilfreich, wenn keine aktuellen Daten benötigt werden). Hier endet man dann also damit einige R::find und R::related durch eigene Queries zu ersetzen. (was übrigens auch prima funktioniert, aber dann nicht mehr im Sinne von ORM ist&#8230;)</p>
<p>Abgesehen davon ist es aber eine super Sache, man kommt aufjedenfall schnell zu Ergebnissen. Ich würde es für alle kleineren PHP-Projekte empfehlen! Für größere Projekte würde ich davon abraten, da man einfach zu schnell den Überblick verliert und man mit dem &#8220;Aufräumen&#8221; schnell mal etwas übersieht was dann zu kritischen Fehlern führen kann.</p>
<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=497&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/12/redbean-php-top-oder-flop/' addthis:title='RedBean PHP &#8211; Top oder Flop? ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><em>Keine ähnlichen Beiträge vorhanden</em></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2011/12/redbean-php-top-oder-flop/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML5 WebSocket</title>
		<link>http://blog.agrafix.net/2011/11/html5-websocket/</link>
		<comments>http://blog.agrafix.net/2011/11/html5-websocket/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 11:08:57 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[TCP]]></category>
		<category><![CDATA[WebSocket]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=482</guid>
		<description><![CDATA[HTML5 unterstützt jetzt das Aufbauen von &#8220;WebSocket&#8221;-Verbindungen. Eine WebSocket Verbindung basiert ähnlich wie HTTP auf dem TCP Protokoll, baut aber eine &#8220;dauerhafte&#8221; Verbindung auf. Die Vorteile gegenüber HTTP ist, dass eine Aktion des Servers keine vorhergehende Anfrage des Clients mehr erfordert, wodurch der Server neue Informationen fasst in Echtzeit ausliefern kann. Dadurch kann man eine [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/11/html5-websocket/' addthis:title='HTML5 WebSocket ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<strong>Ähnliche Beiträge:</strong><ol>
<li><a href='http://blog.agrafix.net/2011/11/sprechblasen-mit-html5-canvas-und-javascript/' rel='bookmark' title='Sprechblasen mit HTML5, Canvas und JavaScript'>Sprechblasen mit HTML5, Canvas und JavaScript</a></li>
<li><a href='http://blog.agrafix.net/2011/10/javascript-und-geolocation/' rel='bookmark' title='JavaScript und Geolocation'>JavaScript und Geolocation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>HTML5 unterstützt jetzt das Aufbauen von &#8220;WebSocket&#8221;-Verbindungen. Eine WebSocket Verbindung basiert ähnlich wie HTTP auf dem TCP Protokoll, baut aber eine &#8220;dauerhafte&#8221; Verbindung auf. Die Vorteile gegenüber HTTP ist, dass eine Aktion des Servers keine vorhergehende Anfrage des Clients mehr erfordert, wodurch der Server neue Informationen fasst in Echtzeit ausliefern kann. Dadurch kann man eine Menge Traffic und viele unnötige HTTP-Requests sparen, die etwa ein AJAX-JavaScript sonst schicken würde um neue Informationen zu erhalten.<br />
Technisch gesehen baut bei einer WebSocket-Verbindung der Browser mit dem Server eine Verbindung auf, die nach einen Handshake dann bestehen bleibt und über die dann Binär- und Textdaten geschickt werden können.</p>
<p>Leider hat das Protokoll im Handshake einige Sicherheitsprobleme (gehabt?) und sich deshalb ständig verändert. Dieser Artikel bezieht sich also auf die Aktuellste Version (<a href="https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17" title="17" target="_blank">17</a>). Diese wird derzeit von der aktuellsten Chrome Version und anderen Webkit Browsern unterstützt, in Firefox und Opera ist WebSocket wegen der Sicherheitsprobleme derzeit deaktiviert.</p>
<p>Um HTML5 WebSocket zu verwenden ist zunächst ein WebSocket-Server nötig. Ich habe hier nach einer PHP-Variante gesucht und habe dann nach einer Weile folgenden gefunden: <a href="https://github.com/lemmingzshadow/php-websocket" title="PHP-WebSocket" target="_blank">php-websocket</a>. Diesen sollte man sich laden und dann kann man ihn per</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">php <span style="color: #660033;">-q</span> php-websocket<span style="color: #000000; font-weight: bold;">/</span>server<span style="color: #000000; font-weight: bold;">/</span>server.php</pre></div></div>

<p> starten. Jetzt ist ein WebSocket-Server auf &#8220;localhost:8000&#8243; zu erreichen. Dort sind derzeit zwei Module geladen, einmal das Modul &#8220;echo&#8221; und einmal das Modul &#8220;chat&#8221;. (Ich werde mich hier nicht mit der Entwicklung eines WebSocket-Server weiter befassen) Das &#8220;echo&#8221; Modul nimmt einfach Anfragen entgegen und schickt diese dann an alle Verbundenen Sockets weiter.</p>
<p>Nun kümmern wir uns um die HTML5-Seite von WebSocket, dem User-Frontend. Dafür bauen wir uns erstmal eine einfache HTML5 Seite:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>HTML5 WebSocket Test<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- jQuery 1.6.4 zur DOM-Manipulation --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-1.6.4.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- meine eigene Wrapper-Library für WebSocket Verbindungen, siehe unten --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;websocketlib.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
// hier wird dann das WebSocket-Script reinkommen, siehe unten
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;float:right;width:40%;&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Log<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logbox&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Chatbox<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;chatbox&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Say something<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'chat'</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'text'</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">''</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'message'</span> <span style="color: #66cc66;">/</span>&gt;</span>
	 <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'submit'</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'Sagen'</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>Für die einfache Verwendung des WebSockets habe ich mir eine kleine Wrapper-Library (<b>websocketlib.js</b>) programmiert:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * Small wrapper library for HTML5 WebSocket
 * 
 * @author Alexander Thiemann &lt;mail@agrafix.net&gt;
 * @version 1.0
 * 
 * @param string WebSocket host, eg. ws://localhost:8010/echo
 * @param function Function to be called when socket is connected
 * @param function Function to be called when socket recieves data, takes 1 argument message
 * @param function Function to be called for logging purposes, takes 1 argument log-message
 * 
 * @see http://blog.agrafix.net/2011/11/html5-websocket/
 */</span>
<span style="color: #003366; font-weight: bold;">var</span> WebSocketLib <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>host<span style="color: #339933;">,</span> onConnect<span style="color: #339933;">,</span> onRecv<span style="color: #339933;">,</span> onLog<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">socket</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> WebSocket<span style="color: #009900;">&#40;</span>host<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onLog</span> <span style="color: #339933;">=</span> onLog<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onRecv</span> <span style="color: #339933;">=</span> onRecv<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onConnect</span> <span style="color: #339933;">=</span> onConnect<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onLog</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Initializing Socket. State: '</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">socket</span>.<span style="color: #660066;">readyState</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">socket</span>.<span style="color: #660066;">onopen</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>._onOpen<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">socket</span>.<span style="color: #660066;">onmessage</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>._onMessage<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">socket</span>.<span style="color: #660066;">onclose</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>._onClose<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	send<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		WebSocketLib.<span style="color: #660066;">socket</span>.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	_onClose<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		WebSocketLib.<span style="color: #660066;">onLog</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Socket Closed.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	_onMessage<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		WebSocketLib.<span style="color: #660066;">onLog</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Recieved new Message from Server: '</span> <span style="color: #339933;">+</span> msg.<span style="color: #660066;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		WebSocketLib.<span style="color: #660066;">onRecv</span><span style="color: #009900;">&#40;</span>msg.<span style="color: #660066;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	_onOpen<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		WebSocketLib.<span style="color: #660066;">onLog</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Socket is Ready. State: '</span> <span style="color: #339933;">+</span> WebSocketLib.<span style="color: #660066;">socket</span>.<span style="color: #660066;">readyState</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>WebSocketLib.<span style="color: #660066;">socket</span>.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			WebSocketLib.<span style="color: #660066;">onConnect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>	
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ich denke dort ist alles relativ selbsterklärend. Das WebSocket ist wirklich sehr leicht zu verwenden! Um diese Wrapper-Library zu verwenden, bauen wir in obiges HTML-Grundgerüst bei &#8220;<em>// hier wird dann das WebSocket-Script reinkommen, siehe unten</em>&#8221; folgendes ein:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	WebSocketLib.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ws://localhost:8010/echo'</span><span style="color: #339933;">,</span> 
	<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		sockReady<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#chatbox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;p&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#logbox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;p&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> sockReady<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#chat'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #003366; font-weight: bold;">var</span> input <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input[name=&quot;message&quot;]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			WebSocketLib.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span>input.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			input.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Zuerst warten wir, bis unser HTML-Dokument im Browser aufgebaut ist. Dann geben wir in Zeile 2 an, wo unser WebSocket-Server läuft. Die Funktion in Zeile 4 wird aufgerufen, sobald das WebSocket verbunden ist. Die Funktion Zeile 6-8 wird aufgerufen, wenn eine Nachricht zurückgegeben wird. Die Funktion Zeile 9-11 wird bei Log-Ereignissen (Hauptsächlich zum Debuggen) aufgerufen. Mit WebSocketLib.send(&#8220;Nachricht&#8221;) in Zeile 19 schicken wir eine Nachricht an den Server.</p>
<p>Wenn nun alles vorbereitet ist, der WebSocket-Server gestartet ist (siehe oben), können wir einem Browser, der WebSocket unterstützt (siehe oben), unsere HTML-Seite aufrufen. Die Log-Ausgabe im HTML-Fenster sieht wie folgt aus:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Initializing Socket. State: 0
Socket is Ready. State: 1</pre></div></div>

<p>Im Consolenfenster des PHP-Server sehen wir:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">2011-11-25 11:26:47 [info] [client 127.0.0.1:30601] Connected
2011-11-25 11:26:47 [info] [client 127.0.0.1:30601] Performing handshake
2011-11-25 11:26:47 [info] [client 127.0.0.1:30601] Handshake sent</pre></div></div>

<p>Die Verbindung ist nun also aufgebaut. Jetzt sollten wir den &#8220;echo&#8221;-Server testen. Wir tippen etwas in das Textfeld und schicken es ab. Der Log sagt:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Recieved new Message from Server: test</pre></div></div>

<p>Und unter &#8220;Chat&#8221; steht jetzt &#8220;test&#8221;. Hat soweit also funktioniert! Jetzt können wir ein neues Browserfenster aufmachen, wieder den Verbindungsvorgang abwarten und dann dort eine Nachricht verschicken. Diese erscheint dann in allen verbundenen Client-Fenstern.</p>
<p>Eigentlich ziemlich einfach zu verwenden, und es öffnet viele neue Möglichkeiten vorallem in Kombination mit Canvas für HTML5-Multiplayer-Games&#8230; hoffen wir also, dass es bald von allen Browser voll unterstützt wird! <img src='http://blog.agrafix.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=482&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/11/html5-websocket/' addthis:title='HTML5 WebSocket ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><strong>Ähnliche Beiträge:</strong><ol>
<li><a href='http://blog.agrafix.net/2011/11/sprechblasen-mit-html5-canvas-und-javascript/' rel='bookmark' title='Sprechblasen mit HTML5, Canvas und JavaScript'>Sprechblasen mit HTML5, Canvas und JavaScript</a></li>
<li><a href='http://blog.agrafix.net/2011/10/javascript-und-geolocation/' rel='bookmark' title='JavaScript und Geolocation'>JavaScript und Geolocation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2011/11/html5-websocket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mit PHP einen simplen Captcha cracken</title>
		<link>http://blog.agrafix.net/2011/02/mit-php-einen-simplen-captcha-cracken/</link>
		<comments>http://blog.agrafix.net/2011/02/mit-php-einen-simplen-captcha-cracken/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 17:20:55 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programmieren]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[crack]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[internet]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=424</guid>
		<description><![CDATA[Solange ein Captcha nicht sehr aufwändig generiert wurde, ist er auch entsprechend leicht zu knacken. Ich habe hier mal ein Beispiel für einen schlechten Captcha: Was ist an diesem Captcha schlecht? Der auszulesende Inhalt ist nicht abwechselnd genug (immer nur Zahlenfolgen), nicht verzerrt, nicht farblich variierend und hebt sich zu gut vom Hintergrund ab. Das [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/02/mit-php-einen-simplen-captcha-cracken/' addthis:title='Mit PHP einen simplen Captcha cracken ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<em>Keine ähnlichen Beiträge vorhanden</em>]]></description>
			<content:encoded><![CDATA[<p>Solange ein Captcha nicht sehr aufwändig generiert wurde, ist er auch entsprechend leicht zu knacken. Ich habe hier mal ein Beispiel für einen schlechten Captcha:</p>
<p><a href="http://blog.agrafix.net/wp-content/uploads/2011/02/eg_captcha.png" rel="lightbox[424]" title="Schlechter Captcha"><img class="alignnone size-full wp-image-425" title="Schlechter Captcha" src="http://blog.agrafix.net/wp-content/uploads/2011/02/eg_captcha.png" alt="Ein Beispiel für einen schlechten Captcha" width="100" height="35" /></a></p>
<p>Was ist an diesem Captcha schlecht? Der auszulesende Inhalt ist nicht abwechselnd genug (immer nur Zahlenfolgen), nicht verzerrt, nicht farblich variierend und hebt sich zu gut vom Hintergrund ab. Das alles werden wir nun ausnutzen um den Captcha zu knacken. </p>
<p>Zuerst müssen wir &#8220;Zahlendefinitionen&#8221; schreiben. Das heißt wir legen für jede Zahl einige eindeutige Fixpunkte fest, mit denen die Zahl eindeutig identifizierbar ist. </p>
<p>Beispiel an der Zahl &#8220;1&#8243;:</p>
<pre>     OO
    OOO
   OOOO
     OO
     OO
     OO
     OO
     OO
     OO
   OOOOOO           </pre>
<p>Die Definition:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> is_one<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 5</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 5</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 4 / 6</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 6</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 6</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 3 / 7</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 4 / 7</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 7</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 7</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 8</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 8</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 9</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 9</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 10</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 10</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 11</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 11</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 12</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 12</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 13</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 13</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 3 / 14</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 4 / 14</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 5 / 14</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 6 / 14</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 7 / 14</span>
	<span style="color: #000088;">$c</span> <span style="color: #339933;">+=</span> check<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 8 / 14</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">27</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Dort sind nun alle Fixpunkte relativ zum &#8220;ersten&#8221; Fixpunkt gespeichert. Der &#8220;erste&#8221; Fixpunkt ist bei der eins der Punkt ganz unten rechts. Nachdem wir solche Definitionen für alle Zahlen von 0-9 erstellt haben geht&#8217;s nun an die Wiedererkennung der Zahlen. Dazu muss zuerst der Hintergrund herausgefiltert werden und die Grafik in ein besser (für unser Programm) lesbares Format gebracht werden. Dies mache ich wie folgt:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> read<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageCreateFromPNG</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$pix</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$sy</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageSy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$sx</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ImageSx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$y</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$y</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$sy</span><span style="color: #339933;">;</span><span style="color: #000088;">$y</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$sx</span><span style="color: #339933;">;</span><span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$col</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorat</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$rgb</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorsforindex</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$col</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rgb</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;red&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">150</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$pix</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$y</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;O&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$pix</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$y</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;W&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// ...</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Nun haben wir den Array $pix, der bei [x][y] entweder W (für weiß) oder O (für schwarz) enthält. Jetzt müssen wir nur noch durch den Array durchgehen und nach unseren Fixpunkt-Mustern suchen:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">        <span style="color: #666666; font-style: italic;">// ....</span>
&nbsp;
        <span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$complete_string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$found_at</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$sx</span><span style="color: #339933;">;</span><span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$y</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$y</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$sy</span><span style="color: #339933;">;</span><span style="color: #000088;">$y</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$y</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;O&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$x</span>|<span style="color: #006699; font-weight: bold;">$y</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$found_at</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_one<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_two<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_three<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_four<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_five<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_six<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_seven<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">7</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_eight<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_nine<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pix</span><span style="color: #339933;">,</span> <span style="color: #000088;">$x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$y</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$no</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$no</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$found_at</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$x</span>|<span style="color: #006699; font-weight: bold;">$y</span>&quot;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$complete_string</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$no</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//...</span></pre></div></div>

<p>Die Variable $complete_string enthält nun den ausgelesenen String. Simple as that <img src='http://blog.agrafix.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
<p>Hier der gesamte Code inklusive der Hilfsfunktion <b>check()</b>. Der Code ist schon etwas älter, also nicht über schlechten Code-Stil wundern &#8211; er soll legendlich das Prinzip erklären: <a href="http://agrafix.net.pastebin.com/b6exg0SW">http://agrafix.net.pastebin.com/b6exg0SW</a></p>
<p>Noch ein Screenshot:<br />
<a href="http://blog.agrafix.net/wp-content/uploads/2011/02/cracked_captcha001.jpg" rel="lightbox[424]" title="Captcha Cracked"><img src="http://blog.agrafix.net/wp-content/uploads/2011/02/cracked_captcha001.jpg" alt="Geknackter Captcha" title="Captcha Cracked" width="158" height="87" class="alignnone size-full wp-image-431" /></a></p>
<p>Das war&#8217;s schon &#8211; viel Vergnügen damit!</p>
<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=424&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/02/mit-php-einen-simplen-captcha-cracken/' addthis:title='Mit PHP einen simplen Captcha cracken ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><em>Keine ähnlichen Beiträge vorhanden</em></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2011/02/mit-php-einen-simplen-captcha-cracken/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Visitor-Stats.de Update</title>
		<link>http://blog.agrafix.net/2011/01/visitor-stats-de-update/</link>
		<comments>http://blog.agrafix.net/2011/01/visitor-stats-de-update/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 15:46:43 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[Aktuelles]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programmieren]]></category>
		<category><![CDATA[Projekte]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[visitor-stats]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=408</guid>
		<description><![CDATA[Heute habe ich endlich mal wieder ein Update für visitor-stats.de fertiggestellt. Große optische Änderungen sind wohl nicht zu erkennen, dennoch wurde hinter den Kulissen einiges verändert. Die JavaScripts basieren jetzt auf jquery und die AJAX-API gibt json-formatierte Antworten. Außerdem habe ich einen &#8220;loadscreen&#8221; eingebaut, der bei gesendeten AJAX-Requests erscheint. Das Projekt ist unter http://www.visitor-stats.de zu [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/01/visitor-stats-de-update/' addthis:title='Visitor-Stats.de Update ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<strong>Ähnliche Beiträge:</strong><ol>
<li><a href='http://blog.agrafix.net/2009/08/ein-weiteres-wordpress-update/' rel='bookmark' title='Ein weiteres WordPress Update'>Ein weiteres WordPress Update</a></li>
<li><a href='http://blog.agrafix.net/2011/02/zippyshare-downloads-automatisieren-update/' rel='bookmark' title='Zippyshare Downloads Automatisieren *update*'>Zippyshare Downloads Automatisieren *update*</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Heute habe ich endlich mal wieder ein Update für visitor-stats.de fertiggestellt. Große optische Änderungen sind wohl nicht zu erkennen, dennoch wurde hinter den Kulissen einiges verändert. Die JavaScripts basieren jetzt auf<a href="http://jquery.com/" target="_blank" title="jQuery JavaScript Framework"> jquery </a>und die AJAX-API gibt json-formatierte Antworten. Außerdem habe ich einen &#8220;loadscreen&#8221; eingebaut, der bei gesendeten AJAX-Requests erscheint. </p>
<p>Das Projekt ist unter <a href="http://www.visitor-stats.de">http://www.visitor-stats.de</a> zu finden.</p>
<p>Für die Realisierung der AJAX-API mit json Antworten habe ich <a href="http://de3.php.net/json_encode">json_encode()</a> benutzt.</p>
<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=408&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2011/01/visitor-stats-de-update/' addthis:title='Visitor-Stats.de Update ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><strong>Ähnliche Beiträge:</strong><ol>
<li><a href='http://blog.agrafix.net/2009/08/ein-weiteres-wordpress-update/' rel='bookmark' title='Ein weiteres WordPress Update'>Ein weiteres WordPress Update</a></li>
<li><a href='http://blog.agrafix.net/2011/02/zippyshare-downloads-automatisieren-update/' rel='bookmark' title='Zippyshare Downloads Automatisieren *update*'>Zippyshare Downloads Automatisieren *update*</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2011/01/visitor-stats-de-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DSLan v1.4</title>
		<link>http://blog.agrafix.net/2010/08/dslan-v1-4/</link>
		<comments>http://blog.agrafix.net/2010/08/dslan-v1-4/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 20:57:23 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projekte]]></category>
		<category><![CDATA[1.4]]></category>
		<category><![CDATA[dslan]]></category>
		<category><![CDATA[staemme]]></category>
		<category><![CDATA[version]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=367</guid>
		<description><![CDATA[Liebe Leser, gerade eben haben wir die DSLan v1.4 veröffentlicht. Die DSLan ermöglicht es einen Local-Area-Netzwerk Server mit maximal 10 Spielern des Spiels Die-Stämme zu erstellen. Download und weitere Info&#8217;s: http://dslan.gfx-dose.de Liebe Grüße, Agrafix Ähnliche Beiträge: Jubiläum jQuery in Greasemonkey<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2010/08/dslan-v1-4/' addthis:title='DSLan v1.4 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<strong>Ähnliche Beiträge:</strong><ol>
<li><a href='http://blog.agrafix.net/2009/08/jubilaum/' rel='bookmark' title='Jubiläum'>Jubiläum</a></li>
<li><a href='http://blog.agrafix.net/2011/02/jquery-in-greasemonkey/' rel='bookmark' title='jQuery in Greasemonkey'>jQuery in Greasemonkey</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Liebe Leser,</p>
<p>gerade eben haben wir die<a href="http://dslan.gfx-dose.net" target="_blank" title="Die Stämme Lan"> DSLan </a>v1.4 veröffentlicht. Die<a href="http://dslan.gfx-dose.net" target="_blank" title="Die Stämme Lan"> DSLan </a>ermöglicht es einen Local-Area-Netzwerk Server mit maximal 10 Spielern des Spiels Die-Stämme zu erstellen.</p>
<p>Download und weitere Info&#8217;s: <a href="http://dslan.gfx-dose.de">http://dslan.gfx-dose.de</a></p>
<p>Liebe Grüße,<br />
Agrafix</p>
<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=367&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2010/08/dslan-v1-4/' addthis:title='DSLan v1.4 ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><strong>Ähnliche Beiträge:</strong><ol>
<li><a href='http://blog.agrafix.net/2009/08/jubilaum/' rel='bookmark' title='Jubiläum'>Jubiläum</a></li>
<li><a href='http://blog.agrafix.net/2011/02/jquery-in-greasemonkey/' rel='bookmark' title='jQuery in Greasemonkey'>jQuery in Greasemonkey</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2010/08/dslan-v1-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zwei einfache Algorithmen: kgV und ggT</title>
		<link>http://blog.agrafix.net/2009/12/zwei-einfache-algorithmen-kgv-und-ggt/</link>
		<comments>http://blog.agrafix.net/2009/12/zwei-einfache-algorithmen-kgv-und-ggt/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 21:55:47 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[mathe]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=199</guid>
		<description><![CDATA[Heute präsentiere ich endlich mal wieder einen Beitrag der sich in die Richtung Mathe/Informatik bewegt. Eigentlich nichts weltbewegendes, nur zwei einfache Algorithmen, die einem beispielsweise beim Bruchrechnen das Leben einfacher machen können: Das kleinste gemeinsame Vielfache und der größte gemeinsame Teiler. &#60;?php /** * größer gemeinsamer Teiler nach Euclid * * @param int $a * [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2009/12/zwei-einfache-algorithmen-kgv-und-ggt/' addthis:title='Zwei einfache Algorithmen: kgV und ggT ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<em>Keine ähnlichen Beiträge vorhanden</em>]]></description>
			<content:encoded><![CDATA[<p>Heute präsentiere ich endlich mal wieder einen Beitrag der sich in die Richtung Mathe/Informatik bewegt. Eigentlich nichts weltbewegendes, nur zwei einfache Algorithmen, die einem beispielsweise beim Bruchrechnen das Leben einfacher machen können: Das kleinste gemeinsame Vielfache und der größte gemeinsame Teiler.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * größer gemeinsamer Teiler nach Euclid
 *
 * @param int $a
 * @param int $b
 * @return int
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> ggT<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$a</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> ggT<span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">%</span><span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * kleinstes gemeinsames Vielfaches
 *
 * @param int $a
 * @param int $b
 * @return int
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> kgV<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">*</span><span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>ggT<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Beispiel</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type:text/plain&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;ggT(114, 24) = &quot;</span><span style="color: #339933;">.</span>ggT<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">114</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">24</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;kgV(45, 35) = &quot;</span><span style="color: #339933;">.</span>kgV<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">45</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">35</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Die Ausgabe sollte wie folgt aussehen:</p>
<pre>ggT(114, 24) = 6
kgV(45, 35) = 315</pre>
<p>Wer den ggT bzw den kgV von mehreren Zahlen braucht, kann sich an folgende Regel halten:</p>
<pre>kgV(a, b, c, d) = kgV(kgV(a, b), kgV(c, d))</pre>
<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=199&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2009/12/zwei-einfache-algorithmen-kgv-und-ggt/' addthis:title='Zwei einfache Algorithmen: kgV und ggT ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><em>Keine ähnlichen Beiträge vorhanden</em></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2009/12/zwei-einfache-algorithmen-kgv-und-ggt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP und register_globals</title>
		<link>http://blog.agrafix.net/2009/08/php-und-register_globals/</link>
		<comments>http://blog.agrafix.net/2009/08/php-und-register_globals/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 17:06:15 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[register_globals]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=44</guid>
		<description><![CDATA[Ich versteh&#8217; es einfach nicht. Warum gibt es immer noch Webhoster die die php.ini-Setting register_globals aktiviert haben? Ich war gestern abend mindestens eine halbe Stunde auf Bug-Suche, bis ich bemerkt hatte das unser liebes register_globals Variablen definiert hatte &#8211; die eigentlich leer bleiben hätte sollen. Ja, man darf mir jetzt unsauberes Coden vorwerfen &#8211; ich [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2009/08/php-und-register_globals/' addthis:title='PHP und register_globals ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<strong>Ähnliche Beiträge:</strong><ol>
<li><a href='http://blog.agrafix.net/2010/02/was-hat-apple-gegen-flash/' rel='bookmark' title='Was hat Apple gegen Flash?'>Was hat Apple gegen Flash?</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Ich versteh&#8217; es einfach nicht. Warum gibt es immer noch Webhoster die die php.ini-Setting register_globals aktiviert haben? Ich war gestern abend mindestens eine halbe Stunde auf Bug-Suche, bis ich bemerkt hatte das unser liebes register_globals Variablen definiert hatte &#8211; die eigentlich leer bleiben hätte sollen. Ja, man darf mir jetzt unsauberes Coden vorwerfen &#8211; ich hätte jeder Variable vor der Verwendung ja einen Initialwert geben können. Allerdings kommt PHP doch eigentlich auch gut ohne aus &#8211; und wenn man mal was quick&#8217;n'dirty machen will scheitert PHP an seinen eigenen Einstellungen&#8230;</p>
<p>register_globals wird endlich mit PHP6 abgeschafft &#8211; seit PHP5.3 gillt es als &#8220;veraltet&#8221;. Und warum gibt&#8217;s dann immer noch Webhoster die sowas standardmäßig aktivieren?!</p>
<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=44&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2009/08/php-und-register_globals/' addthis:title='PHP und register_globals ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><strong>Ähnliche Beiträge:</strong><ol>
<li><a href='http://blog.agrafix.net/2010/02/was-hat-apple-gegen-flash/' rel='bookmark' title='Was hat Apple gegen Flash?'>Was hat Apple gegen Flash?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2009/08/php-und-register_globals/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quadratische Gleichung Lösen</title>
		<link>http://blog.agrafix.net/2009/07/quadratische-gleichung-losen/</link>
		<comments>http://blog.agrafix.net/2009/07/quadratische-gleichung-losen/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 13:06:42 +0000</pubDate>
		<dc:creator>agrafix</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.agrafix.net/?p=18</guid>
		<description><![CDATA[Um das wp-syntax plugin zu testen habe ich ein kleines PHP Script zum Lösen von quadratischen Gleichungen veröffentlicht: &#60;?php /** * ax² + bx + c = 0 solver * * @author agrafix.net */ header&#40;&#34;Content-Type: text/plain;charset=utf-8&#34;&#41;; &#160; // input -&#62; ax² + bx + c = 0 $a = 1; $b = 3; $c = [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2009/07/quadratische-gleichung-losen/' addthis:title='Quadratische Gleichung Lösen ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
<em>Keine ähnlichen Beiträge vorhanden</em>]]></description>
			<content:encoded><![CDATA[<p>Um das wp-syntax plugin zu testen habe ich ein kleines PHP Script zum Lösen von quadratischen Gleichungen veröffentlicht:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * ax² + bx + c = 0 solver
 * 
 * @author agrafix.net
 */</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: text/plain;charset=utf-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// input -&gt; ax² + bx + c = 0</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// calc</span>
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;Eq: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$a</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;x² + &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$b</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;x + &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$c</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; = 0<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #990000;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">*</span><span style="color: #000088;">$a</span><span style="color: #339933;">*</span><span style="color: #000088;">$c</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;D = <span style="color: #006699; font-weight: bold;">$d</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$d</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;L = {}&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$x1</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #000088;">$b</span> <span style="color: #339933;">+</span> <span style="color: #990000;">sqrt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$x2</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #000088;">$b</span> <span style="color: #339933;">-</span> <span style="color: #990000;">sqrt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$d</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x1</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$x2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;L = {&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;}&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;L = {&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;}&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<img src="http://blog.agrafix.net/?ak_action=api_record_view&id=18&type=feed" alt="" /><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://blog.agrafix.net/2009/07/quadratische-gleichung-losen/' addthis:title='Quadratische Gleichung Lösen ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p><em>Keine ähnlichen Beiträge vorhanden</em></p>]]></content:encoded>
			<wfw:commentRss>http://blog.agrafix.net/2009/07/quadratische-gleichung-losen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

