$x = [$y]

"); } function init() { global $items; global $xml; global $step; global $to; global $from; $xml=simplexml_load_file($items); $step=$to=100; $from=0; } function one($str) { global $xml; $tmp=$xml->xpath($str); return $tmp[0]; } function items() { $i=0; $odd=0; global $n; global $toc; global $some; global $xml; $toc=""; global $key; if ($n > 1) { echo("

(print *". ucwords($key) . "*)

"); } foreach ($some as $one) { $i=$i+1; $seeAlso="This is a "; $sep=""; $cats= $xml->xpath("/rss/channel/item[id='$one->id']/category"); foreach ($cats as $key1=>$val) { $seeAlso .="$sep ". ucwords($val) . ""; $sep=" | "; } printf("


"); if ($n > 1) { printf("
"); } printf("%s

\n" . "

%s page, written %s.

" . "%s\n" . "\n", $one->id, $one->title, $seeAlso, $one->pubdate, $one->description ); $odd = 1 - $odd; if ($n > 1) { $toc .= "
  • $one->title
  • "; } } if ($n==0) { echo<<Oops.. nothing found.

    Please try another URL or use the search box.

    Tip: It can take 1 to 3 weeks for the Google spiders to find new content at this site. If you think what you seek has been added recently, try our XML-based search:

    http://menzies.us/csx72/search.php?someWord

    EOF; } echo(""); } function toc() { global $all; global $from; global $key; global $step; global $to; global $toc; echo("
    "); echo(" 

    " . one("/rss/channel/title") ."

    "); echo( "". one("/rss/channel/description") ); echo( one("/rss/channel/navigation")); echo << EOFF; $prefix = $suffix = ""; if($from > 0) { $from0= $from - $step ; $from0 = ($from0 < 0) ? 0 : $from0; $to0=$from - 1; $to0 = ($to0 < 0) ? 0 : $to0; $prefix="Previous: $from0 .. $to0 "; } if ($to < (sizeof($all) - 1 )) { $from1=$to + 1 ; $to1 = $to + $step ; $from1 = ($from1 >= (sizeof($all) - 1)) ? sizeof($all) - 1 : $from1; $to1 = ($to1 >= (sizeof($all) - 1)) ? sizeof($all) - 1 : $to1; $suffix="Next: $from1 .. $to1"; } echo("
      $toc
    " ); echo("
    " . one("/rss/channel/copyright") . "
    " ); echo("
    "); } function head($title) { //global $title; echo << THEEND; echo(one("/rss/channel/shortTitle") . " » " . $title ); echo <<<THEEND
    THEEND; } function footer() { echo <<
    THEEND; echo("
    "); } function commandLine() { global $key; global $from; global $to; global $query0; global $query1; global $query; global $title; $query0="/rss/channel/item"; $query1=$sep=""; foreach( $_GET as $x=>$y ) { $key=$x; if (is_numeric($key)) { $query1= "id='$key'"; break; } if (empty($y) && (y != 0) ) { $query1 .= $sep . "category='$key'"; $sep=" and "; } else { switch ($key) { case "to": $to = $y+0; break; case "from": $from = $y+0; break; } } } if (empty($query1)) { $query1 = "category='$key'"; } $query = $query0 . "[". $query1 . "]" ; $title = (is_numeric($key) ? one("/rss/channel/item[id='$key']/title") : ucwords($key)); } function fromto($a,$from,$to) { if ($from < 0) { $from=0; } if ($to > sizeof($a)) { $to=sizeof($a); } if ($from > $to) { return fromto($a,$to,$from); } $b=array(); for($i=$from;$i<$to;$i++) { array_push($b,$a[$i]); } return $b; } function rankOf($a,$key) { $out=1000; if(sizeof($a->category) == 1) { $out = $a->category["rank"]+0; } else { $max=sizeof($a->category); for($i=0;$i<=$max;$i++) { if (strcmp($a->category[$i],$key) == 0) { $out= $a->category[$i]["rank"]+0; break; } } } return $out+0; } function cmp_rank_then_date($a, $b) { global $key; $arank=rankOf($a,$key); $brank=rankof($b,$key); if ($arank == $brank) { $asecs=$a->pubdate["secs"] + 0; $bsecs=$b->pubdate["secs"] + 0; if ($asecs==$bsecs) { return 0; } return ($asecs < $bsecs ? 1 : - 1); } return ($arank < $brank ? -1 : 1); } function someAlln() { global $all; global $from; global $n; global $query; global $some; global $to; global $xml; $all=$xml->xpath($query); uasort($all,"cmp_rank_then_date"); $some=fromto($all,$from,$to + 1); $n=count($some); } init(); commandLine(); someAlln(); ?>