<?php
//"wrap-functions" which replace non-ASP-core functions with the same names
//when converting to PHP;
function read_file( $filename ) {
$fd = fopen( $filename, "r" );
$contents = fread( $fd, filesize( $filename ) );
//echo ("file contents=" . $contents . "\n");
fclose( $fd );
return $contents;
}
function write_file( $filename,$text_body ) {
$fd = fopen( $filename, "w" );
$contents = fwrite( $fd, $text_body);
//echo ("written into file " . $filename ." the following text: \r\n<br>" . $text_body);
fclose( $fd );
return "";
}
//=======================================================
//returns list of files in the folder
//referenced by relative path
//
//input: folderspec - relative path
//output: returns: showfilelist - list of files surrounded
// "with" vbcrlf
//-------------------------------------------------------
function vir_showfilelist($folderspec){
$target_dir = $folderspec; //echo "<br>listing drectory '$target_dir'<br>";
$dir_handle = dir($target_dir); //echo "Handle: ".$dir_handle->handle."<br>\n";
$dirpath = $dir_handle->path; //echo "Path: ".$dirpath."<br>\n";
$s="\r\n"; //will store listing in $s
while($entry=$dir_handle->read()) { //echo "<a href=\"$dirpath/$entry\">$entry</a><br>\n";
$s=$s . "\r\n" . $entry;
}
$dir_handle->close();
$s=$s . "\r\n";
return $s;
}
function vir_showfilelinks($folderspec){
$target_dir = $folderspec; //echo "<br>listing drectory '$target_dir'<br>";
$dir_handle = dir($target_dir); //echo "Handle: ".$dir_handle->handle."<br>\n";
$dirpath = $dir_handle->path; //echo "Path: ".$dirpath."<br>\n";
$s="\r\n"; //will store listing in $s
while($entry=$dir_handle->read()) { //echo "<a href=\"$dirpath/$entry\">$entry</a><br>\n";
$s=$s . "\r\n" . "<a href=\"$entry\">$entry</a>";
}
$dir_handle->close();
$s=$s . "\r\n";
return $s;
}
?>