forked from kkaiser1952/NCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNCMStats.php
86 lines (77 loc) · 2.64 KB
/
NCMStats.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
// Used by help.php
function convertSecToTime($sec)
{
$date1 = new DateTime("@0");
$date2 = new DateTime("@$sec");
$interval = date_diff($date1, $date2);
$parts = ['years' => 'y', 'months' => 'm', 'days' => 'd', 'hours' => 'h', 'min.' => 'i', 'sec.' => 's'];
$formatted = [];
foreach($parts as $i => $part)
{
$value = $interval->$part;
if ($value !== 0)
{
if ($value == 1){
$i = substr($i, 0, -1);
}
$formatted[] = "$value $i";
}
}
if (count($formatted) == 1)
{
return $formatted[0];
}
else
{
$str = implode(', ', array_slice($formatted, 0, -1));
$str.= ' and ' . $formatted[count($formatted) - 1];
return $str;
}
}
//echo convertSecToTime( 175926108);
require_once "dbConnectDtls.php";
// Logins 10519 newb 559 netCnt 709 allCnt 283940 TOD 838:59:59
$sql = "SELECT COUNT( callsign ) AS callsigns
,COUNT( IF(comments LIKE '%first log in%',1,NULL) ) AS newb
,COUNT( DISTINCT netID ) AS netCnt
,max(recordID) AS records
,SUM(timeonduty) AS TOD
,COUNT( DISTINCT LEFT(grid, 6 )) AS gridCnt
,COUNT( DISTINCT county ) AS countyCnt
,COUNT( DISTINCT state ) AS stateCnt
,COUNT( DISTINCT callsign) AS cscount
,COUNT( DISTINCT netcall) AS netcall
FROM NetLog
WHERE netID <> 0
AND activity NOT LIKE '%TEST%'
";
$stmt = $db_found->prepare($sql);
$stmt -> execute();
$callsigns = $stmt->fetchColumn(0); //echo "\n$callsigns\n";
$stmt -> execute();
$newb = $stmt->fetchColumn(1); //echo "$newb\n";
$stmt -> execute();
$netCnt = $stmt->fetchColumn(2); //echo "$netCnt\n";
$stmt -> execute();
$records = $stmt->fetchColumn(3); //echo "$records\n";
$records = number_format($records,0);
$stmt -> execute();
$tod = $stmt->fetchColumn(4); //echo "$tod\n";
$stmt -> execute();
$gridCnt = $stmt->fetchColumn(5);
$stmt -> execute();
$countyCnt = $stmt->fetchColumn(6);
$stmt -> execute();
$stateCnt = $stmt->fetchColumn(7);
$stmt -> execute();
$cscount = $stmt->fetchColumn(8);
$stmt -> execute();
$netcall = $stmt->fetchColumn(9);
$volHours = convertSecToTime( $tod);
$sql3 = "SELECT count(DISTINCT org) as orgCnt FROM `NetKind`";
$stmt = $db_found->prepare($sql3);
$stmt -> execute();
$orgCnt = $stmt->fetchColumn(0);
// echo "$cscount Stations, $netCnt Nets, $records Logins, $volHours of Volunteer Time";
?>