$request_filename\n"; $output_str = "
$item/ | $desc | \n"; } else { // found directory when requesting a file // Do nothing } } else { // Sub Directory doesn't have this script in it - make it invisible // do nothing } } // Check if the current item is a file else if ( is_file ( $item ) ) { // Item is a file // Check that it is not this script, or the descriptions file if ( ( $item != $scriptname ) && ( $item != $descriptions_filename ) ) { // Item is valid file, break it into it's parts $path_parts = pathinfo( $item ); // Check if it is a php file if ( ( array_key_exists( "extension", $path_parts ) ) && ( $path_parts["extension"] == "php" ) ) { // File is a php file - check if it was the one requested if ( $item === $request_filename ) { // This file is the one requested - add it's sourcecode to the output $output_str .= get_sourcecode($item); } else { // This file is not the one requested // Check if any file was requested if ( $request_filename === "" ) { // No file was requested - add the file to the output table $output_str .= "
$item | $desc |
$item | $desc |
" tag from "$html_code" (if any)
if (substr($html_code, 0, 6) == "") {
$html_code = substr($html_code, 6, strlen($html_code));
}
// Replacement-map to replace deprecated "" tag with ""
$xhtml_convmap = array(
' '' => '',
'color="' => 'style="color:'
);
// Replace "" tags with "" tags, to generate a valid XHTML code
$html_code = strtr($html_code, $xhtml_convmap);
### Okay, Now we have a valid XHTML code
### Let's add the line numbers...
$arr_html_code = explode("
", $html_code);
$total_lines = count($arr_html_code);
$retval = "";
$line_counter = 0;
$last_line_num = $first_line_num + $total_lines;
foreach ($arr_html_code as $html_line) {
// Calculate number of current line
$current_line = $first_line_num + $line_counter;
// Append new line to "$retval"
$retval .=
str_repeat(" ", strlen($last_line_num) - strlen($current_line) ) .
"{$current_line}: " .
$html_line .
"
"
;
$line_counter++;
} // end: foreach
$retval = "" . $retval; // Why? remember Bookmark #1, that I removed the tag ""
return $retval;
} // end: get_sourcecode
?>
Copyright (c) 2004 Evan Hunter