Fix for WML PHP
Posted: Thu Mar 25, 2004 1:45 am
Here's a patch to fix the WML php for 1.19.1... fixed and cleaned it up a little. You'll have to apply it before doing your make install. (hopefully the forum won't ruin the patch file)
cut and paste into wml.patch
cd to your zm-1.19.1 directory
patch -p1 < wml.patch
make install
hit http://zm.yoursite.com/zm_wml.php and wha-la!
-----------------------
diff -Naur zm-1.19.1-orig/web/zm_wml.php zm-1.19.1/web/zm_wml.php
--- zm-1.19.1-orig/web/zm_wml.php 2004-02-15 14:10:59.000000000 -0500
+++ zm-1.19.1/web/zm_wml.php 2004-03-24 20:25:22.000000000 -0500
@@ -55,6 +55,17 @@
switch( $view )
{
+ case "function" :
+ case "events" :
+ {
+ print "<wml>\n";
+ print "<card id=\"zmFuncitons\" title=\"ZM $view\">\n";
+ print "<p mode=\"nowrap\" align=\"center\"><strong>ZM - $view</strong></p>\n";
+ print "<p mode=\"nowrap\" align=\"center\">Not supported yet. Sorry.</p>\n";
+ print "</card>\n";
+ print "</wml>\n";
+ break;
+ }
case "console" :
case "feed" :
{
diff -Naur zm-1.19.1-orig/web/zm_wml_view_console.php zm-1.19.1/web/zm_wml_view_console.php
--- zm-1.19.1-orig/web/zm_wml_view_console.php 2004-02-15 14:10:59.000000000 -0500
+++ zm-1.19.1/web/zm_wml_view_console.php 2004-03-24 20:25:34.000000000 -0500
@@ -22,7 +22,16 @@
$HTTP_SESSION_VARS['event_reset_time'] = "2000-01-01 00:00:00";
$db_now = strftime( "%Y-%m-%d %H:%M:%S" );
-$sql = "select M.*, count(E.Id) as EventCount, count(if(E.StartTime>'$HTTP_SESSION_VARS['event_reset_time']' && E.Archived = 0,1,NULL)) as ResetEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) as DayEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by M.Id order by M.Id";
+$sql = sprintf("SELECT M.*,
+ COUNT(E.Id) AS EventCount,
+ COUNT(if(E.StartTime>'%s' && E.Archived = 0,1,NULL)) AS ResetEventCount,
+ COUNT(if(E.StartTime>'%s' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) AS HourEventCount,
+ COUNT(if(E.StartTime>'%s' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) AS DayEventCount
+ FROM Monitors AS M
+ LEFT JOIN Events AS E
+ ON E.MonitorId = M.Id
+ GROUP BY M.Id
+ ORDER BY M.Id", $HTTP_SESSION_VARS['event_reset_time'], $db_now, $db_now);
$result = mysql_query( $sql );
if ( !$result )
echo mysql_error();
@@ -34,7 +43,13 @@
{
if ( $max_width < $row['Width'] ) $max_width = $row['Width'];
if ( $max_height < $row['Height'] ) $max_height = $row['Height'];
- $sql = "select count(Id) as ZoneCount, count(if(Type='Active',1,NULL)) as ActZoneCount, count(if(Type='Inclusive',1,NULL)) as IncZoneCount, count(if(Type='Exclusive',1,NULL)) as ExcZoneCount, count(if(Type='Inactive',1,NULL)) as InactZoneCount from Zones where MonitorId = '$row['Id']'";
+ $sql = sprintf("SELECT COUNT(Id) AS ZoneCount,
+ COUNT(if(Type='Active',1,NULL)) AS ActZoneCount,
+ COUNT(if(Type='Inclusive',1,NULL)) AS IncZoneCount,
+ COUNT(if(Type='Exclusive',1,NULL)) AS ExcZoneCount,
+ COUNT(if(Type='Inactive',1,NULL)) AS InactZoneCount
+ FROM Zones
+ WHERE MonitorId = '%s'",$row['Id']);
$result2 = mysql_query( $sql );
if ( !$result2 )
echo mysql_error();
@@ -51,12 +66,12 @@
while( $row = mysql_fetch_assoc( $result ) )
{
- $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zmc $row['Device']' | grep -v grep" ) );
+ $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zmc " . $row['Device'] . "' | grep -v grep" ) );
if ( $ps_array[3] )
{
$row['zmc'] = 1;
}
- $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zma $row['Device']' | grep -v grep" ) );
+ $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zma " . $row['Device'] . "' | grep -v grep" ) );
if ( $ps_array[3] )
{
$row['zma'] = 1;
diff -Naur zm-1.19.1-orig/web/zm_wml_view_feed.php zm-1.19.1/web/zm_wml_view_feed.php
--- zm-1.19.1-orig/web/zm_wml_view_feed.php 2004-02-15 14:10:59.000000000 -0500
+++ zm-1.19.1/web/zm_wml_view_feed.php 2004-03-24 20:25:34.000000000 -0500
@@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
-$result = mysql_query( "select * from Monitors where Id = '$mid'" );
+$result = mysql_query( "SELECT * FROM Monitors WHERE Id = '$mid'" );
if ( !$result )
die( mysql_error() );
$monitor = mysql_fetch_assoc( $result );
cut and paste into wml.patch
cd to your zm-1.19.1 directory
patch -p1 < wml.patch
make install
hit http://zm.yoursite.com/zm_wml.php and wha-la!
-----------------------
diff -Naur zm-1.19.1-orig/web/zm_wml.php zm-1.19.1/web/zm_wml.php
--- zm-1.19.1-orig/web/zm_wml.php 2004-02-15 14:10:59.000000000 -0500
+++ zm-1.19.1/web/zm_wml.php 2004-03-24 20:25:22.000000000 -0500
@@ -55,6 +55,17 @@
switch( $view )
{
+ case "function" :
+ case "events" :
+ {
+ print "<wml>\n";
+ print "<card id=\"zmFuncitons\" title=\"ZM $view\">\n";
+ print "<p mode=\"nowrap\" align=\"center\"><strong>ZM - $view</strong></p>\n";
+ print "<p mode=\"nowrap\" align=\"center\">Not supported yet. Sorry.</p>\n";
+ print "</card>\n";
+ print "</wml>\n";
+ break;
+ }
case "console" :
case "feed" :
{
diff -Naur zm-1.19.1-orig/web/zm_wml_view_console.php zm-1.19.1/web/zm_wml_view_console.php
--- zm-1.19.1-orig/web/zm_wml_view_console.php 2004-02-15 14:10:59.000000000 -0500
+++ zm-1.19.1/web/zm_wml_view_console.php 2004-03-24 20:25:34.000000000 -0500
@@ -22,7 +22,16 @@
$HTTP_SESSION_VARS['event_reset_time'] = "2000-01-01 00:00:00";
$db_now = strftime( "%Y-%m-%d %H:%M:%S" );
-$sql = "select M.*, count(E.Id) as EventCount, count(if(E.StartTime>'$HTTP_SESSION_VARS['event_reset_time']' && E.Archived = 0,1,NULL)) as ResetEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if(E.StartTime>'$db_now' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) as DayEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by M.Id order by M.Id";
+$sql = sprintf("SELECT M.*,
+ COUNT(E.Id) AS EventCount,
+ COUNT(if(E.StartTime>'%s' && E.Archived = 0,1,NULL)) AS ResetEventCount,
+ COUNT(if(E.StartTime>'%s' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) AS HourEventCount,
+ COUNT(if(E.StartTime>'%s' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) AS DayEventCount
+ FROM Monitors AS M
+ LEFT JOIN Events AS E
+ ON E.MonitorId = M.Id
+ GROUP BY M.Id
+ ORDER BY M.Id", $HTTP_SESSION_VARS['event_reset_time'], $db_now, $db_now);
$result = mysql_query( $sql );
if ( !$result )
echo mysql_error();
@@ -34,7 +43,13 @@
{
if ( $max_width < $row['Width'] ) $max_width = $row['Width'];
if ( $max_height < $row['Height'] ) $max_height = $row['Height'];
- $sql = "select count(Id) as ZoneCount, count(if(Type='Active',1,NULL)) as ActZoneCount, count(if(Type='Inclusive',1,NULL)) as IncZoneCount, count(if(Type='Exclusive',1,NULL)) as ExcZoneCount, count(if(Type='Inactive',1,NULL)) as InactZoneCount from Zones where MonitorId = '$row['Id']'";
+ $sql = sprintf("SELECT COUNT(Id) AS ZoneCount,
+ COUNT(if(Type='Active',1,NULL)) AS ActZoneCount,
+ COUNT(if(Type='Inclusive',1,NULL)) AS IncZoneCount,
+ COUNT(if(Type='Exclusive',1,NULL)) AS ExcZoneCount,
+ COUNT(if(Type='Inactive',1,NULL)) AS InactZoneCount
+ FROM Zones
+ WHERE MonitorId = '%s'",$row['Id']);
$result2 = mysql_query( $sql );
if ( !$result2 )
echo mysql_error();
@@ -51,12 +66,12 @@
while( $row = mysql_fetch_assoc( $result ) )
{
- $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zmc $row['Device']' | grep -v grep" ) );
+ $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zmc " . $row['Device'] . "' | grep -v grep" ) );
if ( $ps_array[3] )
{
$row['zmc'] = 1;
}
- $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zma $row['Device']' | grep -v grep" ) );
+ $ps_array = preg_split( "/\s+/", exec( "ps -edalf | grep 'zma " . $row['Device'] . "' | grep -v grep" ) );
if ( $ps_array[3] )
{
$row['zma'] = 1;
diff -Naur zm-1.19.1-orig/web/zm_wml_view_feed.php zm-1.19.1/web/zm_wml_view_feed.php
--- zm-1.19.1-orig/web/zm_wml_view_feed.php 2004-02-15 14:10:59.000000000 -0500
+++ zm-1.19.1/web/zm_wml_view_feed.php 2004-03-24 20:25:34.000000000 -0500
@@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
-$result = mysql_query( "select * from Monitors where Id = '$mid'" );
+$result = mysql_query( "SELECT * FROM Monitors WHERE Id = '$mid'" );
if ( !$result )
die( mysql_error() );
$monitor = mysql_fetch_assoc( $result );