18) $stop=date("Ymd", mktime(0,0,0,date("m"), date("d"), date("Y"))); else $stop=date("Ymd",strtotime(date("Y-m-d", mktime(0,0,0,date("m"), date("d"), date("Y")))." -1 day")); } if (!empty($_GET["source"])) $source=$_GET["source"]; else $source="-1"; echo "
\n"; echo "

Flare Alerts Sent

\n"; echo "
\n"; echo "

Display Alerts

\n"; echo "
\n"; echo "

\n"; echo "From: \n"; echo "To:
\n"; include('/home/fact/php_credentials/factweb.php'); $db = new PDO( 'mysql:host='.$host.';dbname=FlareAlerts;charset=utf8mb4', $user, $pass); $query="SELECT fRecepientKey, fRecepientName FROM Recepient ORDER BY fRecepientKey"; $result = $db->query($query)->fetchAll(PDO::FETCH_ASSOC); echo "Recepient \n "; $query="SELECT fSourceKey, fSourceName FROM Sent LEFT JOIN factdata.Source USING(fSourceKey) GROUP BY fSourceKey"; $result = $db->query($query)->fetchAll(PDO::FETCH_ASSOC); echo "Source
\n"; echo "

\n"; // mysql_free_result($result); echo "\n"; echo ""; echo "
\n"; echo "
\n"; if($_SERVER["HTTPS"] != "on") { header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); exit(); } $query="SELECT fSourceName AS 'Source', fSentTime AS 'Sent', CONCAT(fRecepient, ' [', fRecepientKey, ']') AS 'To [key]', fComment AS 'Comment' "; $query.="FROM Sent LEFT JOIN factdata.Source USING (fSourceKey) LEFT JOIN Recepient USING (fRecepientKey) WHERE fSentTime BETWEEN ".$start." AND ".$stop; if ($source != -1) $query.=" AND fSourceKey=".$source; if ($type != -1) $query.=" AND fRecepientKey=".$type; $query.=" ORDER BY fSentTime"; $result = $db->query($query)->fetchAll(PDO::FETCH_ASSOC); echo "

Found ".sizeOf($result)." Alert(s) from ".$start." to ".$stop." ("; if ($source == -1) echo "all sources"; else echo "source key ".$source; echo ", "; if ($type == -1) echo "all recepients"; else echo "recepient key ".$type; echo "):

"; // table with alerts echo "\n"; $first_row = 0; $colnames = ""; foreach($result as $row) { if ($first_row == 0) { $first_row = 1; echo "\n"; $colnames = array_keys($row); foreach($colnames as $colname){ echo "\n"; } echo "\n"; } echo "\n"; foreach ($colnames as $key) { if ($key=="Comment") { if (strpos($row[$key],"ATel") !== false) echo "\n"; else echo "\n"; } else echo "\n"; } echo "\n"; } echo "
".$colname."
".preg_replace("/ATel\ \#(\d{4,5})/", "ATel #$1", $row[$key])."".$row[$key]."".$row[$key]."

\n"; echo "
\n"; echo "
\n"; echo "

Alert Statistics:

"; $query="SELECT fRecepientName AS 'To', Count(*) AS 'count' FROM Sent LEFT JOIN Recepient USING (fRecepientKey) WHERE fSentTime BETWEEN ".$start." AND ".$stop; if ($source != -1) $query.=" AND fSourceKey=".$source; if ($type != -1) $query.=" AND fRecepientKey=".$type; $query.=" GROUP BY fRecepientName ORDER BY count DESC"; echo "\n"; $first_row = 0; $colnames = ""; $result = $db->query($query)->fetchAll(PDO::FETCH_ASSOC); foreach($result as $row) { if ($first_row == 0) { $first_row = 1; echo "\n"; $colnames = array_keys($row); foreach($colnames as $colname){ echo "\n"; } echo "\n"; } echo "\n"; foreach ($colnames as $key) { echo "\n"; } echo "\n"; } echo "
".$colname."
".$row[$key]."
\n"; echo "
\n"; $query="SELECT fSourceName AS 'Source', Count(*) AS 'count' FROM Sent LEFT JOIN factdata.Source USING (fSourceKey) "; $query.="WHERE fSentTime BETWEEN ".$start." AND ".$stop; if ($source != -1) $query.=" AND fSourceKey=".$source; if ($type != -1) $query.=" AND fRecepientKey=".$type; $query.=" GROUP BY fSourceName ORDER BY count DESC"; echo "\n"; $first_row = 0; $colnames = ""; $result = $db->query($query)->fetchAll(PDO::FETCH_ASSOC); foreach($result as $row) { if ($first_row == 0) { $first_row = 1; echo "\n"; $colnames = array_keys($row); foreach($colnames as $colname){ echo "\n"; } echo "\n"; } echo "\n"; foreach ($colnames as $key) { echo "\n"; } echo "\n"; } echo "
".$colname."
".$row[$key]."
\n"; echo "
\n"; $query="SELECT fSourceName AS 'Source', fRecepientName AS 'To', Count(*) AS 'count' FROM Sent "; $query.="LEFT JOIN Recepient USING (fRecepientKey) LEFT JOIN factdata.Source USING (fSourceKey) "; $query.="WHERE fSentTime BETWEEN ".$start." AND ".$stop; if ($source != -1) $query.=" AND fSourceKey=".$source; if ($type != -1) $query.=" AND fRecepientKey=".$type; $query.=" GROUP BY fRecepientName, fSourceName ORDER BY fRecepientName "; echo "\n"; $first_row = 0; $colnames = ""; $result = $db->query($query)->fetchAll(PDO::FETCH_ASSOC); foreach($result as $row) { if ($first_row == 0) { $first_row = 1; echo "\n"; $colnames = array_keys($row); foreach($colnames as $colname){ echo "\n"; } echo "\n"; } echo "\n"; foreach ($colnames as $key) { echo "\n"; } echo "\n"; } echo "
".$colname."
".$row[$key]."
\n"; echo "
\n"; ?>