~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to status/index.php

  • Committer: Keith Hughitt
  • Date: 2011-04-26 12:54:32 UTC
  • mto: This revision was merged to the branch mainline in revision 567.
  • Revision ID: keith.hughitt@nasa.gov-20110426125432-133gg7328xmzatjf
Created a simple data monitor page to keep track of how up-to-date different datasources are.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html>
 
2
<html lang="en">
 
3
<head>
 
4
    <meta charset="utf-8" />
 
5
    <title>Helioviewer.org - Data Monitor</title>
 
6
    <style type='text/css'>
 
7
        #header {font-size:2em; vertical-align: middle; margin-top: 15px; margin-bottom: 26px;}
 
8
        #headerText {display: inline-block; vertical-align: super; font-family: arial,helvetica,liberation sans,bitstream vera sans,freesans,clean,sans-serif; font-size:1.2em;}
 
9
    </style>
 
10
</head>
 
11
<body>
 
12
    <div id='main' style='width:50%; margin-left:auto; margin-right:auto;'>
 
13
        <div id="header">
 
14
        <img src="../resources/images/logos/hvlogo1s_transparent_logo.png" alt="Helioviewer logo" />
 
15
        <div id='headerText'>The Helioviewer Project - Data Monitor</div>
 
16
    </div>
 
17
 
 
18
    <table style='width:70%;'>
 
19
    <tr style='font-weight:bold;'>
 
20
        <td width='150'>Datasource</td>
 
21
        <td width='200'>Latest Image</td>
 
22
        <td width='50' align='center'>Status</td>
 
23
    </tr>    
 
24
    <?php
 
25
        include_once "../api/src/Database/DbConnection.php";
 
26
        include_once "../api/src/Database/ImgIndex.php";
 
27
        include_once "../api/src/Config.php";
 
28
        
 
29
        $config = new Config("../settings/Config.ini");
 
30
        date_default_timezone_set('UTC');
 
31
        
 
32
        // Current time
 
33
        $now = time();
 
34
        
 
35
        $db = new Database_DbConnection();
 
36
        $imgIndex = new Database_ImgIndex();
 
37
        
 
38
        $datasources = $db->query("SELECT * FROM datasources");
 
39
 
 
40
        // Add an entry to the table for each data source
 
41
        while($ds = mysqli_fetch_assoc($datasources)) {
 
42
            // Get date of most recent image
 
43
            $date = $imgIndex->getNewestImage($ds['id']);
 
44
            
 
45
            $img = "<img src='status_%02d.png' alt='datasource status' />";
 
46
 
 
47
            // Determine status from 1 (out of date) to 4 (recent)
 
48
            $elapsed = $now - strtotime($date);
 
49
            
 
50
            if ($elapsed < 60 * 60) {
 
51
                $img = sprintf($img, 4);
 
52
            } else if ($elapsed < 2 * 60 * 60) {
 
53
                $img = sprintf($img, 3);
 
54
            } else if ($elapsed < 3 * 60 * 60) {
 
55
                $img = sprintf($img, 2);
 
56
            } else {
 
57
                $img = sprintf($img, 1);
 
58
            }
 
59
 
 
60
            printf("<tr><td>%s</td><td>%s</td><td align='center'>%s</td></tr>", 
 
61
                   $ds['name'], $date, $img);
 
62
        }
 
63
    ?>
 
64
    </table>
 
65
    </div>
 
66
</body>
 
67
</html>