<?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>BlackHC's Adventures in the Dev World &#187; Web</title>
	<atom:link href="http://blog.blackhc.net/category/coding/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.blackhc.net</link>
	<description>Just another weblog</description>
	<lastBuildDate>Wed, 16 Nov 2011 23:12:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>T61 Extractor</title>
		<link>http://blog.blackhc.net/2011/08/t61-extractor/</link>
		<comments>http://blog.blackhc.net/2011/08/t61-extractor/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 16:38:54 +0000</pubDate>
		<dc:creator>BlackHC</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[extractor]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[thesixtyone]]></category>

		<guid isPermaLink="false">http://blog.blackhc.net/?p=863</guid>
		<description><![CDATA[<a href="http://blog.blackhc.net/2011/08/t61-extractor/" title="T61 Extractor"></a>I've been a vivid fan of thesixtyone.com - until they changed the design. The old site can still be found here: http://old.thesixtyone.com/. Many of my most favorite songs are from this site and I have only been able to listen &#8230;<p class="read-more"><a href="http://blog.blackhc.net/2011/08/t61-extractor/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.blackhc.net/2011/08/t61-extractor/" title="T61 Extractor"></a><p>I've been a vivid fan of <a href="http://www.thesixtyone.com/" target="_blank">thesixtyone.com</a> - until they changed the design. The old site can still be found here: <a href="http://old.thesixtyone.com/" target="_blank">http://old.thesixtyone.com/</a>.</p>
<p>Many of my most favorite songs are from this site and I have only been able to listen to them through the site. However, since the aforementioned design change, the site has really died down in my opinion and I was fearful ever since that it would simply go down some day and vanish - taking my songs and playlists with it.</p>
<p>As counter-measure I've written a java console application to extract playlists and songs from thesixtyone. It uses <a href="http://seleniumhq.org/" target="_blank">Selenium</a> to remote-control a FireFox instance that uses the normal user-interface to play songs and read in playlists.</p>
<p>I've uploaded the code to launchpad: <a href="https://launchpad.net/t61extractor/trunk" target="_blank">https://launchpad.net/t61extractor/trunk</a><br />
I've tested and used it myself and it runs alright.</p>
<p>This was a small weekend project (or rather two weekend project) that I did a few months ago but I only found time now to write about it.</p>
<p>The code should be mostly self-explanatory and it's not a lot of code either.</p>
<p>Cheers,<br />
 Andreas</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blackhc.net/2011/08/t61-extractor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extracting Information from StudiVZ</title>
		<link>http://blog.blackhc.net/2009/10/extracting-information-from-studivz/</link>
		<comments>http://blog.blackhc.net/2009/10/extracting-information-from-studivz/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 18:34:42 +0000</pubDate>
		<dc:creator>BlackHC</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Personal Rantings]]></category>
		<category><![CDATA[University]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Profiles]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[StudiVZ]]></category>

		<guid isPermaLink="false">http://blog.blackhc.net/?p=678</guid>
		<description><![CDATA[<a href="http://blog.blackhc.net/2009/10/extracting-information-from-studivz/" title="Extracting Information from StudiVZ"></a>Some time ago somebody stole 1 million data records from StudiVZ, the German Facebook clone. I'm not exactly sure why people call the person a hacker who stole data, because it appears he simply wrote a tool that harvested the &#8230;<p class="read-more"><a href="http://blog.blackhc.net/2009/10/extracting-information-from-studivz/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.blackhc.net/2009/10/extracting-information-from-studivz/" title="Extracting Information from StudiVZ"></a><p>Some time ago somebody stole 1 million data records from <a href="http://www.studivz.net/" target="_blank">StudiVZ</a>, the German Facebook clone. I'm not exactly sure why people call the person a hacker who stole data, because it appears he simply wrote a tool that harvested the publicly available data from StudiVZ (which everyone with an account can view).</p>
<p>People on StudiVZ share all their data by default---contrary to Facebook which values a person's private data a lot more. Thus by simply opening each profile from a dummy user and processing the HTML data from StudiVZ one can extract a lot and some more information from random people who probably don't even know about it or don't care.. so I'm not sure about the stealing part.</p>
<p>Apparently there are some captcha's when you start browsing searches beyond a few pages. I guess that is where the hacking part comes in, because getting around a captcha probably constitutes hacking---maybe?</p>
<p>Anyway I think part of the media coverage is a bit ridiculous because anyone can write a simple harvester in an hour or two. It took me one and half hours, so I think I'm on the safe side with this estimate and I didn't really have a clue about this stuff before either.</p>
<p>Since I don't want to "hack", I've only written a very tame harvester. It connects to your personal StudiVZ account, and retrieves the name and profile ID (and thus profile URL) of all your friends in the "Meine Freunde" pages.</p>
<p>It could do a lot more with that like retrieving everybody's birthday or random pictures, but I'm too lazy to code that because you use the same pattern for extracting data over and over again and it stops being interesting quite fast.</p>
<p>You can download the project <a href="http://blog.blackhc.net/wp-content/uploads/2009/10/StudiVZExtractor.zip" target="_blank">here</a>. It is a one file C# project. I'm releasing it under GPL (whatever).</p>
<p>It's really easy to explain how it works:</p>
<ul>
<li>It uses <strong>System.Net</strong>'s <strong>HttpWebRequest</strong> and <strong>HttpWebResponse</strong> to get (and post) web pages.</li>
<li>StudiVZ (like every other portal) uses cookies, so I create a <strong>CookieContainer </strong>and use it in every http request.</li>
<li>There are a few hidden values that StudiVZ expects during login. I'm retrieving them from the main page using custom built regular expressions. I've found a <a href="http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx" target="_blank">handy AJAX tester for .NET regular expressions</a>. It was really useful for building the expressions and debugging them. (BTW you can find all URLs I used in the comments.)</li>
<li>After login I use the same pattern: get page &amp; parse using regex for everything.</li>
<li>Visual Studio has an awesome "HTML Visualizer" for strings. It displays the content of a string as HTML page, which is really nifty if you're doing anything related to HTML processing.</li>
</ul>
<p>The code is quite ugly. Well, it's not production code and this is only meant as a proof of concept.</p>
<p>Also note that I have at most violated the AGB of StudiVZ and not committed any criminal acts and I'm not planning to sell my friend's profile IDs or data either <img src='http://blog.blackhc.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Maybe someone can extend the code and make it more useful. I guess it would be fun to automatically download all your pictures (including tags) and feed them into flickr or picasa... but someone else can do that.</p>
<p>Cheers,<br />
Andreas</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blackhc.net/2009/10/extracting-information-from-studivz/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to make WordPress display Full Text in RSS Feeds</title>
		<link>http://blog.blackhc.net/2009/01/how-to-make-wordpress-display-full-text-in-rss-feeds/</link>
		<comments>http://blog.blackhc.net/2009/01/how-to-make-wordpress-display-full-text-in-rss-feeds/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 10:46:17 +0000</pubDate>
		<dc:creator>BlackHC</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Personal Rantings]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Full Text]]></category>
		<category><![CDATA[RSS 2.0]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.blackhc.net/?p=317</guid>
		<description><![CDATA[<a href="http://blog.blackhc.net/2009/01/how-to-make-wordpress-display-full-text-in-rss-feeds/" title="How to make WordPress display Full Text in RSS Feeds"></a>... and why WordPress Moderators are obviously idiots Today I got an email asking me to enable full text RSS feeds - so far so good, only when I activated the "Full Text" option nothing changed - neither in FireFox, &#8230;<p class="read-more"><a href="http://blog.blackhc.net/2009/01/how-to-make-wordpress-display-full-text-in-rss-feeds/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.blackhc.net/2009/01/how-to-make-wordpress-display-full-text-in-rss-feeds/" title="How to make WordPress display Full Text in RSS Feeds"></a><h3>... and why WordPress Moderators are obviously idiots</h3>
<p>Today I got an email asking me to enable full text RSS feeds - so far so good, only when I activated the "Full Text" option nothing changed - neither in FireFox, nor in Google Reader, nor anywhere else. Only in <a href="http://blog.persistent.info/2007/10/feed-proxy-view-raw-rssatom-feed-data.html" target="_blank">Feed Proxy</a> I saw a &lt;content:encoded&gt; tag appear that contained the full text (including html tags), but the description still only contained the excerpt (without html tags).</p>
<p>Before I link you to the thread that made me conclude the statement in the post title, let me quote from the <a href="http://cyber.law.harvard.edu/rss/rss.html" target="_blank">RSS 2.0 specs</a>:</p>
<blockquote><p>A channel may contain any number of &lt;item&gt;s. An item may represent a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. <strong>An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed; see <a href="http://cyber.law.harvard.edu/rss/encodingDescriptions.html" target="_blank">examples</a>), and the link and title may be omitted.</strong> All elements of an item are optional, however at least one of title or description must be present.</p></blockquote>
<p>That said take a look at <a href="http://wordpress.org/support/topic/190901" target="_blank">http://wordpress.org/support/topic/190901</a> - having the problem described above and reading the replies, it just left me with one question:</p>
<p style="padding-left: 30px;"><strong>If Otto42 is a moderator, where does WordPress get its trolls from?</strong></p>
<p>The RSS Specs are pretty unspecific and blurry when it comes to the issue, one can at most point to <a href="http://www.feedvalidator.org/docs/warning/DuplicateDescriptionSemantics.html" target="_blank">http://www.feedvalidator.org/docs/warning/DuplicateDescriptionSemantics.html</a>, but the main issue I have is that the rants of this "moderator" don't help me fix my problem, because Google Reader and FireFox still don't display the full entries.</p>
<h3>A fix for it</h3>
<p>If you want to fix it, you can do the following (in WP 2.7):</p>
<p>Open up <strong>wp-includes/feed-rss2.php</strong> and change</p>
<pre class="brush: php; title: ; notranslate">&lt;?php if (get_option('rss_use_excerpt')) : ?&gt;
&lt;description&gt;&lt;![CDATA[&lt;?php the_excerpt_rss() ?&gt;]]&gt;&lt;/description&gt;
&lt;?php else : ?&gt;
&lt;description&gt;&lt;![CDATA[&lt;?php the_excerpt_rss() ?&gt;]]&gt;&lt;/description&gt;
&lt;?php if ( strlen( $post-&gt;post_content ) &gt; 0 ) : ?&gt;
&lt;content:encoded&gt;&lt;![CDATA[&lt;?php the_content() ?&gt;]]&gt;&lt;/content:encoded&gt;
&lt;?php else : ?&gt;
&lt;content:encoded&gt;&lt;![CDATA[&lt;?php the_excerpt_rss() ?&gt;]]&gt;&lt;/content:encoded&gt;
&lt;?php endif; ?&gt;
&lt;?php endif; ?&gt;</pre>
<p>to</p>
<pre class="brush: php; title: ; notranslate">&lt;?php if (get_option('rss_use_excerpt')) : ?&gt;
&lt;description&gt;&lt;![CDATA[&lt;?php the_excerpt_rss() ?&gt;]]&gt;&lt;/description&gt;
&lt;?php else : ?&gt;
&lt;description&gt;&lt;![CDATA[&lt;?php the_content() ?&gt;]]&gt;&lt;/description&gt;
&lt;?php endif; ?&gt;</pre>
<p>Similarly, if you want to fix your comments, too, open <strong>wp-includes/feed-rss2-comments.php</strong> and change</p>
<pre class="brush: php; title: ; notranslate">&lt;?php if ( post_password_required($comment_post) ) : ?&gt;
&lt;description&gt;&lt;?php echo ent2ncr(__('Protected Comments: Please enter your password to view comments.')); ?&gt;&lt;/description&gt;
&lt;content:encoded&gt;&lt;![CDATA[&lt;?php echo get_the_password_form() ?&gt;]]&gt;&lt;/content:encoded&gt;
&lt;?php else : // post pass ?&gt;
&lt;description&gt;&lt;?php comment_text_rss() ?&gt;&lt;/description&gt;
&lt;content:encoded&gt;&lt;![CDATA[&lt;?php comment_text() ?&gt;]]&gt;&lt;/content:encoded&gt;
&lt;?php endif; // post pass</pre>
<p>to</p>
<pre class="brush: php; title: ; notranslate">&lt;?php if ( post_password_required($comment_post) ) : ?&gt;
&lt;description&gt;&lt;![CDATA[&lt;?php echo get_the_password_form() ?&gt;]]&gt;&lt;/description&gt;
&lt;?php else : // post pass ?&gt;
&lt;description&gt;&lt;![CDATA[&lt;?php comment_text() ?&gt;]]&gt;&lt;/description&gt;
&lt;?php endif; // post pass</pre>
<p>Cheers,<br />
Andreas</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blackhc.net/2009/01/how-to-make-wordpress-display-full-text-in-rss-feeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Hacking II</title>
		<link>http://blog.blackhc.net/2009/01/wordpress-hacking-ii/</link>
		<comments>http://blog.blackhc.net/2009/01/wordpress-hacking-ii/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 12:34:44 +0000</pubDate>
		<dc:creator>BlackHC</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Pages Widget]]></category>
		<category><![CDATA[Private Pages]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.blackhc.net/?p=236</guid>
		<description><![CDATA[<a href="http://blog.blackhc.net/2009/01/wordpress-hacking-ii/" title="WordPress Hacking II"></a>I have a few private pages that I use to store random stuff and ideas and private pages (for a reason I don't understand) don't show up in the pages widget. It turns out that WordPress's get_pages function always filters &#8230;<p class="read-more"><a href="http://blog.blackhc.net/2009/01/wordpress-hacking-ii/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.blackhc.net/2009/01/wordpress-hacking-ii/" title="WordPress Hacking II"></a><p><img class="alignright size-full wp-image-239" title="privatepagesfix" src="http://blog.blackhc.net/wp-content/uploads/2009/01/privatepagesfix.jpg" alt="privatepagesfix" width="265" height="315" />I have a few private pages that I use to store random stuff and ideas and private pages (for a reason I don't understand) don't show up in the pages widget.</p>
<p>It turns out that WordPress's <strong>get_pages</strong> function always filters them out, while <strong>get_posts</strong> doesn't (it actually has some logic to figure out whether to show private pages or not).</p>
<p>I've decided to fix this. A real fix would probably be merging <strong>get_pages</strong> and <strong>get_posts</strong> because both seem to do pretty much the same except that get_posts is a tad bit more advanced, but I'm all for quick fixes at the moment, because I don't have much time and I don't want to end up considering myself a PHP developer <img src='http://blog.blackhc.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>To make <strong>get_pages</strong> return private pages, too, you have to open the file <strong>wp-includes/post.php</strong> and change the following lines near the bottom of the <strong>get_pages</strong> function:</p>
<pre>
<pre class="brush: php; title: ; notranslate">	$query = &quot;SELECT * FROM $wpdb-&gt;posts $join WHERE (post_type = 'page' AND post_status = 'publish') $where &quot;;
	$query .= $author_query;
	$query .= &quot; ORDER BY &quot; . $sort_column . &quot; &quot; . $sort_order ;</pre>
</pre>
<p>to:</p>
<pre>
<pre class="brush: php; title: ; notranslate">	$private_pages_inclusion_where = &quot;&quot;;
	if ( is_user_logged_in() ) {
		$private_pages_inclusion_where  = current_user_can( &quot;read_private_pages&quot; ) ? &quot; OR post_status = 'private'&quot; : &quot; OR post_author = $user_ID AND post_status = 'private'&quot;;
	}

	$query = &quot;SELECT * FROM $wpdb-&gt;posts $join WHERE (post_type = 'page' AND (post_status = 'publish' $private_pages_inclusion_where)) $where &quot;;
	$query .= $author_query;
	$query .= &quot; ORDER BY &quot; . $sort_column . &quot; &quot; . $sort_order ;</pre>
</pre>
<p>If you also want to make it easier to distinguish private pages from normal ones, you can also change the following bits in <strong>wp-includes/classes.php</strong> in the method <strong>Walker_Page::start_el</strong>:</p>
<pre>
<pre class="brush: php; title: ; notranslate">$output .= $indent . '&lt;li class=&quot;' . $css_class . '&quot;&gt;&lt;a href=&quot;' . get_page_link($page-&gt;ID) .
	'&quot; title=&quot;' . attribute_escape(apply_filters('the_title', $page-&gt;post_title)) . '&quot;&gt;' .
	$link_before . apply_filters('the_title', $page-&gt;post_title) . $link_after . '&lt;/a&gt;';
</pre>
</pre>
<p>to:</p>
<pre>
<pre class="brush: php; title: ; notranslate">$output .= $indent . '&lt;li class=&quot;' . $css_class . '&quot;&gt;&lt;a href=&quot;' . get_page_link($page-&gt;ID) .
	'&quot; title=&quot;' . attribute_escape(apply_filters('the_title', $page-&gt;post_title)) . '&quot;&gt;' .
	$link_before . apply_filters('the_title', $page-&gt;post_title) . ($page-&gt;post_status == 'private' ? &quot; (Private)&quot; : &quot;&quot;) . $link_after . '&lt;/a&gt;';
</pre>
</pre>
<p>Cheers,<br />
Andreas</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blackhc.net/2009/01/wordpress-hacking-ii/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Best-of-Explosm Web 2.0</title>
		<link>http://blog.blackhc.net/2008/12/best-of-explosm-web-20/</link>
		<comments>http://blog.blackhc.net/2008/12/best-of-explosm-web-20/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 14:54:08 +0000</pubDate>
		<dc:creator>BlackHC</dc:creator>
				<category><![CDATA[Check This Out!]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Explosm]]></category>
		<category><![CDATA[Mashup]]></category>
		<category><![CDATA[Ubiquity]]></category>
		<category><![CDATA[Yahoo Pipes]]></category>

		<guid isPermaLink="false">http://blog.blackhc.net/?p=177</guid>
		<description><![CDATA[<a href="http://blog.blackhc.net/2008/12/best-of-explosm-web-20/" title="Best-of-Explosm Web 2.0"></a>Yahoo Pipes are an interesting concept, as are the other existing mashup tools (like Microsoft's Popfly or Ubiquity), and it is amazing what can be done with a few clicks with them. Because I've wanted to learn how to work &#8230;<p class="read-more"><a href="http://blog.blackhc.net/2008/12/best-of-explosm-web-20/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.blackhc.net/2008/12/best-of-explosm-web-20/" title="Best-of-Explosm Web 2.0"></a><p><a href="http://pipes.yahoo.com/pipes/"><img class="alignright" style="margin: 10px;" title="Yahoo Pipes Logo" src="http://l.yimg.com/us.yimg.com/i/us/pps/logo_1.gif" alt="" width="119" height="45" /></a><a title="Yahoo Pipes" href="http://pipes.yahoo.com/pipes/" target="_blank">Yahoo Pipes</a> are an interesting concept, as are the other existing mashup tools (like Microsoft's Popfly or <a title="Mozilla's Ubiquity" href="http://ubiquity.mozilla.com/" target="_blank">Ubiquity</a>), and it is amazing what can be done with a few clicks with them.</p>
<p>Because I've wanted to learn how to work with Yahoo Pipes (before the Google Mashup Editor is released to the public), I've decided to take my best-of-explosm viewer to a different level and <strong>prototype </strong>it with Yahoo Pipes.</p>
<p><script src="http://pipes.yahoo.com/js/imagebadge.js">
{"pipe_id":"3EUQm9jU3RGJza7w_g6H4A","_btype":"image","pipe_params":{"page":"1"}}
</script></p>
<p>This just shows the first page (it's easier to view - <em>and create</em> - the feed in groups of 20 pictures than all at once). You can follow the link if you want to view more pages.</p>
<p>Stay tuned for more.<br />
Cheers,<br />
Andreas</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blackhc.net/2008/12/best-of-explosm-web-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More WordPress Pimping</title>
		<link>http://blog.blackhc.net/2008/12/more-wordpress-pimping/</link>
		<comments>http://blog.blackhc.net/2008/12/more-wordpress-pimping/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 18:37:31 +0000</pubDate>
		<dc:creator>BlackHC</dc:creator>
				<category><![CDATA[Check This Out!]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.blackhc.net/?p=135</guid>
		<description><![CDATA[<a href="http://blog.blackhc.net/2008/12/more-wordpress-pimping/" title="More WordPress Pimping"></a>PHP and CSS and all that funky web design stuff are funky, because they are so easy to use and you quickly get results. I like it. I've decided to release my first plugin into the world (it's big hack, &#8230;<p class="read-more"><a href="http://blog.blackhc.net/2008/12/more-wordpress-pimping/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.blackhc.net/2008/12/more-wordpress-pimping/" title="More WordPress Pimping"></a><p>PHP and CSS and all that funky web design stuff are funky, because they are so easy to use and you quickly get results. I like it.</p>
<p>I've decided to release my first plugin into the world (it's big hack, but it has turned out to be very useful on my other blog <a href="http://info1.blackhc.net" target="_blank">http://info1.blackhc.net</a>).</p>
<p>It supports 3 text replacements:<a title="awesome web comic is all I can say.." href="http://www.xkcd.com" target="_blank"></a></p>
<h3><a title="awesome web comic is all I can say.." href="http://www.xkcd.com" target="_blank">Xkcd</a>-style Tooltips as Replacement for Footnotes</h3>
<p>Example:</p>
<pre>[[:This is a default footnote. Hover over it to display it.]]</pre>
<p>Result:</p>
<p><a class="annotation" title="This is a default footnote. Hover over it to display it." href="javascript:;"><strong>&#180;</strong></a></p>
<p>You can use a different marker, too:<br />
Example:</p>
<pre>[[:My Footnote#This is a default footnote. Hover over it to display it.]]</pre>
<p>Result:<br />
<a class="annotation" title="This is a default footnote. Hover over it to display it." href="javascript:;"><sup><strong>My Footnote</strong></sup></a></p>
<h3>Linking to Wikipedia</h3>
<p>Example:</p>
<pre>[[wikipedia:Pie]]</pre>
<p>Result:</p>
<p><a href="http://en.wikipedia.org/wiki/Pie" target="_blank" >Pie</a></p>
<p>The link text can be changed, too, of course.<br />
Example (you can use <strong>:</strong> as seperator, too):</p>
<pre>[[wikipedia:pi#Fake Pie]]</pre>
<p>Result:</p>
<p><a href="http://en.wikipedia.org/wiki/pi" target="_blank" >Fake Pie</a></p>
<h3>Expandable Text</h3>
<p>Example:</p>
<pre>[[expandable#Expandable Text...]]</pre>
<p>Result:</p>
<div class="expandable"><a class="expandable_link" href="javascript:blackhc_replacements_togglediv('blackhc_expandable_6');">Click to expand &#187;</a>
<div class="expandable_text" name="blackhc_expandable_6" id="blackhc_expandable_6" style="display:none">Expandable Text...</div>
<p></div>
<p>The link text can be changed, too:<br />
Example:</p>
<pre>[[expandable#Click me! Click me! Pleeease!#Yay!]]</pre>
<p>Result:</p>
<div class="expandable"><a class="expandable_link" href="javascript:blackhc_replacements_togglediv('blackhc_expandable_7');">Click me! Click me! Pleeease! &#187;</a>
<div class="expandable_text" name="blackhc_expandable_7" id="blackhc_expandable_7" style="display:none">Yay!</div>
<p></div>
<p>And we can nest it and it works with other tags.<br />
Example:</p>
<pre>[[expandable:#Expandable Text...

[[expandable:Click me! Click me! Pleeease!#Yay!]]
<pre class="brush: java; title: ; notranslate">
// some Java code
</pre>
<p>]]</pre>
<p>Result:</p>
<div class="expandable"><a class="expandable_link" href="javascript:blackhc_replacements_togglediv('blackhc_expandable_8');">Click to expand &#187;</a>
<div class="expandable_text" name="blackhc_expandable_8" id="blackhc_expandable_8" style="display:none">Expandable Text...</p>
<div class="expandable"><a class="expandable_link" href="javascript:blackhc_replacements_togglediv('blackhc_expandable_11');">Click me! Click me! Pleeease! &#187;</a>
<div class="expandable_text" name="blackhc_expandable_11" id="blackhc_expandable_11" style="display:none">Yay!</div>
<p></div>
<pre class="brush: java; title: ; notranslate">
// some Java code
</pre>
</div>
<p></div>
<p>We can also use a Heredoc-like mode:<br />
Example:</p>
<pre>[[expandable_ex:EOD#Heredoc-like Expandable#[[[[[[[]][[EOD]]</pre>
<p>Result:</p>
<div class="expandable"><a class="expandable_link" href="javascript:blackhc_replacements_togglediv('blackhc_expandable_9');">Heredoc-like Expandable &#187;</a>
<div class="expandable_text" name="blackhc_expandable_9" id="blackhc_expandable_9" style="display:none">[[[[[[[]][[</div>
<p></div>
<h3>Escaping [[ and ]]</h3>
<p>Example:</p>
<pre>Escaping [[escape_left]] and [[escape_right]]</pre>
<h3>Source Code</h3>
<div class="expandable"><a class="expandable_link" href="javascript:blackhc_replacements_togglediv('blackhc_expandable_10');">Click to expand &#187;</a>
<div class="expandable_text" name="blackhc_expandable_10" id="blackhc_expandable_10" style="display:none">
<pre>
<pre class="brush: php; title: ; notranslate">&lt;?php
/*
Plugin Name: Useful text replacements
Plugin URI: http://blog.blackhc.net
Description: Some useful text replacement for annotations and other nifty things.
Version: 1.01
Author: Andreas 'BlackHC' Kirsch
Author URI: http://blog.blackhc.net

Plugin Name: Latex for WordPress
Plugin URI: http://zhiqiang.org/blog/plugin/mimetex
Description: using WordPress.com or public MimeTex service to add latex formula in post and comment. You don't need to install your own latex service.
Version: 2.01
Author: zhiqiang
Author URI: http://zhiqiang.org
*/

/*
  1.3 and higher are maintained by Zhiqiang.

   Copyright 2006  Anders Dahnielson (email : anders@dahnielson.com)

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/*
  Version-History:
  1.1.2:
  Tweaker: Martin Becker
  Email:   mbecker@physik.uni-wuerzburg.de
  Homepage: http://fstyle.de
  -   Edited discription of plugin, so correct tags will be shown
  -   Put inclusion of Snoopy-Class down into the class (mimetex),
    for in some cases WP will intialize the Snoopy-Class of its own
    after we do here, causing it to not to be able to reinitialize.
    For some reason I don't understand.
    Note: I think all this workaround using our own extra Snoopy-Class can be
    fixed by the wordpress-team by removing the if statement in their Snoopy-Class.
    That would be the case for ./wp-includes/rss-functions.php in ./wp-admin/index.php
  -   Cleaner code

  1.1.1:
  Tweaker: Baris Evrim Demiroz
  Email:   b.evrim /AT/ anlak /DOT/ com
  Homepage: http://www.anlak.com
  -   Switched to Snoopy
  -   Working in comments as well: Thanks to Robert Jones, he gave the code snippet for plugin to work with comments. You may wish to visit him: http://www.jonesieboy.co.uk/blog

  1.1.0:
  Anders Dahnielson, URI: http://dahnielson.com
  -   Anders Dahnielson's original version.
*/

class blackhc_replacements{
  var $uniqueID = 0;

  var $server = &quot;http://l.wordpress.com/latex.php?bg=ffffff&amp;amp;amp;amp;amp;fg=000000&amp;amp;amp;amp;amp;latex=&quot;;
  var $img_format = &quot;png&quot;;
  // $img_format is 'gif' when using mimetex service.
  // more server:
  // &quot;http://l.wordpress.com/latex.php?latex=&quot;;
  // &quot;http://www.bytea.net/cgi-bin/mimetex.cgi?formdata=&quot;; 

  function getUniqueID() {
    return $this-&gt;uniqueID++;
  }   

  // parsing the text to display tex by putting tex-images-tags into the code created by createTex
  function parse($toParse) {
    // tag specification (which tags are to be replaced)
    // change it to
    // $regex = '#\1 stype in your post
        //$regex = '#\$\$(.*?)\$\$#si';

      $text = $toParse;

      $oldText = &quot;&quot;;
      while( $oldText != $text ) {
        $oldText = $text;
        $text = preg_replace_callback('#\(\)!expandable\:(?:(?P&lt;link&gt;[^ <span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_9862de3eecf4dc52c6a9a929838b9dd9.gif' style=' ' class='tex' alt="]*?)\#)?(?P<content>(?:.|(?P<brackets>" /></span><script type='math/tex'>]*?)\#)?(?P<content>(?:.|(?P<brackets></script>!(?:(?&gt;[^<p style='text-align:center;'><span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_7215ee9c7d9dc229d2921a40e899ec5f.gif' style='' class='tex' alt=" " /></span><script type='math/tex;  mode=display'> </script></p>]+)|(?P&gt;brackets))* <span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_aca834c8c17b52c51566427fde231133.gif' style=' ' class='tex' alt="))*?) " /></span><script type='math/tex'>))*?) </script> <span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_c60f26f291f8488381eeade0356666b9.gif' style=' ' class='tex' alt="#si', array(&amp;amp;amp;amp;$this, 'createExpandableTextFix'), $text);

        $text = preg_replace_callback('#" /></span><script type='math/tex'>#si', array(&amp;amp;amp;amp;$this, 'createExpandableTextFix'), $text);

        $text = preg_replace_callback('#</script>!<p style='text-align:center;'><span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_dd88ee048ac907bcbea58670452f70ef.gif' style='' class='tex' alt="expandable\_ex\:(?P<eod>[^ " /></span><script type='math/tex;  mode=display'>expandable\_ex\:(?P<eod>[^ </script></p>]*?)\#(?P&lt;link&gt;[^ <span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_b5066098fdcb4475a1cc912c23836abb.gif' style=' ' class='tex' alt="]*?)\#(?P<content>.*?)(?P=eod) " /></span><script type='math/tex'>]*?)\#(?P<content>.*?)(?P=eod) </script> <span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_0db42a5198a3f5309e764d7c90768275.gif' style=' ' class='tex' alt="#si', array(&amp;amp;amp;amp;$this, 'createExpandableTextExFix'), $text);
      }
    $text = preg_replace_callback('#" /></span><script type='math/tex'>#si', array(&amp;amp;amp;amp;$this, 'createExpandableTextExFix'), $text);
      }
    $text = preg_replace_callback('#</script>!<p style='text-align:center;'><span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_17ce8e470d6abbfccbca9f4771877853.gif' style='' class='tex' alt="\:(?:([^ " /></span><script type='math/tex;  mode=display'>\:(?:([^ </script></p>]*?)\#)?(.*?) <span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_7215ee9c7d9dc229d2921a40e899ec5f.gif' style=' ' class='tex' alt=" " /></span><script type='math/tex'> </script>#si', array(&amp;amp;amp;amp;amp;$this, 'createAnnotation'), $text);

    $text = preg_replace_callback('#\(\)!wikipedia\:(.*?)(?:(?:\#|\:)(.*?))? <span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_7215ee9c7d9dc229d2921a40e899ec5f.gif' style=' ' class='tex' alt=" " /></span><script type='math/tex'> </script>#si', array(&amp;amp;amp;amp;amp;$this, 'createWikiLink'), $text);

    $text = preg_replace( array('#\(\)!escape_left <span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_7215ee9c7d9dc229d2921a40e899ec5f.gif' style=' ' class='tex' alt=" " /></span><script type='math/tex'> </script>#si', '#\(\)!escape_right <span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_7215ee9c7d9dc229d2921a40e899ec5f.gif' style=' ' class='tex' alt=" " /></span><script type='math/tex'> </script>#si'), array( '[' . '[', ']' . ']'), $text );

    return $text;
  }

  function createWikiLink($match)
  {
    $text = $match[2];
    $page = $match[1];
    if( !$text )
      $text = $page;
    return &quot;&lt;a href=\&quot;http://en.wikipedia.org/wiki/&quot;.($page).&quot;\&quot; target=\&quot;_blank\&quot; &gt;&quot;.($text).&quot;&lt;/a&gt;&quot;;
  }

  function createAnnotation($match)
  {
    $superscript = $match[1];
    $text = $match[2];
    if( $superscript == &quot;&quot;  )
      $marker = &quot;&lt;strong&gt;&amp;amp;amp;amp;amp;#180;&lt;/strong&gt;&quot;;
    else
      $marker = &quot;&lt;sup&gt;&lt;strong&gt;&quot; . ($superscript) . &quot;&lt;/strong&gt;&lt;/sup&gt;&quot;;

  return &quot;&lt;a class=\&quot;annotation\&quot; title=\&quot;&quot;.($text).&quot;\&quot; href=\&quot;javascript:;\&quot;&gt;&quot; . ($marker) . &quot;&lt;/a&gt;&quot;;
  }

  // Big Thanks to Salteh!
  function createExpandableText($match)
  {
    $linkText = $match[&quot;link&quot;];
    $text = $match[&quot;content&quot;];

  if ($linkText == &quot;&quot;) {
    $linkText = &quot;Click to expand&quot;;
  }

    $id = &quot;blackhc_expandable_&quot; . ($this-&gt;getUniqueID());
  return '&lt;div class=&quot;expandable&quot;&gt;' .
         '&lt;a class=&quot;expandable_link&quot; href=&quot;javascript:blackhc_replacements_togglediv(\''. $id . '\');&quot;&gt;' . $linkText . ' &amp;amp;amp;amp;amp;#187;&lt;/a&gt;' .
         '&lt;div class=&quot;expandable_text&quot; name=&quot;' . $id . '&quot; id=&quot;' . $id . '&quot; style=&quot;display:none&quot;&gt;' . $text . '&lt;/div&gt;&lt;br&gt;' .
         '&lt;/div&gt;';
  }

  // fix for a php bug
  // the two functions can be removed as soon as preg_replace_callback passes named subpatterns correctly: http://bugs.php.net/bug.php?id=45748
  function createExpandableTextFix( $match ) {
    return $this-&gt;createExpandableText( array( &quot;link&quot; =&gt; $match[1], &quot;content&quot; =&gt; $match[2] ) );
  }

  function createExpandableTextExFix( $match ) {
    return $this-&gt;createExpandableText( array( &quot;link&quot; =&gt; $match[2], &quot;content&quot; =&gt; $match[3] ) );
  }

  // reading the tex-expression and create an image and a image-tag representing that expression
  function createTex($toTex) {
    $formula_text = $toTex[1];
    $imgtext=false;
    if (substr($formula_text, -1, 1) == &quot;!&quot;)  return &quot;<span class='MathJax_Preview'><img src='http://blog.blackhc.net/wp-content/plugins/latex/cache/tex_28a0fe7a6ba0eb1b00ed2935fb5b845a.gif' style=' ' class='tex' alt="".substr($formula_text, 0, -1)."" /></span><script type='math/tex'>".substr($formula_text, 0, -1)."</script>&quot;;
    if (substr($formula_text, 0, 1) == &quot;!&quot;) {  $imgtext=true;$formula_text=substr($formula_text, 1);}
    $formula_hash = md5($formula_text);
    $formula_filename = 'tex_'.$formula_hash.'.'.$this-&gt;img_format;

    $cache_path = ABSPATH . '/wp-content/cache/';
    $cache_formula_path = $cache_path . $formula_filename;
    $cache_url = get_bloginfo('wpurl') . '/wp-content/cache/';
    $cache_formula_url = $cache_url . $formula_filename;

    if ( !is_file($cache_formula_path)) {
       if (!class_exists('Snoopy')) require_once (ABSPATH.'wp-includes/class-snoopy.php');

      $snoopy = new Snoopy;

      $snoopy-&gt;fetch( $this-&gt;server.rawurlencode(html_entity_decode($formula_text)));
      // this will copy the created tex-image to your cache-folder
      if(strlen($snoopy-&gt;results)){
        $cache_file = fopen($cache_formula_path, 'w');
        fputs($cache_file, $snoopy-&gt;results);
        fclose($cache_file);
      }
    }

    // returning the image-tag, referring to the image in your cache folder
    if($imgtext) return &quot;&lt;center&gt;&lt;img src=\&quot;$cache_formula_url\&quot; align=\&quot;absmiddle\&quot; class=\&quot;tex\&quot; alt=\&quot;&quot;.($formula_text).&quot;\&quot; /&gt;&lt;/center&gt;&quot;;
    return &quot;&lt;img src=\&quot;$cache_formula_url\&quot; align=\&quot;absmiddle\&quot; class=\&quot;tex\&quot; alt=\&quot;&quot;.($formula_text).&quot;\&quot; /&gt;&quot;;
  }  

  function headerAdditions() {
    // additions for expandable text
    echo '
  &lt;script language=&quot;JavaScript&quot;&gt;
  function blackhc_replacements_togglediv(divname) {
    var div = document.getElementById(divname);
    div.style.display = (div.style.display==&quot;none&quot;) ? &quot;&quot; : &quot;none&quot;;
  }
  &lt;/script&gt;
  ';
   }
}

$mimetex_object = new blackhc_replacements;
// this specifies where parsing should be done. one can look up further information on wordpress.org
add_action('wp_head', array($mimetex_object, 'headerAdditions') );

add_filter('the_title', array($mimetex_object, 'parse'), 1);
add_filter('the_content', array($mimetex_object, 'parse'), 1);
add_filter('the_excerpt', array($mimetex_object, 'parse'), 1);
// dont allow embedding stuff into comments for security reasons
//add_filter('comment_text', array($mimetex_object, 'parseTex'), 1);

?&gt;</pre>
</pre>
</div>
<p></div>
<p>Hopefully this can be useful for somebody else, too.<br />
Cheers,<br />
 Andreas</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blackhc.net/2008/12/more-wordpress-pimping/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress Hacking</title>
		<link>http://blog.blackhc.net/2008/11/wordpress-hacking/</link>
		<comments>http://blog.blackhc.net/2008/11/wordpress-hacking/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 13:27:20 +0000</pubDate>
		<dc:creator>BlackHC</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.blackhc.net/?p=128</guid>
		<description><![CDATA[<a href="http://blog.blackhc.net/2008/11/wordpress-hacking/" title="WordPress Hacking"></a>Since I've been working on another blog (http://info1.blackhc.net) for my tutorial at university, I've played around with using Microsoft Word for publishing and editing content on the blog. I gotta say that SmartArts are really nice and good way to &#8230;<p class="read-more"><a href="http://blog.blackhc.net/2008/11/wordpress-hacking/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://blog.blackhc.net/2008/11/wordpress-hacking/" title="WordPress Hacking"></a><p>Since I've been working on another blog (<a href="http://info1.blackhc.net" target="_blank">http://info1.blackhc.net</a>) for my tutorial at university, I've played around with using Microsoft Word for publishing and editing content on the blog. I gotta say that SmartArts are really nice and good way to lighten up blog posts easily.</p>
<p>However Word's support for the current version of WordPress is sub-optimal - that is, it totally messes up formatting when retrieving existing blog posts (that is, Word doesn't recognize any paragraphs or line breaks). I've spent some time digging around in the blog's .php code to find a way to fix it and after an hour or so, I've been able to fix it.<br />
It's one-liner I want to share with you:</p>
<pre class="brush: php; title: ; notranslate">
//'description' =&gt; $post['main'], // line 1939 in xmlrpc.php (function mw_getPost)
'description' =&gt; wpautop( $post['main'] ),
</pre>
<p>The function <a href="http://codex.wordpress.org/Function_Reference/wpautop" target="_blank">wpautop </a>adds &lt;p&gt; tags to your text (and by default &lt;br&gt; tags, too).</p>
<p>This will fix the formatting bug in Word. This is a hack, of course, but it works for Word.</p>
<p>WordPress has a bug in its Atom Publishing Protocol code, too:<br />
It messes up the status code header when asking for user credentials, which prevents your browser from displaying the login form.<br />
Again only one line needs to be changed:</p>
<pre class="brush: php; title: ; notranslate">
// header('Status: ' . $msg); // line 1014 in wp-app.php (function: auth_required)
header('Status: 401 ' . $msg);
</pre>
<p>Stay tuned for more updates in the next months.. <img src='http://blog.blackhc.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
Cheers,<br />
Andreas</p>
<p>PS: University is really keeping me busy..</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.blackhc.net/2008/11/wordpress-hacking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

