Ejemplo n.º 1
0
function alert($id)
{
    $ts = time();
    echo "<h3>Time now: " . date("c") . "</h3>";
    if (!file_exists("../m/arm/{$id}")) {
        echo "<p>Your alert was un-armed. No guards were alerted. <a href=mailto:" . getenv("M_EMAIL") . ">Email admin to ask to be ARMED, which sends SMSes out to all responders/guards on duty.</a></p>";
    } else {
        echo "<p>Raising alert to all responders on duty:</p>";
    }
    $alog = "r/{$id}/alert/" . $ts . ".json";
    @mkdir(dirname($alog), 0777, true);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    echo "<ul>";
    $guards = array();
    foreach (glob("../g/r/*.json") as $gj) {
        $g = json_decode(file_get_contents($gj), true);
        // We need both home owner and guard to be armed to get the SMS
        if (file_exists("../m/arm/{$id}") && file_exists("../m/arm/" . $g["ic"])) {
            echo "<li>Alerting " . $g["name"] . " on <a href=\"tel:" . $g["tel"] . "\">" . $g["tel"] . "</a></li>";
            $result = sms(my_number($g["tel"]), "⚠" . $_SESSION["address"] . " tel:" . $_SESSION["tel"] . " " . $_SESSION["name"] . " at " . date("c", $ts));
        } else {
            echo "<li><s>UNARMED: Not alerting " . $g["name"] . " on <a href=\"tel:" . $g["tel"] . "\">" . $g["tel"] . "</a></s></li>";
            unset($result);
        }
        array_push($guards, array("result" => $result, "name" => $g["name"], "ic" => $g["ic"]));
    }
    echo "</ul>";
    curl_close($ch);
    file_put_contents($alog, je(array("ts" => $ts, "guards" => $guards, "raiser" => $_SESSION)));
    if (empty($result)) {
        sesmail($_SESSION["email"], "UNARMED Alert triggered for " . $_SESSION["name"], "Telephone number: " . $_SESSION["tel"] . "\nAlert details: https://h." . getenv('HOST') . "/adisplay/?j=/{$alog}");
    } else {
        sesmail($_SESSION["email"], "ARMED Alert triggered for " . $_SESSION["name"], "Telephone number: " . $_SESSION["tel"] . "\nAlert details: https://h." . getenv('HOST') . "/adisplay/?j=/{$alog}");
    }
    // Now mute until management lift it
    @unlink("../m/arm/{$id}");
}
Ejemplo n.º 2
0
function show_totals($text) {
  global $var, $display, $temps, $counts, $tot_size, $tot_used, $tot_free, $reads, $writes, $errors;
  echo "<tr class='tr_last'>";
  echo "<td><img src='/webGui/images/sum.png' class='icon'>Total</td>";
  echo "<td>$text</td>";
  echo "<td>".($counts>0?my_temp(round($temps/$counts, 1)):'*')."</td>";
  echo "<td>".my_number($reads)."</td>";
  echo "<td>".my_number($writes)."</td>";
  echo "<td>".my_number($errors)."</td>";
  echo "<td></td>";
  if (strstr($text,"Array") && ($var['startMode'] == "Normal")) {
    echo "<td>".my_scale($tot_size*1024, $unit)." $unit</td>";
    switch ($display['text']) {
    case 0:
      $text1 = true; $text2 = true; break;
    case 1: case 2:
      $text1 = false; $text2 = false; break;
    case 10: case 20:
      $text1 = true; $text2 = false; break;
    case 11: case 21:
      $text1 = false; $text2 = true; break;
    }
    if ($text1) {
      echo "<td>".my_scale($tot_used*1024, $unit)." $unit</td>";
    } else {
      $used = $tot_size ? 100 - round(100*$tot_free/$tot_size) : 0;
      echo "<td><div class='usage-disk'><span style='margin:0;width:{$used}%' class='".usage_color($used,false)."'><span>".my_scale($tot_used*1024, $unit)." $unit</span></span></div></td>";
    }
    if ($text2) {
      echo "<td>".my_scale($tot_free*1024, $unit)." $unit</td>";
    } else {
      $free = $tot_size ? round(100*$tot_free/$tot_size) : 0;
      echo "<td><div class='usage-disk'><span style='margin:0;width:{$free}%' class='".usage_color($free,true)."'><span>".my_scale($tot_free*1024, $unit)." $unit</span></span></div></td>";
    }
    echo "<td></td>";
  }
  else
    echo "<td colspan=4></td>";
  echo "</tr>";
}
Ejemplo n.º 3
0
function show_totals($text) {
  global $var, $display, $sum;
  echo "<tr class='tr_last'>";
  echo "<td><img src='/webGui/images/sum.png' class='icon'>Total</td>";
  echo "<td>$text</td>";
  echo "<td>".($sum['count']>0 ? my_temp(round($sum['temp']/$sum['count'],1)) : '*')."</td>";
  echo "<td>".my_number($sum['numReads'])."</td>";
  echo "<td>".my_number($sum['numWrites'])."</td>";
  echo "<td>".my_number($sum['numErrors'])."</td>";
  echo "<td></td>";
  if (strstr($text,'Array') && ($var['startMode']=='Normal')) {
    echo "<td>".my_scale($sum['fsSize']*1024,$unit)." $unit</td>";
    if ($display['text']%10==0) {
      echo "<td>".my_scale($sum['fsUsed']*1024,$unit)." $unit</td>";
    } else {
      $used = $sum['fsSize'] ? 100-round(100*$sum['fsFree']/$sum['fsSize']) : 0;
      echo "<td><div class='usage-disk'><span style='margin:0;width:$used%' class='".usage_color($display,$used,false)."'><span>".my_scale($sum['fsUsed']*1024,$unit)." $unit</span></span></div></td>";
    }
    if ($display['text']<10 ? $display['text']%10==0 : $display['text']%10!=0) {
      echo "<td>".my_scale($sum['fsFree']*1024,$unit)." $unit</td>";
    } else {
      $free = $sum['fsSize'] ? round(100*$sum['fsFree']/$sum['fsSize']) : 0;
      echo "<td><div class='usage-disk'><span style='margin:0;width:$free%' class='".usage_color($display,$free,true)."'><span>".my_scale($sum['fsFree']*1024,$unit)." $unit</span></span></div></td>";
    }
    echo "<td></td>";
  } else
    echo "<td colspan=4></td>";
  echo "</tr>";
}