$request_filename\n"; $output_str = "

$request_filename

\n"; } else { // No file was requested, we are retrieving the current directory contents $request_filename = ""; // Output the title, and save a heading and start of a table echo "Files in "". basename($dir) ."" \n"; $output_str = "

Files in "". basename($dir) .""

\n"; $output_str .= "\n"; } ?> PHP JPEG Metadata Toolkit\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 .= "\n"; } else { // A file was requested, but this file was not the correct one // do nothing } } } // Check if it is a text file else if ( ( array_key_exists( "extension", $path_parts ) ) && ( $path_parts["extension"] == "txt" ) ) { // Check that no file was requested if ( $request_filename === "" ) { // No file was requested - add this valid file to the output table $output_str .= "\n"; } else { // Found a text file when looking for a requested PHP file // Do nothing } } else { // This is not a PHP or a TXT file - File not allowed // Do Nothing } } else { // This file is either the current script or the descriptions file - ignore it // Do nothing } } else { // This item is not a file or a directory - ignore it // Do nothing } } // close the directory closedir( $dir_hnd ); if ( $request_filename === "" ) { $output_str .= "
$item/$desc
$item$desc
$item$desc
\n"; } echo $output_str; function get_sourcecode($filename, $first_line_num=1, $num_color="#999") { // Get highlighted code $html_code = highlight_file($filename, TRUE); // Bookmark #1: // Remove the first "" 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