<?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; php</title>
	<atom:link href="http://dirty-motherfucker.org/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://dirty-motherfucker.org/blog</link>
	<description>All kinds of shit</description>
	<lastBuildDate>Wed, 09 May 2012 12:49:30 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-beta4-20750</generator>
		<item>
		<title>Safely updating TYPO3 extensions</title>
		<link>http://dirty-motherfucker.org/blog/2012/02/22/safely-updating-typo3-extensions/</link>
		<comments>http://dirty-motherfucker.org/blog/2012/02/22/safely-updating-typo3-extensions/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 00:01:26 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[typo3]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[typo3scripts]]></category>

		<guid isPermaLink="false">http://dirty-motherfucker.org/blog/?p=364</guid>
		<description><![CDATA[A difference between the originally installed version and the current was detected! If you have ever read that warning in the TYPO3 extension manager, you know exactly how annoying it can be to find that difference. You made some minor tweak or fix and forgot about it and now you don&#8217;t know what it was [...]]]></description>
			<content:encoded><![CDATA[<p><em>A difference between the originally installed version and the current was detected!</em></p>
<p>If you have ever read that warning in the TYPO3 extension manager, you know exactly how annoying it can be to find that difference.</p>
<p>You made some minor tweak or fix and forgot about it and now you don&#8217;t know what it was and if the updated extension contains the same fix.</p>
<p>Or even worse. You&#8217;re already up to the new extension manager interface where there are neither upload comments nor the warning about local modification. Oh boy, oh boy.</p>
<p>So what can you do? Here&#8217;s what.</p>
<p>To do this, we need 3 scripts from the <a href="http://code.google.com/p/typo3scripts/">typo3scripts</a> script suite.</p>
<ol>
<li>extUpdate.sh</li>
<li>extChangelog.sh</li>
<li>extExtract.php</li>
</ol>
<p>How to install and configure these scripts is explained on their respective wiki pages on the project homepage, so I won&#8217;t repeat that here. Let&#8217;s get right to the interesting parts.</p>
<pre class="brush: bash; title: ; notranslate">$ ./extUpdate.sh
Sourcing script configuration from typo3scripts.conf...Done.
Checking dependencies...Succeeded.
New version of 'direct_mail' available. Installed: 2.6.10 Latest: 2.7.0
New version of 'div2007' available. Installed: 0.7.2 Latest: 0.8.1
New version of 'kb_md5fepw' available. Installed: 0.4.0 Latest: 0.4.1
New version of 'realurl' available. Installed: 1.12.0 Latest: 1.12.1</pre>
<p>First of all, let&#8217;s see the upload comments for those extensions:</p>
<pre class="brush: bash; title: ; notranslate">./extUpdate.sh --changelog
Sourcing script configuration from typo3scripts.conf...Done.
Checking dependencies...Succeeded.
New version of 'direct_mail' available. Installed: 2.6.10 Latest: 2.7.0
2.7.0 (2012-01-30 00:44:37)
 - layout tweaking
 - create draft newsletter and auto sending (e.g. weekly) (thanks to Benni Mack)
 - bug fixes
 please refer to changelog for further info.
 please report any bug or feature or anything in Forge (forge.typo3.org)

New version of 'div2007' available. Installed: 0.7.2 Latest: 0.8.1
0.8.0 (2012-01-23 21:19:28)
 add new classes for email and error message generation
 ready for TYPO3 4.6
0.8.1 (2012-01-28 18:10:45)
 allow the usage of a pibase object instead of class.tx_div2007_alpha_language_base

New version of 'kb_md5fepw' available. Installed: 0.4.0 Latest: 0.4.1
0.4.1 (2010-10-27 21:04:19)
 DEPRECATED: Use &quot;saltedpasswords&quot; and &quot;rsaauth&quot; extensions instead!

New version of 'realurl' available. Installed: 1.12.0 Latest: 1.12.1
1.12.1 (2012-02-17 13:23:27)
 Bug fixes. This is a recommended update to everybody.</pre>
<p>Great! Now we even know that kb_md5fepw is deprecated. The extension manager doesn&#8217;t list deprecated extensions in the update panel as it seems. Oh well, let&#8217;s have a look at those local modifications that keep us from updating our extension.</p>
<pre class="brush: bash; title: ; notranslate">$ ./extExtract.php direct_mail
Sourcing script configuration from typo3scripts.conf...Done.
NOTE: New version available!
Retrieving original extension file for 'direct_mail' 2.6.10...Done.
Extracting file 'direct_mail_2.6.10.t3x'...Done.
$ diff --recursive direct_mail_2.6.10.t3x-extracted/ typo3/typo3conf/ext/direct_mail
diff --recursive direct_mail_2.6.10.t3x-extracted//ext_tables.php typo3/typo3conf/ext/direct_mail/ext_tables.php
100c100
&lt;                       )
---
&gt;                       ),
diff --recursive direct_mail_2.6.10.t3x-extracted//mod2/class.tx_directmail_dmail.php typo3/typo3conf/ext/direct_mail/mod2/class.tx_directmail_dmail.php
421c421
&lt;                       if (t3lib_div::testInt($createMailFrom_UID))    {
---
&gt;                       if (t3lib_div::testInt($createMailFrom_UID) &amp;&amp; $createMailFrom_UID &gt; 0) {
diff --recursive direct_mail_2.6.10.t3x-extracted//mod4/class.tx_directmail_statistics.php typo3/typo3conf/ext/direct_mail/mod4/class.tx_directmail_statistics.php
439c439
&lt;                               ' AND type=0'.
---
&gt;                               ' AND (type=0 OR type=1)'.
diff --recursive direct_mail_2.6.10.t3x-extracted//res/scripts/class.tx_directmail_checkjumpurl.php typo3/typo3conf/ext/direct_mail/res/scripts/class.tx_directmail_checkjumpurl.php
132c132
&lt;                                                       $jumpurl = str_replace('###SYS_TABLE_NAME###', $theTable, $jumpurl);
---
&gt;                                                       $jumpurl = str_replace('###SYS_TABLE_NAME###', substr($theTable, 0, 1), $jumpurl);
</pre>
<p>Well, I don&#8217;t know what those changes do (actually, I totally do), but I better make sure I put them back after the update.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2012/02/22/safely-updating-typo3-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing SDML</title>
		<link>http://dirty-motherfucker.org/blog/2010/09/15/introducing-sdml/</link>
		<comments>http://dirty-motherfucker.org/blog/2010/09/15/introducing-sdml/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 19:50:35 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sdml]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=316</guid>
		<description><![CDATA[On the server-backend of a project I am currently working on, I was also faced with the task of installation and setup procedures for said backend software. It&#8217;s a PHP application with a MySQL database behind it. I was looking for a simple solution to have a PHP script that would set up the database [...]]]></description>
			<content:encoded><![CDATA[<p>On the server-backend of a project I am currently working on, I was also faced with the task of installation and setup procedures for said backend software. It&#8217;s a PHP application with a MySQL database behind it.</p>
<p>I was looking for a simple solution to have a PHP script that would set up the database for me. Using SQL export/import files is just a pain in the ass. They&#8217;re just quite verbose. So usually I would construct the database in a GUI and then export the .sql file and later re-import it. One positive aspect of this was, that the .sql file could be put under version control.</p>
<p>But I wasn&#8217;t satisfied. So I came up with my own solution to the issue and designed a language with a few keywords and even less parameters, which would allow me to model exactly the database as it was at that point.</p>
<p>SDML is really only intended to be used with InnoDB tables (because of the way foreign key constraints are used) and it always defaults to UTF8 usage. And there is no support for user-defined triggers, function or stored procedures. Given MySQL and PHP, I don&#8217;t like to use functions and SPs in the database anymore. Which is the reason no support is planned in SDML.<br />
However, SDML does automatically create triggers for certain constructs that I use quite often (creating/updating timestamp).</p>
<p>Documentation is quite lacking right now, as, well, I literally just released it. You can find it on this <a href="http://code.google.com/p/sdml/">Google Code</a> site.</p>
<p>TL;DR: I wrote a simple language for fast database prototyping &#8211; <a href="http://code.google.com/p/sdml/">Simple Database Markup Language</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2010/09/15/introducing-sdml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passing SOAP faults from NuSoap to C#</title>
		<link>http://dirty-motherfucker.org/blog/2010/04/27/passing-soap-faults-from-nusoap-to-c/</link>
		<comments>http://dirty-motherfucker.org/blog/2010/04/27/passing-soap-faults-from-nusoap-to-c/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 19:59:06 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[nusoap]]></category>
		<category><![CDATA[soap]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=308</guid>
		<description><![CDATA[I am currently implementing a SOAP interface for a PHP application I am working on. The built-in SOAP support in PHP didn&#8217;t really provide everything I needed (namely WSDL generation), so I went with NuSoap. After a lot of pain trying to get a WSDL out of it, that Visual Studio would consume, and correctly [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently implementing a SOAP interface for a PHP application I am working on. The built-in SOAP support in PHP didn&#8217;t really provide everything I needed (namely WSDL generation), so I went with NuSoap.<br />
After a lot of pain trying to get a WSDL out of it, that Visual Studio would consume, and correctly parse the SOAP messages I return, I came along the next big issue today.<br />
Whenever I tried to pass a fault from the server to my C# application, I would receive a nasty exception:</p>
<blockquote><p>Server returned an invalid SOAP Fault.  Please see InnerException for more details.</p></blockquote>
<p>Ok, so let&#8217;s look at that InnerException:</p>
<blockquote><p>Element &#8216;faultstring&#8217; with namespace name &#8221; was not found. Line 6, position 126.</p></blockquote>
<p>What? No &#8220;faultstring&#8221; element? Impossible!<br />
After double-checking my code for obvious errors and confirming with SoapUI that the &#8220;faultstring&#8221; element was indeed present, I started looking for the source of the issue. First I checked the nusoap_fault source, if there was anything weird in there that might confuse the CLR. But it seemed fine.</p>
<p>So I was sure the problem must be in the .Net libraries. I went on to decompile the binaries that are in use when making SOAP requests (namely System.ServiceModel). The actual issue was in System.ServiceModel.Channels.ReceivedFault.CreateFault11(). That function expects the elements of a SOAP fault&#8217;s body to be in a precise order! If the order is anything else than what it expects, it will throw the exception mentioned above.</p>
<p>I did not take the time to check whether this behavior is actually defined by the SOAP definition (although I highly doubt it). I just went on to extend the NuSoap classes to fix the issue. And here they are:</p>
<p>NuSoapServer.php:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
  require_once( &quot;nusoap/nusoap.php&quot; );

  require_once( dirname( __FILE__ ) . &quot;/NuSoapFault.php&quot; );

  /**
  * Wraps a NuSoap server.
  * This class overrides the fault method of nusoap_server to use a customized version of nusoap_fault.
  */
  class NuSoapServer extends nusoap_server {
    /**
     * Specify a fault to be returned to the client.
     * This also acts as a flag to the server that a fault has occured.
     *
     * @param        string $faultcode
     * @param        string $faultstring
     * @param        string $faultactor
     * @param        string $faultdetail
     * @access   public
     */
    function fault( $faultcode, $faultstring, $faultactor='', $faultdetail='' ) {
      if( $faultdetail == &quot;&quot; &amp;&amp; $this-&gt;debug_flag ) {
        $faultdetail = $this-&gt;getDebug();
      }
      $this-&gt;fault = new NuSoapFault( $faultcode, $faultactor, $faultstring, $faultdetail );
      $this-&gt;fault-&gt;soap_defencoding = $this-&gt;soap_defencoding;
    }

  }
?&gt;
</pre>
<p>NuSoapFault.php:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
  require_once( &quot;nusoap/nusoap.php&quot; );

  /**
  * Wraps a SOAP fault.
  * This class overrides nusoap_fault's serialize() method to fix the order in which it's members are serialized.
  * This is necessary to allow for communication with .Net clients.
  */
  class NuSoapFault extends nusoap_fault {
    /**
     * serialize a fault
     *
     * @return       string  The serialization of the fault instance.
     * @access   public
     */
    function serialize() {
      $ns_string = '';
      foreach( $this-&gt;namespaces as $k =&gt; $v ) {
        $ns_string .= &quot;\n  xmlns:$k=\&quot;$v\&quot;&quot;;
      }
      $return_msg =
        '&lt;?xml version=&quot;1.0&quot; encoding=&quot;' . $this-&gt;soap_defencoding . '&quot;?&gt;' .
        '&lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;' . $ns_string . &quot;&gt;\n&quot; .
          '&lt;SOAP-ENV:Body&gt;' .
            '&lt;SOAP-ENV:Fault&gt;' .
              $this-&gt;serialize_val( $this-&gt;faultcode,   'faultcode'   ) .
              $this-&gt;serialize_val( $this-&gt;faultstring, 'faultstring' ) .
              $this-&gt;serialize_val( $this-&gt;faultactor,  'faultactor'  ) .
              $this-&gt;serialize_val( $this-&gt;faultdetail, 'detail'      ) .
            '&lt;/SOAP-ENV:Fault&gt;' .
          '&lt;/SOAP-ENV:Body&gt;' .
        '&lt;/SOAP-ENV:Envelope&gt;';
      return $return_msg;
    }

  }
?&gt;
</pre>
<p>So now in my actual code I don&#8217;t use nusoap_server anymore, but my own NuSoapServer. And now everything works fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2010/04/27/passing-soap-faults-from-nusoap-to-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building PHP 5.3.0 on Ubuntu 8.04 Server</title>
		<link>http://dirty-motherfucker.org/blog/2009/08/06/building-php-5-3-0-on-ubuntu-8-04-server/</link>
		<comments>http://dirty-motherfucker.org/blog/2009/08/06/building-php-5-3-0-on-ubuntu-8-04-server/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 21:07:37 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[administration]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=274</guid>
		<description><![CDATA[When I wanted to build the latest PHP for a server I found several guides online. Sadly none of them worked right away. So after finally getting it all to work like I wanted to, I decided to quickly write up this guide. I start with a clean Ubuntu 8.04 install. So, first things first: [...]]]></description>
			<content:encoded><![CDATA[<p>When I wanted to build the latest PHP for a server I found several guides online. Sadly none of them worked right away.<br />
So after finally getting it all to work like I wanted to, I decided to quickly write up this guide.</p>
<p>I start with a clean Ubuntu 8.04 install. So, first things first:</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get update
sudo apt-get dist-upgrade
sudo shutdown -r now
</pre>
<p>Now that we&#8217;re up-to-date, let&#8217;s begin:</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get build-dep php5
sudo apt-get install libmcrypt-dev libc-client-dev checkinstall
</pre>
<p>Now we have all the crap to build PHP with. Let&#8217;s get PHP itself:</p>
<pre class="brush: plain; title: ; notranslate">
cd /tmp/
wget http://us3.php.net/get/php-5.3.0.tar.gz/from/this/mirror
tar xvzf php-5.3.0.tar.gz
cd php-5.3.0/
</pre>
<p>Now all that is left is to build PHP&#8230;</p>
<pre class="brush: plain; title: ; notranslate">
./configure --prefix=/usr --with-apxs2=/usr/bin/apxs2 --with-config-file-path=/etc/php5/apache2 --with-config-file-scan-dir=/etc/php5/apache2/conf.d --mandir=/usr/share/man --disable-debug --with-regex=php --disable-rpath --disable-static --with-pic --with-layout=GNU --with-pear=/usr/share/php --enable-calendar --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-bcmath --with-bz2 --enable-ctype --with-db4 --without-gdbm --with-iconv --enable-exif --enable-ftp --with-gettext --enable-mbstring --with-pcre-regex=/usr --enable-shmop --enable-sockets --enable-wddx --with-libxml-dir=/usr --with-zlib --with-kerberos=/usr --with-openssl=/usr --enable-soap --enable-zip --with-exec-dir=/usr/lib/php5/libexec --without-mm --with-curl=shared,/usr --with-zlib-dir=/usr --with-gd=shared,/usr --enable-gd-native-ttf --with-gmp=shared,/usr --with-jpeg-dir=shared,/usr --with-xpm-dir=shared,/usr/X11R6 --with-png-dir=shared,/usr --with-freetype-dir=shared,/usr --with-t1lib=shared,/usr --with-ldap=shared,/usr --with-ldap-sasl=/usr --with-mhash=shared,/usr --with-mysql=shared,/usr --with-mysqli=/usr/bin/mysql_config --with-pspell=shared,/usr --with-unixODBC=shared,/usr --with-xsl=shared,/usr --with-snmp=shared,/usr --with-sqlite=shared,/usr --with-mssql=shared,/usr --with-tidy=shared,/usr --with-xmlrpc=shared --with-pgsql=shared,/usr --enable-gd-native-ttf --enable-dba=shared --with-openssl-dir=shared,/usr --enable-gd-jis-conv --enable-json --with-mcrypt=shared,/usr --enable-pcntl --with-pdo-mysql --with-pdo-odbc=unixODBC,/usr --with-pdo-pgsql=shared,/usr --with-pdo-sqlite --enable-xmlreader --with-tsrm-pthreads --with-imap --with-imap-ssl
</pre>
<p>I&#8217;m sure this doesn&#8217;t enable ALL features in PHP, but it works for me so far. If I&#8217;ll ever find I was missing something, I&#8217;ll be sure to update this post.</p>
<p>When building make sure to pass the correct number of CPUs to make with the -j parameter to safe some time.</p>
<pre class="brush: plain; title: ; notranslate">
make -j2
</pre>
<p>And now we wait&#8230;</p>
<p>Now we need to add these lines to our httpd.conf (which is empty in this case)</p>
<pre class="brush: plain; title: ; notranslate">
#LoadModule directive to aid module installations
#LoadModule dummy_module /usr/lib/apache2/modules/mod_dummy.so
</pre>
<p>Now we can build our .deb for PHP.</p>
<pre class="brush: plain; title: ; notranslate">
sudo checkinstall -D --install=no --fstrans=no --maintainer=your@email --reset-uids=yes --nodoc --pkgname=php5 --pkgversion=5.3 --pkgrelease=200908060830 --arch=amd64
</pre>
<p>And that&#8217;s it. Now you have a .deb which you can install on a different system or (as checkinstall told you) just put on this system with dpkg -i.</p>
<p>Have fun</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2009/08/06/building-php-5-3-0-on-ubuntu-8-04-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flash Player version in AWStats &#8211; Revised</title>
		<link>http://dirty-motherfucker.org/blog/2008/11/20/flash-player-version-in-awstats-revised/</link>
		<comments>http://dirty-motherfucker.org/blog/2008/11/20/flash-player-version-in-awstats-revised/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 10:46:43 +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[javacsript]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=198</guid>
		<description><![CDATA[My first implementation of this idea may have been sufficient for general use. For inclusion in WordPress however it was problematic at best. Now that I have revised (and tested) it, I thought I&#8217;d share this updated WordPress plugin. In this version I put the JavaScript code inline. Although I&#8217;m not a big fan of [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://www.dirty-motherfucker.org/blog/2008/11/12/including-flash-player-version-in-awstats/">first implementation</a> of this idea may have been sufficient for general use. For inclusion in WordPress however it was problematic at best.<br />
Now that I have revised (and tested) it, I thought I&#8217;d share this updated WordPress plugin.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/*
Plugin Name: Flash 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 type=&quot;text/javascript&quot;&gt;
		window.onload = function() {
			var version = deconcept.SWFObjectUtil.getPlayerVersion();
			if( document.getElementById &amp;&amp; version[&quot;major&quot;]&gt; 0 ) {
				var flash_version = version[&quot;major&quot;] +&quot;.&quot;+ version[&quot;minor&quot;] +&quot;.&quot;+ version[&quot;rev&quot;];
				document.getElementById(&quot;flashversion&quot;).innerHTML = &quot;&lt;iframe src=\&quot;' . get_settings(&quot;siteurl&quot;) . '/flash_player_version.php?version=&quot; + flash_version + &quot;\&quot; style=\&quot;display: none;\&quot;&gt;&lt;/iframe&gt;&quot;;
			}
		}
	&lt;/script&gt;
	';
}
?&gt;
</pre>
<p>In this version I put the JavaScript code inline. Although I&#8217;m not a big fan of that, it&#8217;s reasonable in this case and I have all the code in one place. This made it easier to fix the second bug. Which was that the whole concept only worked on the main page. On other pages the browser couldn&#8217;t find the flash_version.php file. Which resulted in nasty 404 errors. Now I can simply put the blogs base path into the JavaScript code and everything is well.</p>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2008/11/20/flash-player-version-in-awstats-revised/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>

