Location: PHPKode > projects > Php-Logging-System > phplogsys-1.1.4/includes/squid.php
<?php
//------------------------------------------------------------------------
// See if the MERGESQUIDTABLE is configured and available
//------------------------------------------------------------------------
$mergelogtable = FALSE;
if(defined('MERGESQUIDTABLE') && MERGESQUIDTABLE) {
	if(table_exists(MERGESQUIDTABLE, $dbLink)) {
		$mergelogtable = TRUE;
	}
}

// Get list of log tables
$logTableArray = get_logtables($dbLink, DEFAULTSQUIDTABLE);

//------------------------------------------------------------------------
// Print the top of the form and the table SELECTion if there are multiple
// log tables.
//------------------------------------------------------------------------
$table = get_input('table');
if($table && !validate_input($table, 'table')) {
	echo 'The table has the wrong format.<p>';
	require_once(BASE_PATH . 'includes/html_footer.php');
	exit;
}

?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="GET" name="results" target="_blank">
<table class="pagecontent">
<tr><td><table>
		<tr><td>
<?php
if(count($logTableArray) > 1) { // && !$table) {
	$selected = '';
	if (!$table) {
		$table = DEFAULTSQUIDTABLE;
		$selected = 'selected';
	}
?>
				<table class="searchform">
				<tr class="lighter">
					<td><b>SELECT TABLE:</b>
						<SELECT name="table" id="table">
<?php
	echo "<OPTION $selected>", DEFAULTSQUIDTABLE, '</OPTION>';
	if($mergelogtable) {
		echo '<OPTION>', MERGESQUIDTABLE, '</OPTION>';
	}
	rsort($logTableArray);
	foreach($logTableArray as $value) {
		if($value != DEFAULTSQUIDTABLE && $value != MERGESQUIDTABLE) {
			echo '<OPTION>', htmlentities($value), '</OPTION>';
		}
	}
?>
						</SELECT>
					</td>
				</tr>
				</table>
<?php
} else {
	if(!$table) {
		$table = DEFAULTSQUIDTABLE;
	}
	echo '<table class="searchform"><tr class="lighter"><td><b>USING TABLE: ', $table, '</b></td></tr></table>';
	echo '<input type="hidden" name="table" value="', $table, '">';
}

$sourcearray = array();
$useragentarray = array();
$mimetypearray = array();

// What table to use to fill in the HOST and FACILITY fields?
if($mergelogtable) {
	// $useTable = MERGESQUIDTABLE;
	$useTable = USETABLE;
} elseif($table) {
	$useTable = $table;
} else {
	$useTable = DEFAULTSQUIDTABLE;
}

//------------------------------------------------------------------------
// Use cache?
//------------------------------------------------------------------------
if(USE_CACHE && table_exists(CACHETABLENAME, $dbLink)) {
	// Get the timestamp for the last update.
	$sql = 'SELECT updatetime FROM ' . CACHETABLENAME . ' LIMIT 1';
	$queryresult = perform_query($sql, $dbLink);
	$row = fetch_array($queryresult);
	$cacheUpdate = $row['updatetime'];

	// Print info about the cache.
	echo '<table class="searchform"><tr class="lighter"><td><b>USING CACHE TO POPULATE SOURCE, USER AGENT, AND MIMETYPE FIELDS.</b><br />Cache last updated on ', $cacheUpdate, '.</td></tr></table>';

	// Get the SOURCE list
	$sql = 'SELECT DISTINCT value FROM ' . CACHETABLENAME . ' WHERE type=\'SOURCE\'';
	$queryresult = perform_query($sql, $dbLink);
	while ($line = fetch_array($queryresult)) {
		array_push($sourcearray, '<option>' . $line['value'] . '</option>');
	}
	sort($sourcearray);

	// Get the USERAGENT list
	$sql = 'SELECT DISTINCT value FROM ' . CACHETABLENAME . ' WHERE type=\'USERAGENT\'';
	$queryresult = perform_query($sql, $dbLink);
	while ($line = fetch_array($queryresult)) {
		array_push($useragentarray, '<option>' . $line['value'] . '</option>');
	}
	sort($useragentarray);

	// Get the MIMETYPE list
	$sql = 'SELECT DISTINCT value FROM ' . CACHETABLENAME . ' WHERE type=\'MIMETYPE\'';
	$queryresult = perform_query($sql, $dbLink);
	while ($line = fetch_array($queryresult)) {
		array_push($mimetypearray, '<option>' . $line['value'] . '</option>');
	}
	sort($mimetypearray);
} else {
	//------------------------------------------------------------------------
	// If no cache then get possible values for facility and host from table.
	//------------------------------------------------------------------------
	$sql = 'SELECT DISTINCT source FROM ' . $useTable;
	$queryresult = perform_query($sql, $dbLink);
	while ($line = fetch_array($queryresult)) {
		array_push($sourcearray, '<option>' . $line['source'] . '</option>');
	}
	sort($sourcearray);

	$sql = 'SELECT DISTINCT useragent FROM ' . $useTable;
	$queryresult = perform_query($sql, $dbLink);
	while ($line = fetch_array($queryresult)) {
		array_push($useragentarray, '<option>' . $line['useragent'] . '</option>');
	}
	sort($useragentarray);

	$sql = 'SELECT DISTINCT mimetype FROM ' . $useTable;
	$queryresult = perform_query($sql, $dbLink);
	while ($line = fetch_array($queryresult)) {
		array_push($mimetypearray, '<option>' . $line['value'] . '</option>');
	}
	sort($mimetypearray);
}

//------------------------------------------------------------------------
// Print the rest of the form.
//------------------------------------------------------------------------
?>
		<table class="searchform">
		<tr class="lighter">
			<td><b>REPORT TITLE:</b> <input type=text name="title" id="title" size="75%" /></td>
		</tr>
		</table>
		<table class="searchform">
		<tr class="lighter">
			<?php echo inputgroup('source', 'Source', $sourcearray); ?>
			<?php echo inputgroup('mimetype', 'Mimetype', $mimetypearray); ?>
			<?php echo inputgroup('requestmethod', 'Request Method', array('<OPTION>CONNECT</OPTION>','<OPTION>DELETE</OPTION>','<OPTION>GET</OPTION>','<OPTION>HEAD</OPTION>','<OPTION>OPTIONS</OPTION>','<OPTION>POST</OPTION>','<OPTION>PUT</OPTION>','<OPTION>TRACE</OPTION>'), false, false); ?>
		</tr>
		</table>
		<table class="searchform">
		<tr class="lighter">
			<?php echo ipinputgroup('serverip', 'Server IP'); ?>
			<?php echo inputgroup('useragent', 'User Agent', $useragentarray); ?>
		</tr>
		</table>
		<table class="searchform">
		<tr class="lighter">
			<?php echo dateinputgroup(); ?>
			<td><table align="center" class="formentry">
				<tr><td><b>HILBERT GRAPH TYPE</b></td>
					<td><select name="hilbertgraph" id="hilbertgraph">
							<OPTION>LABEL.DATA.*.*</OPTION>
							<OPTION>OCT1.LABEL.DATA.*</OPTION>
							<OPTION>OCT1.OCT2.LABEL.DATA</OPTION>
						</select>
					</td>
				</tr>
				<tr><td><b>HILBERT GRAPH DATA</b></td>
					<td><select name="hilbertdata" id="hilbertdata">
							<OPTION>Number of Requests</OPTION>
							<OPTION>Sum of Request Sizes</OPTION>
						</select>
					</td>
				</tr>
				</table>
			</td>
			<td><table align="center" class="formentry">
				<tr><td><b>RECORDS PER PAGE</b></td>
					<td><SELECT name="limit" id="limit">
							<OPTION>10</OPTION><OPTION>25</OPTION><OPTION selected>50</OPTION>
							<OPTION>100</OPTION><OPTION>200</OPTION><OPTION>500</OPTION>
							<OPTION>1000</OPTION>
						</SELECT>
					</td>
				</tr>
				<tr><td><b>ORDER BY</b></td>
					<td><SELECT name="orderby" id="orderby">
							<OPTION>mimetype</OPTION>
							<OPTION>replysize</OPTION>
							<OPTION>requestmethod</OPTION>
							<OPTION>requesturl</OPTION>
							<OPTION>responsetime</OPTION>
							<OPTION>seq</OPTION>
							<OPTION>serverip</OPTION>
							<OPTION>source</OPTION>
							<OPTION>squidstatus</OPTION>
							<OPTION selected>timestamp</OPTION>
							<OPTION>useragent</OPTION>
						</SELECT>
					</td>
				</tr>
				<tr><td><b>SEARCH ORDER</b></td>
					<td><SELECT name="order" id="order">
							<OPTION>ASC</OPTION><OPTION selected>DESC</OPTION>
						</SELECT>
					</td>
				</tr>
				</table>
			</td>
		</tr>
		</table>
		<table class="searchform">
		<tr class="lighter">
			<?php echo msginputgroup('Search Request URL'); ?>
		</tr>
		<tr><td><table class="searchform">
				<tr><td class="darker">
						<input type="submit" name="pageId" value="Search Squid">
						<input type="submit" name="pageId" value="Squid IP Map" onMouseover="return overlib('<TABLE border=1 cellspacing=0 cellpadding=0 width=100%><TR><TD class=tooltip>Warning: The ip addresses being graphed will atomatically be set to Include.  It is not recommended to search the graphed ip.</TD></TR></TABLE>');" onMouseout="nd();">
						<input type="submit" name="pageId" value="Squid Bandwidth">
						<input type="submit" name="pageId" value="Squid Daily Bandwidth">
						<input type="reset" value="Reset">
					</td>
				</tr>
				</table>
			</td>
		</tr>
		</table>
	</td>
</tr>
</table>
</form>
<?php
?>
Return current item: Php-Logging-System