<?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>Dirty Motherfucking Blog &#187; javascript</title>
	<atom:link href="http://dirty-motherfucker.org/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://dirty-motherfucker.org/blog</link>
	<description>All kinds of shit</description>
	<lastBuildDate>Wed, 04 Jan 2012 15:38:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19620</generator>
		<item>
		<title>Including Flash Player version in AWStats</title>
		<link>http://dirty-motherfucker.org/blog/2008/11/12/including-flash-player-version-in-awstats/</link>
		<comments>http://dirty-motherfucker.org/blog/2008/11/12/including-flash-player-version-in-awstats/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 11:22:09 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[awstats]]></category>
		<category><![CDATA[flash player]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=178</guid>
		<description><![CDATA[I was interested in what Flash Player version people are using when visiting my site. So i looked around the web for a solution including AWStats. At first i was out of luck until i noticed that AWStats has a discussion forum on sourceforge as well. Someone there came up with a solution which was [...]]]></description>
			<content:encoded><![CDATA[<p>I was interested in what Flash Player version people are using when visiting my site. So i looked around the web for a solution including <a href="http://awstats.sourceforge.net/">AWStats</a>. At first i was out of luck until i noticed that AWStats has a discussion forum on sourceforge as well.<br />
Someone there came up with a <a href="http://sourceforge.net/forum/message.php?msg_id=4711036">solution</a> which was almost perfect for me.</p>
<p>First of all you&#8217;re gonna want to put this in your awstats config file for your site:</p>
<pre class="brush: plain; title: ; notranslate">
ExtraSectionName1=&quot;Flash Player Version&quot;
ExtraSectionCodeFilter1=&quot;200 304&quot;
ExtraSectionCondition1=&quot;URL,\/flash_player_version\.php&quot;
ExtraSectionFirstColumnTitle1=&quot;Version&quot;
ExtraSectionFirstColumnValues1=&quot;QUERY_STRING,version=([^&amp;]+)&quot;
ExtraSectionFirstColumnFormat1=&quot;%s&quot;
ExtraSectionStatTypes1=PL
ExtraSectionAddAverageRow1=0
ExtraSectionAddSumRow1=1
MaxNbOfExtra1=100
MinHitExtra1=1
</pre>
<p>Note that i made some slight adjustments to some strings compared to the original version.<br />
Now you need to add some JavaScript to make appropriate URL requests that AWStats can read from.<br />
Note that this is the original code, not the one i finally ended up with.</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;../swfobject/swfobject.js&quot;&gt;&lt;/script&gt; 

&lt;script type=&quot;text/javascript&quot;&gt;
var version = deconcept.SWFObjectUtil.getPlayerVersion();
if (document.getElementById &amp;&amp; version[&quot;major&quot;] &gt; 0) {
var flash_version = version['major'] +&quot;.&quot;+ version['minor'] +&quot;.&quot;+ version['rev'];
document.getElementById('flashversion').innerHTML = &quot;&lt;iframe src=\&quot;../version.php?version=&quot; + flash_version + &quot;\&quot; style=\&quot;display: none;\&quot;&gt;&lt;/iframe&gt;&quot;;
}
&lt;/script&gt;
</pre>
<p>As i did not want to just jam this into my theme files, i wrote a little WordPress plugin to do the above task.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/*
Plugin Name: Flash Player Version Detection
Plugin URI: http://www.dirty-motherfucker.org/
Description: Detects flash version
Version: 0.1
Author: gencha
Author URI: http://www.dirty-motherfucker.org
*/

$plugin_root = get_settings('siteurl') . '/wp-content/plugins/'.dirname(plugin_basename(__FILE__));

if( preg_match(&quot;/(\/\?feed=|\/feed)/i&quot;,$_SERVER['REQUEST_URI']) ) {
        // RSS Feeds
        // do nothing
} else {
        add_action('wp_head', 'add_head');
}

function add_head() {
	global $plugin_root;
	echo '
        &lt;!-- Flash player version detection --&gt;
        &lt;script src=&quot;' . $plugin_root . '/swfobject.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
        &lt;script src=&quot;' . $plugin_root . '/flash_version.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	';
}
?&gt;
</pre>
<p>I took some small bits from the <a href="http://kimili.com/plugins/kml_flashembed">KML Flash Embed</a> plugin. This will include the appropriate JavaScript files in your blog. Obviously, if you&#8217;re not using WordPress, this is of no use to you. You can just directly include <a href="http://blog.deconcept.com/swfobject/">SWFObject</a> in the head section of your site.</p>
<p>Now the important bit is the JavaScript file that actually performs the URL request which AWStats will later see.</p>
<pre class="brush: jscript; title: ; notranslate">
window.onload = function() {
	var version = deconcept.SWFObjectUtil.getPlayerVersion();
	if( document.getElementById &amp;&amp; version[&quot;major&quot;] &gt; 0 ) {
		var flash_version = version['major'] +&quot;.&quot;+ version['minor'] +&quot;.&quot;+ version['rev'];
		document.getElementById(&quot;flashversion&quot;).innerHTML = &quot;&lt;iframe src=\&quot;../flash_player_version.php?version=&quot; + flash_version + &quot;\&quot; style=\&quot;display: none;\&quot;&gt;&lt;/iframe&gt;&quot;;
	}
}
</pre>
<p>Now the only thing that is left is that you include an empty div tag with the id &#8220;flashversion&#8221; somewhere in your site. Now THIS i did just jam into my theme :P<br />
Although i am sure there is some hook i can use in the WordPress plugin architecture. But i&#8217;m lazy. So there you have it.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2008/11/12/including-flash-player-version-in-awstats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

