Location: PHPKode > projects > DataDivisions > includes/funcDisplayError.php
<?
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# DataDivisions, Build 1.0, 12/11/2003                                      #
# FileName: funcDisplayError.php                                            #
# File Description:                                                         #
#   Provides functions for error reporting displays (back-end, middle and   #
#   front-end functionality)                                                #
#   Functions Included In This File:                                        #
#     globalErrorEreg(), errorPagesFileNames(), errorPagesDayOfMonth()      #
#     errorPagesDayOfWeek(), errorPagesHourOfDay()                          #
#                                                                           #
# +-----------------------------------------------------------------------+ #
# | 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);

// Common Ereg For All Error Functions
function globalErrorEreg() {
	$limitCounter = 0;											// initialize limit of lines returned
	$rawDataArray = array();									// initialize return value
	$rawData = file(errorFile);									// open log file and put into array
	foreach ($rawData as $lineNum=>$lineValue) {				// go through each value within log file array
		if ($limitCounter < 1000) {								// read each line until limit
			array_push($rawDataArray,$lineValue);				// add to return value each good line
			$limitCounter++;									// add to limit counter
		} else {												// if over limit
			break;												// end log checking
		}
	}
	return $rawDataArray;										// return string of contents to orig. display function
}

// Function: Error Pages File Names - refNum = 028
function errorPagesFileNames($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "Common Errors Reported (last 1000)";
	$dataArray = array();
	$dataArrayFull = array();
	$htmlReturn = genDisplayHeader($whichPage,"Reoccurring Errors By File Name Tried",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = globalErrorEreg();
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		$rawDataArray = ereg_replace("  "," ",$htmlReturnArray[$i]);
		$rawDataArray = explode(" ",$htmlReturnArray[$i]);
		if (ereg("File",$htmlReturnArray[$i])) {
			$valOne = 12;
			$valTwo = "File does not exist";
		} else {
			$valOne = 12;
			$valTwo = $rawDataArray[6]." ".$rawDataArray[7]." ".$rawDataArray[8]." ".$rawDataArray[9]." ".$rawDataArray[10];
		}
		$dataArrayFull[ereg_replace(baseRootPath,"",$rawDataArray[$valOne])] = $valTwo;
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}
// Function: Error Pages Day Of Month - refNum = 029
function errorPagesDayOfMonth($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "Errors Reported x Day Of Month";
	// Do First For Month And Year Definitions
	$htmlReturnArray = globalErrorEreg();
	// Determine Month And Year From First Line Of Error File
	$monYearDetArray = explode(" ",$htmlReturnArray[0]);
	if ($monYearDetArray[1] == "Jan") $month = "1";
	if ($monYearDetArray[1] == "Feb") $month = "2";
	if ($monYearDetArray[1] == "Mar") $month = "3";
	if ($monYearDetArray[1] == "Apr") $month = "4";
	if ($monYearDetArray[1] == "May") $month = "5";
	if ($monYearDetArray[1] == "Jun") $month = "6";
	if ($monYearDetArray[1] == "Jul") $month = "7";
	if ($monYearDetArray[1] == "Aug") $month = "8";
	if ($monYearDetArray[1] == "Sep") $month = "9";
	if ($monYearDetArray[1] == "Oct") $month = "10";
	if ($monYearDetArray[1] == "Nov") $month = "11";
	if ($monYearDetArray[1] == "Dec") $month = "12";
	$year = ereg_replace("\]","",$monYearDetArray[4]);
	$dataArray = array();
	// Initialize Data Array To Keep Display Consistent (1,2,3...)
	$dataArrayFull = array(
		"$month/1/$year"=>0,"$month/2/$year"=>0,"$month/3/$year"=>0,"$month/4/$year"=>0,"$month/5/$year"=>0,"$month/6/$year"=>0,"$month/7/$year"=>0,"$month/8/$year"=>0,"$month/9/$year"=>0,"$month/10/$year"=>0,
		"$month/11/$year"=>0,"$month/12/$year"=>0,"$month/13/$year"=>0,"$month/14/$year"=>0,"$month/15/$year"=>0,"$month/16/$year"=>0,"$month/17/$year"=>0,"$month/18/$year"=>0,"$month/19/$year"=>0,"$month/20/$year"=>0,
		"$month/21/$year"=>0,"$month/22/$year"=>0,"$month/23/$year"=>0,"$month/24/$year"=>0,"$month/25/$year"=>0,"$month/26/$year"=>0,"$month/27/$year"=>0,"$month/28/$year"=>0,"$month/29/$year"=>0,"$month/30/$year"=>0,"$month/31/$year"=>0
	);
	$htmlReturn = genDisplayHeader($whichPage,"Errors Reported By Day Of Month (last 1000)",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		if (ereg(" 1 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/1/$year"] += 1;
		if (ereg(" 2 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/2/$year"] += 1;
		if (ereg(" 3 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/3/$year"] += 1;
		if (ereg(" 4 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/4/$year"] += 1;
		if (ereg(" 5 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/5/$year"] += 1;
		if (ereg(" 6 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/6/$year"] += 1;
		if (ereg(" 7 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/7/$year"] += 1;
		if (ereg(" 8 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/8/$year"] += 1;
		if (ereg(" 9 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/9/$year"] += 1;
		if (ereg(" 10 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/10/$year"] += 1;
		if (ereg(" 11 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/11/$year"] += 1;
		if (ereg(" 12 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/12/$year"] += 1;
		if (ereg(" 13 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/13/$year"] += 1;
		if (ereg(" 14 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/14/$year"] += 1;
		if (ereg(" 15 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/15/$year"] += 1;
		if (ereg(" 16 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/16/$year"] += 1;
		if (ereg(" 17 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/17/$year"] += 1;
		if (ereg(" 18 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/18/$year"] += 1;
		if (ereg(" 19 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/19/$year"] += 1;
		if (ereg(" 20 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/20/$year"] += 1;
		if (ereg(" 21 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/21/$year"] += 1;
		if (ereg(" 22 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/22/$year"] += 1;
		if (ereg(" 23 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/23/$year"] += 1;
		if (ereg(" 24 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/24/$year"] += 1;
		if (ereg(" 25 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/25/$year"] += 1;
		if (ereg(" 26 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/26/$year"] += 1;
		if (ereg(" 27 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/27/$year"] += 1;
		if (ereg(" 28 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/28/$year"] += 1;
		if (ereg(" 29 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/29/$year"] += 1;
		if (ereg(" 30 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/30/$year"] += 1;
		if (ereg(" 31 ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["$month/31/$year"] += 1;
	}
	// Limit To Show Only Days With Errors Reported
	for ($i=0; $i<sizeof($dataArrayFull); $i++) {
		$dateCheck = $month."/".$i."/".$year;
		if ($dataArrayFull[$dateCheck] != 0)
			$dataArrayFullReturn[$dateCheck] = $dataArrayFull[$dateCheck];
	}
	$dataArrayFullReturn = array_reverse($dataArrayFullReturn);
	$htmlReturn .= startGenHTMLReturn($dataArrayFullReturn,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}
// Function: Error Pages Day Of Week - refNum = 030
function errorPagesDayOfWeek($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "Errors Reported x Day Of Week";
	$dataArray = array();
	// Initialize Data Array To Keep Display Consistent (Monday,Tuesday,Wednesday...)
	$dataArrayFull = array(
		"Monday"=>0,"Tuesday"=>0,"Wednesday"=>0,"Thursday"=>0,"Friday"=>0,"Saturday"=>0,"Sunday"=>0
	);
	$htmlReturn = genDisplayHeader($whichPage,"Errors Reported By Day Of Week (last 1000)",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = globalErrorEreg();
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		if (ereg("Mon ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["Monday"] += 1;
		if (ereg("Tue ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["Tuesday"] += 1;
		if (ereg("Wed ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["Wednesday"] += 1;
		if (ereg("Thu ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["Thursday"] += 1;
		if (ereg("Fri ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["Friday"] += 1;
		if (ereg("Sat ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["Saturday"] += 1;
		if (ereg("Sun ",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["Sunday"] += 1;
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}
// Function: Error Pages Hour Of Day - refNum = 031
function errorPagesHourOfDay($whichPage,$refNum,$displayType,$displayParam,$displayIndivLoc,$limit,$username) {
	$displayDescription = "Errors Reported x Hour Of Day";
	$dataArray = array();
	// Initialize Data Array To Keep Display Consistent (00,01,02...)
	$dataArrayFull = array(
		"12am - 1am"=>0,"1am - 2am"=>0,"2am - 3am"=>0,"3am - 4am"=>0,"4am - 5am"=>0,"5am - 6am"=>0,"6am - 7am"=>0,"7am - 8am"=>0,"8am - 9am"=>0,"9am - 10am"=>0,"10am - 11am"=>0,"11am - 12pm"=>0,
		"12pm - 1pm"=>0,"1pm - 2pm"=>0,"2pm - 3pm"=>0,"3pm - 4pm"=>0,"4pm - 5pm"=>0,"5pm - 6pm"=>0,"6pm - 7pm"=>0,"7pm - 8pm"=>0,"8pm - 9pm"=>0,"9pm - 10pm"=>0,"10pm - 11pm"=>0,"11pm - 12am"=>0
	);
	$htmlReturn = genDisplayHeader($whichPage,"Errors Reported By Hour Of Day (last 1000)",$refNum,$displayType,$displayParam,$displayIndivLoc,$username);
	$htmlReturnArray = globalErrorEreg();
	for ($i=0; $i<sizeof($htmlReturnArray); $i++) {
		if (ereg(" 00:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["12am - 1am"] += 1;
		if (ereg(" 01:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["1am - 2am"] += 1;
		if (ereg(" 02:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["2am - 3am"] += 1;
		if (ereg(" 03:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["3am - 4am"] += 1;
		if (ereg(" 04:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["4am - 5am"] += 1;
		if (ereg(" 05:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["5am - 6am"] += 1;
		if (ereg(" 06:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["6am - 7am"] += 1;
		if (ereg(" 07:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["7am - 8am"] += 1;
		if (ereg(" 08:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["8am - 9am"] += 1;
		if (ereg(" 09:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["9am - 10am"] += 1;
		if (ereg(" 10:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["10am - 11am"] += 1;
		if (ereg(" 11:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["11am - 12pm"] += 1;
		if (ereg(" 12:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["12pm - 1pm"] += 1;
		if (ereg(" 13:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["1pm - 2pm"] += 1;
		if (ereg(" 14:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["2pm - 3pm"] += 1;
		if (ereg(" 15:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["3pm - 4pm"] += 1;
		if (ereg(" 16:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["4pm - 5pm"] += 1;
		if (ereg(" 17:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["5pm - 6pm"] += 1;
		if (ereg(" 18:",parseErrorLogLines($htmlReturnArray[$i]))) $$dataArrayFull["6pm - 7pm"] += 1;
		if (ereg(" 19:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["7pm - 8pm"] += 1;
		if (ereg(" 20:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["8pm - 9pm"] += 1;
		if (ereg(" 21:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["9pm - 10pm"] += 1;
		if (ereg(" 22:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["10pm - 11pm"] += 1;
		if (ereg(" 23:",parseErrorLogLines($htmlReturnArray[$i]))) $dataArrayFull["11pm - 12am"] += 1;
	}
	$htmlReturn .= startGenHTMLReturn($dataArrayFull,$refNum,$displayDescription,$displayType,$displayParam,$limit,$username);
	$htmlReturn .= templateEndHTML;
	return $htmlReturn;
}
?>
Return current item: DataDivisions