2008-07-14 21:54:50 +08:00
< ? php
//
// ZoneMinder web action file, $Date$, $Revision$
2008-07-25 17:48:16 +08:00
// Copyright (C) 2001-2008 Philip Coombes
2008-07-14 21:54:50 +08:00
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
function getAffectedIds ( $name )
{
$names = $name . " s " ;
$ids = array ();
if ( isset ( $_REQUEST [ $names ]) || isset ( $_REQUEST [ $name ]) )
{
if ( isset ( $_REQUEST [ $names ]) )
2008-09-26 17:47:20 +08:00
$ids = validInt ( $_REQUEST [ $names ]);
2008-07-14 21:54:50 +08:00
else if ( isset ( $_REQUEST [ $name ]) )
2008-09-26 17:47:20 +08:00
$ids [] = validInt ( $_REQUEST [ $name ]);
2008-07-14 21:54:50 +08:00
}
return ( $ids );
}
2009-02-19 22:06:39 +08:00
if ( ZM_OPT_USE_AUTH && ZM_AUTH_HASH_LOGINS && empty ( $user ) && ! empty ( $_REQUEST [ 'auth' ]) )
{
if ( $authUser = getAuthUser ( $_REQUEST [ 'auth' ] ) )
{
userLogin ( $authUser [ 'Username' ], $authUser [ 'Password' ], true );
}
}
2008-09-26 17:47:20 +08:00
if ( ! empty ( $action ) )
2008-07-14 21:54:50 +08:00
{
// General scope actions
2008-09-26 17:47:20 +08:00
if ( $action == " login " && isset ( $_REQUEST [ 'username' ]) && ( ZM_AUTH_TYPE == " remote " || isset ( $_REQUEST [ 'password' ]) ) )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$username = validStr ( $_REQUEST [ 'username' ] );
$password = isset ( $_REQUEST [ 'password' ]) ? validStr ( $_REQUEST [ 'password' ]) : '' ;
userLogin ( $username , $password );
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " logout " )
2008-07-14 21:54:50 +08:00
{
userLogout ();
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
$view = 'none' ;
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " bandwidth " && isset ( $_REQUEST [ 'newBandwidth' ]) )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$_COOKIE [ 'zmBandwidth' ] = validStr ( $_REQUEST [ 'newBandwidth' ]);
setcookie ( " zmBandwidth " , validStr ( $_REQUEST [ 'newBandwidth' ]), time () + 3600 * 24 * 30 * 12 * 10 );
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
// Event scope actions, view permissions only required
if ( canView ( 'Events' ) )
{
2008-09-26 17:47:20 +08:00
if ( $action == " filter " )
2008-07-14 21:54:50 +08:00
{
2008-10-20 16:25:24 +08:00
if ( ! empty ( $_REQUEST [ 'subaction' ]) )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
if ( $_REQUEST [ 'subaction' ] == " addterm " )
$_REQUEST [ 'filter' ] = addFilterTerm ( $_REQUEST [ 'filter' ], $_REQUEST [ 'line' ] );
elseif ( $_REQUEST [ 'subaction' ] == " delterm " )
$_REQUEST [ 'filter' ] = delFilterTerm ( $_REQUEST [ 'filter' ], $_REQUEST [ 'line' ] );
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
elseif ( canEdit ( 'Events' ) )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
if ( ! empty ( $_REQUEST [ 'execute' ]) )
$tempFilterName = " _TempFilter " . time ();
2008-10-14 20:13:55 +08:00
if ( isset ( $tempFilterName ) )
2008-09-26 17:47:20 +08:00
$filterName = $tempFilterName ;
2008-10-14 20:13:55 +08:00
elseif ( ! empty ( $_REQUEST [ 'newFilterName' ]) )
$filterName = $_REQUEST [ 'newFilterName' ];
2008-09-26 17:47:20 +08:00
if ( ! empty ( $filterName ) )
{
$_REQUEST [ 'filter' ][ 'sort_field' ] = validStr ( $_REQUEST [ 'sort_field' ]);
2008-10-14 20:13:55 +08:00
$_REQUEST [ 'filter' ][ 'sort_asc' ] = validStr ( $_REQUEST [ 'sort_asc' ]);
2008-09-26 17:47:20 +08:00
$_REQUEST [ 'filter' ][ 'limit' ] = validInt ( $_REQUEST [ 'limit' ]);
2008-10-20 16:25:24 +08:00
$sql = " replace into Filters set Name = ' " . dbEscape ( $filterName ) . " ', Query = ' " . dbEscape ( serialize ( $_REQUEST [ 'filter' ])) . " ' " ;
if ( ! empty ( $_REQUEST [ 'autoArchive' ]) )
$sql .= " , AutoArchive = ' " . dbEscape ( $_REQUEST [ 'autoArchive' ]) . " ' " ;
if ( ! empty ( $_REQUEST [ 'autoVideo' ]) )
$sql .= " , AutoVideo = ' " . dbEscape ( $_REQUEST [ 'autoVideo' ]) . " ' " ;
if ( ! empty ( $_REQUEST [ 'autoUpload' ]) )
$sql .= " , AutoUpload = ' " . dbEscape ( $_REQUEST [ 'autoUpload' ]) . " ' " ;
if ( ! empty ( $_REQUEST [ 'autoEmail' ]) )
$sql .= " , AutoEmail = ' " . dbEscape ( $_REQUEST [ 'autoEmail' ]) . " ' " ;
if ( ! empty ( $_REQUEST [ 'autoMessage' ]) )
$sql .= " , AutoMessage = ' " . dbEscape ( $_REQUEST [ 'autoMessage' ]) . " ' " ;
if ( ! empty ( $_REQUEST [ 'autoExecute' ]) && ! empty ( $_REQUEST [ 'autoExecuteCmd' ]) )
$sql .= " , AutoExecute = ' " . dbEscape ( $_REQUEST [ 'autoExecute' ]) . " ', AutoExecuteCmd = ' " . dbEscape ( $_REQUEST [ 'autoExecuteCmd' ]) . " ' " ;
if ( ! empty ( $_REQUEST [ 'autoDelete' ]) )
$sql .= " , AutoDelete = ' " . dbEscape ( $_REQUEST [ 'autoDelete' ]) . " ' " ;
if ( ! empty ( $_REQUEST [ 'background' ]) )
$sql .= " , Background = ' " . dbEscape ( $_REQUEST [ 'background' ]) . " ' " ;
dbQuery ( $sql );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
}
2008-07-14 21:54:50 +08:00
}
}
}
// Event scope actions, edit permissions required
if ( canEdit ( 'Events' ) )
{
2008-09-26 17:47:20 +08:00
if ( $action == " rename " && isset ( $_REQUEST [ 'eventName' ]) && ! empty ( $_REQUEST [ 'eid' ]) )
2008-07-14 21:54:50 +08:00
{
dbQuery ( " update Events set Name = ' " . dbEscape ( $_REQUEST [ 'eventName' ]) . " ' where Id = ' " . dbEscape ( $_REQUEST [ 'eid' ]) . " ' " );
}
2008-09-26 17:47:20 +08:00
else if ( $action == " eventdetail " )
2008-07-14 21:54:50 +08:00
{
if ( ! empty ( $_REQUEST [ 'eid' ]) )
{
dbQuery ( " update Events set Cause = ' " . dbEscape ( $_REQUEST [ 'newEvent' ][ 'Cause' ]) . " ', Notes = ' " . dbEscape ( $_REQUEST [ 'newEvent' ][ 'Notes' ]) . " ' where Id = ' " . dbEscape ( $_REQUEST [ 'eid' ]) . " ' " );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
else
{
foreach ( getAffectedIds ( 'markEid' ) as $markEid )
{
dbQuery ( " update Events set Cause = ' " . dbEscape ( $_REQUEST [ 'newEvent' ][ 'Cause' ]) . " ', Notes = ' " . dbEscape ( $_REQUEST [ 'newEvent' ][ 'Notes' ]) . " ' where Id = ' " . dbEscape ( $markEid ) . " ' " );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
}
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " archive " || $action == " unarchive " )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$archiveVal = ( $action == " archive " ) ? 1 : 0 ;
2008-07-14 21:54:50 +08:00
if ( ! empty ( $_REQUEST [ 'eid' ]) )
{
dbQuery ( " update Events set Archived = $archiveVal where Id = ' " . dbEscape ( $_REQUEST [ 'eid' ]) . " ' " );
}
else
{
foreach ( getAffectedIds ( 'markEid' ) as $markEid )
{
dbQuery ( " update Events set Archived = $archiveVal where Id = ' " . dbEscape ( $markEid ) . " ' " );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
}
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " delete " )
2008-07-14 21:54:50 +08:00
{
foreach ( getAffectedIds ( 'markEid' ) as $markEid )
{
deleteEvent ( $markEid );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
if ( ! empty ( $_REQUEST [ 'fid' ]) )
{
2008-09-26 17:47:20 +08:00
dbQuery ( " delete from Filters where Name = ' " . dbEscape ( $_REQUEST [ 'fid' ]) . " ' " );
//$refreshParent = true;
2008-07-14 21:54:50 +08:00
}
}
}
// Monitor control actions, require a monitor id and control view permissions for that monitor
if ( ! empty ( $_REQUEST [ 'mid' ]) && canView ( 'Control' , $_REQUEST [ 'mid' ] ) )
{
2009-09-28 21:34:10 +08:00
require_once ( 'control_functions.php' );
2008-09-26 17:47:20 +08:00
$mid = validInt ( $_REQUEST [ 'mid' ]);
if ( $action == " control " )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$monitor = dbFetchOne ( " select C.*,M.* from Monitors as M inner join Controls as C on (M.ControlId = C.Id) where M.Id = ' " . dbEscape ( $mid ) . " ' " );
2008-07-14 21:54:50 +08:00
2009-09-28 21:34:10 +08:00
$ctrlCommand = buildControlCommand ( $monitor );
2008-07-14 21:54:50 +08:00
2009-09-28 22:16:17 +08:00
if ( $ctrlCommand )
2008-07-14 21:54:50 +08:00
{
$socket = socket_create ( AF_UNIX , SOCK_STREAM , 0 );
if ( $socket < 0 )
{
die ( " socket_create() failed: " . socket_strerror ( $socket ) );
}
2009-02-19 17:45:29 +08:00
$sockFile = ZM_PATH_SOCKS . '/zmcontrol-' . $monitor [ 'Id' ] . '.sock' ;
2008-07-14 21:54:50 +08:00
if ( @ socket_connect ( $socket , $sockFile ) )
{
$options = array ();
2010-02-16 01:09:07 +08:00
foreach ( explode ( " " , $ctrlCommand ) as $option )
2008-07-14 21:54:50 +08:00
{
if ( preg_match ( '/--([^=]+)(?:=(.+))?/' , $option , $matches ) )
{
$options [ $matches [ 1 ]] = $matches [ 2 ] ? $matches [ 2 ] : 1 ;
}
}
$optionString = serialize ( $options );
if ( ! socket_write ( $socket , $optionString ) )
{
die ( " Can't write to control socket: " . socket_strerror ( socket_last_error ( $socket )) );
}
socket_close ( $socket );
}
else
{
$ctrlCommand .= " --id= " . $monitor [ 'Id' ];
// Can't connect so use script
$ctrlOutput = exec ( escapeshellcmd ( $ctrlCommand ) );
}
}
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " settings " )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$zmuCommand = getZmuCommand ( " -m " . $mid . " -B " . $_REQUEST [ 'newBrightness' ] . " -C " . $_REQUEST [ 'newContrast' ] . " -H " . $_REQUEST [ 'newHue' ] . " -O " . $_REQUEST [ 'newColour' ] );
2008-07-14 21:54:50 +08:00
$zmuOutput = exec ( escapeshellcmd ( $zmuCommand ) );
2010-02-16 01:09:07 +08:00
list ( $brightness , $contrast , $hue , $colour ) = explode ( ' ' , $zmuOutput );
2008-09-26 17:47:20 +08:00
dbQuery ( " update Monitors set Brightness = ' " . $brightness . " ', Contrast = ' " . $contrast . " ', Hue = ' " . $hue . " ', Colour = ' " . $colour . " ' where Id = ' " . $mid . " ' " );
2008-07-14 21:54:50 +08:00
}
}
// Control capability actions, require control edit permissions
if ( canEdit ( 'Control' ) )
{
2008-09-26 17:47:20 +08:00
if ( $action == " controlcap " )
2008-07-14 21:54:50 +08:00
{
if ( ! empty ( $_REQUEST [ 'cid' ]) )
{
$control = dbFetchOne ( " select * from Controls where Id = ' " . dbEscape ( $_REQUEST [ 'cid' ]) . " ' " );
}
else
{
$control = array ();
}
// Define a field type for anything that's not simple text equivalent
$types = array (
// Empty
);
$columns = getTableColumns ( 'Controls' );
foreach ( $columns as $name => $type )
{
if ( preg_match ( '/^(Can|Has)/' , $name ) )
{
$types [ $name ] = 'toggle' ;
}
}
$changes = getFormChanges ( $control , $_REQUEST [ 'newControl' ], $types , $columns );
if ( count ( $changes ) )
{
if ( ! empty ( $_REQUEST [ 'cid' ]) )
{
dbQuery ( " update Controls set " . implode ( " , " , $changes ) . " where Id = ' " . dbEscape ( $_REQUEST [ 'cid' ]) . " ' " );
}
else
{
dbQuery ( " insert into Controls set " . implode ( " , " , $changes ) );
//$_REQUEST['cid'] = dbInsertId();
}
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
2009-01-31 01:43:29 +08:00
$view = 'none' ;
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " delete " )
2008-07-14 21:54:50 +08:00
{
if ( isset ( $_REQUEST [ 'markCids' ]) )
{
foreach ( $_REQUEST [ 'markCids' ] as $markCid )
{
dbQuery ( " delete from Controls where Id = ' " . dbEscape ( $markCid ) . " ' " );
dbQuery ( " update Monitors set Controllable = 0, ControlId = 0 where ControlId = ' " . dbEscape ( $markCid ) . " ' " );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
}
}
}
// Monitor edit actions, require a monitor id and edit permissions for that monitor
if ( ! empty ( $_REQUEST [ 'mid' ]) && canEdit ( 'Monitors' , $_REQUEST [ 'mid' ] ) )
{
2008-09-26 17:47:20 +08:00
$mid = validInt ( $_REQUEST [ 'mid' ]);
if ( $action == " function " )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$monitor = dbFetchOne ( " select * from Monitors where Id = ' " . $mid . " ' " );
2008-07-14 21:54:50 +08:00
2008-09-26 17:47:20 +08:00
$newFunction = validStr ( $_REQUEST [ 'newFunction' ]);
$newEnabled = validStr ( $_REQUEST [ 'newEnabled' ]);
2008-07-14 21:54:50 +08:00
$oldFunction = $monitor [ 'Function' ];
$oldEnabled = $monitor [ 'Enabled' ];
2008-09-26 17:47:20 +08:00
if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
dbQuery ( " update Monitors set Function = ' " . dbEscape ( $newFunction ) . " ', Enabled = ' " . $newEnabled . " ' where Id = ' " . $mid . " ' " );
2008-07-14 21:54:50 +08:00
2008-09-26 17:47:20 +08:00
$monitor [ 'Function' ] = $newFunction ;
$monitor [ 'Enabled' ] = $newEnabled ;
2008-07-16 16:44:39 +08:00
//if ( $cookies ) session_write_close();
2008-07-14 21:54:50 +08:00
if ( daemonCheck () )
{
2008-09-26 17:47:20 +08:00
$restart = ( $oldFunction == 'None' ) || ( $newFunction == 'None' ) || ( $newEnabled != $oldEnabled );
zmcControl ( $monitor , $restart ? " restart " : " " );
2008-07-14 21:54:50 +08:00
zmaControl ( $monitor , " reload " );
}
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " zone " && isset ( $_REQUEST [ 'zid' ] ) )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$zid = validInt ( $_REQUEST [ 'zid' ]);
$monitor = dbFetchOne ( " select * from Monitors where Id = ' " . dbEscape ( $mid ) . " ' " );
2008-07-14 21:54:50 +08:00
2008-09-26 17:47:20 +08:00
if ( ! empty ( $zid ) )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$zone = dbFetchOne ( " select * from Zones where MonitorId = ' " . dbEscape ( $mid ) . " ' and Id = ' " . dbEscape ( $zid ) . " ' " );
2008-07-14 21:54:50 +08:00
}
else
{
$zone = array ();
}
if ( $_REQUEST [ 'newZone' ][ 'Units' ] == 'Percent' )
{
$_REQUEST [ 'newZone' ][ 'MinAlarmPixels' ] = intval (( $_REQUEST [ 'newZone' ][ 'MinAlarmPixels' ] * $_REQUEST [ 'newZone' ][ 'Area' ]) / 100 );
$_REQUEST [ 'newZone' ][ 'MaxAlarmPixels' ] = intval (( $_REQUEST [ 'newZone' ][ 'MaxAlarmPixels' ] * $_REQUEST [ 'newZone' ][ 'Area' ]) / 100 );
if ( isset ( $_REQUEST [ 'newZone' ][ 'MinFilterPixels' ]) )
$_REQUEST [ 'newZone' ][ 'MinFilterPixels' ] = intval (( $_REQUEST [ 'newZone' ][ 'MinFilterPixels' ] * $_REQUEST [ 'newZone' ][ 'Area' ]) / 100 );
if ( isset ( $_REQUEST [ 'newZone' ][ 'MaxFilterPixels' ]) )
$_REQUEST [ 'newZone' ][ 'MaxFilterPixels' ] = intval (( $_REQUEST [ 'newZone' ][ 'MaxFilterPixels' ] * $_REQUEST [ 'newZone' ][ 'Area' ]) / 100 );
if ( isset ( $_REQUEST [ 'newZone' ][ 'MinBlobPixels' ]) )
$_REQUEST [ 'newZone' ][ 'MinBlobPixels' ] = intval (( $_REQUEST [ 'newZone' ][ 'MinBlobPixels' ] * $_REQUEST [ 'newZone' ][ 'Area' ]) / 100 );
if ( isset ( $_REQUEST [ 'newZone' ][ 'MaxBlobPixels' ]) )
$_REQUEST [ 'newZone' ][ 'MaxBlobPixels' ] = intval (( $_REQUEST [ 'newZone' ][ 'MaxBlobPixels' ] * $_REQUEST [ 'newZone' ][ 'Area' ]) / 100 );
}
unset ( $_REQUEST [ 'newZone' ][ 'Points' ] );
$types = array ();
$changes = getFormChanges ( $zone , $_REQUEST [ 'newZone' ], $types );
if ( count ( $changes ) )
{
2008-09-26 17:47:20 +08:00
if ( $zid > 0 )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$sql = " update Zones set " . implode ( " , " , $changes ) . " where MonitorId = ' " . dbEscape ( $mid ) . " ' and Id = ' " . dbEscape ( $zid ) . " ' " ;
2008-07-14 21:54:50 +08:00
}
else
{
2008-09-26 17:47:20 +08:00
$sql = " insert into Zones set MonitorId = ' " . dbEscape ( $mid ) . " ', " . implode ( " , " , $changes );
2008-07-14 21:54:50 +08:00
}
dbQuery ( $sql );
2008-07-16 16:44:39 +08:00
//if ( $cookies ) session_write_close();
2008-07-14 21:54:50 +08:00
if ( daemonCheck () )
{
2008-09-26 17:47:20 +08:00
zmaControl ( $mid , " restart " );
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
$view = 'none' ;
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " sequence " && isset ( $_REQUEST [ 'smid' ]) )
2008-07-14 21:54:50 +08:00
{
2008-09-26 17:47:20 +08:00
$smid = validInt ( $_REQUEST [ 'smid' ]);
$monitor = dbFetchOne ( " select * from Monitors where Id = ' " . dbEscape ( $mid ) . " ' " );
$smonitor = dbFetchOne ( " select * from Monitors where Id = ' " . dbEscape ( $smid ) . " ' " );
2008-07-14 21:54:50 +08:00
dbQuery ( " update Monitors set Sequence = ' " . $smonitor [ 'Sequence' ] . " ' where Id = ' " . $monitor [ 'Id' ] . " ' " );
dbQuery ( " update Monitors set Sequence = ' " . $monitor [ 'Sequence' ] . " ' where Id = ' " . $smonitor [ 'Id' ] . " ' " );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
fixSequences ();
}
2008-09-26 17:47:20 +08:00
if ( $action == " delete " )
2008-07-14 21:54:50 +08:00
{
if ( isset ( $_REQUEST [ 'markZids' ]) )
{
$deletedZid = 0 ;
foreach ( $_REQUEST [ 'markZids' ] as $markZid )
{
2008-09-26 17:47:20 +08:00
dbQuery ( " delete from Zones where MonitorId = ' " . dbEscape ( $mid ) . " ' && Id = ' " . dbEscape ( $markZid ) . " ' " );
2008-07-14 21:54:50 +08:00
$deletedZid = 1 ;
}
if ( $deletedZid )
{
2008-07-16 16:44:39 +08:00
//if ( $cookies )
//session_write_close();
2008-07-14 21:54:50 +08:00
if ( daemonCheck () )
2008-09-26 17:47:20 +08:00
zmaControl ( $mid , " restart " );
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
}
}
}
// Monitor edit actions, monitor id derived, require edit permissions for that monitor
if ( canEdit ( 'Monitors' ) )
{
2008-09-26 17:47:20 +08:00
if ( $action == " monitor " )
2008-07-14 21:54:50 +08:00
{
if ( ! empty ( $_REQUEST [ 'mid' ]) )
{
2008-09-26 17:47:20 +08:00
$mid = validInt ( $_REQUEST [ 'mid' ]);
$monitor = dbFetchOne ( " select * from Monitors where Id = ' " . dbEscape ( $mid ) . " ' " );
2008-07-14 21:54:50 +08:00
if ( ZM_OPT_X10 )
{
2008-09-26 17:47:20 +08:00
$x10Monitor = dbFetchOne ( " select * from TriggersX10 where MonitorId = ' " . dbEscape ( $mid ) . " ' " );
2008-07-14 21:54:50 +08:00
if ( ! $x10Monitor )
$x10Monitor = array ();
}
}
else
{
$monitor = array ();
if ( ZM_OPT_X10 )
{
$x10Monitor = array ();
}
}
// Define a field type for anything that's not simple text equivalent
$types = array (
'Triggers' => 'set' ,
'Controllable' => 'toggle' ,
'TrackMotion' => 'toggle' ,
2011-02-07 00:08:16 +08:00
'Enabled' => 'toggle'
2008-07-14 21:54:50 +08:00
);
$columns = getTableColumns ( 'Monitors' );
$changes = getFormChanges ( $monitor , $_REQUEST [ 'newMonitor' ], $types , $columns );
if ( count ( $changes ) )
{
if ( ! empty ( $_REQUEST [ 'mid' ]) )
{
2008-09-26 17:47:20 +08:00
$mid = validInt ( $_REQUEST [ 'mid' ]);
$sql = " update Monitors set " . implode ( " , " , $changes ) . " where Id = ' " . dbEscape ( $mid ) . " ' " ;
2008-07-14 21:54:50 +08:00
dbQuery ( $sql );
2008-10-28 22:24:46 +08:00
if ( isset ( $changes [ 'Name' ]) )
2008-07-14 21:54:50 +08:00
{
exec ( escapeshellcmd ( " mv " . ZM_DIR_EVENTS . " / " . $monitor [ 'Name' ] . " " . ZM_DIR_EVENTS . " / " . $_REQUEST [ 'newMonitor' ][ 'Name' ] ) );
}
2008-10-28 22:24:46 +08:00
if ( isset ( $changes [ 'Width' ]) || isset ( $changes [ 'Height' ]) )
2008-07-14 21:54:50 +08:00
{
$newW = $_REQUEST [ 'newMonitor' ][ 'Width' ];
$newH = $_REQUEST [ 'newMonitor' ][ 'Height' ];
$newA = $newW * $newH ;
$oldW = $monitor [ 'Width' ];
$oldH = $monitor [ 'Height' ];
$oldA = $oldW * $oldH ;
2008-09-26 17:47:20 +08:00
$zones = dbFetchAll ( " select * from Zones where MonitorId = ' " . dbEscape ( $mid ) . " ' " );
2008-07-14 21:54:50 +08:00
foreach ( $zones as $zone )
{
$newZone = $zone ;
$points = coordsToPoints ( $zone [ 'Coords' ] );
for ( $i = 0 ; $i < count ( $points ); $i ++ )
{
$points [ $i ][ 'x' ] = intval (( $points [ $i ][ 'x' ] * ( $newW - 1 )) / ( $oldW - 1 ));
$points [ $i ][ 'y' ] = intval (( $points [ $i ][ 'y' ] * ( $newH - 1 )) / ( $oldH - 1 ));
}
$newZone [ 'Coords' ] = pointsToCoords ( $points );
$newZone [ 'Area' ] = intval ( round (( $zone [ 'Area' ] * $newA ) / $oldA ));
$newZone [ 'MinAlarmPixels' ] = intval ( round (( $newZone [ 'MinAlarmPixels' ] * $newA ) / $oldA ));
$newZone [ 'MaxAlarmPixels' ] = intval ( round (( $newZone [ 'MaxAlarmPixels' ] * $newA ) / $oldA ));
$newZone [ 'MinFilterPixels' ] = intval ( round (( $newZone [ 'MinFilterPixels' ] * $newA ) / $oldA ));
$newZone [ 'MaxFilterPixels' ] = intval ( round (( $newZone [ 'MaxFilterPixels' ] * $newA ) / $oldA ));
$newZone [ 'MinBlobPixels' ] = intval ( round (( $newZone [ 'MinBlobPixels' ] * $newA ) / $oldA ));
$newZone [ 'MaxBlobPixels' ] = intval ( round (( $newZone [ 'MaxBlobPixels' ] * $newA ) / $oldA ));
$changes = getFormChanges ( $zone , $newZone , $types );
if ( count ( $changes ) )
{
2008-09-26 17:47:20 +08:00
dbQuery ( " update Zones set " . implode ( " , " , $changes ) . " where MonitorId = ' " . dbEscape ( $mid ) . " ' and Id = ' " . $zone [ 'Id' ] . " ' " );
2008-07-14 21:54:50 +08:00
}
}
}
}
elseif ( ! $user [ 'MonitorIds' ] )
{
$maxSeq = dbFetchOne ( " select max(Sequence) as MaxSequence from Monitors " , " MaxSequence " );
$changes [] = " Sequence = " . ( $maxSeq + 1 );
dbQuery ( " insert into Monitors set " . implode ( " , " , $changes ) );
2008-09-26 17:47:20 +08:00
$mid = dbInsertId ();
2008-07-14 21:54:50 +08:00
$zoneArea = $_REQUEST [ 'newMonitor' ][ 'Width' ] * $_REQUEST [ 'newMonitor' ][ 'Height' ];
2008-09-26 17:47:20 +08:00
dbQuery ( " insert into Zones set MonitorId = " . dbEscape ( $mid ) . " , Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ' " . sprintf ( " %d,%d %d,%d %d,%d %d,%d " , 0 , 0 , $_REQUEST [ 'newMonitor' ][ 'Width' ] - 1 , 0 , $_REQUEST [ 'newMonitor' ][ 'Width' ] - 1 , $_REQUEST [ 'newMonitor' ][ 'Height' ] - 1 , 0 , $_REQUEST [ 'newMonitor' ][ 'Height' ] - 1 ) . " ', Area = " . $zoneArea . " , AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels = " . intval (( $zoneArea * 3 ) / 100 ) . " , MaxAlarmPixels = " . intval (( $zoneArea * 75 ) / 100 ) . " , FilterX = 3, FilterY = 3, MinFilterPixels = " . intval (( $zoneArea * 3 ) / 100 ) . " , MaxFilterPixels = " . intval (( $zoneArea * 75 ) / 100 ) . " , MinBlobPixels = " . intval (( $zoneArea * 2 ) / 100 ) . " , MinBlobs = 1 " );
//$view = 'none';
mkdir ( ZM_DIR_EVENTS . '/' . $mid , 0755 );
symlink ( $mid , ZM_DIR_EVENTS . '/' . $_REQUEST [ 'newMonitor' ][ 'Name' ] );
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
$restart = true ;
2008-07-14 21:54:50 +08:00
}
if ( ZM_OPT_X10 )
{
2008-07-16 16:44:39 +08:00
$x10Changes = getFormChanges ( $x10Monitor , $_REQUEST [ 'newX10Monitor' ] );
2008-07-14 21:54:50 +08:00
2008-07-16 16:44:39 +08:00
if ( count ( $x10Changes ) )
2008-07-14 21:54:50 +08:00
{
2008-07-16 16:44:39 +08:00
if ( $x10Monitor && isset ( $_REQUEST [ 'newX10Monitor' ]) )
2008-07-14 21:54:50 +08:00
{
2009-03-30 16:56:15 +08:00
dbQuery ( " update TriggersX10 set " . implode ( " , " , $x10Changes ) . " where MonitorId = ' " . dbEscape ( $mid ) . " ' " );
2008-07-14 21:54:50 +08:00
}
elseif ( ! $user [ 'MonitorIds' ] )
{
if ( ! $x10Monitor )
{
2009-03-30 16:56:15 +08:00
dbQuery ( " insert into TriggersX10 set MonitorId = ' " . dbEscape ( $mid ) . " ', " . implode ( " , " , $x10Changes ) );
2008-07-14 21:54:50 +08:00
}
else
{
2009-03-30 16:56:15 +08:00
dbQuery ( " delete from TriggersX10 where MonitorId = ' " . dbEscape ( $mid ) . " ' " );
2008-07-14 21:54:50 +08:00
}
}
2008-09-26 17:47:20 +08:00
$restart = true ;
2008-07-14 21:54:50 +08:00
}
}
2008-09-26 17:47:20 +08:00
if ( $restart )
2008-07-14 21:54:50 +08:00
{
2009-03-30 16:56:15 +08:00
$monitor = dbFetchOne ( " select * from Monitors where Id = ' " . dbEscape ( $mid ) . " ' " );
2008-07-14 21:54:50 +08:00
fixDevices ();
2008-07-16 16:44:39 +08:00
//if ( $cookies )
//session_write_close();
2008-07-14 21:54:50 +08:00
if ( daemonCheck () )
{
zmcControl ( $monitor , " restart " );
zmaControl ( $monitor , " restart " );
}
//daemonControl( 'restart', 'zmwatch.pl' );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
$view = 'none' ;
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
if ( $action == " delete " )
2008-07-14 21:54:50 +08:00
{
if ( isset ( $_REQUEST [ 'markMids' ]) && ! $user [ 'MonitorIds' ] )
{
foreach ( $_REQUEST [ 'markMids' ] as $markMid )
{
if ( canEdit ( 'Monitors' , $markMid ) )
{
$sql = " select * from Monitors where Id = ' " . dbEscape ( $markMid ) . " ' " ;
if ( ! ( $monitor = dbFetchOne ( $sql )) )
continue ;
2008-09-02 00:43:34 +08:00
zmaControl ( $monitor , " stop " );
zmcControl ( $monitor , " stop " );
2008-07-14 21:54:50 +08:00
$sql = " select Id from Events where MonitorId = ' " . dbEscape ( $markMid ) . " ' " ;
$markEids = dbFetchAll ( $sql , 'Id' );
foreach ( $markEids as $markEid )
deleteEvent ( $markEid );
unlink ( ZM_DIR_EVENTS . " / " . $monitor [ 'Name' ] );
system ( " rm -rf " . ZM_DIR_EVENTS . " / " . $monitor [ 'Id' ] );
dbQuery ( " delete from Zones where MonitorId = ' " . dbEscape ( $markMid ) . " ' " );
if ( ZM_OPT_X10 )
dbQuery ( " delete from TriggersX10 where MonitorId = ' " . dbEscape ( $markMid ) . " ' " );
dbQuery ( " delete from Monitors where Id = ' " . dbEscape ( $markMid ) . " ' " );
fixSequences ();
}
}
}
}
}
// Device view actions
if ( canEdit ( 'Devices' ) )
{
2008-09-26 17:47:20 +08:00
if ( $action == " device " )
2008-07-14 21:54:50 +08:00
{
if ( ! empty ( $_REQUEST [ 'command' ]) )
{
setDeviceStatusX10 ( $_REQUEST [ 'key' ], $_REQUEST [ 'command' ] );
}
elseif ( isset ( $_REQUEST [ 'newDevice' ] ) )
{
if ( isset ( $_REQUEST [ 'did' ]) )
{
dbQuery ( " update Devices set Name = ' " . dbEscape ( $_REQUEST [ 'newDevice' ][ 'Name' ]) . " ', KeyString = ' " . dbEscape ( $_REQUEST [ 'newDevice' ][ 'KeyString' ]) . " ' where Id = ' " . dbEscape ( $_REQUEST [ 'did' ]) . " ' " );
}
else
{
dbQuery ( " insert into Devices set Name = ' " . dbEscape ( $_REQUEST [ 'newDevice' ][ 'Name' ]) . " ', KeyString = ' " . dbEscape ( $_REQUEST [ 'newDevice' ][ 'KeyString' ]) . " ' " );
}
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
$view = 'none' ;
2008-07-14 21:54:50 +08:00
}
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " delete " )
2008-07-14 21:54:50 +08:00
{
if ( isset ( $_REQUEST [ 'markDids' ]) )
{
foreach ( $_REQUEST [ 'markDids' ] as $markDid )
{
dbQuery ( " delete from Devices where Id = ' " . dbEscape ( $markDid ) . " ' " );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
}
}
}
// System view actions
if ( canView ( 'System' ) )
{
2008-09-26 17:47:20 +08:00
if ( $action == " setgroup " )
2008-07-14 21:54:50 +08:00
{
if ( ! empty ( $_REQUEST [ 'gid' ]) )
{
2008-09-26 17:47:20 +08:00
setcookie ( " zmGroup " , validInt ( $_REQUEST [ 'gid' ]), time () + 3600 * 24 * 30 * 12 * 10 );
2008-07-14 21:54:50 +08:00
}
else
{
setcookie ( " zmGroup " , " " , time () - 3600 * 24 * 2 );
}
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
}
// System edit actions
if ( canEdit ( 'System' ) )
{
2008-10-07 17:02:17 +08:00
if ( $action == " version " && isset ( $_REQUEST [ 'option' ]) )
2008-07-14 21:54:50 +08:00
{
2008-10-07 17:02:17 +08:00
$option = $_REQUEST [ 'option' ];
2008-07-14 21:54:50 +08:00
switch ( $option )
{
case 'go' :
{
// Ignore this, the caller will open the page itself
break ;
}
case 'ignore' :
{
dbQuery ( " update Config set Value = ' " . ZM_DYN_LAST_VERSION . " ' where Name = 'ZM_DYN_CURR_VERSION' " );
break ;
}
case 'hour' :
case 'day' :
case 'week' :
{
$nextReminder = time ();
if ( $option == 'hour' )
{
$nextReminder += 60 * 60 ;
}
elseif ( $option == 'day' )
{
$nextReminder += 24 * 60 * 60 ;
}
elseif ( $option == 'week' )
{
$nextReminder += 7 * 24 * 60 * 60 ;
}
dbQuery ( " update Config set Value = ' " . $nextReminder . " ' where Name = 'ZM_DYN_NEXT_REMINDER' " );
break ;
}
case 'never' :
{
dbQuery ( " update Config set Value = '0' where Name = 'ZM_CHECK_FOR_UPDATES' " );
break ;
}
}
}
2008-10-07 17:02:17 +08:00
if ( $action == " donate " && isset ( $_REQUEST [ 'option' ]) )
2008-07-14 21:54:50 +08:00
{
2008-10-07 17:02:17 +08:00
$option = $_REQUEST [ 'option' ];
2008-07-14 21:54:50 +08:00
switch ( $option )
{
case 'go' :
{
// Ignore this, the caller will open the page itself
break ;
}
case 'hour' :
case 'day' :
case 'week' :
case 'month' :
{
$nextReminder = time ();
if ( $option == 'hour' )
{
$nextReminder += 60 * 60 ;
}
elseif ( $option == 'day' )
{
$nextReminder += 24 * 60 * 60 ;
}
elseif ( $option == 'week' )
{
$nextReminder += 7 * 24 * 60 * 60 ;
}
elseif ( $option == 'month' )
{
$nextReminder += 30 * 24 * 60 * 60 ;
}
dbQuery ( " update Config set Value = ' " . $nextReminder . " ' where Name = 'ZM_DYN_DONATE_REMINDER_TIME' " );
break ;
}
case 'never' :
case 'already' :
{
dbQuery ( " update Config set Value = '0' where Name = 'ZM_DYN_SHOW_DONATE_REMINDER' " );
break ;
}
}
}
2008-10-07 17:02:17 +08:00
if ( $action == " options " && isset ( $_REQUEST [ 'tab' ]) )
2008-07-14 21:54:50 +08:00
{
$configCat = $configCats [ $_REQUEST [ 'tab' ]];
$changed = false ;
foreach ( $configCat as $name => $value )
{
2008-07-18 00:59:25 +08:00
unset ( $newValue );
if ( $value [ 'Type' ] == " boolean " && empty ( $_REQUEST [ 'newConfig' ][ $name ]) )
$newValue = 0 ;
elseif ( isset ( $_REQUEST [ 'newConfig' ][ $name ]) )
$newValue = preg_replace ( " / \r \n / " , " \n " , stripslashes ( $_REQUEST [ 'newConfig' ][ $name ] ) );
2008-07-14 21:54:50 +08:00
2008-07-18 00:59:25 +08:00
if ( isset ( $newValue ) && ( $newValue != $value [ 'Value' ]) )
{
dbQuery ( " update Config set Value = ' " . $newValue . " ' where Name = ' " . $name . " ' " );
$changed = true ;
2008-07-14 21:54:50 +08:00
}
}
if ( $changed )
{
switch ( $_REQUEST [ 'tab' ] )
{
case " system " :
case " config " :
case " paths " :
2008-09-29 16:55:25 +08:00
$restartWarning = true ;
2008-07-14 21:54:50 +08:00
break ;
case " web " :
case " tools " :
break ;
case " debug " :
case " network " :
case " mail " :
case " ftp " :
2008-09-29 16:55:25 +08:00
$restartWarning = true ;
2008-07-14 21:54:50 +08:00
break ;
case " highband " :
case " medband " :
case " lowband " :
case " phoneband " :
break ;
}
}
loadConfig ( false );
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " user " )
2008-07-14 21:54:50 +08:00
{
if ( ! empty ( $_REQUEST [ 'uid' ]) )
$dbUser = dbFetchOne ( " select * from Users where Id = ' " . dbEscape ( $_REQUEST [ 'uid' ]) . " ' " );
else
2008-09-01 22:03:01 +08:00
$dbUser = array ();
2008-07-14 21:54:50 +08:00
$types = array ();
$changes = getFormChanges ( $dbUser , $_REQUEST [ 'newUser' ], $types );
if ( $_REQUEST [ 'newUser' ][ 'Password' ] )
$changes [ 'Password' ] = " Password = password(' " . dbEscape ( $_REQUEST [ 'newUser' ][ 'Password' ]) . " ') " ;
else
unset ( $changes [ 'Password' ] );
if ( count ( $changes ) )
{
if ( ! empty ( $_REQUEST [ 'uid' ]) )
{
$sql = " update Users set " . implode ( " , " , $changes ) . " where Id = ' " . dbEscape ( $_REQUEST [ 'uid' ]) . " ' " ;
}
else
{
$sql = " insert into Users set " . implode ( " , " , $changes );
}
dbQuery ( $sql );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
if ( $dbUser [ 'Username' ] == $user [ 'Username' ] )
userLogin ( $dbUser [ 'Username' ], $dbUser [ 'Password' ] );
}
2008-09-26 17:47:20 +08:00
$view = 'none' ;
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " state " )
2008-07-14 21:54:50 +08:00
{
if ( ! empty ( $_REQUEST [ 'runState' ]) )
{
2008-07-16 16:44:39 +08:00
//if ( $cookies ) session_write_close();
2008-07-14 21:54:50 +08:00
packageControl ( $_REQUEST [ 'runState' ] );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " save " )
2008-07-14 21:54:50 +08:00
{
if ( ! empty ( $_REQUEST [ 'runState' ]) || ! empty ( $_REQUEST [ 'newState' ]) )
{
$sql = " select Id,Function,Enabled from Monitors order by Id " ;
$definitions = array ();
foreach ( dbFetchAll ( $sql ) as $monitor )
{
$definitions [] = $monitor [ 'Id' ] . " : " . $monitor [ 'Function' ] . " : " . $monitor [ 'Enabled' ];
}
$definition = join ( ',' , $definitions );
if ( $_REQUEST [ 'newState' ] )
$_REQUEST [ 'runState' ] = $_REQUEST [ 'newState' ];
dbQuery ( " replace into States set Name = ' " . dbEscape ( $_REQUEST [ 'runState' ]) . " ', Definition = ' " . dbEscape ( $definition ) . " ' " );
}
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " group " )
2008-07-14 21:54:50 +08:00
{
if ( ! empty ( $_REQUEST [ 'gid' ]) )
{
$sql = " update Groups set Name = ' " . dbEscape ( $_REQUEST [ 'newGroup' ][ 'Name' ]) . " ', MonitorIds = ' " . dbEscape ( join ( ',' , $_REQUEST [ 'newGroup' ][ 'MonitorIds' ])) . " ' where Id = ' " . dbEscape ( $_REQUEST [ 'gid' ]) . " ' " ;
}
else
{
$sql = " insert into Groups set Name = ' " . dbEscape ( $_REQUEST [ 'newGroup' ][ 'Name' ]) . " ', MonitorIds = ' " . dbEscape ( join ( ',' , $_REQUEST [ 'newGroup' ][ 'MonitorIds' ])) . " ' " ;
}
dbQuery ( $sql );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
$view = 'none' ;
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
elseif ( $action == " delete " )
2008-07-14 21:54:50 +08:00
{
if ( isset ( $_REQUEST [ 'runState' ]) )
dbQuery ( " delete from States where Name = ' " . dbEscape ( $_REQUEST [ 'runState' ]) . " ' " );
if ( isset ( $_REQUEST [ 'markUids' ]) )
{
foreach ( $_REQUEST [ 'markUids' ] as $markUid )
dbQuery ( " delete from Users where Id = ' " . dbEscape ( $markUid ) . " ' " );
if ( $markUid == $user [ 'Id' ] )
userLogout ();
}
if ( ! empty ( $_REQUEST [ 'gid' ]) )
{
dbQuery ( " delete from Groups where Id = ' " . dbEscape ( $_REQUEST [ 'gid' ]) . " ' " );
2011-02-07 00:11:56 +08:00
if ( isset ( $_COOKIE [ 'zmGroup' ]) )
2008-07-14 21:54:50 +08:00
{
2011-02-07 00:11:56 +08:00
if ( $_REQUEST [ 'gid' ] == $_COOKIE [ 'zmGroup' ] )
{
unset ( $_COOKIE [ 'zmGroup' ] );
setcookie ( " zmGroup " , " " , time () - 3600 * 24 * 2 );
$refreshParent = true ;
}
2008-07-14 21:54:50 +08:00
}
}
}
}
else
{
2008-09-26 17:47:20 +08:00
if ( ZM_USER_SELF_EDIT && $action == " user " )
2008-07-14 21:54:50 +08:00
{
$uid = $user [ 'Id' ];
$dbUser = dbFetchOne ( " select Id, Password, Language from Users where Id = ' " . dbEscape ( $uid ) . " ' " );
$types = array ();
$changes = getFormChanges ( $dbUser , $_REQUEST [ 'newUser' ], $types );
2008-09-26 17:47:20 +08:00
if ( ! empty ( $_REQUEST [ 'newUser' ][ 'Password' ]) )
$changes [ 'Password' ] = " Password = password(' " . dbEscape ( $_REQUEST [ 'newUser' ][ 'Password' ]) . " ') " ;
2008-07-14 21:54:50 +08:00
else
unset ( $changes [ 'Password' ] );
if ( count ( $changes ) )
{
$sql = " update Users set " . implode ( " , " , $changes ) . " where Id = ' " . dbEscape ( $uid ) . " ' " ;
dbQuery ( $sql );
2008-09-26 17:47:20 +08:00
$refreshParent = true ;
2008-07-14 21:54:50 +08:00
}
2008-09-26 17:47:20 +08:00
$view = 'none' ;
2008-07-14 21:54:50 +08:00
}
}
2008-09-26 17:47:20 +08:00
if ( $action == " reset " )
2008-07-14 21:54:50 +08:00
{
$_SESSION [ 'zmEventResetTime' ] = strftime ( STRF_FMT_DATETIME_DB );
setcookie ( " zmEventResetTime " , $_SESSION [ 'zmEventResetTime' ], time () + 3600 * 24 * 30 * 12 * 10 );
2008-07-16 16:44:39 +08:00
//if ( $cookies ) session_write_close();
2008-07-14 21:54:50 +08:00
}
}
?>