new cleanup and updates
authorRuss Handorf <rhandorf@handorf.org>
Tue, 12 Apr 2016 02:34:39 +0000 (22:34 -0400)
committerRuss Handorf <rhandorf@handorf.org>
Tue, 12 Apr 2016 02:34:39 +0000 (22:34 -0400)
15 files changed:
alert_status.php
cache/weather.Name=19046.cache [new file with mode: 0644]
cameras.php [new file with mode: 0644]
config.php [new file with mode: 0644]
images/loading.gif [new file with mode: 0644]
includes.php
index.php
scripts/minify [new file with mode: 0644]
set_summon_status.php
sqlite.php [new file with mode: 0644]
summon.txt [new file with mode: 0644]
test/check_isy99i_status-lights.php [new file with mode: 0644]
weather-php-test.php [new file with mode: 0644]
weather2.php
weather4.php

index 0b3edee..38186b8 100644 (file)
@@ -1,11 +1,10 @@
 <? 
-
+include("config.php");
 include("includes.php");
 
-if (summon_status("russ")>=1) {
-  echo "<font color='red'><blink><strong>Russ- You're being summoned!</strong></blink></font><br>";
-}
-if (summon_status("beth")>=1) {
-  echo "<font color='red'><blink><strong>Beth- You're being summoned!</strong></blink></font><br>";
-}
+foreach ($summon as $person) {
+  if (summon_status($person) >= 1) {
+    echo "<font color='red'><blink><strong>$person- You're being summoned!</strong></blink></font><br>";
+  }
+} 
 ?>
diff --git a/cache/weather.Name=19046.cache b/cache/weather.Name=19046.cache
new file mode 100644 (file)
index 0000000..3ad10ac
--- /dev/null
@@ -0,0 +1 @@
+a:1:{s:7:"forexml";a:2:{s:1:"@";a:1:{s:4:"site";s:0:"";}s:1:"#";a:2:{s:11:"observation";a:1:{i:0;a:2:{s:1:"#";s:0:"";s:1:"@";a:19:{s:4:"city";s:8:"WXPRAW, ";s:8:"longname";s:8:"WXPRAW, ";s:5:"ident";s:0:"";s:8:"latitude";s:0:"";s:9:"longitude";s:0:"";s:8:"timezone";s:0:"";s:15:"daylight_saving";s:1:"1";s:5:"night";s:1:"1";s:12:"weather_code";s:0:"";s:16:"observation_name";s:11:" (WXPRAW, )";s:4:"time";s:13:"00Z 22 MAY 12";s:11:"wind.string";s:4:"calm";s:11:"wind_direct";s:1:"N";s:14:"wind_speed.knt";s:1:"-";s:15:"pressure.string";s:20:"1000.6 mb (29.56 in)";s:11:"pressure.mb";s:6:"1000.6";s:11:"pressure.in";s:5:"29.56";s:5:"skies";s:0:"";s:12:"text_weather";s:0:"";}}}s:7:"almanac";a:1:{i:0;a:2:{s:1:"#";s:0:"";s:1:"@";a:2:{s:7:"sunrise";s:0:"";s:6:"sunset";s:0:"";}}}}}}
\ No newline at end of file
diff --git a/cameras.php b/cameras.php
new file mode 100644 (file)
index 0000000..51a80e7
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+include("config.php");
+if(isset($_GET['cam'])) {
+  foreach ($cameras as $id=>$camera) {
+    if ($_GET['cam'] == $id) {
+      echo "<img width='704px' height='480px' id='security' src='$camera[1]'>";
+      #echo "<img id='security' src='$camera[1]'>";
+    }
+  }
+} else {
+  $camera=$cameras[0];
+  echo "<img width='704px' height='480px' id='security' src='$camera[1]'>";
+}
+?>
+<table border=1>
+<tr style='background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1E5799), color-stop(50%,#2989D8), color-stop(51%,#207cca), color-stop(100%,#7db9e8));background: -moz-linear-gradient(top, #
+1E5799 0%, #2989D8 50%, #207cca 51%, #7db9e8 100%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1E5799', endColorstr='#7db9e8',GradientType=0 );'>
+<?php
+foreach ($cameras as $id=>$camera) {
+  echo "<td>";
+  ?>
+  <a href="javascript:clearTimeout(t);i=0;ajaxpage('<?php echo "cameras.php?cam=$id'"; ?>, 'contentarea');"  style="font-family: 'Times New Roman';font-size:16pt; color:#ffffff; filter:Glow(color=#ff0000, strength=12);"><?php echo $camera[0]; ?></a>
+  <?php
+  echo "</td>";
+}
+?>
+</tr>
+</table>
diff --git a/config.php b/config.php
new file mode 100644 (file)
index 0000000..c29126d
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+$housename="THIS HOUSE";
+
+$menuitems[0]="weather";
+$menuitems[1]="lighting";
+$menuitems[2]="cameras";
+$menuitems[3]="security";
+$menuitems[4]="climate";
+$menuitems[5]="power";
+#$menuitems[6]="recepies";
+#$menuitems[7]="traffic";
+#$menuitems[8]="groceries";
+#$menuitems[9]="news";
+#$menuitems[10]="music";
+
+$isy99up="username:password";
+$isy99ip="192.168.1.1";
+
+$cameras[0]=array("Front Door","mjpeg-stream-url");
+$cameras[1]=array("Rear Door","mjpeg-stream-url");
+$cameras[2]=array("Left Door","mjpeg-stream-url");
+$cameras[3]=array("Right Door","mjpeg-stream-url");
+
+#UPDATE SUMMON FUNCTION
+$summon[0]="Mama";
+$summon[1]="Pappa";
+$summon[2]="Kiddo #1";
+?>
diff --git a/images/loading.gif b/images/loading.gif
new file mode 100644 (file)
index 0000000..f864d5f
Binary files /dev/null and b/images/loading.gif differ
index f55dd8b..a4ef0cc 100644 (file)
@@ -13,32 +13,37 @@ function get_data($item) {
 }
 
 function summon($person,$status) {
-  if ($person == "russ") {
-    $myFile = "russ.txt";
-    $fh = fopen($myFile, 'w') or die("can't open file");
-    fwrite($fh, $status);
+  $myFile = "summon.txt";
+  $list = file("summon.txt");
+  $fh = fopen($myFile, 'w') or die("can't open file");
+  $matched=0;
+  foreach ($list as $summoned) {
+    list($item,$flag) = split("=",trim($summoned));
+    if ($person == $item) {
+      fwrite($fh, "$person=$status\n");
+      $matched=1; 
+    } else {
+      if (strlen($item) > 0) {
+        fwrite($fh, "$item=$flag\n");
+      }
+    }
+  }
+  fclose($fh);
+  if ($matched==0) {
+    $fh = fopen($myFile, 'a') or die("can't open file");
+    fwrite($fh, "$person=$status\n");
     fclose($fh);
   }
-  if ($person == "beth") {
-    $myFile = "beth.txt";
-    $fh = fopen($myFile, 'w') or die("can't open file");
-    fwrite($fh, $status);
-    fclose($fh); 
-  } 
 }
 
 function summon_status($person) {
-  if ($person == "russ") {
-    $myFile = "russ.txt";
-    $fh = fopen($myFile, 'r') or die("can't open file");
-    $status = fread($fh, 5);
-    fclose($fh);
-  }
-  if ($person == "beth") {
-    $myFile = "beth.txt";
-    $fh = fopen($myFile, 'r') or die("can't open file");
-    $status = fread($fh, 5);
-    fclose($fh);
+  $myFile = "summon.txt";
+  $list = file("summon.txt");
+  foreach ($list as $summoned) {
+    list($item,$flag) = split("=",$summoned);
+    if ($person == $item) {
+      return($flag);
+    }    
   }
   return($status);
 }
index f47bbef..e5a765a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,4 +1,6 @@
-<? include("includes.php"); 
+<?php
+   include("config.php");
+   include("includes.php"); 
    include("xml2array.php");
 ?>
 <html>
@@ -228,18 +230,11 @@ function stopchanges(t) {
 
 function changeIcon(icon) {
   var icons=new Array();
-  icons[0]="home";
-  icons[1]="weather";
-  icons[2]="lighting";
-  icons[3]="music";
-  icons[4]="cameras";
-  icons[5]="security";
-  icons[6]="climate";
-  icons[7]="news";
-  icons[8]="receipes";
-  icons[9]="groceries";
-  icons[10]="traffic";
-  icons[11]="power";
+  <?php
+  foreach ($menuitems as $key=>$icon) {
+    echo "  icons[$key]='$icon';\n";
+  }
+  ?>
   for ( var i=icons.length-1; i>=0; --i ){
     if (icons[i] == icon) {
       document.getElementById(icon).src = "images/"+icon+"-on.png";
@@ -249,21 +244,8 @@ function changeIcon(icon) {
   }
 }
 
-var securitypages=new Array();
-  securitypages[0]="security1.html";
-  securitypages[1]="security2.html";
-  securitypages[2]="security3.html";
-  securitypages[3]="security4.html";
-  securitypages[4]="security5.html";
-  securitypages[5]="security6.html";
-
-function securitypageChange() {
-  ajaxpage(securitypages[i],'contentarea');
-  i++;
-  if (i==securitypages.length) {
-    i=0;
-  }
-  t=setTimeout("securitypageChange()",10000);
+function changepage() {
+    ajaxpage("cameras.php",'contentarea');
 }
 
 function mediacenterSelect(ip) {
@@ -327,8 +309,8 @@ function testDrawText3(canvas)
   context.shadowOffsetX=5;
   context.shadowOffsetY=5;
   context.shadowBlur=10;
-  context.fillText("HANDORF HOUSE", 10, 35);
-  context.strokeText("HANDORF HOUSE", 10, 35);
+  context.fillText("<?php echo $housename; ?>", 10, 35);
+  context.strokeText("<?php echo $housename; ?>", 10, 35);
 }
 testDrawText3(document.getElementById('canvas3'));
 </script>
@@ -362,7 +344,15 @@ title_status();
 <tr><td>
 <div id="contentarea" align="center">
 
-Middle
+<?php
+#  if(isset($_GET['page']) {
+#    switch($_GET['page']) {
+#      case "":
+# 
+#      break;
+#    }
+#  }
+?>
 
 </div>
 </td></tr>
@@ -377,82 +367,69 @@ Middle
 <td ALIGN=center>
 <table border=0 align=center cellpadding=0 cellspacing=0>
 <tr style="background-image: url('images/bottom-controls-repeatablebar.jpg'); background-repeat: repeat-x;">
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);weatherpageChange();imageHeaderChange('images/header-weather.png');changeIcon('weather');"><img src="./images/weather-off.png" onMouseover="" border=0 id="weather"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);lightingStatus();imageHeaderChange('images/header-lighting.png');changeIcon('lighting');"><img src="./images/lighting-off.png" onMouseover="" border=0 id="lighting"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);ajaxpage('jukebox.php', 'contentarea');imageHeaderChange('images/header-thejukebox.png');changeIcon('music');"><img src="./images/music-off.png" onMouseover="" border=0 id="music"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);securitypageChange();imageHeaderChange('images/header-camera.png');changeIcon('cameras');"><img src="./images/cameras-off.png" onMouseover="" border=0 id="cameras"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);securityStatus();imageHeaderChange('images/header-security.png');changeIcon('security');"><img src="./images/security-off.png" onMouseover="" border=0 id="security"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);ajaxpage('check_climate_status.php', 'contentarea');imageHeaderChange('images/header-climate.png');changeIcon('climate');"><img src="./images/climate-off.png" onMouseover="" border=0 id="climate"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);ajaxpage('news.php', 'contentarea');imageHeaderChange('images/header-news.png');changeIcon('news');"><img src="./images/news-off.png" onMouseover="" border=0 id="news"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);weatherpageChange();imageHeaderChange('images/header-recipes.png');changeIcon('receipes');"><img src="./images/receipes-off.png" onMouseover="" border=0 id="receipes"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);ajaxpage('groceries.html', 'contentarea');imageHeaderChange('images/header-groceries.png');changeIcon('groceries');"><img src="./images/groceries-off.png" onMouseover="" border=0 id="groceries"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);;ajaxpage('traffic.html', 'contentarea');imageHeaderChange('images/header-traffic.png');changeIcon('traffic');"><img src="./images/traffic-off.png" onMouseover="" border=0 id="traffic"></a>
-</td>
-<td ALIGN=center>
-<a href="javascript:stopchanges(t);ajaxpage('check_power_status.php', 'contentarea');imageHeaderChange('images/header-power.png');changeIcon('power');"><img src="./images/power-off.png" onMouseover="" border=0 id="power"></a>
-</td>
-</tr>
-<!--
-<tr>
-<td ALIGN=center>
-Weather&nbsp;
-</td>
-<td ALIGN=center>
-Lighting&nbsp;
-</td>
-<td ALIGN=center>
-Music&nbsp;
-</td>
-<td ALIGN=center>
-Cameras&nbsp;
-</td>
-<td ALIGN=center>
-Security&nbsp;
-</td>
-<td ALIGN=center>
-Climate&nbsp;
-</td>
-<td ALIGN=center>
-News&nbsp;
-</td>
-<td ALIGN=center>
-Receipes&nbsp;
-</td>
-<td ALIGN=center>
-Groceries&nbsp;
-</td>
-<td ALIGN=center>
-Traffic&nbsp;
-</td>
-<td ALIGN=center>
-Power&nbsp;
-</td>
+<?php
+  foreach($menuitems as $menu) {
+    echo "<td ALIGN=center>";
+    switch ($menu) {
+      case "weather":
+        ?>
+        <a href="javascript:stopchanges(t);weatherpageChange();imageHeaderChange('images/header-weather.png');changeIcon('weather');"><img src="./images/weather-off.png" onMouseover="" border=0 id="weather"></a>
+        <?php
+        break;
+      case "lighting":
+        ?>
+        <a href="javascript:stopchanges(t);lightingStatus();imageHeaderChange('images/header-lighting.png');changeIcon('lighting');"><img src="./images/lighting-off.png" onMouseover="" border=0 id="lighting"></a>
+        <?php
+        break;
+      case "cameras":
+        ?>
+        <a href="javascript:stopchanges(t);changepage('cameras');imageHeaderChange('images/header-camera.png');changeIcon('cameras');"><img src="./images/cameras-off.png" onMouseover="" border=0 id="cameras"></a>
+        <?php
+        break;
+      case "security":
+       ?>
+       <a href="javascript:stopchanges(t);securityStatus();imageHeaderChange('images/header-security.png');changeIcon('security');"><img src="./images/security-off.png" onMouseover="" border=0 id="security"></a>
+        <?php
+        break;
+      case "climate":
+        ?>
+        <a href="javascript:stopchanges(t);ajaxpage('check_climate_status.php', 'contentarea');imageHeaderChange('images/header-climate.png');changeIcon('climate');"><img src="./images/climate-off.png" onMouseover="" border=0 id="climate"></a>
+        <?php
+        break;
+      case "power":
+        ?>
+        <a href="javascript:stopchanges(t);ajaxpage('check_power_status.php', 'contentarea');imageHeaderChange('images/header-power.png');changeIcon('power');"><img src="./images/power-off.png" onMouseover="" border=0 id="power"></a>
+        <?php
+        break;
+      case "recepies":
+        ?>
+        <a href="javascript:stopchanges(t);weatherpageChange();imageHeaderChange('images/header-recipes.png');changeIcon('receipes');"><img src="./images/receipes-off.png" onMouseover="" border=0 id="receipes"></a>
+        <?php
+        break;
+      case "traffic":
+        ?>
+        <a href="javascript:stopchanges(t);;ajaxpage('traffic.html', 'contentarea');imageHeaderChange('images/header-traffic.png');changeIcon('traffic');"><img src="./images/traffic-off.png" onMouseover="" border=0 id="traffic"></a>
+        <?php
+        break;
+      case "news":
+        ?>
+        <a href="javascript:stopchanges(t);ajaxpage('news.php', 'contentarea');imageHeaderChange('images/header-news.png');changeIcon('news');"><img src="./images/news-off.png" onMouseover="" border=0 id="news"></a>
+        <?php
+        break;
+      case "music":
+        ?>
+        <a href="javascript:stopchanges(t);ajaxpage('jukebox.php', 'contentarea');imageHeaderChange('images/header-thejukebox.png');changeIcon('music');"><img src="./images/music-off.png" onMouseover="" border=0 id="music"></a>
+        <?php
+        break;
+    }
+    echo "</td>";
+  }
+?>
 
+</td>
 </tr>
--->
-
 </td></tr></table>
 </table>
-
 </div>
 
 </td></tr>
diff --git a/scripts/minify b/scripts/minify
new file mode 100644 (file)
index 0000000..3524429
--- /dev/null
@@ -0,0 +1,104 @@
+#!/usr/bin/php -q
+<?php
+    /**
+    * This is a minification script. It minifies the desired script "in-place"
+    * 
+    *  Usage (Unix): ./minify file1 file2 ...
+    *  Usage (Windows): C:\php\php.exe minify file1 file2 ...
+    * 
+    * The minification is medium, and it can over halve a scripts size.
+    * Combined with subsequent gzip compression the results can be excellent. For
+    * example a 70k script of mine was reduced to just 7k. (!) Substantial
+    * bandwidth savings for you, and much improved performance for your users.
+    *
+    * NOTE: Usage on Windows works, but is less tested
+    */
+
+    /**
+    * Check for arg
+    */
+    if (empty($_SERVER['argv'][1])) {
+        echo "RGraph minification script\n";
+        echo "==========================\n";
+        echo "Usage (Unix):     " . $_SERVER['argv'][0] . " file1 file2 ...\n";
+        echo "Usage (Windows): C:\php\php.exe " . $_SERVER['argv'][0] . " file1 file2 ...\n\n";
+        exit;
+
+    } else {
+
+        for ($i=1; $i<count($_SERVER['argv']); ++$i) {
+            Minify($_SERVER['argv'][$i]);
+        }
+    }
+
+
+    /**
+    * This is the function that does the work of minifying the file
+    * 
+    * @param $filename string The filename to be minified
+    */
+    function Minify($filename)
+    {
+        /**
+        * Begin
+        */
+        $original = file_get_contents($filename);
+        $new = preg_replace('/^ +/m', '', $original);    // Lose spaces at the start of lines
+        $new = preg_replace('/ *\/\/.*$/m', '', $new);   // Lose comments of the style: "// ..."
+        $new = preg_replace("/;\r?\n/m", ";\r\n", $new); // Make all lines end with \r\n
+        //$new = preg_replace("|\r\n\*|", "", $new);
+        
+        /**
+        * Get rid of block comments
+        */
+        $out = '';
+        $inBlock = false; // Are we in a block comment
+        for ($i=0; $i<strlen($new); $i++) {
+            if (substr($new, $i, 1) == '/') {
+                // Read the next char
+                if (!$inBlock AND substr($new, $i, 2) == '/*') {
+                    $inBlock = true;
+                }
+            } elseif (substr($new, $i, 2) == '*/') {
+                $inBlock = false;
+                $i++;
+                continue;
+            }
+            
+            if (!$inBlock) {
+                $out .= substr($new, $i, 1);
+            }
+        }
+        
+        /**
+        * Get rid of double line breaks
+        * 
+        * NOTE: Is this necessary?
+        */
+        $out = preg_replace('|\n+|', "\n", $out);
+        
+        /**
+        * Further tweaks
+        * UPDATED: 28th March 2009 - Line endings have been changed - they should all be \r\n
+        */
+        $out = str_replace(";\r\n}", ';}', $out);
+        $out = str_replace(";\r\nRGraph", ';RGraph', $out);
+        $out = preg_replace('/;\r\n([a-z])/i', ';$1', $out);
+        $out = str_replace('if (', 'if(', $out);
+        $out = str_replace(') {', '){', $out);
+        $out = str_replace("}\r\n", '}', $out);
+        $out = str_replace("{\r\n", '{', $out); // UPDATED
+        $out = str_replace("{\r\n", '{', $out); // UPDATED
+        $out = str_replace("}\r\n}", '}}', $out); // UPDATED
+        $out = str_replace("}\r\n}", '}}', $out); // UPDATED
+        $out = str_replace("}\r\n}", '}}', $out); // UPDATED
+        $out = preg_replace('/ {2,}= /', ' = ', $out);
+        
+        // Mark the file as minified
+        $out = "// THIS FILE HAS BEEN MINIFIED\r\n" . $out;
+    
+        file_put_contents($filename, $out);
+        
+        printf(" Minifying {$filename} Before: %s After: %s Saving: %d%%\n", number_format(strlen($original)), number_format(strlen($out)), number_format((((strlen($original) - strlen($out)) / strlen($original)) * 100), 1));
+    }
+?>
\ No newline at end of file
index 9850723..2050b00 100644 (file)
@@ -2,9 +2,10 @@
 $person=$_GET['person'];
 $state=$_GET['status'];
 
+include("config.php");
 include("includes.php");
 
-echo "$person,$status";
+#echo "$person,$status";
 
 summon($person,$status);
 ?>
diff --git a/sqlite.php b/sqlite.php
new file mode 100644 (file)
index 0000000..5752d9f
--- /dev/null
@@ -0,0 +1,26 @@
+<?
+$handle = sqlite_open("boxee_catalog.db") or die("Could not open database"); 
+
+$query = "select * from audio_files";
+
+$result = sqlite_query($handle, $query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle)));
+
+// if rows exist
+if (sqlite_num_rows($result) > 0) {
+    // get each row as an array
+    // print values
+    echo "<table cellpadding=10 border=1>";
+    while($row = sqlite_fetch_array($result)) {
+        echo "<tr>";
+        echo "<td>".$row[0]."</td>";
+        echo "<td>".$row[1]."</td>";
+        echo "<td>".$row[2]."</td>";
+        echo "</tr>";
+    }
+    echo "</table>";
+}
+
+// all done
+// close database file
+sqlite_close($handle);
+?> 
diff --git a/summon.txt b/summon.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/check_isy99i_status-lights.php b/test/check_isy99i_status-lights.php
new file mode 100644 (file)
index 0000000..f492bcc
--- /dev/null
@@ -0,0 +1,72 @@
+<? 
+
+ include("includes.php");
+ include("config.php");
+ include("xml2array.php");
+
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL,"http://$isy99ip/rest/nodes");
+
+  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+  curl_setopt($ch, CURLOPT_USERPWD, $isy99up);
+
+
+  $output = curl_exec($ch);
+  $array=xml2array($output);
+  echo "<pre>";
+  #print_r($array);
+  foreach($array['nodes']['node'] as $device) {
+    if ($device['enabled'] == "true") {
+      switch($device['type']) {
+        case "1.66.67.0":
+          echo $device['name']."\n";
+          break;
+        case "1.31.65.0":
+          echo $device['name']."\n"; 
+          break;
+        case "2.56.66.0":
+          echo $device['name']."\n";       
+          break;
+        case "2.20.56.0":
+          echo $device['name']."\n";       
+          break;
+        case "2.9.56.0":
+          echo $device['name']."\n";       
+          break;
+        case "2.6.64.15":
+          echo $device['name']."\n";       
+          break;
+        case "2.26.58.0":
+          echo $device['name']."\n";       
+          break;
+        case "2.20.56.30":
+          echo $device['name']."\n";       
+          break;
+        case "2.8.66.0":
+          echo $device['name']."\n";
+          break;
+        case "1.32.65.0":
+          echo $device['name']."\n";
+          break;
+        case "2.26.65.0":
+          echo $device['name']."\n";
+          break;
+        case "1.65.69.0":
+          echo $device['name']."\n";
+          break;
+        case "2.16.56.0":
+          echo $device['name']."\n";
+          break;
+        case "2.18.56.0":
+          echo $device['name']."\n";
+          break;
+        #case "":
+        #  echo $device['name']."\n";
+        #  break;
+      } 
+    }
+  }
+  #exit;
+  #echo substr(($array['nodeInfo']['node']['property']['0_attr']['formatted']),0,-1)." F";
+?>
diff --git a/weather-php-test.php b/weather-php-test.php
new file mode 100644 (file)
index 0000000..41fa20a
--- /dev/null
@@ -0,0 +1,107 @@
+<?php ob_start('ob_gzhandler') ?>
+<?
+function get_data($item) {
+  $doc = new DOMDocument();
+  $doc->load('http://weather/weather/all-output.xml');
+  $arrFeeds = array();
+  foreach ($doc->getElementsByTagName('weather') as $node) {
+    $itemRSS = array ( 
+      $item => $node->getElementsByTagName($item)->item(0)->nodeValue,
+      );
+    array_push($arrFeeds, $itemRSS);
+  }
+  echo $itemRSS[$item];
+}
+?>
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="libraries/RGraph.common.core.js" ></script>
+    <script src="libraries/RGraph.common.context.js" ></script>
+    <script src="libraries/RGraph.common.annotate.js" ></script>
+    <script src="libraries/RGraph.common.tooltips.js" ></script>
+    <script src="libraries/RGraph.common.zoom.js" ></script>
+    <script src="libraries/RGraph.common.resizing.js" ></script>
+    <script src="libraries/RGraph.meter.js" ></script>
+    <script src="libraries/RGraph.odo.js" ></script>
+    <!--[if IE 8]><script src="excanvas/excanvas.compressed.js"></script><![endif]-->
+
+    <script>
+        window.onload = function ()
+        {
+            var meter1 = new RGraph.Meter('meter1', -20, 120, <? get_data("outsideTemp"); ?>);
+            
+            var grad1 = meter1.context.createRadialGradient(meter1.canvas.width / 2,meter1.canvas.height - 25,0,meter1.canvas.width / 2,meter1.canvas.height - 25,100);
+            grad1.addColorStop(0, 'red');
+            grad1.addColorStop(1, 'white');
+
+            var grad2 = meter1.context.createRadialGradient(meter1.canvas.width / 2, meter1.canvas.height - 25,0,meter1.canvas.width / 2, meter1.canvas.height - 25,100);
+            grad2.addColorStop(0, 'green');
+            grad2.addColorStop(1, 'white');
+            
+            var grad3 = meter1.context.createRadialGradient(meter1.canvas.width / 2, meter1.canvas.height - 25,0,meter1.canvas.width / 2, meter1.canvas.height - 25,100);
+            grad3.addColorStop(0, 'blue');
+            grad3.addColorStop(1, 'white');
+            //meter1.Set('chart.contextmenu', [['Zoom in', RGraph.Zoom], ['Show palette', RGraph.Showpalette], ['Clear annotations', function () {RGraph.Clear(meter1.canvas); meter1.Draw();}], null, ['Cancel', function () {}]]);
+            meter1.Set('chart.annotatable', false);
+            meter1.Set('chart.labels.position', 'inside');
+            meter1.Set('chart.title', '<? get_data("outsideTemp"); ?>');
+            meter1.Set('chart.title.vpos', 0.5);
+            meter1.Set('chart.title.color', 'black');
+            meter1.Set('chart.red.color', grad3);
+            meter1.Set('chart.yellow.color', grad2);
+            meter1.Set('chart.green.color', grad1);
+            meter1.Set('chart.red.start', -20);
+            meter1.Set('chart.red.end', 55);
+            meter1.Set('chart.yellow.start', 55);
+            meter1.Set('chart.yellow.end', 90);
+            meter1.Set('chart.green.start', 90);
+            meter1.Set('chart.green.end', 120);
+            meter1.Set('chart.shadow', true);
+            meter1.Set('chart.shadow.color', 'gray');
+            meter1.Set('chart.shadow.offsetx', 0);
+            meter1.Set('chart.shadow.offsety', 0);
+            meter1.Set('chart.shadow.blur', 15);
+            meter1.Set('chart.zoom.hdir', 'center');
+            meter1.Set('chart.zoom.vdir', 'center');
+            meter1.Set('chart.contextmenu', [['Clear', function () {RGraph.Clear(meter1.canvas); meter1.Draw();}]]);
+            meter1.Draw();
+
+            var odo2 = new RGraph.Odometer('odo2', 0, 360, <? get_data("windDirectionDegrees"); ?>);
+            odo2.Set('chart.annotatable', false);
+            //odo2.Set('chart.needle.thickness', 6);
+            odo2.Set('chart.needle.color', 'black');
+            odo2.Set('chart.needle.tail', false);
+            //odo2.Set('chart.needle.type', 'triangle');
+            odo2.Set('chart.label.area', 22);
+            odo2.Set('chart.contextmenu', [['Clear', function () {RGraph.Clear(odo2.canvas); odo2.Draw();}]]);
+            //odo2.Set('chart.border', document.all ? false : true);
+            //odo2.Set('chart.tickmarks.highlighted', true);
+            odo2.Set('chart.labels', ['N','NE','E','SE','S','SW','W','NW']);
+            odo2.Set('chart.red.min', 360);
+            odo2.Set('chart.red.color', 'gray');
+            //odo2.Set('chart.value.text', true);
+            odo2.Set('chart.value.units.post', ' degrees');
+            odo2.Draw();
+
+        }
+    </script>
+</head>
+<body>
+
+<table>
+<tr><td>Temperature</td><td>Wind</td></tr>
+<tr><td>
+    <div style="text-align: center">
+        <canvas id="meter1" width="300" height="150"><div class="canvasfallback">[No canvas support]</div></canvas>
+    </div>
+</td><td>
+    <div style="text-align: center">
+        <canvas id="odo2" width="200" height="200"><div class="canvasfallback">[No canvas support]</div></canvas>
+    </div>
+
+</td></tr>
+</table>
+</body>
+</html>
index 9df1549..ec07e1b 100644 (file)
@@ -1,4 +1,4 @@
-<img width="75%" src="http://radblast.weatherunderground.com/cgi-bin/radar/WUNIDS_map?station=DIX&brand=wui&num=6&delay=15&type=N0R&frame=0&scale=1.000&noclutter=0&t=1144248527&lat=39.93652725&lon=-75.15544891&label=Philadelphia,+PA&showstorms=0&map.x=400&map.y=240&centerx=400&centery=240&transx=0&transy=0&showlabels=1&severe=0&rainsnow=0&lightning=0">
+<img width="75%" src="https://radblast.wunderground.com/cgi-bin/radar/WUNIDS_map?station=DIX&brand=wui&num=10&delay=15&type=N0R&frame=0&scale=1&noclutter=0&showstorms=0&mapx=400&mapy=240&centerx=400&centery=240&transx=0&transy=0&showlabels=1&severe=0&rainsnow=0&lightning=0&smooth=0&rand=24330197&lat=40.11301422&lon=-75.18637848&label=Oreland%2C+PA">
 <?php 
   include("weather-footer.php");
 ?>
index e6cd238..320dae0 100644 (file)
@@ -1,5 +1,5 @@
 <br>
-<img width="75%" src="http://radblast.weatherunderground.com/cgi-bin/radar/WUNIDS_map?station=DIX&brand=wui&num=6&delay=15&type=N0R&frame=0&scale=1.000&noclutter=0&t=1144248527&lat=39.93652725&lon=-75.15544891&label=Philadelphia,+PA&showstorms=0&map.x=400&map.y=240&centerx=400&centery=240&transx=0&transy=0&showlabels=1&severe=0&rainsnow=0&lightning=1"></td></tr>
+<img width="75%" src="https://radblast.wunderground.com/cgi-bin/radar/WUNIDS_map?station=DIX&brand=wui&num=10&delay=15&type=N0R&frame=0&scale=1&noclutter=0&showstorms=0&mapx=400&mapy=240&centerx=400&centery=240&transx=0&transy=0&showlabels=1&severe=0&rainsnow=0&lightning=1&smooth=0&rand=24330197&lat=40.11301422&lon=-75.18637848&label=Oreland%2C+PA"></td></tr>
 
 <?php 
   include("weather-footer.php");