diff --git a/web/zm_actions.php b/web/zm_actions.php index 0b6185a45..bdc2f1bf4 100644 --- a/web/zm_actions.php +++ b/web/zm_actions.php @@ -26,7 +26,20 @@ if ( $action ) { userLogin( $username, $password ); } - elseif ( canEdit( 'Events' ) ) + elseif ( $action == "logout" ) + { + userLogout(); + $refresh_parent = true; + $view = 'none'; + } + elseif ( $action == "bandwidth" && $new_bandwidth ) + { + $bandwidth = $new_bandwidth; + setcookie( "bandwidth", $new_bandwidth, time()+3600*24*30*12*10 ); + $refresh_parent = true; + $view = 'none'; + } + if ( canEdit( 'Events' ) ) { if ( $action == "rename" && $event_name && $eid ) { @@ -111,7 +124,7 @@ if ( $action ) } } } - elseif ( canEdit( 'Settings' ) ) + if ( canEdit( 'Monitors', $mid ) ) { if ( $action == "function" && $mid ) { @@ -255,7 +268,7 @@ if ( $action ) exec( escapeshellcmd( "mv ".EVENTS_PATH."/$monitor[Name] ".EVENTS_PATH."/$new_name" ) ); } } - else + elseif ( !$user[MonitorIds] ) { $sql = "insert into Monitors set ".implode( ", ", $changes ); $result = mysql_query( $sql ); @@ -303,7 +316,7 @@ if ( $action ) $refresh_parent = true; } } - if ( $mark_mids ) + if ( $mark_mids && !$user[MonitorIds] ) { foreach( $mark_mids as $mark_mid ) { @@ -342,6 +355,70 @@ if ( $action ) } } } + if ( canEdit( 'System' ) ) + { + if ( $action == "user" && isset( $uid ) ) + { + if ( $uid > 0 ) + { + $result = mysql_query( "select * from Users where Id = '$uid'" ); + if ( !$result ) + die( mysql_error() ); + $row = mysql_fetch_assoc( $result ); + } + else + { + $zone = array(); + } + + $changes = array(); + if ( $new_username != $row[Username] ) $changes[] = "Username = '$new_username'"; + if ( $new_password != $row[Password] ) $changes[] = "Password = password('$new_password')"; + if ( $new_enabled != $row[Enabled] ) $changes[] = "Enabled = '$new_enabled'"; + if ( $new_stream != $row[Stream] ) $changes[] = "Stream = '$new_stream'"; + if ( $new_events != $row[Events] ) $changes[] = "Events = '$new_events'"; + if ( $new_monitors != $row[Monitors] ) $changes[] = "Monitors = '$new_monitors'"; + if ( $new_system != $row[System] ) $changes[] = "System = '$new_system'"; + if ( $new_monitor_ids != $row[MonitorIds] ) $changes[] = "MonitorIds = '$new_monitor_ids'"; + + if ( count( $changes ) ) + { + if ( $uid > 0 ) + { + $sql = "update Users set ".implode( ", ", $changes )." where Id = '$uid'"; + } + else + { + $sql = "insert into Users set ".implode( ", ", $changes ); + } + $result = mysql_query( $sql ); + if ( !$result ) + die( mysql_error() ); + $view = 'none'; + $refresh_parent = true; + if ( $row[Username] == $user[Username] ) + { + userLogin( $row[Username], $row[Password] ); + } + } + } + elseif ( $action == "delete" ) + { + if ( $mark_uids ) + { + foreach( $mark_uids as $mark_uid ) + { + $result = mysql_query( "delete from Users where Id = '$mark_uid'" ); + if ( !$result ) + die( mysql_error() ); + } + if ( $row[Username] == $user[Username] ) + { + userLogout(); + } + } + } + } if ( $action == "learn" ) { if ( !$mark_eids && $mark_eid ) diff --git a/web/zm_config.php.z b/web/zm_config.php.z index e080c0131..69cee5256 100644 --- a/web/zm_config.php.z +++ b/web/zm_config.php.z @@ -160,6 +160,10 @@ $jws = array( 'video' => array( 'w'=>100, 'h'=>80 ), 'image' => array( 'w'=>48, 'h'=>80 ), 'stats' => array( 'w'=>600, 'h'=>150 ), + 'options' => array( 'w'=>600, 'h'=>400 ), + 'user' => array( 'w'=>230, 'h'=>320 ), 'settings' => array( 'w'=>200, 'h'=>225 ), + 'logout' => array( 'w'=>200, 'h'=>100 ), + 'bandwidth' => array( 'w'=>200, 'h'=>90 ), ); ?> diff --git a/web/zm_funcs.php b/web/zm_funcs.php index a2756044f..124842548 100644 --- a/web/zm_funcs.php +++ b/web/zm_funcs.php @@ -21,9 +21,9 @@ function userLogin( $username, $password ) { - global $HTTP_SESSION_VARS; + global $user, $HTTP_SESSION_VARS; - $sql = "select * from Users where Username = '$username' and Password = password('$password')"; + $sql = "select * from Users where Username = '$username' and Password = password('$password') and Enabled = 1"; $result = mysql_query( $sql ); if ( !$result ) echo mysql_error(); @@ -31,34 +31,43 @@ function userLogin( $username, $password ) { $HTTP_SESSION_VARS[user] = $user; } -} - -function canView( $area ) -{ - global $user; - - return( $user[$area] == 'View' || $user[$area] == 'Edit' ); -} - -function canEdit( $area ) -{ - global $user; - - return( $user[$area] == 'Edit' ); -} - -function deleteUser( $uid ) -{ - global $user; - - if ( $user[Users] == 'Edit' && $uid ) + else { - $result = mysql_query( "delete from Users where Id = '$uid'" ); - if ( !$result ) - die( mysql_error() ); + $HTTP_SESSION_VARS[user] = array(); } } +function userLogout() +{ + global $user, $HTTP_SESSION_VARS; + + unset( $HTTP_SESSION_VARS[user] ); + unset( $user ); + + session_destroy(); +} + +function visibleMonitor( $mid ) +{ + global $user; + + return( !$user[MonitorIds] || in_array( $mid, split( ',', $user[MonitorIds] ) ) ); +} + +function canView( $area, $mid=false ) +{ + global $user; + + return( ($user[$area] == 'View' || $user[$area] == 'Edit') && ( !$mid || visibleMonitor( $mid ) ) ); +} + +function canEdit( $area, $mid=false ) +{ + global $user; + + return( $user[$area] == 'Edit' && ( !$mid || visibleMonitor( $mid ) ) ); +} + function deleteEvent( $eid ) { global $user; diff --git a/web/zm_html.php b/web/zm_html.php index 1067410e8..b46f7a2c3 100644 --- a/web/zm_html.php +++ b/web/zm_html.php @@ -24,22 +24,11 @@ if ( !$bandwidth ) $new_bandwidth = "low"; } -if ( $new_bandwidth ) -{ - $bandwidth = $new_bandwidth; - setcookie( "bandwidth", $new_bandwidth, time()+3600*24*30*12*10 ); -} - ini_set( "session.use_trans_sid", "0" ); ini_set( "session.name", "ZMSESSID" ); session_start(); -require_once( 'zm_config.php' ); -require_once( 'zm_db.php' ); -require_once( 'zm_funcs.php' ); -require_once( 'zm_actions.php' ); - if ( ZM_OPT_USE_AUTH ) { $user = $HTTP_SESSION_VARS[user]; @@ -49,14 +38,19 @@ else $user = array( "Username"=>"admin", "Password"=>"", - "Active"=>1, - "Feed"=>'View', - "Event"=>'Edit', - "Settings"=>'Edit', - "Users"=>'None', + "Enabled"=>1, + "Stream"=>'View', + "Events"=>'Edit', + "Monitors"=>'Edit', + "System"=>'Edit', ); } +require_once( 'zm_config.php' ); +require_once( 'zm_db.php' ); +require_once( 'zm_funcs.php' ); +require_once( 'zm_actions.php' ); + if ( !$user ) { $view = "login"; @@ -117,6 +111,36 @@ window.setTimeout( "window.location.replace('')", 250 ); + + + +ZM - Logout + + + + + + + + + + + + + +
ZoneMinder Logout
Current login is ''
+ + ')", 250 ); $cycle_count = 0; while( $row = mysql_fetch_assoc( $result ) ) { + if ( !visibleMonitor( $row[Id] ) ) + { + continue; + } $row['zmc'] = zmcCheck( $row ); $row['zma'] = zmaCheck( $row ); //$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]'"; @@ -180,6 +208,10 @@ window.setTimeout( "window.location.replace('')", 250 ); + + + + + + + +"high", "medium"=>"medium", "low"=>"low" ); + $new_bandwidth = $bandwidth; +?> + + + + +
Set New Bandwidth
+ + + + + +ZM - Options + + + + + + + + + + + + +
Users    
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdUsernamePasswordEnabledStreamEventsMonitorsSystemMonitor IdsMark
******** disabled>
 
disabled 
+ + + + + +ZM - User - <?= $row[Username] ?> + + + + + + + + + + + + + + + +'No', 1=>'Yes' ); +?> + +'None', 'View'=>'View' ); +?> + +'None', 'View'=>'View', 'Edit'=>'Edit' ); +?> + + + + + + + +
User - ""
Username
New Password
Confirm Password
Enabled
Stream
Events
Monitors
System
Restricted Camera Ids
+ + ')", ); } case "montagestatus" : { - if ( !canView( 'Feed' ) ) + if ( !canView( 'Stream' ) ) { $view = "error"; break; @@ -716,7 +1026,7 @@ window.setTimeout( "window.location.reload(true)", ); } case "watch" : { - if ( !canView( 'Feed' ) ) + if ( !canView( 'Stream' ) ) { $view = "error"; break; @@ -745,7 +1055,7 @@ window.focus(); } case "watchfeed" : { - if ( !canView( 'Feed' ) ) + if ( !canView( 'Stream' ) ) { $view = "error"; break; @@ -805,7 +1115,7 @@ window.setTimeout( "window.location.reload(true)", ); - + @@ -851,7 +1161,7 @@ window.setTimeout( "window.location.reload(true)", ); } case "settings" : { - if ( !canView( 'Settings' ) ) + if ( !canView( 'Monitors' ) ) { $view = "error"; break; @@ -902,12 +1212,12 @@ function closeWindow() - - - - + + + + - +
Settings  
ParameterValue
Brightness disabled>
Contrast disabled>
Hue disabled>
Colour disabled>
Brightness disabled>
Contrast disabled>
Hue disabled>
Colour disabled>
disabled>   disabled>  
@@ -917,13 +1227,13 @@ function closeWindow() } case "watchstatus" : { - if ( !canView( 'Feed' ) ) + if ( !canView( 'Stream' ) ) { $view = "error"; break; } $zmu_command = ZMU_PATH." -m $mid -s -f"; - if ( canEdit( 'Settings' ) && isset($force) ) + if ( canEdit( 'Monitors' ) && isset($force) ) { $zmu_command .= ($force?" -a":" -c"); } @@ -993,13 +1303,13 @@ window.setTimeout( "window.location.replace( '' )",   Status:  -  fps Cancel Forced Alarm Force Alarm @@ -1890,6 +2200,7 @@ function newWindow(Url,Name,Width,Height) + disabled> @@ -1897,6 +2208,7 @@ function newWindow(Url,Name,Width,Height)
+ @@ -1906,11 +2218,11 @@ Learn Pref:  - - + +
Prev Delete & Prev Delete & Next Delete & Prev Delete & Next  Next 
@@ -2087,7 +2399,7 @@ function closeWindow() } function deleteEvent() { - location.href = "?view=none&action=delete&mark_eid="; + location.href = "?view=none&action=delete&mid=&mark_eid="; //window.close(); } @@ -2209,7 +2521,7 @@ function closeWindow() } case "monitor" : { - if ( !canView( 'Settings' ) ) + if ( !canView( 'Monitors' ) ) { $view = "error"; break; @@ -2341,7 +2653,7 @@ $source_types = array( "Local"=>"Local", "Remote"=>"Remote" );     - disabled>   + disabled>   @@ -2351,7 +2663,7 @@ $source_types = array( "Local"=>"Local", "Remote"=>"Remote" ); } case "zones" : { - if ( !canView( 'Settings' ) ) + if ( !canView( 'Monitors' ) ) { $view = "error"; break; @@ -2459,14 +2771,14 @@ function configureButton(form,name) ,-, - disabled> + disabled>   - disabled> + disabled>
@@ -2478,7 +2790,7 @@ function configureButton(form,name) } case "zone" : { - if ( !canView( 'Settings' ) ) + if ( !canView( 'Monitors' ) ) { $view = "error"; break; @@ -2760,7 +3072,7 @@ function closeWindow()     - disabled>   + disabled>   @@ -2848,7 +3160,7 @@ location.replace(''); } case "function" : { - if ( !canEdit( 'Settings' ) ) + if ( !canEdit( 'Monitors' ) ) { $view = "error"; break; diff --git a/web/zm_styles.css b/web/zm_styles.css index 522c569f9..b891ce3b2 100644 --- a/web/zm_styles.css +++ b/web/zm_styles.css @@ -17,19 +17,129 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -.text { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px; color: #333333; font-weight: normal } -.redtext { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px; color: #DC143C; font-weight: bold } -.ambtext { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px; color: #FF8C00; font-weight: bold } -.blutext { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px; color: #48D1CC; font-weight: bold } -.gretext { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px; color: #688E23; font-weight: bold } -.smallhead { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px; color: #016A9D; font-weight: bold; line-height: 20px } -.head { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:11px; color: #000066; font-weight: bold } -.bighead { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12px; color: #000066; font-weight: bold } -a:link { color: #7F7FB2; text-decoration: none } -a:visited { color: #7F7FB2; text-decoration: none } -a:hover { color: #666699; text-decoration: underline} -.form { border: 1px #7F7FB2 solid; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #333333 } -.textsmall { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:9px; color: #333333; font-weight: normal } -.closetext { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:10px; color: #333333; font-weight: normal; line-height: 12px } -img.normal { border: white solid 1px } -img.alarm { border: red solid 1px } +.text { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #333333; + font-weight: normal +} +.redtext { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #DC143C; + font-weight: bold +} +.ambtext { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #FF8C00; + font-weight: bold +} +.blutext { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #48D1CC; + font-weight: bold +} +.gretext { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #688E23; + font-weight: bold +} +.smallhead { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #016A9D; + font-weight: bold; + line-height: 20px +} +.head { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:11px; + color: #000066; + font-weight: bold +} +.bighead { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:12px; + color: #000066; + font-weight: bold +} +a:link { + color: #7F7FB2; + text-decoration: none +} +a:visited { + color: #7F7FB2; + text-decoration: none +} +a:hover { + color: #666699; + text-decoration: underline +} +.form { + border: 1px #7F7FB2 solid; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + color: #333333 +} +.textsmall { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:9px; + color: #333333; + font-weight: normal +} +.closetext { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #333333; + font-weight: normal; + line-height: 12px +} +img.normal { + border: white solid 1px +} +img.alarm { + border: red solid 1px +} +td.activetab { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #333333; + font-weight: bold; + border-left: #7F7FB2 solid 2px; + border-top: #7F7FB2 solid 2px; + border-right: #7F7FB2 solid 2px; + border-bottom: #7F7FB2 dotted 1px; + text-align: center; +} +td.passivetab { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #333333; + font-weight: normal; + border: #7F7FB2 solid 1px; + background: #EEEEEE; + text-align: center; +} +td.nontab { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #333333; + font-weight: normal; + border-bottom: #7F7FB2 solid 1px; +} +td.ruled { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size:10px; + color: #333333; + font-weight: normal; + border-top: #7F7FB2 solid 1px; +} +tr.over { + background: #EEEEEE; +} +tr.out { + background: #FFFFFF; +}