listfiles.inc (works)<?php function make_file_list($dir="") { if($dir == "") { $dir = $_SERVER["DOCUMENT_ROOT"]; } $dirAry = scandir($dir); foreach($dirAry as $value) { $fullpath = $dir . DIRECTORY_SEPARATOR . $value; if(is_dir($value)) { //Write list item echo '<li id="'.$fullpath.'" onclick="showInfo(this)" ondblclick="refreshFileList(this)">'; echo '<span onclick="refreshFileList(parent)" class="expandIcon">+</span>'; echo '<img src="media/dir.ico" width="16px" height="16px" alt="Directory"/> '; echo $value; echo '<ul></ul>'; echo "</li>\n"; } elseif(is_file($value)) { //Write list item echo '<li id="'.$fullpath.'" onclick="showInfo(this)" ondblclick="showFile(this)">'; echo '<span class="expandVoid"></span>'; echo '<img src="media/file.ico" width="16px" height="16px" alt="File"/> '; echo $value; echo '<ul></ul>'; echo "</li>\n"; } else { //Write list item echo '<li id="'.$fullpath.'" onclick="showInfo(this)" ondblclick="showFile(this)">'; echo '<span class="expandVoid"></span>'; echo '<img src="media/vlc.ico" width="16px" height="16px" alt="Other"/> '; echo $value; echo '<ul></ul>'; echo "</li>\n"; } } } make_file_list($_POST["dir"]);?>
showfile.inc (doesn't work) (I changed the post value from "dir" to "file_name").
<?php //Extension lists $txtExts = '.css,.cgi,.htm,.html,.js,.log,.php,.php3,.pl,.shtml,.txt'; $imgExts = '.bmp,.gif,.jpg,.jpeg,.ico,.png,.tiff'; $flashExts = '.swf'; $mediaExts = '.acc,.asf,.avi,.mov,.mp3,.mp4,.qt,.wma,.wmv'; function make_txt_editor() { echo '<form name="txtEditor" action="java script:saveFile();" method="GET">'."\n"; echo '<textarea></textarea>'."\n"; echo '<input type="submit" value="Save Changes"/>'."\n"; echo '</form>'."\n"; } function examine_ext($file_name) { echo "File name: ".$file_name; echo "test"; $extIndex = strpos($file_name, '.'); if($extIndex < 0) { $ext = ''; echo "no extension"; } else { $ext = substring($file_name, $extIndex); echo $ext; } //If there's no extension if($ext == '') { make_txt_editor(); } //If the extension is for a txtx file if(strpos($txtExts, $ext) != -1) { make_txt_editor(); } //If the extension is for an image file if(strpos($imgExts, $ext) != -1) { make_img(); } //If the extension is for a flash file elseif(strpos($flashExts, $ext) != -1) { make_flash_obj(); } //If the extension is for another media file elseif(strpos($mediaExts, $ext) != -1) { make_media_obj(); } //Open in text editor as last ditch effort else { make_txt_editor(); } } examine_ext($_POST["file_name"]);?>
In showfile.inc, the 2 echo statements in examine_ext($file_name) work so I know the function is successfully being called, but no value is displayed for file_name.When the echo statement is outside the function, no value is displayed there either.