<?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>Yet another web log &#187; Scripts</title>
	<atom:link href="http://blog.philippheckel.com/tag/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.philippheckel.com</link>
	<description>Life, Linux and other things</description>
	<lastBuildDate>Tue, 24 Aug 2010 05:24:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>WP-UN: WordPress version update notification with cron</title>
		<link>http://blog.philippheckel.com/2010/01/29/wp-un-wordpress-version-update-notification-with-cron/</link>
		<comments>http://blog.philippheckel.com/2010/01/29/wp-un-wordpress-version-update-notification-with-cron/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:32:30 +0000</pubDate>
		<dc:creator>Philipp C. Heckel</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Cron]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.philippheckel.com/?p=164</guid>
		<description><![CDATA[WordPress is a very popular open-source blog software and is used widely throughout the Internet. However, with great success comes great attack potential: like any other wide spread open-source software, WordPress is target for frequent hacking attacks and spam-bots. All the more important is it to always update the distribution to the latest release. As [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wordpress.org/">WordPress</a> is a very popular open-source blog software and is used widely throughout the Internet. However, with great success comes great attack potential: like any other wide spread open-source software, WordPress is target for frequent hacking attacks and spam-bots. All the more important is it to always update the distribution to the latest release.</p>
<p>As Debian/Ubuntu user, I am spoiled when it comes to update management: <em>apt-get</em> updates most of my software, and <em>apticron</em> notifies me when updates are available. For WordPress however, the packaged versions of Debian/Ubuntu are really old and less adjustable which unfortunately makes a manual installation inevitable. While there are several automated WordPress update mechanisms out there, I couldn&#8217;t find a simple notify-on-update tool.</p>
<p>This post introduces the <em>WordPress Update Notifier</em> (WP-UN), a simple script that frequently compares the installed WordPress version with the latest available one. If a new version is available, it sends an e-mail to a given address.</p>
<p><span id="more-164"></span></p>
<h3 id="toc-requirements">Requirements</h3>
<p>WP-UN needs a local mail server such as <a href="http://www.sendmail.org/">Sendmail</a> or <a href="http://www.postfix.org/">Postfix</a> to deliver the notification e-mail. </p>
<h3 id="toc-download-installation">Download &amp; Installation</h3>
<p>Download the script, save it to your preferred location and make it executable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>wp-un \
          http:<span style="color: #000000; font-weight: bold;">//</span>blog.philippheckel.com<span style="color: #000000; font-weight: bold;">/</span>uploads<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2010</span><span style="color: #000000; font-weight: bold;">/</span>01<span style="color: #000000; font-weight: bold;">/</span>wp-un
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>wp-un</pre></div></div>

<p>That&#8217;s it for the installation. The script can now be called by simply running <em>wp-un</em>.</p>
<p><strong>Download</strong>: <a href="http://blog.philippheckel.com/uploads/2010/01/wp-un">WP-UN 0.1, January 2010</a></p>
<h3 id="toc-usage">Usage</h3>
<p>Now you can call the script with the following arguments:</p>
<ul>
<li><strong>&#8211;test</strong>: to test if the notification works, use the <em>&#8211;test</em> parameter (optional).</li>
<li><strong>INSTALL-DIR</strong>: the path to your local WordPress installation, for example /var/www/myblog.</li>
<li><strong>NOTIFY-EMAIL</strong>: the e-mail address of the person to notify if a new WordPress version is available.</li>
</ul>
<p>By default, the script is completely silent so that adding a cronjob doesn&#8217;t require output redirections. If, however, the <em>&#8211;test</em> option is given, it is more verbose and sends the notification e-mail in any case.</p>
<p>If a new WordPress version is available, the output looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ wp-un --test /var/www/myblog admin@example.com
Checking installed version... WordPress 2.5.1
Checking latest version... WordPress 2.9.1
Update required; Sending notification to admin@example.com... done.</pre></div></div>

<p>If WordPress is up-to-date, WP-UN would normally not send any notification. If, however, the <em>&#8211;test</em> option is enabled, it sends the e-mail no matter what. In this case, the output will look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ wp-un --test /var/www/myblog admin@example.com
Checking installed version... WordPress 2.9.1
Checking latest version... WordPress 2.9.1
Update not necessary; WordPress is up-to-date.
TEST-flag enabled: sending notfication to admin@example.com... done.</pre></div></div>

<p>The notification you receive will look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;"> The WordPress installation on host example.com needs an update:
&nbsp;
   Installed Version: WordPress 2.5.1
                  at: /var/www/myblog
&nbsp;
      Latest Version: WordPress 2.9.1
            Download: http://www.wordpress.org/latest.tar.gz</pre></div></div>

<h3 id="toc-as-cronjob">As cronjob</h3>
<p>If you want to be notified as soon as a new version comes out, installing a cronjob is a good idea. Simply run <em>crontab -e</em> and add the following line to the file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span> <span style="color: #000000;">6</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>wp-un <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>myblog admin<span style="color: #000000; font-weight: bold;">@</span>example.com</pre></div></div>

<p>WP-UN will now run every morning at 6am and notify you if a new WordPress version is out there!</p>
<h3 id="toc-conclusion">Conclusion</h3>
<p>WP-UN is just one of many solutions and it&#8217;s only the work of one afternoon. However, it doesn&#8217;t need any additional software and keeps it simple. It serves its purpose and keeps my WordPress installation always up-to-date. If you have any suggestions or questions, feel free to comment below.></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.philippheckel.com/2010/01/29/wp-un-wordpress-version-update-notification-with-cron/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copy videos from Youtube &amp; Co. to your iPod Video with Ubuntu</title>
		<link>http://blog.philippheckel.com/2008/07/29/copy-videos-from-youtube-to-your-ipod-video-with-ubuntu/</link>
		<comments>http://blog.philippheckel.com/2008/07/29/copy-videos-from-youtube-to-your-ipod-video-with-ubuntu/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 16:22:04 +0000</pubDate>
		<dc:creator>Philipp C. Heckel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Multimedia]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://blog.philippheckel.com/2008/07/30/copy-videos-from-youtube-co-to-your-ipod-video-with-ubuntu/</guid>
		<description><![CDATA[Since nearly everybody in the US and more and more Europeans have an iPod and the whole world loves Youtube, wouldn&#8217;t it be nice to copy these flash streaming videos (flv-files) to your iPod Video? &#8212; Yes, it is possible. And I will tell you how. 1st step: Copy the flash video files (capture the [...]]]></description>
			<content:encoded><![CDATA[<p>Since nearly everybody in the US and more and more Europeans have an iPod and the whole world loves Youtube, wouldn&#8217;t it be nice to copy these flash streaming videos (flv-files) to your iPod Video? &#8212; Yes, it is possible. And I will tell you how.</p>
<p><span id="more-8"></span></p>
<h3 id="toc-1st-step-copy-the-flash-video-files-capture-the-flv-files">1<sup>st</sup> step: Copy the flash video files (capture the FLV-files)</h3>
<p>Ubuntu (and I guess nearly every Linux distribution) makes it really easy to download the flash videos which can be streamed on platforms like Youtube and all the others. <em>Bad luck for Windows users.</em></p>
<ul>
<li>Just open your browser (Opera in my case, Firefox does it too)</li>
<li>Go to the website with the video you want to stream</li>
<li>Hit &#8220;Play&#8221;, wait a few seconds and push &#8220;Pause&#8221; so that the video starts to buffer</li>
<li>Now open the <em>/tmp</em>-folder in a file manager like Nautilus or Konquerer</li>
<li>You will find a file with a name like &#8220;Flashzad23&#8243;, in any case something starting with &#8220;Flash&#8221;</li>
<li>Rename this file to &#8220;my-youtube-video.flv&#8221;. This also works when the buffering process has not been finished yet</li>
</ul>
<p>That&#8217;s it. </p>
<p>If you just want to watch the video, it&#8217;s possible to just open it with your favourite player such as VLC, Totem, MPlayer, etc. This also works while it is still buffering! But since you want to copy it to the iPod Video, you need to resize/re-encode it to a <em>m4v</em>- or <em>mov</em>-file.</p>
<h3 id="toc-2nd-step-resizere-encode-the-flv-file-for-the-ipod-video">2<sup>nd</sup> step: Resize/Re-encode the flv-file for the iPod Video</h3>
<p>Unfortunately, I didn&#8217;t find a perfect <em>and</em> fast solution to re-encode flv-videos for the iPod. I will demonstrate two ways, the <em>fast</em> one for movies and series you only want to watch once. And the <em>perfect</em> one for videos you want to keep on the iPod for a longer time.</p>
<h4 id="toc-install-ffmpeg-from-the-medibuntu-repository">Install &#8220;ffmpeg&#8221; from the Medibuntu repository</h4>
<p>For both ways it is at least necessary to install the packages <em>ffmpeg</em> and <em>libavcodec0</em> from the Medibuntu Repository instead of the regular Ubuntu reps. </p>
<p>You can find out how to do this on the <a href="https://help.ubuntu.com/community/Medibuntu">Ubuntu help pages</a>.</p>
<h4 id="toc-the-fast-way">The fast way</h4>
<p>The fast way a one big <em>disadvantage</em>: The iPod isn&#8217;t able to estimate the length of the video. That means it&#8217;s not possible to use the nice diamond control to jump within the video. Regular rewind and fast-forward is still possible anyway.</p>
<p>Luckily, you only need one tool: ffmpeg. Just install it via apt-get:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">ffmpeg</span></pre></div></div>

<p>Basically, just use this command to convert a flv-file to a mov-file (readable/playable by the iPod Video):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;my-youtube-video.flv&quot;</span> <span style="color: #660033;">-f</span> mp4 <span style="color: #660033;">-vcodec</span> mpeg4 <span style="color: #660033;">-maxrate</span> 1000k \
   <span style="color: #660033;">-b</span> 700k <span style="color: #660033;">-qmin</span> <span style="color: #000000;">3</span> <span style="color: #660033;">-qmax</span> <span style="color: #000000;">5</span> <span style="color: #660033;">-bufsize</span> <span style="color: #000000;">4096</span> <span style="color: #660033;">-g</span> <span style="color: #000000;">300</span> <span style="color: #660033;">-acodec</span> aac <span style="color: #660033;">-ab</span> 192k \
   <span style="color: #660033;">-s</span> 320x240 <span style="color: #660033;">-aspect</span> <span style="color: #000000;">4</span>:<span style="color: #000000;">3</span> <span style="color: #ff0000;">&quot;my-youtube-video.mov&quot;</span></pre></div></div>

<p>To simplify the mass-conversion, I wrote a tiny script which can be copied to your own &#8220;.bin&#8221;-directory (cp. <a href="/2008/05/16/launch-nautilus-with-the-current-working-directory/">this article</a>):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #000000; font-weight: bold;">@</span>; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$file</span> <span style="color: #660033;">-f</span> mp4 <span style="color: #660033;">-vcodec</span> mpeg4 <span style="color: #660033;">-maxrate</span> 1000k <span style="color: #660033;">-b</span> 700k <span style="color: #660033;">-qmin</span> <span style="color: #000000;">3</span> <span style="color: #660033;">-qmax</span> <span style="color: #000000;">5</span> \
           <span style="color: #660033;">-bufsize</span> <span style="color: #000000;">4096</span> <span style="color: #660033;">-g</span> <span style="color: #000000;">300</span> <span style="color: #660033;">-acodec</span> aac <span style="color: #660033;">-ab</span> 192k <span style="color: #660033;">-s</span> 320x240 <span style="color: #660033;">-aspect</span> <span style="color: #000000;">4</span>:<span style="color: #000000;">3</span> <span style="color: #007800;">$file</span>.mov
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<h4 id="toc-the-perfect-and-slow-way">The perfect (and slow) way</h4>
<p>Well, this way might be the better one since the disadvantage from above doesn&#8217;t occur. Unfortunately, it does take <em>a lot longer</em>. A LOT! But just try it out by yourself.</p>
<p>I found an <a href="/uploads/2008/07/flv2ipod.sh">flv-to-iPod (m4v) encoding script</a> on ubuntu.com written by John Dong. Find instructions and installation hints to the script on the <a href="https://help.ubuntu.com/community/iPodVideoEncoding#Script 1: pypodconv Script">Ubuntu Wiki</a></p>
<h3 id="toc-3rd-and-last-step-transfer-the-video-to-the-ipod">3<sup>rd</sup> and last step: Transfer the video to the iPod</h3>
<p>Use gtkpod or your favorite iPod managing software to transfer the video to your iPod.<br />
I hope this helped a little. Please let me know if you have difficulties or found a better (easier) way to do the conversion!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.philippheckel.com/2008/07/29/copy-videos-from-youtube-to-your-ipod-video-with-ubuntu/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Launch Nautilus in the current working directory</title>
		<link>http://blog.philippheckel.com/2008/05/16/launch-nautilus-with-the-current-working-directory/</link>
		<comments>http://blog.philippheckel.com/2008/05/16/launch-nautilus-with-the-current-working-directory/#comments</comments>
		<pubDate>Fri, 16 May 2008 21:33:08 +0000</pubDate>
		<dc:creator>Philipp C. Heckel</dc:creator>
				<category><![CDATA[Office]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nautilus]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://blog.philippheckel.com/2008/05/16/launch-nautilus-with-the-current-working-directory/</guid>
		<description><![CDATA[Working on the console is sometimes tiring, especially when you have to rename files. Using Nautilus is much quicker for these types of actions. The problem is, that if you&#8217;re working in a deep depth of your file tree and your path is very long, it may take you some extra seconds to open this [...]]]></description>
			<content:encoded><![CDATA[<p>Working on the console is sometimes tiring, especially when you have to rename files. Using Nautilus is much quicker for these types of actions. The problem is, that if you&#8217;re working in a deep depth of your file tree and your path is very long, it may take you some extra seconds to open this path in the Nautilus browser. So wouldn&#8217;t it be much easier to simply type <em>naut</em> on the console to <em>open Nautilus with the current working directory</em>? </p>
<p><span id="more-6"></span></p>
<h3 id="toc-update-feb09">Update Feb/09</h3>
<p>Apparently, this can be solved in a really easy way as <em>Mads Buus</em> suggested in the comments-section. The GNOME desktop environment ships with a tool called <em>gnome-open</em>, which can be used for this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ gnome-open .</pre></div></div>

<p>This opens Nautilus in the current working directory. Note: Don&#8217;t forget the dot after the command!</p>
<p>You might also want to look how to make a shortcut for this command, cmp. Mads Buus&#8217; comment below. Thanks again for this much easier solution!</p>
<h3 id="toc-the-solution">The solution</h3>
<p>The solution is basically just a one-line command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;'<span style="color: #780078;">`pwd`</span>'&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> nautilus <span style="color: #660033;">--browser</span></pre></div></div>

<p>To make it shorter, we can just put these lines in a script called <em>naut</em>. You can either save the script where you like to or put it in your very own <em>.bin</em>-directory (which I will do here).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bin
$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'#!/bin/bash\necho &quot;'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'`pwd`'</span><span style="color: #000000; font-weight: bold;">\'</span><span style="color: #ff0000;">'&quot; | xargs nautilus --browser'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bin<span style="color: #000000; font-weight: bold;">/</span>naut
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x ~<span style="color: #000000; font-weight: bold;">/</span>.bin<span style="color: #000000; font-weight: bold;">/</span>naut</pre></div></div>

<p>Make sure to add the <em>.bin</em>-directory to your PATH variable:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'\n# Private binaries\nexport PATH=$PATH:~/.bin'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc</pre></div></div>

<h3 id="toc-usage-of-the-naut-command">Usage of the <em>naut</em>-command</h3>
<p>You can now use the <em>naut</em>-command in your console window (make sure to restart the console window before). Here is a small example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;/very/long and complicated/path/to/a/very/important/directory&quot;</span>
$ naut</pre></div></div>

<p>Et voilà , the Nautilus window will pop up.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.philippheckel.com/2008/05/16/launch-nautilus-with-the-current-working-directory/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Roundcube login via PHP script</title>
		<link>http://blog.philippheckel.com/2008/05/16/roundcube-login-via-php-script/</link>
		<comments>http://blog.philippheckel.com/2008/05/16/roundcube-login-via-php-script/#comments</comments>
		<pubDate>Fri, 16 May 2008 00:44:04 +0000</pubDate>
		<dc:creator>Philipp C. Heckel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Roundcube]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://blog.philippheckel.com/2008/05/16/roundcube-login-via-php-script/</guid>
		<description><![CDATA[Roundcube is an AJAX/PHP based e-mail application which is really flexible and easy to use in comparison to other free web based solutions. For the customer interface of Silversun, I wanted to use RC as the internal web mail application and therefore had to embed it into my system. To avoid that the customer has [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.roundcube.net/">Roundcube</a> is an AJAX/PHP based e-mail application which is really flexible and easy to use in comparison to other free web based solutions. </p>
<p>For the customer interface of <a href="http://www.silversun.de/">Silversun</a>, I wanted to use RC as the internal web mail application and therefore had to embed it into my system. To avoid that the customer has to log in twice (customer interface and Roundcube), I had to simulate the login request with a PHP script.</p>
<p><span id="more-4"></span></p>
<p><strong>Update Nov/08</strong>:<br />
After the comment of <a href="#comment-1171">Matias</a>, I reviewed the code and fixed some issues. Now it should work properly even with the newest Roundcube version (0.2-beta). The class file itself contains installation instructions. Please read them carefully.</p>
<p><strong>Update Mar/09</strong>:<br />
Just tested the script with version 0.2.1 and it works like a charm, at least for my installation.</p>
<p><strong>Update Dec/09</strong>:<br />
<a href="#comment-13861">Diego</a> just confirmed (via e-mail) that the script also works for 0.3.1 without modification. </p>
<p><strong>Update May/10</strong>:<br />
I just tested the scripts with Roundcube 0.4-beta, and it still works without modification. I also added the section <a href="#Debugging">Debugging</a> make it easier to figure out what&#8217;s wrong.</p>
<h3 id="toc-prepare-rc">Prepare RC</h3>
<p>To perform the Roundcube login via a web site, it is necessary to turn off the <em>check_ip/ip_check</em> option in the <em>main.inc.php</em> file, because our script (= server IP address) will send the login data and pass it to RC instead of the user&#8217;s browser (= user IP address). </p>
<h3 id="toc-the-roundcubelogin-class">The RoundcubeLogin class</h3>
<p>This small class only consists of four functions and it shouldn&#8217;t be necessary to modify it in order to get the login to work.</p>
<ul>
<li><a href="http://blog.philippheckel.com/uploads/2008/05/RoundcubeLogin.class.phps">RoundcubeLogin.class.php</a><br />Provides the functionality to login, logout and check the login status.</li>
<li><a href="http://blog.philippheckel.com/uploads/2008/05/rclogin.phps">rclogin.php</a><br />A small script to test if everything works as expected.</li>
</ul>
<p>The class provides four public methods:</p>
<ul>
<li>
  <strong>login($username, $password)</strong><br />
  Perform a login to the Roundcube mail system.<br />
  <u>Note</u>: If the client is already logged in, the script will re-login the user (logout/login). To prevent this behaviour, use the <em>isLoggedIn()</em>-function.<br />
  <u>Returns</u>: <em>TRUE</em> if the login suceeds, <em>FALSE</em> if the user/pass-combination is wrong<br />
  <u>Throws</u>: May throw a <em>RoundcubeLoginException</em> if Roundcube sends an unexpected answer (that might happen if a new Roundcube version behaves differently)
</li>
<li>
  <strong>isLoggedIn()</strong><br />
  Checks whether the client/browser is logged in and has a valid Roundcube session.<br />
  <u>Returns</u>: <em>TRUE</em> if the user is logged in, <em>FALSE</em> otherwise.<br />
  <u>Throws</u>: May also throw a <em>RoundcubeLoginException</em> (see above).
</li>
<li>
  <strong>logout()</strong><br />
  Performs a logout on the current Roundcube session.<br />
  <u>Returns</u>: <em>TRUE</em> if the logout was a success, <em>FALSE</em> otherwise.<br />
  <u>Throws</u>: May also throw a <em>RoundcubeLoginException</em> (see above).
</li>
<li>
  <strong>redirect()</strong><br />
  Simply redirects to Roundcube.
</li>
</ul>
<h3 id="toc-sample-usage">Sample usage</h3>
<p>The script below demonstrates how the class can be used. If the client is already logged in, it simply redirects the browser to the Roundcube application. If not, it performs a login and then redirects to Roundcube.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;RoundcubeLogin.class.php&quot;</span><span style="color: #339933;">;</span>	
&nbsp;
<span style="color: #666666; font-style: italic;"># Create RC login object.
</span><span style="color: #666666; font-style: italic;"># Note: The first parameter is the URL-path of the RC inst.,
</span><span style="color: #666666; font-style: italic;">#       NOT the file-system path
</span><span style="color: #666666; font-style: italic;"># e.g. http://host.com/path/to/roundcube/ --&gt; &quot;/path/to/roundcube&quot;
</span><span style="color: #000088;">$rcl</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RoundcubeLogin<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/roundcube/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
try <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;"># If we are already logged in, simply redirect
</span>   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rcl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isLoggedIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #000088;">$rcl</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>
&nbsp;
   <span style="color: #666666; font-style: italic;"># If not, try to login and simply redirect on success
</span>   <span style="color: #000088;">$rcl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">login</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;some-email-address&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;plain-text-password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$rcl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isLoggedIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #000088;">$rcl</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>
&nbsp;
   <span style="color: #666666; font-style: italic;"># If the login fails, display an error message
</span>   <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ERROR: Login failed due to a wrong user/pass combination.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
catch <span style="color: #009900;">&#40;</span>RoundcubeLoginException <span style="color: #000088;">$ex</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;ERROR: Technical problem, &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ex</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$rcl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dumpDebugStack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3 id="Debugging" >Debugging</h3>
<p>If you&#8217;re having problems with the <a href="/uploads/2008/05/RoundcubeLogin.class.phps">RoundcubeLogin.class.php</a> class itself, try using the <a href="/uploads/2008/05/rclogin.phps">rclogin.php</a>-file for debugging: open the file in your browser (http://myhost/roundcube/rclogin.php), and take a look at the output. The <tt>RoundcubeLogin</tt>-class performs a series of request/response cycles and parses the output to figure out if you&#8217;re logged in. </p>
<p>Known issues:</p>
<ol>
<li><b>No Roundcube installation found at &#8216;&#8230;&#8217;</b><br />
   This error message is thrown if the path-value in the <tt>RoundcubeLogin</tt> constructur was not set correctly. It must be set to the part of the URL that represents the path, e.g. in case of http://myhost/roundcube/ you must create the object like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$rcl</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RoundcubeLogin<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/roundcube/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li><b>Unable to determine login-status due to technical problems.</b><br />
  This error can occur in the methods login(), logout() and isLoggedIn(). The <tt>RoundcubeLogin</tt>-class expects Roundcube to send certain headers in response to the login/logout-requests. If those headers could not be found, this error is thrown. Possible reasons are: </p>
<ul>
<li>New RC version</li>
<li>Cookies must be enabled</li>
<li><em>ip_check/check_ip</em> option in the <em>main.inc.php</em> must be <tt>false</tt></li>
</ul>
</li>
<li><b>Unable to determine the login status. Unable to continue due to technical problems.</b><br />
  This error occurs if the script cannot determine if you are logged in or not, because the returned HTML code neither contains the login-form (= logged out) nor the message DIV (= logged in). This might happen if Roundcube changed the HTML-code.</li>
</ol>
<h3 id="toc-im-open-for-suggestions">I&#8217;m open for suggestions</h3>
<p>Please feel free to post your comment or suggestions. That&#8217;s the only way to ensure that it works with all versions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.philippheckel.com/2008/05/16/roundcube-login-via-php-script/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Switch off sound on Ubuntu before login</title>
		<link>http://blog.philippheckel.com/2008/05/15/switch-off-sound-on-ubuntu-before-login/</link>
		<comments>http://blog.philippheckel.com/2008/05/15/switch-off-sound-on-ubuntu-before-login/#comments</comments>
		<pubDate>Thu, 15 May 2008 20:53:06 +0000</pubDate>
		<dc:creator>Philipp C. Heckel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.philippheckel.com/2008/05/15/switch-off-sound-on-ubuntu-before-login/</guid>
		<description><![CDATA[Most of the Ubuntu users know the situation: You&#8217;re sitting in a public place, let&#8217;s say a lecture or a café, and you forgot to switch off the sound of your laptop. Unfortunately, you can&#8217;t avoid the first short drumming. But by using the following command, it is at least possible to switch off the [...]]]></description>
			<content:encoded><![CDATA[<p>Most of the Ubuntu users know the situation: You&#8217;re sitting in a public place, let&#8217;s say a lecture or a café, and you forgot to switch off the sound of your laptop. Unfortunately, you can&#8217;t avoid the first short drumming. But by using the following command, it is at least possible to switch off the longer welcome melody of Ubuntu before you actually log in.</p>
<p><span id="more-5"></span></p>
<h3 id="toc-preparation-create-a-short-mute-script">Preparation: Create a short <em>mute</em>-script</h3>
<p>Create your custom <em>.bin</em>-directory, add it to your <em>.bashrc</em>, create a <em>mute</em>-script and make it executable.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> $ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bin
 $ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'\n# Private binaries\nexport PATH=$PATH:~/.bin'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc
 $ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'#!/bin/bash\namixer set Master mute'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bin<span style="color: #000000; font-weight: bold;">/</span>mute
 $ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x ~<span style="color: #000000; font-weight: bold;">/</span>.bin<span style="color: #000000; font-weight: bold;">/</span>mute</pre></div></div>

<h3 id="toc-avoid-the-embarrassment-use-the-script">Avoid the embarrassment: Use the script</h3>
<p>You can now use the script by simply typing <em>mute</em> in your console window. To use it before logging into GNOME/KDE, follow these steps.</p>
<ul>
<li>Switch to a different tty by pressing <em>CTRL+ALT+F1</em></li>
<li>Log in with your username and password</li>
<li>Run the script by typing <em>mute</em></li>
<li>And finally switch back to the graphical login window: <em>CTRL+ALT+F7</em></li>
</ul>
<p>Well, I hope this helps a little. Of course you don&#8217;t have to use the script but can just type:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ amixer set Master mute</pre></div></div>

<p>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.philippheckel.com/2008/05/15/switch-off-sound-on-ubuntu-before-login/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
