Source of: php3/toparser.php3

<?

//
// TOPARSER 0.1 - Mike Krus  mwkrus@yahoo.com   http://mkrus.free.fr/
//
// You may use this code for whatever purpose as long you keep this message
// and don't blame me if does not work!!
//

// error_reporting(E_ALL);

function themeparser($themeorg$ODBY "upd"$SRTHEMES "0"
                     
$NUMTHEMES "6"$cols 3)
{
    
$hostname $themeorg ".themes.org";
    
$port 80;
    
$uri "/themes.rdf.phtml?odby=$ODBY&sc=desc&srtheme=$SRTHEMES&numthemes=$NUMTHEMES&moderated=off";

    
$header_passed  0;
    
$cache "cache/cache.to." $themeorg $ODBY $SRTHEMES $NUMTHEMES ".txt";

    
$comment "(cached for one hour)";

    
$ctime fileMtime($cache);
    
$ntime Time();
    
$dtime $ntime $ctime;
    
$filedate "No date given";

    
$themecount 0;
    
$linelength 1024;

    
$colwidth 100 $cols;

    if(
$dtime $ntime || $dtime 3600 || fileSize($cache) < 20) {
        
$cfile fopen($cache"w");
        if(!
$cfile) {
            echo (
"Could not create cache file " $cache "\n");
            exit;
        }

        
$fpread fsockopen("$hostname"$port, &$errno, &$errstr);
        if(!
$fpread) {
               echo 
"Error connecting to " $hostname ": " $errstr "<br>\n";
        } else {

            
fputs($fpread"GET " $uri " HTTP/1.0\n");
            
fputs($fpread"User-Agent: PHP TOParser/0.1  mkrus@free.fr\n");
            
fputs($fpread"Host: " $hostname ":80\n");
            
fputs($fpread"Accept: */*\n\n");

            
$str fgets($fpread$linelength);
            if(
strstr($str"404") != "") {
                echo 
"Document <A HREF=\"http://" $hostname $uri"\">http://" $hostname $uri "</A> not found\n";
                
fclose($cfile);
                exit;
            }

            while (!
feof($fpread)) {
                if (
$header_passed == 1) {
                    
$str trim(fgets($fpread$linelength));
                    
                    if(
$str == "") { continue; }

                    if(
strstr($str"<channel>") != "") {

                        
$keepon 1;
                        while(
1) {
                            
$locstr trim(fgets($fpread$linelength));
                            if(
$locstr == "") { continue; }

                            if(
strstr($locstr"<title>") != "") {
                                
$channeltitle strtok($locstr"<>");
                                
$channeltitle strtok("<>");
                                
$channeltitle strtok("<>");
                            } elseif(
strstr($locstr"<link>") != "") {
                                
$channelurl strtok($locstr"<>");
                                
$channelurl strtok("<>");
                                
$channelurl strtok("<>");
                            } elseif(
strstr($locstr"</channel>") != "") {
                                break;
                            }
                        }
                        continue;
                    }

                    if(
strstr($str"<item>") != "") {

                        if(
$themecount $cols == 0) { 
                            
fputs($cfile"<table width=\"100%\" cellpadding=5 cols=$cols><TR valign=top>");
                        }

                        
fputs($cfile"<TH width=\"$colwidth%\"><table cellpadding=0 cellspacing=0 border=0 bgcolor=\"#000000\" width=\"100%\"><tr><td>\n");
                        
fputs($cfile"<table cellpadding=4 cellspacing=1 border=0 width=\"100%\">\n");
                        
fputs($cfile"<tr><td class=\"NBT\" background=\"Images/news_title_background.gif\"><p><font size=\"3\">\n");

                        
$invers "";
                        if(isset(
$vertab)) unset($vertab);

                        while(
1) {

                            
$str trim(fgets($fpread$linelength));

                            if(
$invers != "") {
                                if(
strstr($str"</ver") != "") {
                                    
$invers "";
                                } elseif(
strstr($str"<link>") != "") {
                                    
$tmp strtok($str"<>");
                                    
$tmp strtok("<>");
                                    
$vertab[] = $invers;
                                    
$vertab[] = strtok("<>");
                                } elseif(
strstr($str"</item>") != "") {
                                    break;
                                }
                            } else  {
                                if(
strstr($str"<name>") != "") {
                                    
$name strtok($str"<>");
                                    
$name strtok("<>");
                                    
$name strtok("<>");
                                } elseif(
strstr($str"<updated>") != "") {
                                    
$update strtok($str"<>");
                                    
$update strtok("<>");
                                    
$update strtok("<>");
                                    
$update Date("m/d/y"$update);
                                } elseif(
strstr($str"<id>") != "") {
                                    
$tid strtok($str"<>");
                                    
$tid strtok("<>");
                                    
$tid strtok("<>");
                                } elseif(
strstr($str"<link>") != "") {
                                    
$link strtok($str"<>");
                                    
$link strtok("<>");
                                    
$link strtok("<>");
                                } elseif(
strstr($str"<shot>") != "") {
                                    
$shot strtok($str"<>");
                                    
$shot strtok("<>");
                                    
$shot strtok("<>");
                                } elseif(
strstr($str"<thumb>") != "") {
                                    
$thumb strtok($str"<>");
                                    
$thumb strtok("<>");
                                    
$thumb strtok("<>");
                                } elseif(
strstr($str"<vers>") != "") {
                                    
$vers strtok($str"<>");
                                    
$vers strtok("<>");
                                    
$vers strtok("<>");
                                } elseif(
strstr($str"<ver ") != "") {
                                    
$toto strtok($str" ");
                                    
$toto strtok(" ");
                                    
$invers strtok($toto"<>");
                                } elseif(
strstr($str"</item>") != "") {
                                    break;
                                }
                            }
                        }

                        
fputs($cfile"<A class=\"NBT\" HREF=\"$link\">$name</A>&nbsp;</font></p></td></tr>\n");
                        
fputs($cfile"<TR><TH class=\"NBB\" bgcolor=\"#cccccc\"><A HREF=\"$shot\"><IMG BORDER=0 SRC=\"$thumb\" WIDTH=150 HEIGHT=120 aLT=\"Screen Shot\"></A><BR></TH></TR>\n");

                        
fputs($cfile"<tr><td class=\"NBC\"><table width=\"100%\" cellpadding=0 cellspacing=0 border=0><TR>\n");
                        
fputs($cfile"<td class=\"NBC\"><font size=\"1\">Last update: " $update "</font></td>");
                        
fputs($cfile"<td class=\"NBC\" align=right><font size=\"2\">");

                        if(isset(
$vertab)) {
                            
$i=0$j=0;
                            while(
$i count($vertab)) {
                                
$verkey $vertab[$i];
                                
$verlink $vertab[$i 1];
                                if(
$j 0) { fputs($cfile"|&nbsp"); }
                                
fputs($cfile"<A HREF=\"http://" $hostname "/php/download.phtml?query=download&rev=" $verkey "&server=themes.org&object=" $themeorg ".theme." $tid"\">" $verkey "</A>&nbsp;");
                                
$j++;
                                
$i+=2;
                            }
                        }

                        
fputs($cfile"</font></td></tr></table></td></tr>\n");
                        
fputs($cfile"</table></td></tr></table></TH>\n");

                        if(
$themecount $cols == $cols 1) { 
                            
fputs($cfile"</TR></table>"); 
                        }

                        
$themecount++;
                    }

                } else {
                    
$str ltrim(Chop(fgets($fpread$linelength)));

                    if (
$str == "") {
                        
$header_passed 1;
                    }
                }
            }

            for(
$i $themecount $cols$i $ncols$i++)
                
fputs($cfile"<TD width=\"$colwidth%\">&nbsp;</tD>");
            if(
$themecount $cols) { fputs($cfile"</TR></table>"); }

            
fputs($cfile"<table width=\"100%\" cellpadding=5>");
            
fputs($cfile"<TR><Td><table cellpadding=0 cellspacing=0 border=0 bgcolor=\"#000000\" width=\"100%\"><tr><td>\n");
            
fputs($cfile"<table cellpadding=4 cellspacing=1 border=0 width=\"100%\">\n");
            
$filedate Date("H:i m/d/y");
            
fputs($cfile"<tr><td class=\"NBC\"><p>Last update: " $filedate " GMT");
            
fputs($cfile" -- <A HREF=\"http://" $hostname $uri "\">RDF</A> -- " $themecount " themes\n");

        }
        
fclose($fpread);
        
fclose($cfile);

        
$comment "";

    }

    include 
"$cache"

    echo(
"$comment</TD></TR></table></td></tr></table></td></tr></table>");
    
flush();
}

?>

The syntax highlighted source is automatically generated by PHP from the plaintext script.
If you want to see the source of this page, have a look here.