<?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>BOHUCO.NET &#187; Tech</title>
	<atom:link href="http://bohuco.net/blog/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://bohuco.net/blog</link>
	<description>Die Sollbruchstelle des Internets.</description>
	<lastBuildDate>Thu, 02 Feb 2012 22:00:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Firefox 4 &#8211; Neue HTTP Header</title>
		<link>http://bohuco.net/blog/2011/04/firefox-4-neue-http-header/</link>
		<comments>http://bohuco.net/blog/2011/04/firefox-4-neue-http-header/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 18:52:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Online Marketing]]></category>
		<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Entwicklung]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1764</guid>
		<description><![CDATA[Mit der neuen Version des Firefox wurden einige neue HTTP Header eingeführt die Entwicklern die Arbeit etwas erleichtern sollen und den Benutzer besser schützen. Framebreaker &#8211; X-Frame-Options Mit dem Header X-Frame-Options:DENY wird angezeigt das die Seite nicht in einem iFrame/Frame eingebunden werden darf. Alternativ geht auch die Einstellung: SAMEORIGIN damit zumindest Seiten von der selben [...]]]></description>
			<content:encoded><![CDATA[<p>Mit der neuen Version des Firefox wurden einige neue HTTP Header eingeführt die Entwicklern die Arbeit etwas erleichtern sollen und den Benutzer besser schützen.</p>
<p><span id="more-1764"></span></p>
<h2>Framebreaker &#8211; X-Frame-Options</h2>
<p>Mit dem Header<a href="https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header"> X-Frame-Options:DENY</a> wird angezeigt das die Seite nicht in einem iFrame/Frame eingebunden werden darf. Alternativ geht auch die Einstellung: SAMEORIGIN damit zumindest Seiten von der selben Domain die Seite framen dürfen.</p>
<h2>Nicht Tracken &#8211; DNT</h2>
<p>Der DNT (Do Not Track)-Header wird vom Firefox als Anfrage-Header mitgeschickt wenn der Benutzer das konfiguriert hat. Er soll anzeigen das man den User nicht für Werbezwecke verfolgen soll. Laut <a href="http://blog.sidstamm.com/2011/01/opting-out-of-behavioral-ads.html">Blog Artikel</a> sind damit die &#8220;Online Behavioral Ads&#8221; bzw. Remarketing gemeint.</p>
<h2>User Agent kürzer</h2>
<p>Der <a href="https://developer.mozilla.org/En/Gecko_User_Agent_String_Reference">Firefox User Agent Header</a> wurde verkürzt und verrät jetzt weniger. Der <a href="http://hacks.mozilla.org/2010/09/final-user-agent-string-for-firefox-4/">UA für Firefox 4</a> sieht damit zum Beispiel so aus: </p>
<pre>Mozilla/5.0 (Windows NT x.y; rv:2.0.1) Gecko/20100101 Firefox/4.0.1</pre>
<h2>SSL aber fix &#8211; Strict-Transport-Security</h2>
<p>Der <a href="https://developer.mozilla.org/en/Security/HTTP_Strict_Transport_Security">Strict-Transport-Security Header</a> zeigt an das die Seite nur über SSL aufrufbar ist. Dieser Header wird vom Server geschickt und dann im Browser zwischengespeichert. Nach dem ersten Aufruf weiß der Browser also dann immer das die Seite nur verschlüsselt angezeigt werden kann. Man kann den Header auf Subdomains ausweiten und mit einem Timeout versehen:</p>
<pre>Strict-Transport-Security: max-age:expireTime [; includeSubdomains]</pre>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/04/firefox-4-neue-http-header/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embed YouTube Videos With iFrame in WordPress (Editor removes Tag Problem)</title>
		<link>http://bohuco.net/blog/2011/03/embed-youtube-videos-with-iframe-in-wordpress-editor-removes-tag-problem/</link>
		<comments>http://bohuco.net/blog/2011/03/embed-youtube-videos-with-iframe-in-wordpress-editor-removes-tag-problem/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 22:05:17 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Youtube]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1737</guid>
		<description><![CDATA[This damn WordPress visual editor removes always your YouTube video iFrame? Just install the TSL iframe unfilter plugin and the editor will leave your code untouched &#8230;]]></description>
			<content:encoded><![CDATA[<p>This damn WordPress visual editor removes always your YouTube video iFrame? Just install the <a href="http://wordpress.org/extend/plugins/tsl-iframe-unfilter/">TSL iframe unfilter</a> plugin and the editor will leave your code untouched &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/03/embed-youtube-videos-with-iframe-in-wordpress-editor-removes-tag-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Translate your Site with Google Translate and jQuery</title>
		<link>http://bohuco.net/blog/2011/02/translate-your-site-with-google-translate-and-jquery/</link>
		<comments>http://bohuco.net/blog/2011/02/translate-your-site-with-google-translate-and-jquery/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 11:14:38 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Web Entwicklung]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[translate]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1723</guid>
		<description><![CDATA[With the new Google Translate API and the jQuery Plugin from Balazs Endresz you can add more language versions within seconds. We need the HTML for the language-chooser and a short javascript &#8230; &#160; &#60;script&#62; &#160; $(function(){ $('#languages a').click(function(evt){ $('#content').translate($(this).attr('rel')); $('#languages a').removeClass('active'); $(this).addClass('active'); }); }); &#160; &#60;/script&#62; &#160; &#60;div id=&#34;languages&#34;&#62; &#60;a rel=&#34;de&#34; class=&#34;active&#34; href=&#34;#&#34;&#62;Deutsch&#60;/a&#62; &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>With the new <a href="http://translate.google.com/">Google Translate API</a> and the jQuery Plugin from <a href="http://code.google.com/p/jquery-translate/">Balazs Endresz</a> you can add more language versions within seconds.</p>
<p><span id="more-1723"></span></p>
<p>We need the HTML for the language-chooser and a short javascript &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&nbsp;
&lt;script&gt; 
&nbsp;
	$(function(){
		$('#languages a').click(function(evt){
			$('#content').translate($(this).attr('rel'));
			$('#languages a').removeClass('active');
			$(this).addClass('active');
		});
	});
&nbsp;
&lt;/script&gt;
&nbsp;
&lt;div id=&quot;languages&quot;&gt;
	&lt;a rel=&quot;de&quot; class=&quot;active&quot; href=&quot;#&quot;&gt;Deutsch&lt;/a&gt;
	| &lt;a rel=&quot;en&quot; href=&quot;#&quot;&gt;English&lt;/a&gt;
	| &lt;a rel=&quot;es&quot; href=&quot;#&quot;&gt;Español&lt;/a&gt;
	| &lt;a rel=&quot;fr&quot; href=&quot;#&quot;&gt;Française&lt;/a&gt;
&lt;/div&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/02/translate-your-site-with-google-translate-and-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>OAuth mit PHP am Beispiel der Twitter API</title>
		<link>http://bohuco.net/blog/2011/02/oauth-mit-php-am-beispiel-der-twitter-api/</link>
		<comments>http://bohuco.net/blog/2011/02/oauth-mit-php-am-beispiel-der-twitter-api/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 11:10:06 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1706</guid>
		<description><![CDATA[Auf den ersten Blick ist OAuth eine scheißkomplizierte Sache, aber mit dieser kurzen Anleitung und dem Zend Framework wird es plötzlich ganz einfach &#8230; &#8220;Signierte Requests&#8221;, &#8220;Request- und Access-Token&#8221; &#8230; alles nicht so schlimm wie es sich anhört. Die Zend_Oauth_Consumer Klasse von Zend Framework nimmt einem die meiste Arbeit ab. Am Beispiel von Twitter zeig [...]]]></description>
			<content:encoded><![CDATA[<p>Auf den ersten Blick ist OAuth eine scheißkomplizierte Sache, aber mit dieser kurzen Anleitung und dem Zend Framework wird es plötzlich ganz einfach &#8230;</p>
<p><span id="more-1706"></span></p>
<p>&#8220;Signierte Requests&#8221;, &#8220;Request- und Access-Token&#8221; &#8230; alles nicht so schlimm wie es sich anhört. Die Zend_Oauth_Consumer Klasse von Zend Framework nimmt einem die meiste Arbeit ab. Am Beispiel von Twitter zeig ich mal schnell wie das geht.</p>
<p><strong>Allgemein</strong><br />
Der grundsätzliche Ablauf ist folgender: Als erstes bei der API einen Request-Token anfordern, mit diesem Token dann den Benutzer auf die Twitter-Seite umleiten (Redirect) und wenn der Benutzer auf &#8220;Erlauben&#8221; klickt wird man zurück auf die eigene Seite umgeleitet und bekommt einen Access-Token.</p>
<p>Für den ganzen Ablauf muß man sich vorher von Twitter einen consumerKey und consumerSecret abholen, dazu muß die eigene Anwendung, die auf die Twitter API zugreifen will, registriert werden. Das kann man unter folgender URL machen: <a href="http://dev.twitter.com/apps/new">http://dev.twitter.com/apps/new</a></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$config</span><span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'callbackUrl'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://bohuco.net/labs/twitter-backup'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'siteUrl'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://twitter.com/oauth'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'consumerKey'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ueQgVFLypAzN0vkbiZiyw'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'consumerSecret'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'9SB9W8J66lPsKyu766bzGpoPN21q0tjJh6JV1Rp8'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Request Token anfordern</strong><br />
Der Request Token dient dazu die nachfolgende Anfrage zu signieren und gilt immer nur für einen Request. Man braucht ihn also für den nachfolgenden Redirect auf die Twitter-Authorize Seite. Den Request Token muß man aufheben weil man damit die Antwort von Twitter wieder entschlüsseln muß darum speichern wir ihn in der Session.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$consumer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Oauth_Consumer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$token</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$consumer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequestToken</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_REQUEST_TOKEN'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Wenn man den Request Token in der Session hinterlegt hat kann man den Benutzer auf die Twitter Seite umleiten und hoffen das er mit einer positiven Antwort zurückkommt &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$consumer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-12-um-12.03.21.png"><img src="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-12-um-12.03.21-300x159.png" alt="" title="Bildschirmfoto 2011-02-12 um 12.03.21" width="300" height="159" class="aligncenter size-medium wp-image-1707" /></a></p>
<p>Falls der Benutzer dann wirklich zurückkommt wird mittels Request-Token (aus der Session) und der Antwort von Twitter (die in $_GET steht) der Access-Token erzeugt. Den Access-Token kann man entweder in der Session oder in der Datenbank speichern, er läuft nicht ab und gilt solange bis der Benutzer diese Berechtigung bei Twitter wieder aufhebt.</p>
<p>Den Request-Token kann man vergessen den braucht man jetzt nicht mehr.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$consumer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Oauth_Consumer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_ACCESS_TOKEN'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$consumer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAccessToken</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #339933;">,</span> <span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_REQUEST_TOKEN'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_REQUEST_TOKEN'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span></pre></div></div>

<p>Der gesamte Quelltext würde dann ca. so aussehen &#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$config</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'callbackUrl'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://bohuco.net/labs/twitter-backup'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'siteUrl'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://twitter.com/oauth'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'consumerKey'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ueQgVFLypAzN0vkbiZiyw'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'consumerSecret'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'9SB9W8J66lPsKyu766bzGpoPN21q0tjJh6JV1Rp8'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// get request token and redirect user to twitter authorize page</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_ACCESS_TOKEN'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$consumer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Oauth_Consumer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$token</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$consumer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequestToken</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_REQUEST_TOKEN'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$token</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$consumer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirect</span><span style="color: #009900;">&#40;</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;">// user come back from twitter</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_REQUEST_TOKEN'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$consumer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Oauth_Consumer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_ACCESS_TOKEN'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$consumer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAccessToken</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #339933;">,</span> <span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_REQUEST_TOKEN'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_REQUEST_TOKEN'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// user has granted access ... now we can use the api</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_ACCESS_TOKEN'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000088;">$token</span> <span style="color: #339933;">=</span> <span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'TWITTER_ACCESS_TOKEN'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$userName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$token</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">screen_name</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$twitter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Service_Twitter<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$userName</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'accessToken'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$token</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$twitter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">account</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">rateLimitStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// ...</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Damit man es besser versteht hab ich das in einer Grafik festgehalten &#8230;</p>
<p><a href="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-12-um-12.05.12.png"><img src="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-12-um-12.05.12.png" alt="" title="Bildschirmfoto 2011-02-12 um 12.05.12" width="611" height="585" class="aligncenter size-full wp-image-1708" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/02/oauth-mit-php-am-beispiel-der-twitter-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP in der Cloud: cloudControl aus Deutschland bietet PaaS für PHP</title>
		<link>http://bohuco.net/blog/2011/02/php-cloud-cloudcontrol-paas/</link>
		<comments>http://bohuco.net/blog/2011/02/php-cloud-cloudcontrol-paas/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 21:11:39 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[paas]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1689</guid>
		<description><![CDATA[Wer eine Webseite betreibt oder gar eine Webapplikation muss sich unweigerlich um Hosting und Server Administration kümmern. Dabei gibt es mittlerweile unendlich viele Möglichkeiten &#8230; aber jetzt kommt noch eine dazu: Platform as a Service (PaaS) Keine Hardware Investitionen, nie wieder Server administrieren oder Sicherheitspatches einspielen müssen, das System skaliert automatisch und das Deploy wird [...]]]></description>
			<content:encoded><![CDATA[<p>Wer eine Webseite betreibt oder gar eine Webapplikation muss sich unweigerlich um Hosting und Server Administration kümmern. Dabei gibt es mittlerweile unendlich viele Möglichkeiten &#8230; aber jetzt kommt noch eine dazu: <strong>Platform as a Service (PaaS)</strong></p>
<p>Keine Hardware Investitionen, nie wieder Server administrieren oder Sicherheitspatches einspielen müssen, das System skaliert automatisch und das Deploy wird einfacher: Das klingt doch alles wunderbar und das alles bietet SaaS!</p>
<p>Platform as a Service (PaaS) gibt es seit einigen Jahren für Java (<a href="http://code.google.com/appengine/">Google AppEngine</a>) oder für .NET (<a href="http://www.microsoft.com/windowsazure/">Microsoft Azure</a>) aber für PHP sieht es derzeit noch etwas mau aus. Diese Lücke möchte jetzt <a href="http://cloudcontrol.com">cloudControl</a> aus Potsdam schließen &#8230;</p>
<p><span id="more-1689"></span></p>
<p><strong>Die Features</strong></p>
<p>cloudControl ist in erster Linie eine Webserver-Plattform basierend auf Linux mit Apache und PHP, für eine funktionierende Webapplikation wird allerdings auch eine Datenbank benötigt. Derzeit stehen MongoDb und MySQL in unterschiedlichen Größen zur Auswahl. Maximal kann eine MySQL Datenbank ein Terabyte groß sein. Für MongoDb ist regulär bei 250 GB Schluss, mehr gibt&#8217;s aber anscheinend auf Anfrage.</p>
<p>Außerdem stehen noch folgende Add-ons zur Verfügung: <a href="http://memcached.org/">Memcached</a> als Caching-Layer, für das Monitoring <a href="http://www.newrelic.com/web-app-monitoring-features.html">New Relic RPM</a> und SSL. </p>
<p>Alle Plattform-Funktionen werden über das spezielle Kommandozeilen Werkzeug cctrl gesteuert. Manche Features kann man zusätzlich über die geschützte WebConsole abrufen.</p>
<p>Mit cloudControl lässt sich ein Staging-System mit beliebigen Aufbau realisieren. Jeder Stage (auch Deployment genannt) ist dabei ein eigener Branch und lässt sich mit dem Deploy-Tool separat ansprechen, ein Deploy auf den Test-Stage würde so aussehen:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">&nbsp;
cctrlapp bohuco/test deploy</pre></div></div>

<p>Die <a href="http://cloudcontrol.com/developers/documentation/user-management/account-management/">Benutzerverwaltung</a> wird auch über die Kommandozeile gemacht. Der Inhaber einer Applikation kann beliebige Entwickler hinzufügen und entfernen (cctrluser create / activate / delete).</p>
<p><strong>Der Preis</strong></p>
<p>cloudControl rechnet in sogenannten Boxen ab. Eine Box kann 2 PHP Requests pro Sekunde bearbeiten und ist vergleichbar mit einer viertel <a href="http://aws.amazon.com/ec2/faqs/#What_is_an_EC2_Compute_Unit_and_why_did_you_introduce_it">Amazon EC2 Compute Unit</a>. Die erste Box ist kostenlos, jede weitere kostet 0,05 EUR pro Stunde. Die Boxen werden automatisch auf die aktuellen Anforderungen skaliert bis zu einer Maximalgrenze die der Benutzer festlegen kann.</p>
<p><a href="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-08-um-20.16.07.png"><img src="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-08-um-20.16.07-300x208.png" alt="" title="Bildschirmfoto 2011-02-08 um 20.16.07" width="300" height="208" class="aligncenter size-medium wp-image-1690" /></a></p>
<p>Alle Features lassen sich kostenlos auf unbegrenzte Zeit testen. Dabei sind die Add-ons auf relativ enge Grenzen gesetzt, wenn man mehr braucht werden dann zusätzliche Kosten fällig die auch stündlich abgerechnet werden. Die kostenlose MySQL-DB darf zum Beispiel nur 5 Mb haben, eine MongoDB 16 Mb. </p>
<p><strong>Handling</strong></p>
<p>Die Kommunikation mit der Plattform wird über ein Kommandozeilen-Tool namens <a href="http://pypi.python.org/pypi/cctrl/1.0.0">cctrl</a> abgewickelt (in Python geschrieben ???). Das Tool ist für Windows, Mac und Linux verfügbar und die Handhabung wird in verschiedenen Tutorials beschrieben. Für die Source-Code-Versionierung wird standardmäßig <a href="http://bazaar.canonical.com/en/">Bazar</a> verwendet, man kann aber einfach beim Anlegen eines neuen Projekts Git angeben:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">&nbsp;
cctrlapp APP_NAME create php --repo git</pre></div></div>

<p>Mein Test-Projekt war innerhalb weniger Minuten angelegt und am Server verfügbar. Folgende Schritte waren notwendig (Mac OSX):</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">&nbsp;
mkdir bohuco
cd bohuco
cctrlapp bohuco create php --repo git
vim index.php
git init
git add .
git commit -m &quot;initial commit&quot;
cctrlapp bohuco push
cctrlapp bohuco deploy</pre></div></div>

<p>Voilà: <a href="http://bohuco.cloudcontrolled.com/">http://bohuco.cloudcontrolled.com/</a></p>
<p>Wie man auf dem phpinfo() Screenshot sieht, ist derzeit PHP 5.3.2 installiert, APC ist aktiviert, memory_limit ist auf 128 MB, post_max_size auf 20 MB &#8230;</p>
<p> <a href="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-08-um-20.56.34.png"><img src="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-08-um-20.56.34-281x300.png" alt="" title="Bildschirmfoto 2011-02-08 um 20.56.34" width="281" height="300" class="aligncenter size-medium wp-image-1692" /></a></p>
<p>Gehostet wird laut Twitter-Aussage auf Amazon EC2 in Irland: &#8220;@brgmn Freut uns, dass es gefällt. Server sind zur Zeit Amazon EC2 EU Region. ^pst&#8221;. Einige Details zum technische Setup kann man in den <a href="http://cloudcontrol.com/developers/faq-en/features-and-functions/">FAQs</a> finden.</p>
<p><strong>Dokumentation und Support</strong></p>
<p>&#8230; lassen keine Wünsche offen. Support via Telefon, E-Mail, Twitter und Chat. Die Dokumentation ist umfangreich und gut gegliedert. <a href="http://cloudcontrol.com/developers/tutorial/choose-operating-system/">Tutorials</a> für unterschiedliche Betriebssysteme und sogar einen <a href="http://cloudcontrol.com/assets/downloads/cloudControl_cheatsheet.pdf">Cheet Sheet</a> für die wichtigsten Funktionen wurde erstellt.</p>
<p><a href="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-08-um-21.11.35.png"><img src="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-08-um-21.11.35-300x187.png" alt="" title="Bildschirmfoto 2011-02-08 um 21.11.35" width="300" height="187" class="aligncenter size-medium wp-image-1694" /></a></p>
<p><strong>Performance</strong></p>
<p>Hier die Ausgabe eines ab -n 1000 -c 10 auf meine einfache PHP-Seite. Die Seite macht nur ein echo und die Applikation ist auf eine Box begrenzt.</p>
<pre>

Server Software:
Server Hostname:        bohuco.cloudcontrolled.com
Server Port:            80

Document Path:          /
Document Length:        28 bytes

Concurrency Level:      10
Time taken for tests:   14.203 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      290000 bytes
HTML transferred:       28000 bytes
<strong>Requests per second:    70.41 [#/sec] (mean)</strong>
Time per request:       142.027 [ms] (mean)
Time per request:       14.203 [ms] (mean, across all concurrent requests)
Transfer rate:          19.94 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       53   63   5.0     62     105
Processing:    56   79  28.9     69     335
Waiting:       56   78  28.8     69     335
Total:        113  141  29.4    133     400

Percentage of the requests served within a certain time (ms)
  50%    133
  66%    140
  75%    146
  80%    152
  90%    166
  95%    187
  98%    234
  99%    295
 100%    400 (longest request)
</pre>
<p><strong>Auch Nice &#8230;</strong></p>
<p>Das Deployment ist via SFTP zugänglich:<br />
sftp://dep_id@app_name.cloudcontrolled.com/files</p>
<p>Die Log-Files lassen sich abrufen:<br />
cctrlapp bohuco/default log error</p>
<p>Es wird bald ein MySQL Admin Tool geben.</p>
<p>.htaccess ist möglich und mod_rewrite ist aktiv</p>
<p><strong>Fazit</strong></p>
<p><a href="http://cloudcontrol.com/">cloudControl</a> sieht auf den ersten Blick wunderbar aus. Wie sich die Plattform im Live-Betrieb bzw. Entwickler-Alltag verhält kann ich nach so kurzer Zeit nicht sagen. Aber das Ding ist auf jeden Fall einen zweiten Blick wert. Fast alles was ich ausprobiert habe hat auf Anhieb funktioniert (nur Apache Access Log konnte ich nicht downloaden).</p>
<p><a href="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-08-um-21.44.46.png"><img src="http://bohuco.net/blog/wp-content/uploads/2011/02/Bildschirmfoto-2011-02-08-um-21.44.46-300x178.png" alt="" title="Bildschirmfoto 2011-02-08 um 21.44.46" width="300" height="178" class="aligncenter size-medium wp-image-1696" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/02/php-cloud-cloudcontrol-paas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Commandline Script in Farbe</title>
		<link>http://bohuco.net/blog/2011/02/php-commandline-script-in-farbe/</link>
		<comments>http://bohuco.net/blog/2011/02/php-commandline-script-in-farbe/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 06:53:00 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP5]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1685</guid>
		<description><![CDATA[Bei PHP Gangster hab ich soeben eine kleine Klasse entdeckt mit der CLI Scripte farbige Ausgaben machen können &#8230; Usage: &#160; $color = new Color&#40;&#41;; $color-&#62;set&#40;'red'&#41;; &#160; echo &#34;red textn&#34;; &#160; $color-&#62;reset&#40;&#41;; $color-&#62;echoString&#40;&#34;red text on bluen&#34;, 'red_u', 'blue'&#41;;]]></description>
			<content:encoded><![CDATA[<p>Bei <a href="http://www.phpgangsta.de/farben-in-der-kommandozeile-nutzen">PHP Gangster</a> hab ich soeben eine kleine Klasse entdeckt mit der CLI Scripte farbige Ausgaben machen können &#8230;</p>
<p>Usage:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$color</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Color<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$color</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'red'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;red textn&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$color</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">reset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$color</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">echoString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;red text on bluen&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'red_u'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'blue'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/02/php-commandline-script-in-farbe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP5 WebSocket Example &#8211; A Simple Chat</title>
		<link>http://bohuco.net/blog/2011/01/php5-websocket-example-a-simple-chat/</link>
		<comments>http://bohuco.net/blog/2011/01/php5-websocket-example-a-simple-chat/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 08:08:21 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Websockets]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1672</guid>
		<description><![CDATA[The classic example for websockets is a chat. This chat example has only 200 lines of code (excl. the Websocket class), is really easy to understand and customizable. The WebSocket class takes a function (or class method) as callback for every socket action, for this example i use the process method of the WebsocketChat Class: [...]]]></description>
			<content:encoded><![CDATA[<p>The classic example for websockets is a chat. This chat example has only 200 lines of code (excl. the Websocket class), is really easy to understand and customizable.</p>
<p><span id="more-1672"></span></p>
<p>The WebSocket class takes a function (or class method) as callback for every socket action, for this example i use the process method of the WebsocketChat Class:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$chat</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WebsocketChat<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// new WebSocketServer( socket address, socket port, callback function )</span>
<span style="color: #000088;">$webSocket</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WebSocketServer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;84.38.67.247&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8081</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chat</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'process'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$webSocket</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The WebsocketChat Class handles user actions and messages. We have two actions: &#8216;login&#8217; and &#8216;chat&#8217;. &#8216;login&#8217; happens when a new user sets his username, &#8216;chat&#8217; is always when a user sends a new message:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">Class</span> WebsocketChat <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * @var array
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$messages</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: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> process<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">,</span> <span style="color: #000088;">$server</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$msg</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</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;">$msg</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">action</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'login'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">action</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'chat'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>On the client-side we have to send the right actions if someone clicks &#8216;login&#8217; or &#8216;send message&#8217;.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
$<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>evt<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	evt.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	send<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'action'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'chat'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'text'</span><span style="color: #339933;">:</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[name=text]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#login'</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>evt<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	evt.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	send<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'action'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'login'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'username'</span><span style="color: #339933;">:</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[name=username]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#chat'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#login'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</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;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The login action adds a new chat user to the user-array and loads the last five messages for this new user.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">action</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'login'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_var</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">username</span><span style="color: #339933;">,</span> FILTER_SANITIZE_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">messages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">messages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// on login send last five chat messages</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">messages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #000088;">$max</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span>count<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">messages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">messages</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>If the &#8216;chat&#8217; action is called then add a new WebsocketChatMessage to the message array and send it to all current chat-users:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">action</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'chat'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_var</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$msg</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span><span style="color: #339933;">,</span> FILTER_SANITIZE_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
	<span style="color: #000088;">$lastMessage</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WebsocketChatMessage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</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;
	<span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">messages</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$lastMessage</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUsers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">socket</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$lastMessage</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>			
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The WebsocketChatMessage is just a container-class for holding the message data:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">Class</span> WebsocketChatMessage <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$timestamp</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">username</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$username</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">timestamp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$timestamp</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __toString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%s %s: %s'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strftime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%H:%M'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">timestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="http://bohuco.net/labs/php-websocket-chat/">View Chat Example</a> on <a href="http://bohuco.net/labs/">BOHUCO Labs</a></p>
<p><a href="http://bohuco.net/labs/php-websocket-chat/?source=server.php">View server.php Code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/01/php5-websocket-example-a-simple-chat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Der Erklärbär: Aspect-Oriented Programming mit PHP &#8211; Teil 1 &#8211; Signal Slot</title>
		<link>http://bohuco.net/blog/2011/01/aspect-oriented-design-php-signal-slot/</link>
		<comments>http://bohuco.net/blog/2011/01/aspect-oriented-design-php-signal-slot/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 12:05:16 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[aod]]></category>
		<category><![CDATA[aop]]></category>
		<category><![CDATA[Erklärbär]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1661</guid>
		<description><![CDATA[Wiedermal was Neues!? Wiedermal wird die (Web-)Programmierer-Welt auf den Kopf gestellt!? Objektorientiert ist gelber Schnee von Vorgestern, Design-Patterns verwendet heute schon deine Oma fürs Putzen &#8230; und jetzt kommt: TaTaaaa! AOP &#8211; Aspect Oriented Programming. Der Erklärbär erklärt&#8217;s! (er versucht es zumindest) AOP &#8230; was?! Noch nie gehört, oder doch?! &#8230; Ja auch die AOP [...]]]></description>
			<content:encoded><![CDATA[<p>Wiedermal was Neues!? Wiedermal wird die (Web-)Programmierer-Welt auf den Kopf gestellt!? Objektorientiert ist gelber Schnee von Vorgestern, Design-Patterns verwendet heute schon deine Oma fürs Putzen &#8230; und jetzt kommt: TaTaaaa! AOP &#8211; Aspect Oriented Programming.</p>
<p><strong>Der Erklärbär erklärt&#8217;s!</strong> (er versucht es zumindest)</p>
<p><span id="more-1661"></span></p>
<p>AOP &#8230; was?! Noch nie gehört, oder doch?! &#8230; Ja auch die AOP gibst schon einige Jahre aber es dauert hald immer ein wenig bis die Sachen bei den Webentwicklern ankommen. Grundsätzlich geht es beim Aspect Orientierten Design darum die Schwächen der Objektorientierten Entwicklung auszubessern &#8230;</p>
<p><em>&#8220;Wie, was Schwächen der OOP?&#8221;</em> &#8230; Ja klar, man kann zwar alle Klassen überschreiben oder erweitern aber was ist wenn man nur einen kleinen Teil einer Methode ändern will, dann muß man immer gleich die ganze Methode duplizieren und den kleinen Teil umschreiben. Aber das erzeugt viel unnötigen zusätzlichen Quelltext. Ausserdem kann es sein das diese Form der Erweiterung nicht Möglich ist und man an diversen Stellen dann die Methoden-Aufrufe umschreiben muß &#8230;. das will doch wirklich Keiner!</p>
<p><em>&#8220;Und AOP machts besser?&#8221;</em> Ja, machts viel besser! Im <a href="http://de.wikipedia.org/wiki/Aspektorientierte_Programmierung">Wikipedia</a> wirds a bissl kompliziert erklärt: Verschiedene Aspekte (Concerns) die die ganze Applikation betreffen Bla Bla &#8230; &#8230; Konkret und einfach gesagt: Man kann hald net immer alles in ein Klassensystem pressen, gerade applikationsübergreifende Elemente wie Logging, Caching oder Parameter-Behandlung passen da überhaupt nicht rein und da springt dann die AOP ein.</p>
<p>Beispiel Logging:</p>
<p>In eine Methode ein Logging einzubauen ist ja relativ einfach:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doSomething<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logger</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'start doSomething'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// do something</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logger</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'end doSomething'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Wunderbar! Jetzt hat man da den Logger drin und nach einer Woche will man aber auch an den selben Stellen etwas zusätzliches oder anderes machen lassen, Caching zum Beispiel, also bastelt mans dazu:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doSomething<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logger</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'start doSomething'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">inCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// return from cache</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// do something</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">logger</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'end doSomething'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Das wär ja auch noch ganz OK wenn man den Cache überall verwenden will, aber er soll hald nur unter gewissen Voraussetzungen verwendet werden, dann kann mans jetzt entweder der Methode als Parameter übergeben, oder als Klassenvariable dem Konstruktor, beides will man nicht weil man dann alle Aufrufe anpassen müsste (im schlimmsten Fall).</p>
<p><strong>Rettung: Signals and Slots</strong></p>
<p>Darum baut man sich einen &#8220;Signal Slot&#8221; hinein, früher hätte ich gesagt einen &#8220;Callback-Hook&#8221; oder im WordPress nennen sie es &#8220;Action&#8221;. Ein Signal markiert eine bestimmte Stelle im Quelltext aber ohne eine konkrete Aufgabe zu haben, in diesem Fall hätten wir ein Start-Signal und einen End-Signal, via Slots kann man den Signals eine Aufgabe zuordnen die aber nur in dem einen bestimmten Fall gilt und alle anderen Aufrufe nicht betrifft:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doSomething<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">signals</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">emit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'start'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// do something</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">signals</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">emit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'end'</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;">// attach slots somewhere else in the application</span>
<span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">signals</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'start'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$log</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'info'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">signals</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'log'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$log</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'info'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Nachteile der ganzen Sache: Wenn man die Signal-Slots ausgiebig verwendet, hat man hald viele &#8220;leere&#8221; emit-Calls im Quelltext die natürlich auch etwas Zeit für die Ausführung beanspruchen, also bissi schlechtere Performance. Nächster Nachteil, wenn man die Signals nicht vernünftig benennt oder dokumentiert kennt sich kein Schwein mehr aus, siehe WordPress! Die Verständlichkeit des Quelltexts leidet auch darunter weil man nicht mehr genau weiß was eine Methode macht ohne sich auch die Slots anzusehen.</p>
<p>&#8230; Licht und Schatten, aber bei WordPress funktioniert&#8217;s trotz der angesprochenen Probleme wunderbar. Jeder Entwickler kann aufgrund der vielen Signals (Actions) die eigene Logik in das Grundsystem integrieren ohne es anzugreifen. Und das Grundsystem bleibt damit weiterhin updatebar &#8211; voi cool gell!</p>
<p><a href="http://en.wikipedia.org/wiki/Signals_and_slots">Wikipedia: Signals and Slots</a><br />
<a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Wikipedia: AOP</a><br />
<a href="http://weierophinney.net/matthew/archives/251-Aspects,-Filters,-and-Signals,-Oh,-My!.html">Phly, boy, phly &#8211; Aspects, Signals, Filters</a><br />
<a href="http://phpadvent.org/2010/aspect-oriented-design-by-garrett-woodworth">PHP Advent 2010 &#8211; AOD</a></p>
<p>Im Teil 2 wird der Erklärbär dann Aspect-Oriented Filters erklären &#8230; das wird wieder ein Spaß (oder?).</p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/01/aspect-oriented-design-php-signal-slot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Google Ranking Checker with Locale-Support</title>
		<link>http://bohuco.net/blog/2011/01/new-google-ranking-checker-with-locale-support/</link>
		<comments>http://bohuco.net/blog/2011/01/new-google-ranking-checker-with-locale-support/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 07:17:56 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP5]]></category>
		<category><![CDATA[Ranking]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1651</guid>
		<description><![CDATA[A new release of the Google Ranking Checker Class is available now. The new version 1.2.0 is released under a Creative Commons license (by-sa 3.0) and supports locale settings for language and country. You can test the Google Ranking Checker Class on BOHUCO Labs: http://bohuco.net/labs/google-ranking-check &#8230; or Download the Source-Code: http://bohuco.net/labs/google-ranking-check/RankingChecker120.php.gz Usage Example: &#160; require_once [...]]]></description>
			<content:encoded><![CDATA[<p>A new release of the<a href="http://bohuco.net/blog/2010/07/google-ranking-checker-class-in-php/"> Google Ranking Checker Class</a> is available now. The new version 1.2.0 is released under a Creative Commons license (<a href="http://creativecommons.org/licenses/by-sa/3.0/at/">by-sa 3.0</a>) and supports locale settings for language and country.</p>
<p><span id="more-1651"></span></p>
<p>You can test the Google Ranking Checker Class on <a href="http://bohuco.net/labs">BOHUCO Labs</a>:</p>
<p><a href="http://bohuco.net/labs/google-ranking-check">http://bohuco.net/labs/google-ranking-check</a></p>
<p>&#8230; or Download the Source-Code:</p>
<p><a href="http://bohuco.net/labs/google-ranking-check/RankingChecker120.php.gz">http://bohuco.net/labs/google-ranking-check/RankingChecker120.php.gz</a></p>
<p>Usage Example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'RankingChecker.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rankingChecker</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RankingChecker<span style="color: #009900;">&#40;</span><span style="color: #000088;">$apiKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rankingChecker</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setLocale</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'de'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'at'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$rankings</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rankingChecker</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">check</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bohuco'</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;">'bohuco.net'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rankings</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Thanks for all the comments and suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/01/new-google-ranking-checker-with-locale-support/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Mount Amazon Ec2 with Mac OSX</title>
		<link>http://bohuco.net/blog/2011/01/mount-amazon-ec2-with-mac-osx/</link>
		<comments>http://bohuco.net/blog/2011/01/mount-amazon-ec2-with-mac-osx/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 08:16:02 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1647</guid>
		<description><![CDATA[MacFusion is a free OSX app for mounting FTP and SFTP (SSH) drives into mac finder. Usually you use a user/password combination for authentification but if you want mount an amazon ec2 instance you have to use the pem-file you get here. First copy the pem file to the hidden .ssh folder and add the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://macfusionapp.org/">MacFusion</a> is a free OSX app for mounting FTP and SFTP (SSH) drives into mac finder. Usually you use a user/password combination for authentification but if you want mount an amazon ec2 instance you have to use the pem-file you get <a href="https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&amp;action=access-key">here</a>.</p>
<p><span id="more-1647"></span></p>
<p>First copy the pem file to the hidden .ssh folder and add the content of the pem-file to your keychain:</p>
<pre>cp mypemfile.pem ~/.ssh
ssh-add -K ~/.ssh/mypemfile.pem</pre>
<p>Next open the ssh-config file (usually its empty) &#8230;</p>
<pre>vim ~/.ssh/config</pre>
<p>&#8230; and add the config for you instance:</p>
<pre>Host public-ec2-dns.compute.amazonaws.com
HostName public-ec2-dns.compute.amazonaws.com
User root
IdentityFile ~/.ssh/mypemfile.pem</pre>
<p><a href="http://www.macupdate.com/app/mac/24768/macfusion">Download MacFusion</a><br />
<a href="http://aws.amazon.com/ec2/">Amazon EC2</a><br />
see <a href="http://superuser.com/questions/88359/mount-ec2-instance-via-ssh-on-mac-os-x">superuser.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/01/mount-amazon-ec2-with-mac-osx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

