<?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</title>
	<atom:link href="http://bohuco.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://bohuco.net/blog</link>
	<description>Die Sollbruchstelle des Internets.</description>
	<lastBuildDate>Mon, 30 Apr 2012 10:30:15 +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>Javascript MindFuck: Google Maps GeoCoder Callback with Parameters</title>
		<link>http://bohuco.net/blog/2012/04/javascript-mindfuck-google-maps-geocoder-callback-with-parameters/</link>
		<comments>http://bohuco.net/blog/2012/04/javascript-mindfuck-google-maps-geocoder-callback-with-parameters/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 10:29:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[geocoding]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1858</guid>
		<description><![CDATA[If you have ever tried to geocode with google maps you have perhaps noticed that you can&#8217;t easy pass more data to the callback function. And geocoding on an array of addresses won&#8217;t work too, because you get always the result for the last entry of your array. To solve that issues you must encapsulate [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever tried to geocode with google maps you have perhaps noticed that you can&#8217;t easy pass more data to the callback function. And geocoding on an array of addresses won&#8217;t work too, because you get always the result for the last entry of your array.</p>
<p><span id="more-1858"></span></p>
<p>To solve that issues you must encapsulate your callback into another anonymous function (closure) that returns itself to the callback.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> locations <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
locations.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>address<span style="color: #339933;">:</span><span style="color: #3366CC;">'hauptplatz 1, 4020 linz, austria'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'otherInfo'</span><span style="color: #339933;">=&gt;</span><span style="color: #3366CC;">'info'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>idx <span style="color: #000066; font-weight: bold;">in</span> locations<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> location <span style="color: #339933;">=</span> locations<span style="color: #009900;">&#91;</span>idx<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> address <span style="color: #339933;">=</span> location<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'address'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    geocoder.<span style="color: #660066;">geocode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'address'</span><span style="color: #339933;">:</span>address<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>location<span style="color: #339933;">,</span> idx<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>results<span style="color: #339933;">,</span> <span style="color: #000066;">status</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">status</span> <span style="color: #339933;">==</span> google.<span style="color: #660066;">maps</span>.<span style="color: #660066;">GeocoderStatus</span>.<span style="color: #660066;">OK</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> latlng <span style="color: #339933;">=</span> results<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">geometry</span>.<span style="color: #660066;">location</span><span style="color: #339933;">;</span>
&nbsp;
                console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>location<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>idx<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>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span>location<span style="color: #339933;">,</span> idx<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2012/04/javascript-mindfuck-google-maps-geocoder-callback-with-parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Bootstrap Version by Twitter</title>
		<link>http://bohuco.net/blog/2012/02/new-bootstrap-version-by-twitter/</link>
		<comments>http://bohuco.net/blog/2012/02/new-bootstrap-version-by-twitter/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 22:00:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Web Entwicklung]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1825</guid>
		<description><![CDATA[Today Twitter released a new version of their popular html/css boilerplate for webpages. A good time to introduce my favorite bootstrap features &#8230; 1. Icons, Icons, Icons Bootstrap includes a fat icon sprite with 120 small icons from glyphicons.com. all have transparent background and are available in black and in white. 2. Inline Labels Put some [...]]]></description>
			<content:encoded><![CDATA[<p>Today Twitter released a new version of their popular html/css boilerplate for webpages. A good time to introduce my favorite bootstrap features &#8230;</p>
<p><strong>1. Icons, Icons, Icons</strong></p>
<p>Bootstrap includes a fat icon sprite with 120 small icons from <a href="http://glyphicons.com/">glyphicons.com</a>. all have transparent background and are available in black and in white.</p>
<p><iframe width="100%" height="60" scrolling="no" src="http://bohuco.net/dev/bootstrap#icons"></iframe></p>
<p><strong>2. Inline Labels</strong></p>
<p>Put some highlights in your texts with inline labels.</p>
<p><iframe width="100%" height="60" scrolling="no" src="http://bohuco.net/dev/bootstrap#labels"></iframe></p>
<p><strong>3. Real Button Porn</strong></p>
<p>Buttons in different colors, with and without dropdown and in groups or lonely.</p>
<p><iframe width="100%" height="80" scrolling="no" src="http://bohuco.net/dev/bootstrap#buttons"></iframe></p>
<p>&#8230; and what is your favorite feature from twitter bootstrap?</p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2012/02/new-bootstrap-version-by-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>7 Fields Every Database Table May Need &#8230;</title>
		<link>http://bohuco.net/blog/2011/08/7-fields-every-database-table-may-need/</link>
		<comments>http://bohuco.net/blog/2011/08/7-fields-every-database-table-may-need/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 19:28:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1794</guid>
		<description><![CDATA[No matter if you work with MySQL, MSSQL, PostgreSQL or another database system, there are some columns any database table most likely may need &#8230; createDate the createDate of a row is a very nice info that can be used for quick statistics, if your boss wants to know how many users on one day [...]]]></description>
			<content:encoded><![CDATA[<p>No matter if you work with MySQL, MSSQL, PostgreSQL or another database system, there are some columns any database table most likely may need &#8230;</p>
<p><span id="more-1794"></span></p>
<h2>createDate</h2>
<p>the createDate of a row is a very nice info that can be used for quick statistics, if your boss wants to know how many users on one day registered you can simple select it via SQL and group by day. you can also modify rows based on this date like: delete all users created before year 2000 or something like this &#8230; and you can use it for forensic research: &#8220;is it really possible that such a new user already wrote one million comments?&#8221;</p>
<h2>active, inactive or deleted</h2>
<p>i use often a flag like active to mark a row as &#8220;not deleted&#8221;, you can also turn it to the opposite, important is only that you don&#8217;t delete rows in your table &#8230; better you mark it as deleted and so you can use it still for statistics or reactivate it some day. if you don&#8217;t delete your rows every link to other tables will remain intact.</p>
<h2>hidden or visible</h2>
<p>it&#8217;s almost like active/inactive but a bit different, a hidden row can be active but i don&#8217;t want to show it to a frontend user, for example test records can be hidden. in your business logic you can treat a hidden row as normal but in the end don&#8217;t show it to the frontend user.</p>
<h2>status</h2>
<p>is the multi-talent of every database table, you will need it always even if you don&#8217;t know it now, in some weeks/month/years you will be so thankfull that you have it. a status col can save you many other cols like active or hidden. this col can be a set or a tiny integer field. the set is better style, the integer is better for extending status types &#8230; if you use integers then use constants in your source code or comment the int-values somewhere you easy can find it &#8230; i write it in the mysql col description. because i use int as type i usually take 0 as an &#8220;unknown&#8221; or &#8220;new&#8221; status, if a status is defined then it gets a positive or negative value &#8230; for example 1 = active, -1 inactive or 1 visible and -1 invisible.</p>
<h2>changeDate or lastModified</h2>
<p>another important date field: as the createDate you can use it for forensics (example: if a user change a password today and wrote that he can&#8217;t login since yesterday then something is strange) and statistics (example: users with status:inactive and changeDate today are all users that deactivated their accounts today) but you can also set the lastModified http header from it (google loves it) and maybe you can use it for caching or clean up caches.</p>
<h2>id</h2>
<p>surprise, surprise &#8230; really every table should have a primary key for simpler editing/deleting and fast access.</p>
<h2>description</h2>
<p>it&#8217;s not always necessary to have a description for a row, but really often. the description field is a varchar or text field for an internal notice, it won&#8217;t be shown to a frontend user. there are so many scenarios where you can need it &#8230; admins can write why the record is like it is, or it can hold a brief history of changes, or just who has changed the row. sometimes it&#8217;s abused for settings ( example: a menu-entry with description dns=1 &#8230; it means DoNotShow=1 <img src='http://bohuco.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  don&#8217;t do that please )</p>
<div style="float:right">
<script type="text/javascript">var dzone_url = 'http://bohuco.net/blog/2011/08/7-fields-every-database-table-may-need/';</script><br />
<script type="text/javascript">var dzone_title = '7 Fields Every Database Table May Need';</script><br />
<script type="text/javascript">var dzone_blurb = 'No matter if you work with MySQL, MSSQL, PostgreSQL or another database system, there are some columns any database table most likely may need ...';</script><br />
<script type="text/javascript">var dzone_style = '1';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script>
</div>
<p>&#8230; thats my silver bullets for database design &#8230; what do you think!</p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/08/7-fields-every-database-table-may-need/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Image Watermarks in WordPress</title>
		<link>http://bohuco.net/blog/2011/06/image-watermarks-in-wordpress/</link>
		<comments>http://bohuco.net/blog/2011/06/image-watermarks-in-wordpress/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 19:37:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Web Entwicklung]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1768</guid>
		<description><![CDATA[Here a quick and easy way to put watermarks in your images. Just copy the code in the function.php of the active theme and you can watermark your pictures in wordpress admin. Features: - Set watermarks for galleries - Watermark button on gallery screen - Set position of watermark in source code - Pictures gets [...]]]></description>
			<content:encoded><![CDATA[<p>Here a quick and easy way to put watermarks in your images. Just copy the code in the function.php of the active theme and you can watermark your pictures in wordpress admin.</p>
<p><span id="more-1768"></span></p>
<p><a href="http://bohuco.net/blog/wp-content/uploads/2011/06/Bildschirmfoto-2011-06-02-um-21.39.42.png"><img src="http://bohuco.net/blog/wp-content/uploads/2011/06/Bildschirmfoto-2011-06-02-um-21.39.42-300x124.png" alt="" title="Bildschirmfoto 2011-06-02 um 21.39.42" width="300" height="124" class="alignright size-medium wp-image-1773" /></a></p>
<p>Features:<br />
- Set watermarks for galleries<br />
- Watermark button on gallery screen<br />
- Set position of watermark in source code<br />
- Pictures gets the watermark only once also if you click again<br />
- Inserts watermarks only in the big version of the file (not in thumbnails)<br />
- Watermarks are not removable from the images</p>
<p>Install and Requirements:<br />
- copy the source code to the functions.php<br />
- Image Magick (composite command) is required</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'media_upload_form_url'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bohuco_upload_gallery'</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: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tab'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tab'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'gallery'</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;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attachments'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$uploadDir</span> <span style="color: #339933;">=</span> wp_upload_dir<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attachments'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> wp_get_attachment_metadata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 'full'</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_meta'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'copyright'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'_WATERMARK_'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				ffs_image_modify<span style="color: #009900;">&#40;</span><span style="color: #000088;">$uploadDir</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'basedir'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'image_meta'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'copyright'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_WATERMARK_'</span><span style="color: #339933;">;</span>
				wp_update_attachment_metadata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</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: #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: #009933; font-style: italic;">/**
 * adds the watermark button to the gallery dialog
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> bohuco_upload_gallery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</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: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'watermark'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'watermark'</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;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;script type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text/javascript<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;jQuery(function(){ jQuery('&lt;tr&gt;&lt;td colspan=2&gt;Watermark added!&lt;/td&gt;&lt;/tr&gt;').appendTo('#gallery-settings table'); }); &lt;/script&gt;&quot;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;script type=<span style="color: #000099; font-weight: bold;">\&quot;</span>text/javascript<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;jQuery(function(){ jQuery('&lt;tr&gt;&lt;td&gt;&lt;input type=<span style="color: #000099; font-weight: bold;">\&quot;</span>submit<span style="color: #000099; font-weight: bold;">\&quot;</span> class=<span style="color: #000099; font-weight: bold;">\&quot;</span>button savebutton<span style="color: #000099; font-weight: bold;">\&quot;</span> name=<span style="color: #000099; font-weight: bold;">\&quot;</span>watermark<span style="color: #000099; font-weight: bold;">\&quot;</span> id=<span style="color: #000099; font-weight: bold;">\&quot;</span>save-all<span style="color: #000099; font-weight: bold;">\&quot;</span> value=<span style="color: #000099; font-weight: bold;">\&quot;</span>Insert watermark<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;/td&gt;&lt;/tr&gt;').appendTo('#gallery-settings table'); }); &lt;/script&gt;&quot;</span><span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$html</span><span style="color: #339933;">;</span>	
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$var</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * modify an image
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> bohuco_image_modify<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// watermark image ... use png or gif with alpha</span>
	<span style="color: #000088;">$watermark</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/images/watermark.png'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// imagemagick command ... set gravity to NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast</span>
	<span style="color: #000088;">$command</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;composite -gravity Center <span style="color: #009933; font-weight: bold;">%s</span> <span style="color: #009933; font-weight: bold;">%s</span> <span style="color: #009933; font-weight: bold;">%s</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$watermark</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$command</span><span style="color: #339933;">,</span> <span style="color: #000088;">$return</span><span style="color: #339933;">,</span> <span style="color: #000088;">$code</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$code</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/06/image-watermarks-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>Nebel des Grauens &#8211; PHPFog</title>
		<link>http://bohuco.net/blog/2011/03/nebel-des-grauens-phpfog/</link>
		<comments>http://bohuco.net/blog/2011/03/nebel-des-grauens-phpfog/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 06:31:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[paas]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1743</guid>
		<description><![CDATA[Man will ja in diesen Tagen fast nicht von Gau oder Super-Gau sprechen aber der Herr Lucas Calson, Gründer und Inhaber von PHPFog, wird die Ereignisse der letzten Tage sicher so bezeichnen &#8230; &#8220;PHP Fog &#8211; Reliable Cloud Platform&#8221; ist erst vor kurzem gestartet und musste schon nach wenigen Tagen wieder offline gehen. Das vielversprechende [...]]]></description>
			<content:encoded><![CDATA[<p>Man will ja in diesen Tagen fast nicht von Gau oder Super-Gau sprechen aber der Herr Lucas Calson, Gründer und Inhaber von PHPFog, wird die Ereignisse der letzten Tage sicher so bezeichnen &#8230;</p>
<p><span id="more-1743"></span></p>
<p>&#8220;PHP Fog &#8211; Reliable Cloud Platform&#8221; ist erst vor kurzem gestartet und musste schon nach wenigen Tagen wieder offline gehen. Das vielversprechende Unternehmen bietet Platform as a Service (PaaS) für PHP an. Mittels weniger Klicks kann man neue Cloud-Applikationen erstellen und sogar mit beliebten Open Source Programmen befüllen. So ist das neue WordPress-Blog in wenigen Minuten online und kann beliebig angepasst und erweitert werden.</p>
<p>In der Theorie hört sich das besser an, als es in der Praxis funktioniert hat. Denn nur wenn die ganze Plattform gut durchdacht und ausfallsicher ist funktionieren auch die einzelnen Applikationen und da haperts bei PHPFog anscheinend noch gewaltig.</p>
<p><strong>Chronik:</strong><br />
Letzten Samstag kam das erste Mail das meine (Test-)Applikation nicht mehr online ist weil die Plattform von Hackern angegriffen wurde:</p>
<blockquote><p>&#8220;On Saturday March 15th at 11pm, the main PHP Fog site was compromised by a group of hackers. I want to let you know how sorry I am, but you do not have to worry.&#8221;</p></blockquote>
<p>Stunden später dann das nächste Status-Update zum Ausfall:</p>
<blockquote><p>&#8220;I am very sorry for the inconvenience. Our team has been working non-stop for over 21 hours now and have reached the point of exhaustion. We are performing a comprehensive audit and security upgrade to prevent anything like this from happening again. This upgrade unfortunately is taking longer than we expected.&#8221;</p></blockquote>
<p>Erst vier Tage späte konnten alle Seiten wieder online geschaltet werden, auch wenn sich die Plattform-Betreiber anscheinend nicht ganz sicher sind:</p>
<blockquote><p>&#8220;Your PHP Fog sites should be running again&#8221;</p></blockquote>
<p>Meine Test-Seite ist immer noch nicht online, ist aber auch nicht so wichtig, aber was wäre wenn ich eine richtig große und bekannte Seite/Domain zu PHPFog transferiert hätte und jetzt vier Tage offline gewesen wäre? Was würden meine Kunden dazu sagen?</p>
<p><strong>Was war passiert?</strong></p>
<p>Ein paar &#8220;Teenager&#8221; haben wohl eine Sicherheitslücke auf einem alten Server entdeckt der als Ausfallsicherung fungiert hat.  </p>
<p>Lucas Carlson <a href="http://blog.phpfog.com/2011/03/22/how-we-got-owned-by-a-few-teenagers-and-why-it-will-never-happen-again/">beschreibt den Angriff</a> im Firmenblog, inklusive der Gegenmaßnahmen die solche Angriffe in Zukunft verhindern sollen.</p>
<p>Trotzdem: Keine besonders gute Werbung für die Cloud oder PaaS. Was vor 15 Jahren die 1-Mann-Hosting-Buden waren, sind jetzt anscheinend die 20-Mann-Cloud-Buden? Alles schön billig, aber dafür auch schön unsicher.</p>
<p>Angeblich waren ziemlich viele unglückliche Zufälle und &#8220;Bad Timings&#8221; Schuld an der ganzen Misere. Genauer betrachtet haben sie ihren Legacy-Code nicht entfernt, waren nachlässig mit den Passwörtern und haben Fehler in der Architektur gemacht. </p>
<p>Also: Immer schön Vorsichtig bei der Auswahl des Hostings sein und nicht einfach auf den billigsten Anbieter wechseln, oder in die Cloud, nur weil es gerade Hip ist.</p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/03/nebel-des-grauens-phpfog/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>Google und die Link-Einkäufer</title>
		<link>http://bohuco.net/blog/2011/02/google-und-link-einkaufer/</link>
		<comments>http://bohuco.net/blog/2011/02/google-und-link-einkaufer/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 06:42:32 +0000</pubDate>
		<dc:creator>DerFichtl</dc:creator>
				<category><![CDATA[Online Marketing]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://bohuco.net/blog/?p=1717</guid>
		<description><![CDATA[Erst vor kurzem wurde in Deutschland ein Link-Netzwerk aufgedeckt weil ein Blogger nicht mitspielen wollte. Aber im Vergleich zu JCPenney war das nur ein winzig kleiner Fisch &#8230; Das Bloggergate in Deutschland hat zumindest in einschlägigen Kreisen für etwas Wirbel gesorgt. Da ging es um die intergenia AG die auch das bekannte deutsche Blog &#8220;Basic [...]]]></description>
			<content:encoded><![CDATA[<p>Erst vor kurzem wurde in Deutschland ein Link-Netzwerk aufgedeckt weil ein Blogger nicht mitspielen wollte. Aber im Vergleich zu JCPenney war das nur ein winzig kleiner Fisch &#8230;</p>
<p><span id="more-1717"></span></p>
<p>Das <a href="http://www.netbooknews.de/32977/basicthinking-onlinekosten-gmbh-und-der-keyword-spam/">Bloggergate</a> in Deutschland hat zumindest in einschlägigen Kreisen für etwas Wirbel gesorgt. Da ging es um die intergenia AG die auch das bekannte deutsche Blog &#8220;Basic Thinking&#8221; betreibt. Aber das neue, amerikanische Bloggergate das die New York Times jetzt aufgedeckt hat spielt in einer anderen Liga.</p>
<p>JC Penney ist ein großer amerikanischer Retailer und Online Store der in den letzten Monaten mit ausgezeichneten Suchergebnissen glänzte. Für viele generische Produkt-Kategorien wie: &#8220;home decor&#8221;, &#8220;skinny jeans&#8221;, &#8220;tablecloth&#8221; &#8230; wurden Seiten von jcpenney.com auf Nummer Eins gezeigt. </p>
<p>Das ging solange gut bis sich jemand gewundert hat und mal im <a href="http://www.opensiteexplorer.org/">opensiteexplorer</a> die eingehenden Links nachgeprüft hat. Dabei ist dann schnell aufgefallen das die meisten Links von irgendwelchen Seiten kommen die absolut gar nichts mit Kleidung oder Haushalt zu tun haben.</p>
<p>Seiten wie nuclear.engineeringaddict.com oder casinofokus.com linkten im Footer mit den besagten Begriffen auf jcpenney.com. Das J.C. Penney nicht selber alle Blogger angeschrieben hat liegt wohl auf der Hand es wahr anscheinend die SEO Agentur <a href="http://www.SearchDex.com">SearchDex</a> die über das Link Netzwerk <a href="http://www.tnx.net">TNX</a> die Links gekauft hat.</p>
<p>Bei TNX bekommt man pro Link sogenannte TNX Points die man dann wieder gegen eingehende Links eintauschen kann. Dabei wird einfach mittels Perl oder PHP Script eine beliebige Anzahl von Linkplätzen auf der Seite markiert die TNX dann befüllen kann.</p>
<p>Mittlerweile wurde jcpenney.com schon abgestraft und erscheint für die angesprochenen Begriffe nicht mehr auf der ersten Seite. Google ist aber nur durch den Hinweis der NYT draufgekommen und die Masche hat immerhin min. vier Monate funktioniert.</p>
<p>tnx.net dürfte ab jetzt also tot sein &#8230; aber fraglich ist schon warum Google das nicht früher gecheckt hat.</p>
<p>via <a href="http://gizmodo.com/#!5758846/how-jc-penney-became-the-number-one-search-result-for-nearly-every-google-search">gizmodo</a>, new york times</p>
]]></content:encoded>
			<wfw:commentRss>http://bohuco.net/blog/2011/02/google-und-link-einkaufer/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>
	</channel>
</rss>

