<?
header('Content-type: application/xml; charset="utf-8"',true);
   $picdir = "./images";
   $picdir = "./layouts/".$_REQUEST['m'];

   $dirlist = array();

   if ($handle = opendir( $picdir)) {
      $i=0;
      while (false !== ($file = readdir($handle))) {
         if ($file == "." || $file == "..")
         continue;

         if ( substr(strtolower($file),-4) == ".jpg"){
            $base = basename($file,".jpg");
            if ( !file_exists( $picdir."/"."th_".$base.".gif" ) )
               continue;
            $text = file_exists( $picdir."/".$base.".txt" ) ? file_get_contents($picdir."/".$base.".txt") : "-";
            $dirlist[ $i++ ] = array( "base"=>$base, "text"=>$text);
         }
      }
      closedir($handle);
   }

   printf("<picinfo>\n");
   for ( $i = 0 ; $i < count($dirlist) ; $i++ ) {
      printf("<pic>\n");
         printf("<dir>%s</dir>\n", $picdir);
         printf("<base>%s</base>\n", $dirlist[$i]["base"]);
         printf("<text>%s</text>\n", $dirlist[$i]["text"]);
      printf("</pic>\n");
   }

   // end the document and output
   printf("</picinfo>\n");

?>