|
Posted by Steve on 11/10/06 00:33
ok...gunna reply in order of importance. here's the report you'd call in
your browser...name it whatever you'd like...i'll post most important
required files in subsequent threads. sorry for the text wrapping. ASSUME
MYSQL AS DB!
======================
<?
$pageTitle = 'Site Access';
$fullHeader = false;
$securityEnabled = true;
require_once 'relative.path.php';
require_once $relativePath . 'site.cfg.php';
require_once $site->includeDirectory . 'head.inc.php';
$getReport = isset($_REQUEST['getReport']) ? true : false;
$groupBy = isset($_REQUEST['groupBy']) ? $_REQUEST['breakOut'] :
'PAGE';
if (!is_array($groupBy)){ $groupBy = array($groupBy); }
$fromMonth = $_POST['fromMonth'];
$fromYear = $_POST['fromYear'];
$toMonth = $_POST['toMonth'];
$toYear = $_POST['toYear'];
if ($fromMonth == ''){ $fromMonth = date('n'); }
if ($fromYear == ''){ $fromYear = date('Y'); }
if ($toMonth == ''){ $toMonth = date('n'); }
if ($toYear == ''){ $toYear = date('Y'); }
$fromDate = strtotime($fromMonth . '/01/' . $fromYear );
$toDate = strtotime($toMonth . '/01/' . $toYear );
if ($fromDate > $toDate)
{
$switchDate = $fromDate;
$fromDate = $toDate;
$toDate = $switchDate;
}
$months = array(
'01' => 'January' ,
'02' => 'February' ,
'03' => 'March' ,
'04' => 'April' ,
'05' => 'May' ,
'06' => 'June' ,
'07' => 'July' ,
'08' => 'August' ,
'09' => 'September' ,
'10' => 'October' ,
'11' => 'November' ,
'12' => 'December'
);
$years = array();
$thisYear = date('Y');
for ($i = $thisYear; $i >= ($thisYear - 5); $i--)
{
$years[] = $i;
}
?>
<div class="bullet" style="background:white no-repeat url('<?=
$site->imagesDirectory ?>bullet.jpg');">
<?= $pageTitle ?>
</div>
<hr>
<?
if (!$getReport)
{
?>
<form method="post">
<span class="label">Start</span>
<span>
<select class="value" name="fromMonth" style="width:120px;">
<?
foreach ($months as $month => $name)
{
$selected = $month == $fromMonth ? 'selected' : '';
?>
<option value="<?= $month ?>" <?= $selected ?>><?= $name ?></option>
<?
}
?>
</select>
<select class="value" name="fromYear" style="width:75px;">
<?
foreach (array_values($years) as $year)
{
$selected = $year == $fromYear ? 'selected' : '';
?>
<option value="<?= $year ?>" <?= $selected ?>><?= $year ?></option>
<?
}
?>
</select>
</span>
<br>
<span class="label">End</span>
<span>
<select class="value" name="toMonth" style="width:120px;">
<?
foreach ($months as $month => $name)
{
$selected = $month == $toMonth ? 'selected' : '';
?>
<option value="<?= $month ?>" <?= $selected ?>><?= $name ?></option>
<?
}
?>
</select>
<select class="value" name="toYear" style="width:75px;">
<?
foreach (array_values($years) as $year)
{
$selected = $year == $toYear ? 'selected' : '';
?>
<option value="<?= $year ?>" <?= $selected ?>><?= $year ?></option>
<?
}
?>
</select>
</span>
<br>
<br>
<input type="submit" value="Run Report">
<input type="hidden" name="getReport" value="1">
</form>
<?
echo $sessionFooter;
exit;
}
// report output
require_once $site->classDirectory . 'report.class.php';
$groups = db::describe('siteTracking');
$groups = array('STAMP', 'PAGE');
$sql = "
SELECT Id ,
Page ,
IpAddress ,
UserName ,
DATE_FORMAT(Stamp, '%c-%e-%Y') Stamp
FROM siteTracking
ORDER BY " . implode (', ', $groups) . "
";
$records = db::execute($sql);
$columns = array(
'PAGE' ,
'IPADDRESS' ,
'USERNAME' ,
'STAMP'
);
$title = '';
switch ($groupBy[0])
{
case 'PAGE' : $title = 'Page Visited';
case 'IPADDRESS' : $title = 'Ip Address';
case 'USERNAME' : $title = 'User Name';
case 'STAMP' : $title = 'Date Visited';
}
$title = $pageTitle . ' - ' . $title;
$reportColumns[] = new reportColumn('PAGE');
$reportColumns[] = new reportColumn(
'IPADDRESS' ,
'IP Address'
);
$reportColumns[] = new reportColumn(
'USERNAME' ,
'User Name'
);
$reportColumns[] = new reportColumn(
'STAMP' ,
'Date Of Visit' ,
'date'
);
$reportSummaries[] = new reportSummary(
'PAGE' ,
new reportFormula(
'[PAGE]' ,
'PAGE' ,
'COUNT'
)
);
$report = new report(
$title ,
$records ,
$reportColumns ,
$groups ,
$reportColumns ,
$reportSummaries
);
echo $report->toHTML();
echo $sessionFooter;
?>
Navigation:
[Reply to this message]
|