コード例 #1
0
ファイル: subscribeModule.php プロジェクト: CMPUT391/c391proj
include "PHPconnectionDB.php";
//establish connection
$conn = connect();
session_start();
if ($_SESSION['status'] != 's') {
    ?>
				Not a valid scientist, Please log in again. 
				<a href = 'LogoutModule.php'>
					<button>Login</button>
				</a>
				<?php 
    return;
}
$pid = $_SESSION['personid'];
echo "<form name='submit1' method='POST' action='subscribeModule.php'>";
$rows = get_sensors($conn);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $submit = $_POST['sensors'];
    $i = 0;
    foreach ($rows as $row) {
        if (!empty($submit) and in_array($row['SENSOR_ID'], $submit)) {
            add_subscription($conn, $row['SENSOR_ID'], $pid);
        } else {
            remove_subscription($conn, $row['SENSOR_ID'], $pid);
        }
        $i++;
    }
    echo "Subscribed to selected sensors. (Total:" . count(get_subscribed_sensors($conn, $pid)) . ")";
}
echo "<table border='1' class='table table-hover'>";
echo "<tr><td>Subscribed</td><td>SENSOR_ID</td><td>LOCATION</td></tr>";
コード例 #2
0
ファイル: api.php プロジェクト: undefx/delphi-epidata
             $epidata = get_cdc($epiweeks, $locations);
             store_result($data, $epidata);
         } else {
             $data['message'] = 'unauthenticated';
         }
     }
 } else {
     if ($source === 'sensors') {
         if (require_all($data, array('auth', 'names', 'locations', 'epiweeks'))) {
             if ($_REQUEST['auth'] === $AUTH['sensors']) {
                 // parse the request
                 $names = extract_values($_REQUEST['names'], 'str');
                 $locations = extract_values($_REQUEST['locations'], 'str');
                 $epiweeks = extract_values($_REQUEST['epiweeks'], 'int');
                 // get the data
                 $epidata = get_sensors($names, $locations, $epiweeks);
                 store_result($data, $epidata);
             } else {
                 $data['message'] = 'unauthenticated';
             }
         }
     } else {
         if ($source === 'nowcast') {
             if (require_all($data, array('locations', 'epiweeks'))) {
                 // parse the request
                 $locations = extract_values($_REQUEST['locations'], 'str');
                 $epiweeks = extract_values($_REQUEST['epiweeks'], 'int');
                 // get the data
                 $epidata = get_nowcast($locations, $epiweeks);
                 store_result($data, $epidata);
             }