All pastes #472574 Raw Edit

linecheck [lucas]

public text v1 · immutable
·published 2007-05-05 18:09 UTC
rendered paste body
<?

# Display this header file
#-------------------------
$header = "header.htm";
$footer = "footer.htm";

# Display This Text before the directory list
#--------------------------------------------
$text = "<center><b><h2>Beta Index:</h2></b></center>";

$font = "<font face=Tahoma size=3><b>";
$endfont = "</b></font>";

# Don't edit below here.
#______________________________________________________

#start timing code
#------------------
$t_start = array_sum(explode(' ', microtime()));

# Open header file (if it exsists) and display it.
#-------------------------------------------------
if (file_exists($header)){
	$newfile = fopen($header,"r");
	$content = fread($newfile, filesize($header));
	fclose($newfile);
	print $content;
}

# Print the title
#----------------
print "<p><center>$text<table>\n";

# Read the directory
#-------------------
$dir="./"; 
if (is_dir($dir)) {   
   $fd = @opendir($dir);   
      while (($part = @readdir($fd)) == true) {   
         if ($part != "." && $part != "..") {   
            $file_array[]=$part; 
         }   
      }   
      if ($fd == true) {   
         closedir($fd);   
      } 
   } 
 
# Sort the directory alphabetically
#----------------------------------
sort($file_array); 
reset($file_array); 
for($i=0;$i<count($file_array);$i++) { 
	$npart=$file_array[$i]; 
 	$fsize=filesize($npart); 
 	
 	# Only grab directories - Leave files alone
 	#------------------------------------------
	if (is_dir($npart)) {
		print("<tr><td><a href=\"$npart\">$font$npart$endfont</a></td></tr>\n");
		$z++;  
	} 
} 




# Increment hit counter
#----------------------

$filename = "counter.txt";
if (file_exists($filename)){
	$newfile = fopen($filename,"r");
	$hits = fread($newfile, filesize($filename));
	fclose($newfile);
	$hits ++;

	# Save the new file count
	#------------------------

	$newfile = fopen($filename,"w");
	fwrite($newfile, $hits);
	fclose($newfile);

}
#End of timed code here
#----------------------
$exec_time = array_sum(explode(' ', microtime())) - $t_start;
$exec_time1 = (ceil($exec_time * 10000))/10000;

?>

<tr><td>&nbsp;</td></tr>
<tr><td>
<font size="1" face="Tahoma"><b>Execution time: <? echo $exec_time1; ?> sec.</b></font><br>
<font size="1" face="Tahoma"><b>
Total Directories: <? echo $z; ?><br>
Total Hits: <? echo $hits; ?><br></b></font>
</td>
</tr>
</table>


<?
# Open footer file (if it exsists) and display it.
#-------------------------------------------------
if (file_exists($footer)){
	$newfile = fopen($footer,"r");
	$content = fread($newfile, filesize($footer));
	fclose($newfile);
	print $content;
}
?>