<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>
<rss version="2.0" xml:base="http://randomfoo.net/code" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>random($code) - Example</title>
 <link>http://randomfoo.net/code/taxonomy/term/29/0</link>
 <description></description>
 <language>en</language>
<item>
 <title>DropCash PHP Output</title>
 <link>http://randomfoo.net/code/node/16</link>
 <description>&lt;p&gt;I started &lt;a href=&quot;http://www.dropcash.com/campaign/lhl/octobernovember_bandwidth/&quot;&gt;my first Dropcash campaign&lt;/a&gt; today. and coded up a large custom &quot;badge&quot; for my campaign with a little bit of PHP glue.&lt;/p&gt;

&lt;p&gt;If you&#039;re using PHP5 you&#039;ll probably want to use &lt;a href=&quot;http://www.zend.com/php5/articles/php5-simplexml.php&quot;&gt;SimpleXML&lt;/a&gt;, which looks totally rockin&#039;, but for us less adventurous shlubs, give &lt;a href=&quot;http://www.sitepoint.com/article/xml-php-pear-xml_serializer&quot;&gt;PEAR::XML_Serializer&lt;/a&gt; an install (you might need to -f for since it&#039;s still &#039;beta&#039;) and check this out:&lt;/p&gt;

&lt;pre&gt;&amp;lt;?php
  // Caching
  $cache = &#039;/tmp/dropcash&#039;;
  $agelimit = 5 * 60; // 5 minutes
  $timestamp = @filemtime($cachefile);
  $age = time() - $timestamp;

  if($age &gt; $agelimit || $_SERVER[&#039;QUERY_STRING&#039;] == &#039;update&#039;) {
    $f = fopen($cache, &#039;w&#039;);
    fwrite($f, file_get_contents(&#039;http://www.dropcash.com/campaign/[user]/[campaign_name]/xml&#039;));
  }

  $xml = file_get_contents($cache);

  require_once &#039;XML/Unserializer.php&#039;;
  $u = &amp;new XML_Unserializer();
  $u-&gt;unserialize($xml);
  $dc = $u-&gt;getUnserializedData();

  $percent = $dc[&#039;percentage&#039;];
  $percentpx = floor($percent * 4); // 400px bar
  $goal =  $dc[&#039;goal&#039;];
  $collected = $dc[&#039;total_collected&#039;];
?&amp;gt;&lt;/pre&gt;

&lt;p&gt;This will probably make more sense w/ the rest of the badge code since it&#039;s a bit style-based (for the percentpx).&lt;/p&gt;</description>
 <comments>http://randomfoo.net/code/node/16#comment</comments>
 <category domain="http://randomfoo.net/code/taxonomy/term/29">Example</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/21">Major</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/38">PHP</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/12">random($foo)</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/34">Web</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/5">Public Domain</category>
 <enclosure url="http://randomfoo.net/code/files/dropcash.php.txt" length="3883" type="text/plain" />
 <pubDate>Fri, 22 Oct 2004 22:27:14 -0700</pubDate>
 <dc:creator>lhl</dc:creator>
 <guid isPermaLink="false">16 at http://randomfoo.net/code</guid>
</item>
<item>
 <title>Self-Updating Web Software</title>
 <link>http://randomfoo.net/code/node/13</link>
 <description>&lt;p&gt;Anil announced the &lt;a href=&quot;http://www.sixapart.com/pronet/2004/10/movable_type_31_2.html&quot;&gt;recent release of MT 3.12&lt;/a&gt;, which has, among other things, &lt;q&gt;automatic generation of .htaccess files for dynamic pages&lt;/q&gt;.&lt;/p&gt;

&lt;p&gt;One of the great things about Drupal is its integrated URL handling, so that&#039;s definitely part of the way to go.  Apache, or &#039;full system&#039; integration is certainly a big step for web software to take.  Of course, there are those pesky permissions problems and securities risks...&lt;/p&gt;

&lt;p&gt;Here&#039;s a little bit I wrote a while back for a file that&#039;s in a public folder listing (labeled &#039;!!!_donotclick_youwillbebanned.foo&#039; and w/ a robots.txt Deny rule) to block aggressive spiders:&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://randomfoo.net/code/node/13&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://randomfoo.net/code/node/13#comment</comments>
 <category domain="http://randomfoo.net/code/taxonomy/term/24">Brainfart</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/29">Example</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/38">PHP</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/28">Related</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/45">TODO</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/34">Web</category>
 <pubDate>Wed, 20 Oct 2004 09:15:10 -0700</pubDate>
 <dc:creator>lhl</dc:creator>
 <guid isPermaLink="false">13 at http://randomfoo.net/code</guid>
</item>
<item>
 <title>Weighted Round-Robin Redirection</title>
 <link>http://randomfoo.net/code/node/7</link>
 <description>&lt;p&gt;Here&#039;s a quick and dirty way to do weighted round-robin redirection.  I assign the key rather than the entire array for weighted array creation so it&#039;s not the &lt;em&gt;most&lt;/em&gt; inefficient way to do it ever (a more efficient way is to call &lt;code&gt;rand(1,100)&lt;/code&gt; and then have a big switch, but it&#039;s a PITA to shuffle, especially as you add more sites).&lt;/p&gt;

&lt;p&gt;Anyway, the following example shows 50% of the traffic going to url-3, 37.5% to url-2, and 12.5% to url-1:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://randomfoo.net/code/node/7&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://randomfoo.net/code/node/7#comment</comments>
 <category domain="http://randomfoo.net/code/taxonomy/term/29">Example</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/12">random($foo)</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/33">Redirection</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/5">Public Domain</category>
 <pubDate>Mon, 18 Oct 2004 02:15:40 -0700</pubDate>
 <dc:creator>lhl</dc:creator>
 <guid isPermaLink="false">7 at http://randomfoo.net/code</guid>
</item>
</channel>
</rss>
