<?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>WebDevWonders.com</title>
	<atom:link href="http://webdevwonders.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://webdevwonders.com</link>
	<description>[ Your everyday web development resource ]</description>
	<lastBuildDate>Mon, 08 Apr 2013 11:23:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Configuring a permanent SSH tunnel for MySQL connections on Debian</title>
		<link>http://webdevwonders.com/configuring-a-permanent-ssh-tunnel-for-mysql-connections-on-debian/</link>
		<comments>http://webdevwonders.com/configuring-a-permanent-ssh-tunnel-for-mysql-connections-on-debian/#comments</comments>
		<pubDate>Sun, 30 Dec 2012 23:06:24 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ssh tunnel]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=521</guid>
		<description><![CDATA[This article shows how to setup a permanent SHH tunnel between a webserver and a database server running MySQL. First of all we will create two new users, one on each server. Of course you may also use existing users, &#8230; <a href="http://webdevwonders.com/configuring-a-permanent-ssh-tunnel-for-mysql-connections-on-debian/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This article shows how to setup a permanent SHH tunnel between a webserver and a database server running MySQL. First of all we will create two new users, one on each server. Of course you may also use existing users, but I prefer to have users dedicated just for the tunneling job. So we will start with the database server, where we create a new user and enable him to login via Publickey Authentication by editing &#8220;sshd_config&#8221;-file:</p>
<pre class="black">
adduser ssh-tunnel
nano /etc/ssh/sshd_config
</pre>
<p>Now add the user to &#8220;AllowUsers&#8221; and set &#8220;PubkeyAuthentication&#8221; to &#8220;yes&#8221;:</p>
<pre>
AllowUsers ssh-tunnel
PubkeyAuthentication yes
</pre>
<p>Then restart SSH:</p>
<pre class="black">
/etc/init.d/ssh restart
</pre>
<p>Now lets switch to the webserver and create a new user as well (also install autossh if not done already):</p>
<pre class="black">
aptitude install autossh
adduser ssh-tunnel-mysql
</pre>
<p>Now add the user to &#8220;AllowUsers&#8221; just as done before with the new user on the database server:</p>
<pre>
AllowUsers ssh-tunnel-mysql
</pre>
<p>Also restart SSH here:</p>
<pre class="black">
/etc/init.d/ssh restart
</pre>
<p>Now login to the webserver with the newly created user &#8220;ssh-tunnel-mysql&#8221;. Next you can already try to open a tunnel. But make sure to replace SSH port, MySQL port and IP according to your configuration:</p>
<pre class="black">
/usr/bin/autossh -M 20042 -N -L 3308:127.0.0.1:3306 -p 22 ssh-tunnel@1.2.3.4
</pre>
<p>You might get the following error:</p>
<pre class="black">
Warning: remote port forwarding failed for listen port 20042
</pre>
<p>It means your port is in use. In this case just change &#8220;20042&#8243; to an unused port. Once you have established the tunnel it&#8217;s time to test it. Do this in a new console window and make sure to use the correct password for the &#8220;ssh-tunnel&#8221; user:</p>
<pre class="black">
mysql -h 127.0.0.1 -P 3308 -ussh-tunnel -pPASSWORD
</pre>
<p>Now you should be connected and able to work with the MySQL database on the database server. Try the following, it should list all your databases that exist the database server:</p>
<pre class="black">
SHOW DATABASES;
</pre>
<p>Since we have confirmed that the tunnel is working we can now create a public key to enable logon without a password. Make sure to execute the following commands on the webserver as the tunnel user (leave the passphrase empty when asked for it):</p>
<pre class="black">
cd ~
mkdir .ssh
ssh-keygen -t dsa -b 1024 -f ~/.ssh/ssh-tunnel-key
</pre>
<p>Now you created a public/private key pair on the webserver. Next the public key has to be enabled inside the authorized_keys file on the database server. For this you need to login to the database server as the tunnel user and execute the following commands:</p>
<pre class="black">
cd ~
mkdir .ssh
chmod 700 .ssh
cd .ssh/
touch authorized_keys
chmod 600 authorized_keys
</pre>
<p>Now everything is setup on the database server. So we can go back to the webserver and copy the key. Again make sure to be logged in as the tunnel user and change SSH port and IP to yours:</p>
<pre class="black">
cat ~/.ssh/*.pub | ssh ssh-tunnel@1.2.3.4 -p 22 'umask 077; cat >>.ssh/authorized_keys'
</pre>
<p>Now test your connection again, this time by using the key:</p>
<pre class="black">
/usr/bin/autossh -M 20042 -N -L 3308:127.0.0.1:3306 -p 22 
-i /home/ssh-tunnel-mysql/.ssh/ssh-tunnel-key ssh-tunnel@1.2.3.4
</pre>
<p>Everything working without a password now? Then you can put the tunnel in the background by using the parameter &#8220;-f&#8221;. This way your tunnel will remain active even when you close your console window:</p>
<pre class="black">
/usr/bin/autossh -M 20042 -f -N -L 3308:127.0.0.1:3306 -p 22 
-i /home/ssh-tunnel-mysql/.ssh/ssh-tunnel-key ssh-tunnel@1.2.3.4
</pre>
<p>If you want to close the tunnel you can use the &#8220;kill&#8221;-command with the PID of the tunnel or if you are using the tunnel user just for the case of tunneling by simply executing &#8220;killall&#8221;:</p>
<pre class="black">
killall -u ssh-tunnel-mysql
</pre>
<p>Thats it. If anything is missing, wrong or any problems occur please let me know via my <a href="http://webdevwonders.com/contact/" title="Contact">contact form</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/configuring-a-permanent-ssh-tunnel-for-mysql-connections-on-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install, automate and secure AWStats including GeoIP-Plugin on Debian</title>
		<link>http://webdevwonders.com/how-to-install-automate-and-secure-awstats-including-geoip-plugin-on-debian/</link>
		<comments>http://webdevwonders.com/how-to-install-automate-and-secure-awstats-including-geoip-plugin-on-debian/#comments</comments>
		<pubDate>Tue, 11 Sep 2012 09:17:44 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[awstats]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[geoip]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=495</guid>
		<description><![CDATA[If you don&#8217;t want to use a 3rd-party website analytics tool like i.e. Google Analytics but still want to monitor your visitors, pageviews and so on, then AWStats might be the right tool for you. It works serverside by analyzing &#8230; <a href="http://webdevwonders.com/how-to-install-automate-and-secure-awstats-including-geoip-plugin-on-debian/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you don&#8217;t want to use a 3rd-party website analytics tool like i.e. Google Analytics but still want to monitor your visitors, pageviews and so on, then <a href="http://awstats.sourceforge.net/" title="AWStats" target="_blank" onclick="pageTracker._trackPageview('/outgoing/awstats.sourceforge.net/?referer=');">AWStats</a> might be the right tool for you. It works serverside by analyzing your logfiles and creating a simple graphical website on the most important info about your visitors. Although it is not as detailed as most frontend analytics tools it still provides a very good overview.<br />
This is how installation works on Debian, assuming you are running Apache2 server:</p>
<pre class="black">
apt-get install awstats
</pre>
<p>The debian installer does not automatically set the correct paths in the AWStats configuration script, so we have to do this manually (for all text editing just use your favorite editor, I will be using nano throughout this tutorial):</p>
<pre class="black">
nano /usr/share/doc/awstats/examples/awstats_configure.pl
</pre>
<pre>
$AWSTATS_PATH='/usr/share/awstats';
$AWSTATS_ICON_PATH='/usr/share/awstats/icon';
$AWSTATS_CSS_PATH='/usr/share/awstats/css';
$AWSTATS_CLASSES_PATH='/usr/share/awstats/lib';
$AWSTATS_CGI_PATH='/usr/lib/cgi-bin';
$AWSTATS_MODEL_CONFIG='/usr/share/doc/awstats/examples/awstats.model.conf';
$AWSTATS_DIRDATA_PATH='/var/lib/awstats';
</pre>
<p>Now the configuration should be ok. In the next step we have to make the configuration script executable by the apache2 user, most probably www-data:</p>
<pre class="black">
chown www-data /usr/lib/cgi-bin/awstats.pl
</pre>
<p>Now AWStats is already up and running. But we are still far from being done. Next we should check your apache2 configuration for the following lines and add them if not present (it will enable the AWStats icons for our AWStats infosite):</p>
<pre class="black">
nano /etc/apache2/apache2.conf
</pre>
<pre>
Alias /awstats-icon/ /usr/share/awstats/icon/
&lt;Directory /usr/share/awstats/icon&gt;
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
&lt;/Directory&gt;
</pre>
<p>Ok. Next thing to do is updating some settings in our AWStats configuration file. We need to set the correct path to our Apache access log, set our site domain and I would also suggest to change the default LogFormat and disable DNSLookup.</p>
<pre class="black">
nano /etc/awstats/awstats.conf
</pre>
<pre>
LogFile="/var/log/apache2/access.log"
LogFormat=1
SiteDomain="webdevwonders.com"
DNSLookup=0
</pre>
<p>Now we can try to run AWStats for the first time (remember to fill in your domain name instead of mine):</p>
<pre class="black">
/usr/lib/cgi-bin/awstats.pl -config=webdevwonders.com -update
/usr/lib/cgi-bin/awstats.pl -config=awstats.webdevwonders.com.conf
</pre>
<p>If you get an error message with one or the other command you might want to check your configuration settings once again. One problem that might occur is access denied to the apache log. Fix it like this and try executing the commands from above once again:</p>
<pre class="black">
chmod 755 /var/log/apache2
</pre>
<p>If everything works we can continue by enabling browser access to our statistics:</p>
<pre class="black">
chown www-data /usr/lib/cgi-bin/awstats.pl
</pre>
<p>Now try to open the AWStats statistics in your browser. The path should look like this (again of course your own domain name): http://webdevwonders.com/cgi-bin/awstats.pl. If you receive a 504 Gateway Timeout you will have to increase the timeout value inside apache2.conf. Something between 20 and 60 seconds should be enough.<br />
Now next is the automation of our statistics by adding a cronjob that will automatically update them:</p>
<pre class="black">
nano /etc/crontab
</pre>
<p>Add the following line for a 15 minute crontab or change the update cycle according to your needs (adjust domain name as usual).</p>
<pre>
/15 *   * * *   root    /usr/lib/cgi-bin/awstats.pl -config=awstats.webdevwonders.com.conf
</pre>
<p>Now let&#8217;s protect our statistics from prying eyes. We are doing this by adding a .htaccess file to our &#8220;cgi-bin&#8221;-directory:</p>
<pre class="black">
cd /usr/lib/cgi-bin/
touch .htaccess
nano .htaccess
</pre>
<p>Now insert the following (please note that for this tutorial we will simply put the .htpasswd file in &#8220;/var/www/awstats&#8221; but you might consider putting it somewhere else).</p>
<pre>
&lt;FilesMatch "awstats.pl"&gt;
    AuthName "Login Required"
    AuthType Basic
    AuthUserFile /var/www/awstats/.htpasswd
    require valid-user
&lt;/FilesMatch&gt;
</pre>
<p>Now create the .htpasswd file (remember to fill in your own username):</p>
<pre class="black">
cd /var/www/
mkdir awstats
cd awstats
htpasswd -c /var/www/awstats/.htpasswd username
</pre>
<p>Almost done, but we have to enable &#8220;AllowOverride&#8221; for the &#8220;cgi-bin&#8221;-directory to have Apache make use of our access rule. So edit the part inside your VirtualHost configuration:</p>
<pre class="black">
nano /etc/apache2/sites-available/default
</pre>
<pre>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
&lt;Directory "/usr/lib/cgi-bin"&gt;
    AllowOverride All
    ...
&lt;/Directory&gt;
</pre>
<p>One more thing: Restart Apache.</p>
<pre class="black">
/etc/init.d/apache2 restart
</pre>
<p>Check your AWStats URL once again. It should be protected. AWStats configuration is fine like this and will show you lots of nice info about your visitors already, but there is one more module called <a href="http://dev.maxmind.com/geoip/downloadable" title="GeoIP" target="_blank" onclick="pageTracker._trackPageview('/outgoing/dev.maxmind.com/geoip/downloadable?referer=');">GeoIP</a> which is a &#8220;nice to have&#8221;-plugin. It will show you the country where your visitors are located at, even with a nice country flag icon!<br />
Before we can start installing GeoIP we need to install the GNU GCC Compiler, which is included in the &#8220;build-essential&#8221;-package, as well as the library <a href="http://zlib.net/" title="zlib" target="_blank" onclick="pageTracker._trackPageview('/outgoing/zlib.net/?referer=');">zlib</a>:</p>
<pre class="black">
apt-get install build-essential
wget http://zlib.net/zlib-1.2.7.tar.gz
tar xvzf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure --prefix=/usr/local/zlib &#038;&#038; make &#038;&#038; make install
</pre>
<p>Now let&#8217;s go ahead and download and install the GeoIP plugin:</p>
<pre class="black">
wget http://maxmind.com/download/geoip/api/c/GeoIP.tar.gz
tar xzvf GeoIP.tar.gz
cd GeoIP*
./configure &#038;&#038; make &#038;&#038; make install
</pre>
<p>Although installation should work, in some cases you might get an error like this:</p>
<pre class="black">
checking for zlib.h... no
configure: error: Zlib header (zlib.h) not found. Tor requires zlib to build.
You may need to install a zlib development package.
</pre>
<p>This problem can be fixed by installing zlib1g-dev package. Afterwards retry the installation:</p>
<pre class="black">
apt-get install zlib1g-dev
./configure &#038;&#038; make &#038;&#038; make install
</pre>
<p>Now continue with removing all previous installation files and finish installation of GeoIP:</p>
<pre class="black">
cd ..
cd ..
rm -rfv zlib*
cpan
install Geo::IP
quit
</pre>
<p>One final step: Check in your AWStats configuration if the LoadPlugin is enabled and the path is set correctly:</p>
<pre class="black">
nano /etc/awstats/awstats.conf
</pre>
<pre>
LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
</pre>
<p>Now, just for the sake of making sure everything is enabled, let&#8217;s restart Apache once more:</p>
<pre class="black">
/etc/init.d/apache2 restart
</pre>
<p>And that&#8217;s it! Hopefully you will have AWStats up and running as expected. If anything in this tutorial is missing, not working or simply wrong please let me know via my <a href="http://webdevwonders.com/contact/" title="Contact" target="_blank">contact form</a> so I can update the tutorial accordingly. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/how-to-install-automate-and-secure-awstats-including-geoip-plugin-on-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to animate a rectangle bottom up with Raphaël.js</title>
		<link>http://webdevwonders.com/how-to-animate-a-rectangle-bottom-up-with-raphael-js/</link>
		<comments>http://webdevwonders.com/how-to-animate-a-rectangle-bottom-up-with-raphael-js/#comments</comments>
		<pubDate>Tue, 28 Aug 2012 19:39:39 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[Animation]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[raphael.js]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=480</guid>
		<description><![CDATA[Since I did not find an easy way on how to animate a rectangle bottom up with Raphael.js while searching the net I thought it might be helpful to post my simple solution of a bottom up rectangle animation with &#8230; <a href="http://webdevwonders.com/how-to-animate-a-rectangle-bottom-up-with-raphael-js/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since I did not find an easy way on how to animate a rectangle bottom up with Raphael.js while searching the net I thought it might be helpful to post my simple solution of a bottom up rectangle animation with Raphaël.js. So here it is:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #999999; font-style: italic;">// Create options object that specifies the rectangle</span>
<span style="color: #0000E6; font-weight: bold;">var</span> rect_opt <span style="color: #222222;">=</span> <span style="color: #222222;">&#123;</span>
    width<span style="color: #222222;">:</span> <span style="color: #222222;">100</span><span style="color: #222222;">,</span>
    height<span style="color: #222222;">:</span> <span style="color: #222222;">200</span><span style="color: #222222;">,</span>
    x<span style="color: #222222;">:</span> <span style="color: #222222;">0</span><span style="color: #222222;">,</span>
    y<span style="color: #222222;">:</span> <span style="color: #222222;">0</span>
<span style="color: #222222;">&#125;</span>
&nbsp;
<span style="color: #999999; font-style: italic;">// Container that will contain animation (suppose document contains a div with id 'raphael')</span>
<span style="color: #0000E6; font-weight: bold;">var</span> div <span style="color: #222222;">=</span> document.<span style="color: #222222;">getElementById</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">'raphael'</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
&nbsp;
<span style="color: #999999; font-style: italic;">// Create new raphael object</span>
<span style="color: #0000E6; font-weight: bold;">var</span> ctx <span style="color: #222222;">=</span> <span style="color: #0000E6; font-weight: bold;">new</span> Raphael<span style="color: #222222;">&#40;</span>div<span style="color: #222222;">,</span> rect_opt.<span style="color: #222222;">width</span><span style="color: #222222;">,</span> rect_opt.<span style="color: #222222;">height</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
&nbsp;
<span style="color: #999999; font-style: italic;">// Set animation speed</span>
<span style="color: #0000E6; font-weight: bold;">var</span> speed <span style="color: #222222;">=</span> <span style="color: #222222;">10000</span><span style="color: #222222;">;</span>
&nbsp;
<span style="color: #999999; font-style: italic;">/*
 * Create rectangle object with y-position at bottom by setting it to the specified height,
 * also give the rectangle a height of '0' to make it invisible before animation starts
 */</span>
<span style="color: #0000E6; font-weight: bold;">var</span> rect <span style="color: #222222;">=</span> ctx.<span style="color: #222222;">rect</span><span style="color: #222222;">&#40;</span>rect_opt.<span style="color: #222222;">x</span><span style="color: #222222;">,</span> rect_opt.<span style="color: #222222;">height</span><span style="color: #222222;">,</span> rect_opt.<span style="color: #222222;">width</span><span style="color: #222222;">,</span> <span style="color: #222222;">0</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
&nbsp;
<span style="color: #999999; font-style: italic;">// Color the rectangle nicely</span>
rect.<span style="color: #222222;">attr</span><span style="color: #222222;">&#40;</span><span style="color: #222222;">&#123;</span>
    fill<span style="color: #222222;">:</span><span style="color: #CE7B00;">'#289CFE'</span><span style="color: #222222;">,</span>
    stroke<span style="color: #222222;">:</span><span style="color: #CE7B00;">'none'</span>
<span style="color: #222222;">&#125;</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
&nbsp;
<span style="color: #999999; font-style: italic;">/*
 * Animate the rectangle from bottom up by setting the height to the earlier specified
 * height and by setting the y-position to the top of the rectangle
 */</span>
rect.<span style="color: #222222;">animate</span><span style="color: #222222;">&#40;</span><span style="color: #222222;">&#123;</span>
    y<span style="color: #222222;">:</span>rect_opt.<span style="color: #222222;">y</span><span style="color: #222222;">,</span>
    height<span style="color: #222222;">:</span>rect_opt.<span style="color: #222222;">height</span>
<span style="color: #222222;">&#125;</span><span style="color: #222222;">,</span> speed<span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span></pre></div></div>

<p>And here is how it looks like in action (infinite loop):</p>
<div id="raphael_rect"></div>
<p><script type="text/javascript">
var rect_opt = {
    width: 100,
    height: 200,
    x: 0,
    y: 0
}
var div = document.getElementById('raphael_rect');
var ctx = new Raphael(div, rect_opt.width, rect_opt.height);
var speed = 5000;
var rect = ctx.rect(rect_opt.x, rect_opt.height, rect_opt.width, 0);
rect.attr({
    fill:'#289CFE',
    stroke:'none'
});
function animateRaphaelRect(){
    rect.attr({
        y:rect_opt.height,
        height:0
    })
    rect.animate({
        y:rect_opt.y,
        height:rect_opt.height
    }, speed, function(){
        animateRaphaelRect();
    });
}
animateRaphaelRect();
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/how-to-animate-a-rectangle-bottom-up-with-raphael-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix for wkhtmltopdf rendering issue when using SVG</title>
		<link>http://webdevwonders.com/wkhtmltopdf-rendering-issue-when-using-svg/</link>
		<comments>http://webdevwonders.com/wkhtmltopdf-rendering-issue-when-using-svg/#comments</comments>
		<pubDate>Sat, 25 Aug 2012 21:46:54 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[Animation]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[raphael.js]]></category>
		<category><![CDATA[svg]]></category>
		<category><![CDATA[wkhtmltopdf]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=473</guid>
		<description><![CDATA[I recently spent some hours trying to find out why my SVG graph wasn&#8217;t rendering properly with wkhtmltopdf. Since the same problem might occur to others I wanted to share it here. So this is the issue: It seems like &#8230; <a href="http://webdevwonders.com/wkhtmltopdf-rendering-issue-when-using-svg/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently spent some hours trying to find out why my SVG graph wasn&#8217;t rendering properly with wkhtmltopdf. Since the same problem might occur to others I wanted to share it here. So this is the issue: It seems like wkhtmltopdf has a problem with rendering when you use &#8220;stroke-dasharray&#8221; inside a SVG with a value of &#8220;0&#8243;, which may be used to set a path to a continuous line. Whenever this is used, wkhtmltopdf will fail to render the SVG properly (see <a href="http://code.google.com/p/wkhtmltopdf/issues/detail?id=650" title="Bug report for further info" target="_blank" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/wkhtmltopdf/issues/detail?id=650&amp;referer=');">bug report for further info</a>).<br />
If this happened to you while using <a href="http://raphaeljs.com/" title="Raphael.js" target="_blank" onclick="pageTracker._trackPageview('/outgoing/raphaeljs.com/?referer=');">Raphael.js</a> you can fix this by updating a value inside the library. Raphael.js is using a &#8220;0&#8243; for &#8220;stroke-dasharray&#8221; whenever you either leave the value empty or use &#8220;none&#8221; as the value. Inside the library you will find this where an object &#8220;dasharray&#8221; is initialized (right above the initialization of the function &#8220;addDashes&#8221;). You can replace both zeros by a very high value, i.E. 99999. It only needs to be higher than the pixel length of your path, because then it will still be shown as a continuous line.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/wkhtmltopdf-rendering-issue-when-using-svg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Malicious file download &#8211; and nobody will notice</title>
		<link>http://webdevwonders.com/malicious-file-download-and-nobody-will-notice/</link>
		<comments>http://webdevwonders.com/malicious-file-download-and-nobody-will-notice/#comments</comments>
		<pubDate>Fri, 24 Aug 2012 19:27:47 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Security/Privacy]]></category>
		<category><![CDATA[cross-origin]]></category>
		<category><![CDATA[data-URI]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[redirect]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=451</guid>
		<description><![CDATA[I recently came across a very sneaky yet impressive way of tricking people into downloading a malicious file. But before you continue reading you might want to download the newest Flash Player version?! Yeah, I know Flash is dead, but &#8230; <a href="http://webdevwonders.com/malicious-file-download-and-nobody-will-notice/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently came across a very sneaky yet impressive way of tricking people into downloading a malicious file. But before you continue reading you might want to <a id="download_flash" title="Download Flash Player" href="http://get.adobe.com/flashplayer/download/?installer=Flash_Player_11_for_Internet_Explorer" target="_blank" onclick="pageTracker._trackPageview('/outgoing/get.adobe.com/flashplayer/download/?installer=Flash_Player_11_for_Internet_Explorer&amp;referer=');">download the newest Flash Player version</a>?! Yeah, I know Flash is dead, but please give it a try anyway and see if you notice anything strange about it&#8230;<br />
Done? Ok. So what you just downloaded was, of course, not a new Flash Player version but a possibly malicious file from my website. Maybe you noticed that the file was requested from webdevwonders.com instead of adobe.com.<br />
The name of the domain is actually the only easy way to notice that you are just downloading a different file from another server than expected. Now imagine a malicious download from a domain like flashplayer-download.com. How many people would be suspicious, even if he or she read the name of the file host?<br />
But lets have a look at the code now (by the way, this will NOT work in Internet Explorer):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #999999; font-style: italic;">// Called 'onclick' of the link</span>
<span style="color: #0000E6; font-weight: bold;">function</span> openFlashWebsite<span style="color: #222222;">&#40;</span><span style="color: #222222;">&#41;</span> <span style="color: #222222;">&#123;</span>
    <span style="color: #999999; font-style: italic;">// http://get.adobe.com/flashplayer/download/?installer=Flash_Player_11_for_Internet_Explorer</span>
    window.<span style="color: #0000E6;">open</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">'data:text/html,&lt;meta http-equiv=&quot;refresh&quot; content=&quot;0;URL=http://get.adobe.com/flashplayer/download/?installer=Flash_Player_11_for_Internet_Explorer&quot;&gt;'</span><span style="color: #222222;">,</span> <span style="color: #CE7B00;">'foo'</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
    setTimeout<span style="color: #222222;">&#40;</span>triggerDownload<span style="color: #222222;">,</span> <span style="color: #222222;">4500</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
<span style="color: #222222;">&#125;</span>
<span style="color: #999999; font-style: italic;">// Will be called after a timeout of 4.5 secs</span>
<span style="color: #0000E6; font-weight: bold;">function</span> triggerDownload<span style="color: #222222;">&#40;</span><span style="color: #222222;">&#41;</span> <span style="color: #222222;">&#123;</span>
  window.<span style="color: #0000E6;">open</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">'http://webdevwonders.com/download/flashplayer'</span><span style="color: #222222;">,</span> <span style="color: #CE7B00;">'foo'</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
<span style="color: #222222;">&#125;</span></pre></div></div>

<p>Now what is happening here? First of all the function &#8220;openFlashWebsite&#8221; is called by clicking the link. It will initiate a new window with a &#8220;text/html&#8221; data URI that will itself initiate a new window (or tab) that will immediately open the Flash Player download site via a meta refresh. But secondly, the function also starts a timeout, which will be triggered after 4.5 seconds and will open a document with a &#8220;Content-Disposition: attachment;&#8221;-Header that will trigger the download of a file called &#8220;flashplayer_11.exe&#8221;, which is served by this blog. The sneaky thing about it is, that this download will get attached directly to the opened site which will be the Adobe Flash Player download site, tricking the user into thinking that this is the expected Flash Player download. This is made possible by the concept of web browser documents having the ability to navigate other (cross-origin) windows to arbitrary URLs. A deeper explanation of the issue is given in &#8220;The Tangled Web&#8221; by Michal Zalewski, <a href="http://lcamtuf.blogspot.dk/2012/05/yes-you-can-have-fun-with-downloads.html" onclick="pageTracker._trackPageview('/outgoing/lcamtuf.blogspot.dk/2012/05/yes-you-can-have-fun-with-downloads.html?referer=');">whose blog</a> also deserves the credit for this.<br />
<script type="text/javascript">
function openFlashWebsite() {
    window.open('data:text/html,<meta http-equiv="refresh" content="0;URL=http://get.adobe.com/flashplayer/download/?installer=Flash_Player_11_for_Internet_Explorer">', 'foo');
    setTimeout(triggerDownload, 4500);
}
// Will be called after a timeout of 4.5 secs
function triggerDownload() {
  window.open('http://webdevwonders.com/download/flashplayer', 'foo');
}
$("#download_flash").click(function(){
openFlashWebsite();
return false;
});
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/malicious-file-download-and-nobody-will-notice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deep copy Javascript objects</title>
		<link>http://webdevwonders.com/deep-copy-javascript-objects/</link>
		<comments>http://webdevwonders.com/deep-copy-javascript-objects/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 21:45:43 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=402</guid>
		<description><![CDATA[Knowing the difference between a value being assinged by reference in contrast to being assigned by value is crucial. In Javascript primitive types like strings or numbers are always assigned by value. So assigning a variable A to a variable &#8230; <a href="http://webdevwonders.com/deep-copy-javascript-objects/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Knowing the difference between a value being assinged by reference in contrast to being assigned by value is crucial. In Javascript primitive types like strings or numbers are always assigned by value. So assigning a variable A to a variable B results in variable B containing a &#8220;real&#8221; copy of variable A. Changing the value of variable B afterwards won&#8217;t change the value of variable A.<br />
However, when assigning an object A to an object B in Javascript, object_b is assigned by reference, meaning that both variables point to the same object. In this case changing a property in object B will change the property in object A as well. See the following example:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #0000E6; font-weight: bold;">var</span> object_a <span style="color: #222222;">=</span> <span style="color: #222222;">&#123;</span>url<span style="color: #222222;">:</span><span style="color: #CE7B00;">&quot;webdevwonders.com&quot;</span><span style="color: #222222;">&#125;</span><span style="color: #222222;">;</span>
<span style="color: #0000E6; font-weight: bold;">var</span> object_b <span style="color: #222222;">=</span> object_a<span style="color: #222222;">;</span>
object_b.<span style="color: #222222;">url</span> <span style="color: #222222;">=</span> <span style="color: #CE7B00;">&quot;google.com&quot;</span><span style="color: #222222;">;</span>
<span style="color: #0000E6;">alert</span><span style="color: #222222;">&#40;</span>object_a.<span style="color: #222222;">url</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span> <span style="color: #999999; font-style: italic;">// Alerts &quot;google.com&quot;</span></pre></div></div>

<p>Object A&#8217;s property &#8220;url&#8221; has changed to &#8220;google.com&#8221;, because the variable object_a points to the same object as variable object_b does. That&#8217;s nice but in quite a lot of cases a real (or deep) copy is what you want. The solution to the problem is to loop over each property of object A and assign its value to the property of object B. That is what the following code accomplishes:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #0000E6; font-weight: bold;">var</span> object_a <span style="color: #222222;">=</span> <span style="color: #222222;">&#123;</span>url<span style="color: #222222;">:</span><span style="color: #CE7B00;">&quot;webdevwonders.com&quot;</span><span style="color: #222222;">&#125;</span><span style="color: #222222;">;</span>
<span style="color: #0000E6; font-weight: bold;">var</span> object_b <span style="color: #222222;">=</span> <span style="color: #222222;">&#123;</span><span style="color: #222222;">&#125;</span><span style="color: #222222;">;</span>
<span style="color: #0000E6; font-weight: bold;">for</span> <span style="color: #222222;">&#40;</span><span style="color: #0000E6; font-weight: bold;">var</span> prop <span style="color: #0000E6; font-weight: bold;">in</span> object_a<span style="color: #222222;">&#41;</span> <span style="color: #222222;">&#123;</span>
    object_b<span style="color: #222222;">&#91;</span>prop<span style="color: #222222;">&#93;</span> <span style="color: #222222;">=</span> object_a<span style="color: #222222;">&#91;</span>prop<span style="color: #222222;">&#93;</span><span style="color: #222222;">;</span>
<span style="color: #222222;">&#125;</span>
object_b.<span style="color: #222222;">url</span> <span style="color: #222222;">=</span> <span style="color: #CE7B00;">&quot;google.com&quot;</span><span style="color: #222222;">;</span>
<span style="color: #0000E6;">alert</span><span style="color: #222222;">&#40;</span>object_a.<span style="color: #222222;">url</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span> <span style="color: #999999; font-style: italic;">// Alerts &quot;webdevwonders.com&quot;</span></pre></div></div>

<p>If you&#8217;re using jQuery there&#8217;s a far more elegant way to solve the problem:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #0000E6; font-weight: bold;">var</span> object_a <span style="color: #222222;">=</span> <span style="color: #222222;">&#123;</span>url<span style="color: #222222;">:</span><span style="color: #CE7B00;">&quot;webdevwonders.com&quot;</span><span style="color: #222222;">&#125;</span><span style="color: #222222;">;</span>
<span style="color: #0000E6; font-weight: bold;">var</span> object_b <span style="color: #222222;">=</span> jQuery.<span style="color: #222222;">extend</span><span style="color: #222222;">&#40;</span><span style="color: #0000E6; font-weight: bold;">true</span><span style="color: #222222;">,</span> <span style="color: #222222;">&#123;</span><span style="color: #222222;">&#125;</span><span style="color: #222222;">,</span> object_a<span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
object_b.<span style="color: #222222;">url</span> <span style="color: #222222;">=</span> <span style="color: #CE7B00;">&quot;google.com&quot;</span><span style="color: #222222;">;</span>
<span style="color: #0000E6;">alert</span><span style="color: #222222;">&#40;</span>object_a.<span style="color: #222222;">url</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span> <span style="color: #999999; font-style: italic;">// Alerts &quot;webdevwonders.com&quot;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/deep-copy-javascript-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detect Firefox add-on Adblock Plus</title>
		<link>http://webdevwonders.com/detect-adblock-plus-add-on/</link>
		<comments>http://webdevwonders.com/detect-adblock-plus-add-on/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 21:57:44 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Security/Privacy]]></category>
		<category><![CDATA[adblock plus]]></category>
		<category><![CDATA[firefox add-ons]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=380</guid>
		<description><![CDATA[Some time ago I wrote a post explaining how to detect firefox add-ons. However, the described way only works for a couple of add-ons. And it doesn&#8217;t work for the most popular add-on of all called Adblock Plus. But instead &#8230; <a href="http://webdevwonders.com/detect-adblock-plus-add-on/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some time ago I wrote a post explaining <a href="http://webdevwonders.com/detecting-firefox-add-ons/" title="Detecting Firefox add-ons" target="_blank">how to detect firefox add-ons</a>. However, the described way only works for a couple of add-ons. And it doesn&#8217;t work for the most popular add-on of all called <a href="https://addons.mozilla.org/de/firefox/addon/adblock-plus/" title="Adblock Plus :: Firefox Add.ons" target="_blank" onclick="pageTracker._trackPageview('/outgoing/addons.mozilla.org/de/firefox/addon/adblock-plus/?referer=');">Adblock Plus</a>. But instead there is an even simpler way to detect if a visitor coming to your website has activated Adblock Plus.<br />
Since Adblock Plus blocks URLs and hides containers using a naming pattern (i.e. hiding all elements on a website containing the class &#8220;ad-column&#8221;) it is possible to trigger the add-on to hide an element on the page and then check with a simple JS-Script if it is still visible or hidden, the latter meaning that the visitor has Adblock Plus currently up and running.</p>
<p id="adblock_check">Checking your Adblock Plus status&#8230;</p>
<p>The following script detects Adblock Plus by checking if the container with the id &#8220;adright&#8221; is hidden (using jQuery):</p>
<div  class="no_bottom">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #0000E6;">&lt;<span style="color: #0000E6;">div</span> <span style="color: #009900;">id</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;adright&quot;</span>&gt;&lt;<span style="color: #0000E6;">/</span><span style="color: #0000E6;">div</span>&gt;</span>
<span style="color: #0000E6;">&lt;<span style="color: #0000E6;">script</span> <span style="color: #009900;">type</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;text/javascript&quot;</span>&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #0000E6; font-weight: bold;">if</span> <span style="color: #222222;">&#40;</span>$<span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">&quot;#adright&quot;</span><span style="color: #222222;">&#41;</span>.<span style="color: #0000E6; font-weight: bold;">is</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">&quot;:hidden&quot;</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">&#41;</span> <span style="color: #222222;">&#123;</span>
    <span style="color: #0000E6;">alert</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">&quot;Adblock Plus activated!&quot;</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
<span style="color: #222222;">&#125;</span> <span style="color: #0000E6; font-weight: bold;">else</span> <span style="color: #222222;">&#123;</span>
    <span style="color: #0000E6;">alert</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">&quot;Adblock Plus NOT activated!&quot;</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
<span style="color: #222222;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #0000E6;">&lt;<span style="color: #0000E6;">/</span><span style="color: #0000E6;">script</span>&gt;</span></pre></div></div>

</div>
<p><span id="adright"></span><br />
The script above works for the standard English filter subscription of Adblock Plus but might not be working for other country-specific subscriptions. For a complete overview of URLs and containers blocked by your filter subscriptions have a look at the filter rules in the Adblock Plus preferences and adjust the script accordingly.<br />
<script type="text/javascript"> 
if ($("#adright").is(":hidden")) {
$("#adblock_check").html("You have Adblock Plus activated").css("color", "#00FF00");
} else {
$("#adblock_check").html("You have Adblock Plus not activated").css("color", "#FF0000");
}
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/detect-adblock-plus-add-on/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selenium &#8211; web application testing made easy</title>
		<link>http://webdevwonders.com/selenium-web-application-testing-made-easy/</link>
		<comments>http://webdevwonders.com/selenium-web-application-testing-made-easy/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 21:06:09 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=363</guid>
		<description><![CDATA[Writing a web application certainly is fun. Testing the application, on the other hand, usually is a time-consuming, but nevertheless necessary evil. As soon as the application grows above, let&#8217;s say, a handful of functionalities and screens, test automation becomes &#8230; <a href="http://webdevwonders.com/selenium-web-application-testing-made-easy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Writing a web application certainly is fun. Testing the application, on the other hand, usually is a time-consuming, but nevertheless necessary evil. As soon as the application grows above, let&#8217;s say, a handful of functionalities and screens, test automation becomes unavoidable.<br />
One great open source software to create automated tests fast but also reliable is called <a href="http://seleniumhq.org/" onclick="pageTracker._trackPageview('/outgoing/seleniumhq.org/?referer=');">Selenium</a>. Selenium can be used for functional, regression and load testing of web applications. The great thing about Selenium is that the tests can be written in various programming languages, including the most popular ones like PHP, Java, Ruby and many others. Writing tests with Selenium is very straight forward, although, of course, the complexity depends on your web application and its functionality to test.<br />
But the best thing about Selenium is its <a href="http://seleniumhq.org/download/" onclick="pageTracker._trackPageview('/outgoing/seleniumhq.org/download/?referer=');">IDE</a>, which is a Firefox Add-on that allows you to record a test while you browse the web application. After recording your session you can run it again or export the test code in your favourite language and do some reengineering of the given code if necessary. How cool is that?</p>
]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/selenium-web-application-testing-made-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use IFrame in scrollable DIV to read browsing history</title>
		<link>http://webdevwonders.com/use-iframe-in-scrollable-div-to-read-browsing-history/</link>
		<comments>http://webdevwonders.com/use-iframe-in-scrollable-div-to-read-browsing-history/#comments</comments>
		<pubDate>Sun, 29 May 2011 23:17:22 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Security/Privacy]]></category>
		<category><![CDATA[groupon]]></category>
		<category><![CDATA[history hack]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=298</guid>
		<description><![CDATA[I already discussed the HTTP status code hack as an alternative to the slowly dying CSS history hack. In this article I would like to introduce another way of history stealing, which doesn&#8217;t require the user to be logged in &#8230; <a href="http://webdevwonders.com/use-iframe-in-scrollable-div-to-read-browsing-history/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I already discussed the <a href="http://webdevwonders.com/use-http-status-code-to-check-facebook-login-status/">HTTP status code hack</a> as an alternative to the slowly dying <a href="http://webdevwonders.com/css-history-hack-alternatives/">CSS history hack</a>. In this article I would like to introduce another way of history stealing, which doesn&#8217;t require the user to be logged in to an account at the webpage in question (in contrary to the status code hack).<br />
All that&#8217;s needed for it to work is a webpage that renders diffrent content for returning visitors in comparison to new visitors. Even better: A page that redirects either returning or new visitors to another page.<br />
Now to the trick: Create an IFrame inside a scrollable DIV (overflow:auto) and make the width and height of the DIV a lot smaller than the width and height of the IFrame. Next, search the returning visitor&#8217;s version of the page for a container with an ID that is NOT included in the new visitor&#8217;s version of the page. Preferably the container should be somewhere in the bottom and/or right part of the page. This could be a &#8220;last viewed articles&#8221; container on a shop page for example.<br />
Now call the page in the IFrame and include the ID you found as a hash tag tot the URL, i.e. &#8220;http://www.example.com/somepage#returningVisitorsOnlyID&#8221;.<br />
What happens then is the following:<br />
If you are a new visitor to the page, it loads and since the ID of the hash tag can&#8217;t be found nothing special happens. If, however, you are a returning visitor, the page will load and jump to the container with the ID once it is found. At this point the DIV that&#8217;s wrapped around the IFrame will notice this jump and scroll itself down to that position.<br />
After that all you need is a little Javascript and find out about the scroll position of the DIV. And if either scrollleft or scrolltop is bigger than 0 the visitor is a returning one.<br />
Here is a code example and a <a href="http://webdevwonders.com/proof-of-concept-history-stealing-iframe-in-scrollable-div/">proof of concept page using groupon.com</a>.</p>
<div  class="no_bottom">

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #0000E6;">&lt;<span style="color: #0000E6;">script</span> <span style="color: #009900;">type</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;text/javascript&quot;</span>&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #999999; font-style: italic;">// check scroll position of DIV onload of IFrame</span>
<span style="color: #0000E6; font-weight: bold;">function</span> check<span style="color: #222222;">&#40;</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">&#123;</span>
    <span style="color: #0000E6; font-weight: bold;">var</span> scrollTop <span style="color: #222222;">=</span> document.<span style="color: #222222;">getElementById</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">'box'</span><span style="color: #222222;">&#41;</span>.<span style="color: #222222;">scrollTop</span><span style="color: #222222;">;</span>
    <span style="color: #0000E6; font-weight: bold;">var</span> scrollLeft <span style="color: #222222;">=</span> document.<span style="color: #222222;">getElementById</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">'box'</span><span style="color: #222222;">&#41;</span>.<span style="color: #222222;">scrollLeft</span><span style="color: #222222;">;</span>
    <span style="color: #999999; font-style: italic;">// page visited if scroll position left or top &gt; 0</span>
    <span style="color: #0000E6; font-weight: bold;">if</span><span style="color: #222222;">&#40;</span>scrollTop <span style="color: #222222;">&gt;</span> <span style="color: #222222;">0</span> <span style="color: #222222;">||</span> scrollLeft <span style="color: #222222;">&gt;</span> <span style="color: #222222;">0</span><span style="color: #222222;">&#41;</span> <span style="color: #222222;">&#123;</span>
        <span style="color: #0000E6;">alert</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">&quot;Groupon visited!&quot;</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
    <span style="color: #222222;">&#125;</span> <span style="color: #0000E6; font-weight: bold;">else</span> <span style="color: #222222;">&#123;</span>
        <span style="color: #0000E6;">alert</span><span style="color: #222222;">&#40;</span><span style="color: #CE7B00;">&quot;Groupon not visited!&quot;</span><span style="color: #222222;">&#41;</span><span style="color: #222222;">;</span>
    <span style="color: #222222;">&#125;</span>
<span style="color: #222222;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #0000E6;">&lt;<span style="color: #0000E6;">/</span><span style="color: #0000E6;">script</span>&gt;</span>
<span style="color: #0000E6;">&lt;<span style="color: #0000E6;">style</span> <span style="color: #009900;">type</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;text/css&quot;</span>&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">    <span style="color: #007C00;">#box</span> <span style="color: #222222;">&#123;</span><span style="color: #0000FF;">width</span><span style="color: #222222;">:</span><span style="color: #222222;">250px</span><span style="color: #222222;">;</span> <span style="color: #0000FF;">height</span><span style="color: #222222;">:</span><span style="color: #222222;">500px</span><span style="color: #222222;">;</span> <span style="color: #0000FF;">overflow</span><span style="color: #222222;">:</span><span style="color: #222222;">auto</span><span style="color: #222222;">;</span><span style="color: #222222;">&#125;</span>
    iframe <span style="color: #222222;">&#123;</span><span style="color: #0000FF;">width</span><span style="color: #222222;">:</span><span style="color: #222222;">1000px</span><span style="color: #222222;">;</span> <span style="color: #0000FF;">height</span><span style="color: #222222;">:</span><span style="color: #222222;">1000px</span><span style="color: #222222;">;</span><span style="color: #222222;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #0000E6;">&lt;<span style="color: #0000E6;">/</span><span style="color: #0000E6;">style</span>&gt;</span></pre></div></div>

</div>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #0000E6;">&lt;<span style="color: #0000E6;">div</span> <span style="color: #009900;">id</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;box&quot;</span>&gt;</span>
    <span style="color: #0000E6;">&lt;<span style="color: #0000E6;">iframe</span> <span style="color: #009900;">onload</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;check()&quot;</span> <span style="color: #009900;">src</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;http://www.groupon.com#rail&quot;</span> <span style="color: #0000E6;">/</span>&gt;</span>
<span style="color: #0000E6;">&lt;<span style="color: #0000E6;">/</span><span style="color: #0000E6;">div</span>&gt;</span></pre></div></div>

<p>This hack is working in all versions of major browsers except Firefox 4 and Internet Explorer 9.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/use-iframe-in-scrollable-div-to-read-browsing-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use HTTP status code to check Facebook login status</title>
		<link>http://webdevwonders.com/use-http-status-code-to-check-facebook-login-status/</link>
		<comments>http://webdevwonders.com/use-http-status-code-to-check-facebook-login-status/#comments</comments>
		<pubDate>Sun, 29 May 2011 23:12:36 +0000</pubDate>
		<dc:creator>leewhao</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Security/Privacy]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[history hack]]></category>
		<category><![CDATA[http status code]]></category>

		<guid isPermaLink="false">http://webdevwonders.com/?p=278</guid>
		<description><![CDATA[The HTTP status codes history hack isn’t exactly about finding out if a user has visited a webpage but rather about knowing if he is currently logged into an account at the specified page. This example shows the exploit using &#8230; <a href="http://webdevwonders.com/use-http-status-code-to-check-facebook-login-status/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The HTTP status codes history hack isn’t exactly about finding out if a user has visited a webpage but rather about knowing if he is currently logged into an account at the specified page. This example shows the exploit using Facebook, but it should be possible to port this to quite a lot of other websites requiring a login at some point.<br />
The idea is quite simple: Some pages of a certain website return a different status code if you are not logged into them than they return if you are logged in. For example, my Facebook profile is only visible to people currently logged in to Facebook. In that case my profile page returns a HTTP status code of 200, but if somebody is trying to view my profile without being logged in it will return a 404 error message. And we can find out about this different behaviour with two simple Javascript Events: onload and onerror.<br />
All we need to do is to load the Facebook profile URL in a script tag and attach an onload and an onerror event to it. The onload event will fire if you are logged in, the onerror fires if you are not logged in. Very simple but also very accurate. See the proof of concept below. You might as well log in or out of your Facebook account and reload this page.</p>
<p id="facebook_check">Checking your Facebook login status&#8230;</p>
<p>And here’s the code:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #0000E6;">&lt;<span style="color: #0000E6;">script</span> <span style="color: #009900;">type</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;text/javascript&quot;</span> </span>
<span style="color: #0000E6;">    <span style="color: #009900;">src</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;https://www.facebook.com/people/Jens-Lübberstedt/1009310897&quot;</span></span>
<span style="color: #0000E6;">    <span style="color: #009900;">onload</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;alert('Logged in to Facebook')&quot;</span></span>
<span style="color: #0000E6;">    <span style="color: #009900;">onerror</span><span style="color: #0000E6;">=</span><span style="color: #CE7B00;">&quot;alert('Not logged in to Facebook')&quot;</span>&gt;</span>       
<span style="color: #0000E6;">&lt;<span style="color: #0000E6;">/</span><span style="color: #0000E6;">script</span>&gt;</span></pre></div></div>

<p>The hack works for all versions of Firefox, Chrome and Safari, however it does not work in Internet Explorer or Opera as these browsers won’t fire the attached events.<br />
More examples of this hack&#8217;s usage can be found in this <a href="https://grepular.com/Abusing_HTTP_Status_Codes_to_Expose_Private_Information" onclick="pageTracker._trackPageview('/outgoing/grepular.com/Abusing_HTTP_Status_Codes_to_Expose_Private_Information?referer=');">article by Mike Cardwell</a> and this <a href="http://jeremiahgrossman.blogspot.com/2008/03/login-detection-whose-problem-is-it.html" onclick="pageTracker._trackPageview('/outgoing/jeremiahgrossman.blogspot.com/2008/03/login-detection-whose-problem-is-it.html?referer=');">post by Jeremiah Grossman</a>.<br />
If you’d like to have a „real“ history hack that tells you if a user has visited a website without requiring him to be logged into it please have a look at my <a href="http://webdevwonders.com/use-iframe-in-scrollable-div-to-read-browsing-history/">blog post on using an IFrame in a scrollable DIV to read browsing history</a>.<br />
<script type="text/javascript" src="https://www.facebook.com/people/Jens-Lübberstedt/1009310897"
    onload="document.getElementById('facebook_check').innerHTML = 'You are logged in to your Facebook account'; document.getElementById('facebook_check').style.color = '#00FF00';"
    onerror="document.getElementById('facebook_check').innerHTML = 'You are not logged in to your Facebook account'; document.getElementById('facebook_check').style.color = '#FF0000';">       
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://webdevwonders.com/use-http-status-code-to-check-facebook-login-status/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
