Location: PHPKode > projects > DataDivisions > includes/funcDisplayDir.php
<?
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# DataDivisions, Build 1.0, 12/11/2003                                      #
# FileName: funcDisplayDir.php                                              #
# File Description:                                                         #
#   Provides functions for directory and file coursing displays (back-end,  #
#   middle and front-end functionality)                                     #
#   NOTE: NOT IMPLEMENTED AS OF BUILD 1.0 - THEREFORE NOT POLISHED SCRIPTS  #
#   Functions Included In This File:                                        #
#     dirNamesInSite() [dirStruct_dirNamesInSite()]                         #
#     filesInDir() [dirStruct_dirFilesInDir()]                              #
#     dirsBySize() [dirStruct_dirsBySize()]                                 #
#     dirsAsNextLevel() [dirStruct_dirsAsNextLevel()]                       #
#     fileNames() [dirStruct_fileNames()]                                   #
#     mostCommonFileNames() [dirStruct_mostCommonFileNames()]               #
#     filesByFileType() [dirStruct_filesByFileType()]                       #
#     filesByFileSize() [dirStruct_filesByFileSize()]                       #
#     imageNames() [dirStruct_imageNames()]                                 #
#     imageSizes() [dirStruct_imageSizes()]                                 #
#     textBasedFiles() [dirStruct_textBasedFiles()]                         #
#     scriptFiles() [dirStruct_scriptFiles()]                               #
#                                                                           #
# +-----------------------------------------------------------------------+ #
# | DataDivisions - Website Statistic Visualization Software              | #
# | Copyright (c) 2003, Brian Willison                                    | #
# +-----------------------------------------------------------------------+ #
# | The contents of this file are subject to the GNU General Public       | #
# | License version 2 (June 1991). This file and all its contents (incl.  | #
# | functions, methods, etc.) are free for general use within any         | #
# | community. This software is distributed with the intent to allow      | #
# | developers the opportunity to copy, manipulate and revamp this        | #
# | application in part or whole for best use cases.                      | #
# |                                                                       | #
# | This software is distributed "AS-IS" with no warranties of any kind   | #
# | either expressed or implied.                                          | #
# |                                                                       | #
# | Please refer to the GPL license document for more information:        | #
# | (_docs/gplLicense.pdf)                                                | #
# +-----------------------------------------------------------------------+ #
# | Developer, Designer, Initial Creator:                                 | #
# | Brian Willison (hide@address.com)                       | #
# +-----------------------------------------------------------------------+ #
# | Initial Download Reference:                                           | #
# | http://datadivisions.sourceforge.net                                  | #
# +-----------------------------------------------------------------------+ #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

require_once(funcDisplayCommonFile);

// Function: Directory Coursing For dirNamesInSite() - refNum = 033
$return_dirNamesInSite = "";
function dirStruct_dirNamesInSite($pathIncoming) {
global $return_dirNamesInSite;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != "..") {
			if (@is_dir($pathIncoming."/".$file)) {
				$return_dirNamesInSite .= $pathIncoming."/".$file.",";
				dirStruct_dirNamesInSite($pathIncoming."/".$file);	// grab ALL directories and files
			}
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_dirNamesInSite);
	return $rawDataArray;
}
// Function: Directory Names In Site - refNum = 033
function dirNamesInSite($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "List Of Directories In Website";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Directories In Site",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_dirNamesInSite(baseRootPath);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For filesInDir() - refNum = 034
$return_filesInDir = "";
function dirStruct_filesInDir($pathIncoming) {
global $return_filesInDir;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != "..") {
			$ext = explode(".",$file);
			if (@$ext[1]) {
				$return_filesInDir .= $pathIncoming."/".$file.",";
			}
			dirStruct_filesInDir($pathIncoming."/".$file);	// grab ALL directories and files
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_filesInDir);
	return $rawDataArray;
}
// Function: Files In Directories - refNum = 034
function filesInDir($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "List Of Files In Website Directories";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Files By Directory",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_filesInDir(baseRootPath);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For dirsBySize() - refNum = 035
$return_dirsBySize = "";
function dirStruct_dirsBySize($pathIncoming) {
global $return_dirsAsNextLevel;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != "..") {
			if (@is_dir($pathIncoming."/".$file)) {
				$return_dirsAsNextLevel .= $pathIncoming."/".$file.",";
				dirStruct_dirsBySize($pathIncoming."/".$file);	// grab ALL directories and files
			}
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_dirsAsNextLevel);
	return $rawDataArray;
}
// Function: Directories By Size - refNum = 035
function dirsBySize($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "Website Directories x Total Size";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Directories By Total Size",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_dirsBySize(baseRootPath);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For dirsAsNextLevel() - refNum = 036
$return_dirsAsNextLevel = "";
function dirStruct_dirsAsNextLevel($pathIncoming) {
global $return_dirsAsNextLevel;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != "..") {
			if (@is_dir($pathIncoming."/".$file)) {
				$return_dirsAsNextLevel .= $pathIncoming."/".$file.",";
				dirStruct_dirsAsNextLevel($pathIncoming."/".$file);	// grab ALL directories and files
			}
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_dirsAsNextLevel);
	return $rawDataArray;
}
// Function: Directories As Next Level - refNum = 036
function dirsAsNextLevel($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "Directory Hierarchy Structure";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Directory Hierarchy",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_dirsAsNextLevel(baseRootPath);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For fileNames() - refNum = 037
$return_fileNames = "";
function dirStruct_fileNames($pathIncoming) {
global $return_fileNames;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != ".." && !ereg(".ht",$file)) {
			$ext = explode(".",$file);
			if (@$ext[1]) {
				$return_fileNames .= $file.",";				// add just file name
			}
			dirStruct_fileNames($pathIncoming."/".$file);	// grab ALL directories and files
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_fileNames);
	return $rawDataArray;
}
// Function: File Names - refNum = 037
function fileNames($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "List Of File Names In Website";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Files Names In Site",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_fileNames(baseRootPath);
	sort($htmlReturnArray);
	reset($htmlReturnArray);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For mostCommonFileNames() - refNum = 038
$return_mostCommonFileNames = "";
function dirStruct_mostCommonFileNames($pathIncoming) {
global $return_mostCommonFileNames;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != "..") {
			$ext = explode(".",$file);
			if (@$ext[1]) {
				$return_mostCommonFileNames .= $pathIncoming."/".$file.",";
			}
			dirStruct_mostCommonFileNames($pathIncoming."/".$file);	// grab ALL directories and files
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_mostCommonFileNames);
	return $rawDataArray;
}
// Function: Most Common File Names - refNum = 038
function mostCommonFileNames($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "List Of Most Common Files Names In Website";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Most Common File Names In Site",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_mostCommonFileNames(baseRootPath);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For filesByFileType() - refNum = 039
$return_filesByFileType = "";
function dirStruct_filesByFileType($pathIncoming) {
global $return_filesByFileType;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != "..") {
			$ext = explode(".",$file);
			if (@$ext[1]) {
				$return_filesByFileType .= $pathIncoming."/".$file.",";
			}
			dirStruct_filesByFileType($pathIncoming."/".$file);	// grab ALL directories and files
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_filesByFileType);
	return $rawDataArray;
}
// Function: Files By File Type - refNum = 039
function filesByFileType($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "List Of Files In Website By File Type";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Files By File Type",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_filesByFileType(baseRootPath);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For filesByFileSize() - refNum = 040
$return_filesByFileSize = "";
function dirStruct_filesByFileSize($pathIncoming) {
global $return_filesByFileSize;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != "..") {
			$ext = explode(".",$file);
			if (@$ext[1]) {
				$return_filesByFileSize .= $pathIncoming."/".$file.",";
			}
			dirStruct_filesByFileSize($pathIncoming."/".$file);	// grab ALL directories and files
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_filesByFileSize);
	return $rawDataArray;
}
// Function: Files By File Size - refNum = 040
function filesByFileSize($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "Website Files x Individual File Size";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Files By File Size",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_filesByFileSize(baseRootPath);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For imageNames() - refNum = 041
$return_imageNames = "";
function dirStruct_imageNames($pathIncoming) {
global $return_fileNames;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != ".." && !ereg(".ht",$file)) {
			$ext = explode(".",$file);
			if (@$ext[1]) {
				if (@$ext[1] == "jpg" || @$ext[1] == "gif" || @$ext[1] == "png")
					$return_fileNames .= $file.",";					// add just file name
			}
			dirStruct_imageNames($pathIncoming."/".$file);	// grab ALL directories and files
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_fileNames);
	return $rawDataArray;
}
// Function: Image Names - refNum = 041
function imageNames($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "List Of Image File Names In Website";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Image Files By Name",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_imageNames(baseRootPath);
	sort($htmlReturnArray);
	reset($htmlReturnArray);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For imageSizes() - refNum = 042
$return_imageSizes = "";
function dirStruct_imageSizes($pathIncoming) {
global $return_imageSizes;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != "..") {
			$ext = explode(".",$file);
			if (@$ext[1]) {
				$return_imageSizes .= $pathIncoming."/".$file.",";
			}
			dirStruct_imageSizes($pathIncoming."/".$file);	// grab ALL directories and files
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_imageSizes);
	return $rawDataArray;
}
// Function: Image Sizes - refNum = 042
function imageSizes($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "Image Names x Individual File Size";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Image Files By Size",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_imageSizes(baseRootPath);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For textBasedFiles() - refNum = 043
$return_textBasedFiles = "";
function dirStruct_textBasedFiles($pathIncoming) {
global $return_fileNames;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != ".." && !ereg(".ht",$file)) {
			$ext = explode(".",$file);
			if (@$ext[1]) {
				if (@$ext[1] == "txt" || @$ext[1] == "rft")
					$return_fileNames .= $file.",";					// add just file name
			}
			dirStruct_textBasedFiles($pathIncoming."/".$file);	// grab ALL directories and files
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_fileNames);
	return $rawDataArray;
}
// Function: Text-Based Files - refNum = 043
function textBasedFiles($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "List Of Text Files In Website";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Text Files By Name",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_textBasedFiles(baseRootPath);
	sort($htmlReturnArray);
	reset($htmlReturnArray);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}

// Function: Directory Coursing For scriptFiles() - refNum = 044
$return_scriptFiles = "";
function dirStruct_scriptFiles($pathIncoming) {
global $return_fileNames;
	$dir = @opendir($pathIncoming);
	while ($file = @readdir($dir)) {
		if ($file != "." && $file != ".." && !ereg(".ht",$file)) {
			$ext = explode(".",$file);
			if (@$ext[1]) {
				if (@$ext[1] == "cgi" || @$ext[1] == "pl" || @$ext[1] == "php" || @$ext[1] == "sql" || @$ext[1] == "js" || @$ext[1] == "as")
					$return_fileNames .= $file.",";					// add just file name
			}
			dirStruct_scriptFiles($pathIncoming."/".$file);	// grab ALL directories and files
		}
	}
	@closedir($dir);
	$rawDataArray = explode(",",$return_fileNames);
	return $rawDataArray;
}
// Function: Script Files - refNum = 044
function scriptFiles($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "List Of Script Files In Website";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Script Files By Name",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = dirStruct_scriptFiles(baseRootPath);
	sort($htmlReturnArray);
	reset($htmlReturnArray);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawData = $htmlReturnArray[$i];
		$rawData = ereg_replace("".baseRootPath."","",$rawData);
		$dataArrayFull[$rawData] = "";
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}
?>
Return current item: DataDivisions