<?php

$the_path_digest		= "/hsphere/local/home/podarcis/podarcis.nl/news/digest";
$the_url_digest			= "/news/digest/";
$tmpfile			= "/tmp/tmp.txt";

function list_files() {

global $the_path_digest, $SCRIPT_NAME, $lang ;
	
	print "\n<center><h3>Herpdigest News</h3></center><br>";
	print "\n<i>Disclaimer<br>\"HerpDigest is a separate publication than Pod@rcis.  And as 
		separate entities they are not responsible for either's editorial 
		policies, financial aspects or any other aspects. HerpDigest is 
		reprinted here in its entirety as a service of Podarcis with  
		HerpDigest's permission</i>.\"<br><br>";
	$fd = popen ("/bin/ls -t $the_path_digest", "r");
	while (!feof ($fd)) {
                $file = fgets($fd, 4096);
		if ( $file ) {
  		   $link=str_replace("_", " " , $file);
   		  $link=str_replace(".txt", "" , $link);
		   if ( $lang = "ned" ){
			print "\n" . "<li><a href=$SCRIPT_NAME?lang=ned&the_file=" . $file . " >" . $link ."</a><br>";
		    }
		    else {
			print "\n" . "<li><a href=$SCRIPT_NAME?the_file=" . $file . " >" . $link ."</a><br>";
		    }
	   }
	}
}

# --

function print_file($the_file) {

global $the_path_digest,$the_digest_file,  $lang, $txtfile, $tmpfile, $fcontents, $fd, $the_file_type, $tmp, $SCRIPT_NAME;
	
    if ( file_exists ( $the_path_digest . "/" . $the_file)){
	$header=str_replace("_", " " , $the_file);
	$header=str_replace(".txt", "" , $header);
	print "<center><h3>" . $header . "</h3></center>";
     	$fd = fopen ($the_path_digest . "/" . $the_file, "r");
	while (!feof ($fd)) {
    		$line = fgets($fd, 4096);
		if ( $line ){
			print $line;
			print "<br>";
		}
		}
	    fclose ($fd);
	}
    else {
	list_files();
	}
}

# --

############ Start page

print"<html>
<head>
<title>Podarcis hoofdpagina </title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"/stylecss/mainstyle.css\">
</head>
 
<body background=\"/images/Achtergrond.jpg\">";

include("/hsphere/local/home/podarcis/podarcis.nl/include/include.php");

if (  $the_file ) {
   print_file($the_file);
   if ( $lang==ned){
	print "\n" . "<a href=$SCRIPT_NAME?lang=ned >" . "Ga terug" ."</a><br>";
    }
    else {
	print "\n" . "<a href=$SCRIPT_NAME>" . "Go back" ."</a><br>";
    }
}
else {
list_files();
}
print "\n</body>\n</html>";

?>
