2008-07-14 21:54:50 +08:00
< ? php
//
// ZoneMinder web options view 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
2016-12-26 23:23:16 +08:00
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2008-07-14 21:54:50 +08:00
//
2018-09-08 04:31:11 +08:00
if ( ! canView ( 'System' ) ) {
2017-09-27 05:14:27 +08:00
$view = 'error' ;
return ;
2008-07-14 21:54:50 +08:00
}
2018-09-08 04:31:11 +08:00
$canEdit = canEdit ( 'System' );
2008-10-09 17:15:53 +08:00
2008-07-14 21:54:50 +08:00
$tabs = array ();
2015-05-22 01:23:31 +08:00
$tabs [ 'skins' ] = translate ( 'Display' );
2015-05-10 21:10:30 +08:00
$tabs [ 'system' ] = translate ( 'System' );
$tabs [ 'config' ] = translate ( 'Config' );
2019-05-12 01:39:40 +08:00
$tabs [ 'API' ] = translate ( 'API' );
2015-07-09 23:41:46 +08:00
$tabs [ 'servers' ] = translate ( 'Servers' );
2015-12-16 00:13:21 +08:00
$tabs [ 'storage' ] = translate ( 'Storage' );
2015-05-10 21:10:30 +08:00
$tabs [ 'web' ] = translate ( 'Web' );
$tabs [ 'images' ] = translate ( 'Images' );
$tabs [ 'logging' ] = translate ( 'Logging' );
$tabs [ 'network' ] = translate ( 'Network' );
$tabs [ 'mail' ] = translate ( 'Email' );
$tabs [ 'upload' ] = translate ( 'Upload' );
$tabs [ 'x10' ] = translate ( 'X10' );
$tabs [ 'highband' ] = translate ( 'HighBW' );
$tabs [ 'medband' ] = translate ( 'MediumBW' );
$tabs [ 'lowband' ] = translate ( 'LowBW' );
$tabs [ 'users' ] = translate ( 'Users' );
2020-09-26 10:46:54 +08:00
$tabs [ 'control' ] = translate ( 'Control' );
2008-07-14 21:54:50 +08:00
2008-09-26 17:47:20 +08:00
if ( isset ( $_REQUEST [ 'tab' ]) )
2017-09-27 05:14:27 +08:00
$tab = validHtmlStr ( $_REQUEST [ 'tab' ]);
2008-09-26 17:47:20 +08:00
else
2017-09-27 05:14:27 +08:00
$tab = 'system' ;
2008-07-14 21:54:50 +08:00
$focusWindow = true ;
2018-09-08 04:31:11 +08:00
xhtmlHeaders ( __FILE__ , translate ( 'Options' ));
2016-03-24 04:12:51 +08:00
2008-07-14 21:54:50 +08:00
?>
< body >
2018-09-08 04:31:11 +08:00
< ? php echo getNavBarHTML (); ?>
2020-09-26 20:30:15 +08:00
< div class = " container-fluid " >
< div class = " row flex-nowrap " >
< nav id = " sidebar " >
2020-08-02 23:20:18 +08:00
< ul class = " nav nav-pills flex-column h-100 " >
2008-07-14 21:54:50 +08:00
< ? php
2017-09-27 05:14:27 +08:00
foreach ( $tabs as $name => $value ) {
2008-07-14 21:54:50 +08:00
?>
2020-07-30 03:00:44 +08:00
< li class = " nav-item form-control-sm my-1 " >< a class = " nav-link<?php echo $tab == $name ? ' active' : '' ?> " href = " ?view=<?php echo $view ?>&tab=<?php echo $name ?> " >< ? php echo $value ?> </a></li>
2008-07-14 21:54:50 +08:00
< ? php
}
?>
2017-09-27 05:14:27 +08:00
</ ul >
2020-07-26 02:18:09 +08:00
</ nav >
2020-08-11 04:48:20 +08:00
< div class = " container-fluid col-sm-offset-2 h-100 pr-0 " >
2018-09-08 04:31:11 +08:00
< br />
2017-09-27 05:14:27 +08:00
< div id = " options " >
2008-07-14 21:54:50 +08:00
< ? php
2017-09-27 05:14:27 +08:00
if ( $tab == 'skins' ) {
2010-11-24 09:35:12 +08:00
?>
2020-07-27 10:33:29 +08:00
< form name = " optionsForm " method = " get " action = " ? " >
2017-09-27 05:14:27 +08:00
< input type = " hidden " name = " view " value = " <?php echo $view ?> " />
< input type = " hidden " name = " tab " value = " <?php echo $tab ?> " />
2020-07-26 02:18:09 +08:00
< div class = " form-group row " >
< label for = " skin " class = " col-sm-3 col-form-label " >< ? php echo translate ( 'Skin' ) ?> </label>
2017-09-27 05:14:27 +08:00
< div class = " col-sm-6 " >
2019-09-18 00:06:54 +08:00
< select name = " skin " class = " form-control chosen " >
2017-10-02 21:11:55 +08:00
< ? php
2019-09-18 00:06:54 +08:00
# Have to do this stuff up here before including header.php because fof the cookie setting
2020-07-27 10:33:29 +08:00
$skin_options = array_map ( 'basename' , glob ( 'skins/*' , GLOB_ONLYDIR ));
2018-09-08 04:31:11 +08:00
foreach ( $skin_options as $dir ) {
2019-09-18 00:06:54 +08:00
echo '<option value="' . $dir . '" ' . ( $skin == $dir ? 'SELECTED="SELECTED"' : '' ) . '>' . $dir . '</option>' ;
2017-10-02 21:11:55 +08:00
}
?>
2017-10-01 02:19:32 +08:00
</ select >
2020-07-26 02:18:09 +08:00
< span class = " form-text " >< ? php echo translate ( 'SkinDescription' ); ?> </span>
2017-10-01 02:19:32 +08:00
</ div >
</ div >
2020-07-26 02:18:09 +08:00
< div class = " form-group row " >
< label for = " css " class = " col-sm-3 col-form-label " > CSS </ label >
2017-10-02 21:11:55 +08:00
< div class = " col-sm-6 " >
2019-09-18 00:06:54 +08:00
< select name = " css " class = " form-control chosen " >
2017-10-02 21:11:55 +08:00
< ? php
2020-07-27 10:33:29 +08:00
foreach ( array_map ( 'basename' , glob ( 'skins/' . $skin . '/css/*' , GLOB_ONLYDIR )) as $dir ) {
2019-09-18 00:06:54 +08:00
echo '<option value="' . $dir . '" ' . ( $css == $dir ? 'SELECTED="SELECTED"' : '' ) . '>' . $dir . '</option>' ;
2017-10-02 21:11:55 +08:00
}
?>
</ select >
2020-07-26 02:18:09 +08:00
< span class = " form-text " >< ? php echo translate ( 'CSSDescription' ); ?> </span>
2017-10-02 21:11:55 +08:00
</ div >
</ div >
< div id = " contentButtons " >
2019-09-29 00:58:17 +08:00
< button value = " Save " type = " submit " >< ? php echo translate ( 'Save' ) ?> </button>
2017-10-02 21:11:55 +08:00
</ div >
</ form >
2019-05-12 01:39:40 +08:00
< ? php
2017-09-27 05:14:27 +08:00
} else if ( $tab == 'users' ) {
2008-07-14 21:54:50 +08:00
?>
2019-02-10 13:39:19 +08:00
< form name = " userForm " method = " post " action = " ? " >
2014-12-05 07:44:23 +08:00
< input type = " hidden " name = " view " value = " <?php echo $view ?> " />
< input type = " hidden " name = " tab " value = " <?php echo $tab ?> " />
2008-07-14 21:54:50 +08:00
< input type = " hidden " name = " action " value = " delete " />
2018-09-08 04:31:11 +08:00
< table id = " contentTable " class = " table table-striped " >
2018-03-26 23:50:14 +08:00
< thead class = " thead-highlight " >
2008-07-14 21:54:50 +08:00
< tr >
2015-05-10 21:10:30 +08:00
< th class = " colUsername " >< ? php echo translate ( 'Username' ) ?> </th>
< th class = " colLanguage " >< ? php echo translate ( 'Language' ) ?> </th>
< th class = " colEnabled " >< ? php echo translate ( 'Enabled' ) ?> </th>
< th class = " colStream " >< ? php echo translate ( 'Stream' ) ?> </th>
< th class = " colEvents " >< ? php echo translate ( 'Events' ) ?> </th>
< th class = " colControl " >< ? php echo translate ( 'Control' ) ?> </th>
< th class = " colMonitors " >< ? php echo translate ( 'Monitors' ) ?> </th>
2015-08-16 01:24:48 +08:00
< th class = " colGroups " >< ? php echo translate ( 'Groups' ) ?> </th>
2015-05-10 21:10:30 +08:00
< th class = " colSystem " >< ? php echo translate ( 'System' ) ?> </th>
2020-10-01 23:51:59 +08:00
< th class = " colDevices " >< ? php echo translate ( 'Devices' ) ?> </th>
2015-05-10 21:10:30 +08:00
< th class = " colBandwidth " >< ? php echo translate ( 'Bandwidth' ) ?> </th>
< th class = " colMonitor " >< ? php echo translate ( 'Monitor' ) ?> </th>
2019-05-29 22:28:25 +08:00
< ? php if ( ZM_OPT_USE_API ) { ?> <th class="colAPIEnabled"><?php echo translate('APIEnabled') ?></th><?php } ?>
2015-05-10 21:10:30 +08:00
< th class = " colMark " >< ? php echo translate ( 'Mark' ) ?> </th>
2008-07-14 21:54:50 +08:00
</ tr >
</ thead >
< tbody >
< ? php
2018-09-08 04:31:11 +08:00
$sql = 'SELECT * FROM Monitors ORDER BY Sequence ASC' ;
2008-07-14 21:54:50 +08:00
$monitors = array ();
2020-06-24 10:19:46 +08:00
foreach ( dbFetchAll ( $sql ) as $monitor ) {
2017-09-27 05:14:27 +08:00
$monitors [ $monitor [ 'Id' ]] = $monitor ;
2008-07-14 21:54:50 +08:00
}
2018-09-08 04:31:11 +08:00
$sql = 'SELECT * FROM Users ORDER BY Username' ;
2020-06-24 10:19:46 +08:00
foreach ( dbFetchAll ( $sql ) as $user_row ) {
2017-09-27 05:14:27 +08:00
$userMonitors = array ();
2020-06-24 10:19:46 +08:00
if ( ! empty ( $user_row [ 'MonitorIds' ]) ) {
foreach ( explode ( ',' , $user_row [ 'MonitorIds' ]) as $monitorId ) {
2018-09-18 20:52:43 +08:00
// A deleted monitor will cause an error since we don't update
// the user monitors list on monitor delete
2020-06-24 10:19:46 +08:00
if ( ! isset ( $monitors [ $monitorId ]) ) continue ;
2017-09-27 05:14:27 +08:00
$userMonitors [] = $monitors [ $monitorId ][ 'Name' ];
2008-07-14 21:54:50 +08:00
}
2017-09-27 05:14:27 +08:00
}
2020-06-24 10:19:46 +08:00
ZM\Logger :: Debug ( " monitors: " . $user_row [ 'Username' ] . ' ' . $user_row [ 'MonitorIds' ] . ' :' . print_r ( $userMonitors , true ));
2008-07-14 21:54:50 +08:00
?>
< tr >
2020-08-27 02:52:10 +08:00
< td class = " colUsername " >< ? php echo makeLink ( '?view=user&uid=' . $user_row [ 'Id' ], validHtmlStr ( $user_row [ 'Username' ]) . ( $user [ 'Username' ] == $user_row [ 'Username' ] ? '*' : '' ), $canEdit ) ?> </td>
2020-06-24 10:19:46 +08:00
< td class = " colLanguage " >< ? php echo $user_row [ 'Language' ] ? validHtmlStr ( $user_row [ 'Language' ]) : 'default' ?> </td>
< td class = " colEnabled " >< ? php echo translate ( $user_row [ 'Enabled' ] ? 'Yes' : 'No' ) ?> </td>
< td class = " colStream " >< ? php echo validHtmlStr ( $user_row [ 'Stream' ]) ?> </td>
< td class = " colEvents " >< ? php echo validHtmlStr ( $user_row [ 'Events' ]) ?> </td>
< td class = " colControl " >< ? php echo validHtmlStr ( $user_row [ 'Control' ]) ?> </td>
< td class = " colMonitors " >< ? php echo validHtmlStr ( $user_row [ 'Monitors' ]) ?> </td>
< td class = " colGroups " >< ? php echo validHtmlStr ( $user_row [ 'Groups' ]) ?> </td>
< td class = " colSystem " >< ? php echo validHtmlStr ( $user_row [ 'System' ]) ?> </td>
2020-10-01 23:51:59 +08:00
< td class = " colDevices " >< ? php echo validHtmlStr ( $user_row [ 'Devices' ]) ?> </td>
2020-06-24 10:19:46 +08:00
< td class = " colBandwidth " >< ? php echo $user_row [ 'MaxBandwidth' ] ? $bandwidth_options [ $user_row [ 'MaxBandwidth' ]] : ' ' ?> </td>
< td class = " colMonitor " >< ? php echo count ( $userMonitors ) ? ( join ( ', ' , $userMonitors )) : ' ' ?> </td>
< ? php if ( ZM_OPT_USE_API ) { ?> <td class="colAPIEnabled"><?php echo translate($user_row['APIEnabled']?'Yes':'No') ?></td><?php } ?>
< td class = " colMark " >< input type = " checkbox " name = " markUids[] " value = " <?php echo $user_row['Id'] ?> " data - on - click - this = " configureDeleteButton " < ? php if ( ! $canEdit ) { ?> disabled="disabled"<?php } ?>/></td>
2008-07-14 21:54:50 +08:00
</ tr >
< ? php
}
?>
</ tbody >
</ table >
< div id = " contentButtons " >
2020-10-04 06:12:44 +08:00
< ? php echo makeButton ( '?view=user&uid=0' , 'AddNewUser' , canEdit ( 'System' )); ?>
2017-12-13 00:15:53 +08:00
< button type = " submit " class = " btn-danger " name = " deleteBtn " value = " Delete " disabled = " disabled " >< ? php echo translate ( 'Delete' ) ?> </button>
2008-07-14 21:54:50 +08:00
</ div >
</ form >
2020-09-16 21:30:45 +08:00
< ? php
2020-09-26 10:46:54 +08:00
} else if ( $tab == 'control' ) {
if ( canView ( 'Control' ) ) {
$redirect = '?view=controlcaps' ;
} else {
$redirect = '?view=error' ;
}
// Have to do this
header ( 'Location: ' . $redirect );
2020-09-16 21:30:45 +08:00
} else if ( $tab == 'servers' ) {
?>
2019-02-10 13:39:19 +08:00
< form name = " serversForm " method = " post " action = " ? " >
2015-07-09 23:41:46 +08:00
< input type = " hidden " name = " view " value = " <?php echo $view ?> " />
< input type = " hidden " name = " tab " value = " <?php echo $tab ?> " />
< input type = " hidden " name = " action " value = " delete " />
< input type = " hidden " name = " object " value = " server " />
2017-10-16 23:31:01 +08:00
< table id = " contentTable " class = " table table-striped " >
2018-03-26 23:50:14 +08:00
< thead class = " thead-highlight " >
2015-07-09 23:41:46 +08:00
< tr >
2017-10-16 23:31:01 +08:00
< th class = " colName " >< ? php echo translate ( 'Name' ) ?> </th>
2018-11-22 23:04:33 +08:00
< th class = " colUrl " >< ? php echo translate ( 'Url' ) ?> </th>
2018-11-28 06:35:25 +08:00
< th class = " colPathToIndex " >< ? php echo translate ( 'PathToIndex' ) ?> </th>
< th class = " colPathToZMS " >< ? php echo translate ( 'PathToZMS' ) ?> </th>
2018-11-30 03:26:30 +08:00
< th class = " colPathToApi " >< ? php echo translate ( 'PathToApi' ) ?> </th>
2017-10-25 03:43:32 +08:00
< th class = " colStatus " >< ? php echo translate ( 'Status' ) ?> </th>
2017-11-28 03:56:48 +08:00
< th class = " colMonitorCount " >< ? php echo translate ( 'Monitors' ) ?> </th>
2017-10-25 07:08:52 +08:00
< th class = " colCpuLoad " >< ? php echo translate ( 'CpuLoad' ) ?> </th>
2017-10-25 03:43:32 +08:00
< th class = " colMemory " >< ? php echo translate ( 'Free' ) . '/' . translate ( 'Total' ) . ' ' . translate ( 'Memory' ) ?> </th>
< th class = " colSwap " >< ? php echo translate ( 'Free' ) . '/' . translate ( 'Total' ) . ' ' . translate ( 'Swap' ) ?> </th>
2018-01-11 01:59:27 +08:00
< th class = " colStats " >< ? php echo translate ( 'RunStats' ) ?> </th>
< th class = " colAudit " >< ? php echo translate ( 'RunAudit' ) ?> </th>
< th class = " colTrigger " >< ? php echo translate ( 'RunTrigger' ) ?> </th>
2019-02-27 22:29:11 +08:00
< th class = " colEventNotification " >< ? php echo translate ( 'RunEventNotification' ) ?> </th>
2015-07-09 23:41:46 +08:00
< th class = " colMark " >< ? php echo translate ( 'Mark' ) ?> </th>
</ tr >
</ thead >
< tbody >
2020-09-16 21:30:45 +08:00
< ? php
$monitor_counts = dbFetchAssoc ( 'SELECT Id,(SELECT COUNT(Id) FROM Monitors WHERE ServerId=Servers.Id) AS MonitorCount FROM Servers' , 'Id' , 'MonitorCount' );
foreach ( ZM\Server :: find () as $Server ) {
$svr_opt = 'class="serverCol" data-sid="' . $Server -> Id () . '"' ;
?>
2015-07-09 23:41:46 +08:00
< tr >
2020-09-16 21:30:45 +08:00
< td class = " colName " >< ? php echo makeLink ( '#' , validHtmlStr ( $Server -> Name ()), $canEdit , $svr_opt ) ?> </td>
< td class = " colUrl " >< ? php echo makeLink ( '#' , validHtmlStr ( $Server -> Url ()), $canEdit , $svr_opt ) ?> </td>
< td class = " colPathToIndex " >< ? php echo makeLink ( '#' , validHtmlStr ( $Server -> PathToIndex ()), $canEdit , $svr_opt ) ?> </td>
< td class = " colPathToZMS " >< ? php echo makeLink ( '#' , validHtmlStr ( $Server -> PathToZMS ()), $canEdit , $svr_opt ) ?> </td>
2018-11-28 22:54:22 +08:00
< td class = " colStatus <?php if ( $Server->Status () == 'NotRunning' ) { echo 'danger'; } ?> " >
2020-09-16 21:30:45 +08:00
< ? php echo makeLink ( '#' , validHtmlStr ( $Server -> Status ()), $canEdit , $svr_opt ) ?> </td>
< td class = " colMonitorCount " >< ? php echo makeLink ( '#' , validHtmlStr ( $monitor_counts [ $Server -> Id ()]), $canEdit , $svr_opt ) ?> </td>
< td class = " colCpuLoad <?php if ( $Server->CpuLoad () > 5 ) { echo 'danger'; } ?> " >< ? php echo makeLink ( '#' , $Server -> CpuLoad (), $canEdit , $svr_opt ) ?> </td>
2019-03-26 00:08:56 +08:00
< td class = " colMemory <?php if ( (! $Server->TotalMem ()) or ( $Server->FreeMem ()/ $Server->TotalMem () < .1) ) { echo 'danger'; } ?> " >
2020-09-16 21:30:45 +08:00
< ? php echo makeLink ( '#' , human_filesize ( $Server -> FreeMem ()) . ' / ' . human_filesize ( $Server -> TotalMem ()), $canEdit , $svr_opt ) ?> </td>
2018-11-22 23:04:33 +08:00
< td class = " colSwap <?php if ( (! $Server->TotalSwap ()) or ( $Server->FreeSwap ()/ $Server->TotalSwap () < .1) ) { echo 'danger'; } ?> " >
2020-09-16 21:30:45 +08:00
< ? php echo makeLink ( '#' , human_filesize ( $Server -> FreeSwap ()) . ' / ' . human_filesize ( $Server -> TotalSwap ()) , $canEdit , $svr_opt ) ?> </td>
< td class = " colStats " >< ? php echo makeLink ( '#' , $Server -> zmstats () ? 'yes' : 'no' , $canEdit , $svr_opt ) ?> </td>
< td class = " colAudit " >< ? php echo makeLink ( '#' , $Server -> zmaudit () ? 'yes' : 'no' , $canEdit , $svr_opt ) ?> </td>
< td class = " colTrigger " >< ? php echo makeLink ( '#' , $Server -> zmtrigger () ? 'yes' : 'no' , $canEdit , $svr_opt ) ?> </td>
< td class = " colEventNotification " >< ? php echo makeLink ( '#' , $Server -> zmeventnotification () ? 'yes' : 'no' , $canEdit , $svr_opt ) ?> </td>
2017-10-25 03:43:32 +08:00
2019-01-16 22:59:58 +08:00
< td class = " colMark " >< input type = " checkbox " name = " markIds[] " value = " <?php echo $Server->Id () ?> " data - on - click - this = " configureDeleteButton " < ? php if ( ! $canEdit ) { ?> disabled="disabled"<?php } ?>/></td>
2020-09-16 21:30:45 +08:00
</ tr >
2015-07-09 23:41:46 +08:00
< ? php } #end foreach Server ?>
</ tbody >
</ table >
< div id = " contentButtons " >
2020-09-16 21:30:45 +08:00
< button type = " button " id = " NewServerBtn " value = " <?php echo translate('AddNewServer') ?> " disabled = " disabled " >< ? php echo translate ( 'AddNewServer' ) ?> </button>
2017-12-13 00:15:53 +08:00
< button type = " submit " class = " btn-danger " name = " deleteBtn " value = " Delete " disabled = " disabled " >< ? php echo translate ( 'Delete' ) ?> </button>
2015-07-09 23:41:46 +08:00
</ div >
</ form >
2020-09-16 21:30:45 +08:00
< ? php
} else if ( $tab == 'storage' ) {
?>
2019-02-10 13:39:19 +08:00
< form name = " storageForm " method = " post " action = " ? " >
2015-12-16 00:13:21 +08:00
< input type = " hidden " name = " view " value = " <?php echo $view ?> " />
< input type = " hidden " name = " tab " value = " <?php echo $tab ?> " />
< input type = " hidden " name = " action " value = " delete " />
< input type = " hidden " name = " object " value = " storage " />
2018-09-08 04:31:11 +08:00
< table id = " contentTable " class = " table table-striped " >
2018-03-26 23:50:14 +08:00
< thead class = " thead-highlight " >
2015-12-16 00:13:21 +08:00
< tr >
2016-05-02 22:40:42 +08:00
< th class = " colId " >< ? php echo translate ( 'Id' ) ?> </th>
2018-07-25 21:39:08 +08:00
< th class = " colName " >< ? php echo translate ( 'Name' ) ?> </th>
< th class = " colPath " >< ? php echo translate ( 'Path' ) ?> </th>
2017-10-16 23:31:01 +08:00
< th class = " colType " >< ? php echo translate ( 'Type' ) ?> </th>
2017-12-19 02:16:54 +08:00
< th class = " colScheme " >< ? php echo translate ( 'StorageScheme' ) ?> </th>
2017-12-23 03:39:43 +08:00
< th class = " colServer " >< ? php echo translate ( 'Server' ) ?> </th>
2018-04-29 00:38:10 +08:00
< th class = " colDiskSpace " >< ? php echo translate ( 'DiskSpace' ) ?> </th>
2019-11-27 03:36:39 +08:00
< th class = " colEvents " >< ? php echo translate ( 'Events' ) ?> </th>
2015-12-16 00:13:21 +08:00
< th class = " colMark " >< ? php echo translate ( 'Mark' ) ?> </th>
2017-12-12 01:51:38 +08:00
</ tr >
2015-12-16 00:13:21 +08:00
</ thead >
< tbody >
2020-09-16 21:30:45 +08:00
< ? php
foreach ( ZM\Storage :: find ( null , array ( 'order' => 'lower(Name)' ) ) as $Storage ) {
$str_opt = 'class="storageCol" data-sid="' . $Storage -> Id () . '"' ;
?>
2015-12-16 00:13:21 +08:00
< tr >
2020-09-16 21:30:45 +08:00
< td class = " colId " >< ? php echo makeLink ( '#' , validHtmlStr ( $Storage -> Id ()), $canEdit , $str_opt ) ?> </td>
< td class = " colName " >< ? php echo makeLink ( '#' , validHtmlStr ( $Storage -> Name ()), $canEdit , $str_opt ) ?> </td>
< td class = " colPath " >< ? php echo makeLink ( '#' , validHtmlStr ( $Storage -> Path ()), $canEdit , $str_opt ) ?> </td>
< td class = " colType " >< ? php echo makeLink ( '#' , validHtmlStr ( $Storage -> Type ()), $canEdit , $str_opt ) ?> </td>
< td class = " colScheme " >< ? php echo makeLink ( '#' , validHtmlStr ( $Storage -> Scheme ()), $canEdit , $str_opt ) ?> </td>
< td class = " colServer " >< ? php echo makeLink ( '#' , validHtmlStr ( $Storage -> Server () -> Name ()), $canEdit , $str_opt ) ?> </td>
2020-01-08 00:01:53 +08:00
< td class = " colDiskSpace " >< ? php echo human_filesize ( $Storage -> disk_used_space ()) . ' of ' . human_filesize ( $Storage -> disk_total_space ()) ?> </td>
2020-01-14 01:53:50 +08:00
< td class = " ColEvents " >< ? php echo $Storage -> EventCount () . ' using ' . human_filesize ( $Storage -> event_disk_space ()) ?> </td>
2020-01-14 02:43:14 +08:00
< td class = " colMark " >< input type = " checkbox " name = " markIds[] " value = " <?php echo $Storage->Id () ?> " data - on - click - this = " configureDeleteButton " < ? php if ( $Storage -> EventCount () or ! $canEdit ) { ?> disabled="disabled"<?php } ?><?php echo $Storage->EventCount() ? ' title="Can\'t delete as long as there are events stored here."' : ''?>/></td>
2017-12-12 01:51:38 +08:00
</ tr >
2015-12-16 00:13:21 +08:00
< ? php } #end foreach Server ?>
</ tbody >
</ table >
< div id = " contentButtons " >
2020-09-14 22:50:04 +08:00
< button type = " button " id = " NewStorageBtn " value = " <?php echo translate('AddNewStorage') ?> " disabled = " disabled " >< ? php echo translate ( 'AddNewStorage' ) ?> </button>
2017-12-13 00:15:53 +08:00
< button type = " submit " class = " btn-danger " name = " deleteBtn " value = " Delete " disabled = " disabled " >< ? php echo translate ( 'Delete' ) ?> </button>
2015-12-16 00:13:21 +08:00
</ div >
</ form >
2019-05-13 00:15:08 +08:00
< ? php
} else if ( $tab == 'API' ) {
2019-05-13 01:57:25 +08:00
2019-05-13 00:15:08 +08:00
$apiEnabled = dbFetchOne ( " SELECT Value FROM Config WHERE Name='ZM_OPT_USE_API' " );
2019-05-13 00:34:55 +08:00
if ( $apiEnabled [ 'Value' ] != '1' ) {
2019-05-13 00:15:08 +08:00
echo " <div class='errorText'>APIs are disabled. To enable, please turn on OPT_USE_API in Options->System</div> " ;
}
else {
?>
< form name = " userForm " method = " post " action = " ? " >
2020-07-26 02:18:09 +08:00
< button class = " float-left " type = " submit " name = " updateSelected " id = " updateSelected " >< ? php echo translate ( 'Update' ) ?> </button>
< button class = " btn-danger float-right " type = " submit " name = " revokeAllTokens " id = " revokeAllTokens " >< ? php echo translate ( 'RevokeAllTokens' ) ?> </button>
2019-09-18 00:46:11 +08:00
< br />
2019-05-13 00:15:08 +08:00
< ? php
2019-09-18 00:46:11 +08:00
function revokeAllTokens () {
2019-05-13 00:15:08 +08:00
$minTokenTime = time ();
2019-09-18 00:46:11 +08:00
dbQuery ( 'UPDATE `Users` SET `TokenMinExpiry`=?' , array ( $minTokenTime ));
echo '<span class="timedSuccessBox">' . translate ( 'AllTokensRevoked' ) . '</span>' ;
2019-05-13 00:15:08 +08:00
}
2019-09-18 00:46:11 +08:00
function updateSelected () {
2020-01-02 23:17:07 +08:00
# Turn them all off, then selectively turn the checked ones back on
2019-09-18 00:46:11 +08:00
dbQuery ( 'UPDATE `Users` SET `APIEnabled`=0' );
2020-01-02 23:17:07 +08:00
if ( isset ( $_REQUEST [ 'tokenUids' ]) ) {
foreach ( $_REQUEST [ 'tokenUids' ] as $markUid ) {
$minTime = time ();
dbQuery ( 'UPDATE `Users` SET `TokenMinExpiry`=? WHERE `Id`=?' , array ( $minTime , $markUid ));
}
2019-05-13 00:15:08 +08:00
}
2020-01-02 23:17:07 +08:00
if ( isset ( $_REQUEST [ 'apiUids' ]) ) {
foreach ( $_REQUEST [ 'apiUids' ] as $markUid ) {
dbQuery ( 'UPDATE `Users` SET `APIEnabled`=1 WHERE `Id`=?' , array ( $markUid ));
}
2019-05-13 00:15:08 +08:00
}
2019-09-18 00:46:11 +08:00
echo '<span class="timedSuccessBox">' . translate ( 'Updated' ) . '</span>' ;
2019-05-13 00:15:08 +08:00
}
2020-01-02 23:17:07 +08:00
if ( array_key_exists ( 'revokeAllTokens' , $_POST ) ) {
2019-05-13 00:15:08 +08:00
revokeAllTokens ();
}
2020-01-02 23:17:07 +08:00
if ( array_key_exists ( 'updateSelected' , $_POST ) ) {
2019-05-13 00:15:08 +08:00
updateSelected ();
}
?>
< br />< br />
< input type = " hidden " name = " view " value = " <?php echo $view ?> " />
< input type = " hidden " name = " tab " value = " <?php echo $tab ?> " />
< input type = " hidden " name = " action " value = " delete " />
< table id = " contentTable " class = " table table-striped " >
< thead class = " thead-highlight " >
< tr >
< th class = " colUsername " >< ? php echo translate ( 'Username' ) ?> </th>
< th class = " colMark " >< ? php echo translate ( 'Revoke Token' ) ?> </th>
< th class = " colMark " >< ? php echo translate ( 'API Enabled' ) ?> </th>
</ tr >
</ thead >
< tbody >
< ? php
$sql = 'SELECT * FROM Users ORDER BY Username' ;
2019-09-18 00:46:11 +08:00
foreach ( dbFetchAll ( $sql ) as $row ) {
2019-05-13 00:15:08 +08:00
?>
< tr >
2019-05-13 01:57:25 +08:00
< td class = " colUsername " >< ? php echo validHtmlStr ( $row [ 'Username' ]) ?> </td>
2019-05-13 00:15:08 +08:00
< td class = " colMark " >< input type = " checkbox " name = " tokenUids[] " value = " <?php echo $row['Id'] ?> " /></ td >
< td class = " colMark " >< input type = " checkbox " name = " apiUids[] " value = " <?php echo $row['Id'] ?> " < ? php echo $row [ 'APIEnabled' ] ? 'checked' : '' ?> /></td>
</ tr >
< ? php
}
?>
</ tbody >
</ table >
</ form >
< ? php
} // API enabled
} // $tab == API
else {
2018-10-20 03:00:47 +08:00
$config = array ();
$configCat = array ();
$configCats = array ();
2019-09-18 00:46:11 +08:00
$result = $dbConn -> query ( 'SELECT * FROM `Config` ORDER BY `Id` ASC' );
2018-10-20 03:00:47 +08:00
if ( ! $result )
echo mysql_error ();
2020-06-24 10:19:46 +08:00
while ( $row = dbFetchNext ( $result ) ) {
2018-10-20 03:00:47 +08:00
$config [ $row [ 'Name' ]] = $row ;
if ( ! ( $configCat = & $configCats [ $row [ 'Category' ]]) ) {
$configCats [ $row [ 'Category' ]] = array ();
$configCat = & $configCats [ $row [ 'Category' ]];
}
$configCat [ $row [ 'Name' ]] = $row ;
}
2017-10-13 00:09:05 +08:00
if ( $tab == 'system' ) {
2019-09-18 00:46:11 +08:00
$configCats [ $tab ][ 'ZM_LANG_DEFAULT' ][ 'Hint' ] = join ( '|' , getLanguages ());
$configCats [ $tab ][ 'ZM_SKIN_DEFAULT' ][ 'Hint' ] = join ( '|' , array_map ( 'basename' , glob ( 'skins/*' , GLOB_ONLYDIR )));
$configCats [ $tab ][ 'ZM_CSS_DEFAULT' ][ 'Hint' ] = join ( '|' , array_map ( 'basename' , glob ( 'skins/' . ZM_SKIN_DEFAULT . '/css/*' , GLOB_ONLYDIR ) ));
2017-10-13 02:43:53 +08:00
$configCats [ $tab ][ 'ZM_BANDWIDTH_DEFAULT' ][ 'Hint' ] = $bandwidth_options ;
2019-10-02 21:07:18 +08:00
2020-02-12 02:24:26 +08:00
function timezone_list () {
static $timezones = null ;
2019-10-02 21:07:18 +08:00
2020-02-12 02:24:26 +08:00
if ( $timezones === null ) {
$timezones = [];
$offsets = [];
$now = new DateTime ( 'now' , new DateTimeZone ( 'UTC' ));
2019-10-02 21:07:18 +08:00
2020-02-12 02:24:26 +08:00
foreach ( DateTimeZone :: listIdentifiers () as $timezone ) {
$now -> setTimezone ( new DateTimeZone ( $timezone ));
$offsets [] = $offset = $now -> getOffset ();
$timezones [ $timezone ] = '(' . format_GMT_offset ( $offset ) . ') ' . format_timezone_name ( $timezone );
}
2019-10-02 21:07:18 +08:00
2020-02-12 02:24:26 +08:00
array_multisort ( $offsets , $timezones );
}
2019-10-02 21:07:18 +08:00
2020-02-12 02:24:26 +08:00
return $timezones ;
}
2019-10-02 21:07:18 +08:00
2020-02-12 02:24:26 +08:00
function format_GMT_offset ( $offset ) {
$hours = intval ( $offset / 3600 );
$minutes = abs ( intval ( $offset % 3600 / 60 ));
return 'GMT' . ( $offset ? sprintf ( '%+03d:%02d' , $hours , $minutes ) : '' );
}
2019-10-02 21:07:18 +08:00
2020-02-12 02:24:26 +08:00
function format_timezone_name ( $name ) {
$name = str_replace ( '/' , ', ' , $name );
$name = str_replace ( '_' , ' ' , $name );
$name = str_replace ( 'St ' , 'St. ' , $name );
return $name ;
}
2020-02-12 03:31:48 +08:00
$configCats [ $tab ][ 'ZM_TIMEZONE' ][ 'Hint' ] = array ( '' => translate ( 'TZUnset' )) + timezone_list ();
2020-02-12 02:24:26 +08:00
} # end if tab == system
2008-07-14 21:54:50 +08:00
?>
2020-07-26 02:18:09 +08:00
< form name = " optionsForm " class = " " method = " post " action = " ? " >
2014-12-05 07:44:23 +08:00
< input type = " hidden " name = " view " value = " <?php echo $view ?> " />
< input type = " hidden " name = " tab " value = " <?php echo $tab ?> " />
2008-07-14 21:54:50 +08:00
< input type = " hidden " name = " action " value = " options " />
< ? php
2019-10-02 21:07:18 +08:00
$configCat = $configCats [ $tab ];
foreach ( $configCat as $name => $value ) {
$shortName = preg_replace ( '/^ZM_/' , '' , $name );
$optionPromptText = ! empty ( $OLANG [ $shortName ]) ? $OLANG [ $shortName ][ 'Prompt' ] : $value [ 'Prompt' ];
2008-07-14 21:54:50 +08:00
?>
2020-07-26 02:18:09 +08:00
< div class = " form-group form-row " >
2020-08-02 23:20:18 +08:00
< label for = " <?php echo $name ?> " class = " col-md-4 control-label text-md-right " >< ? php echo $shortName ?> </label>
2020-07-30 22:03:03 +08:00
< div class = " col-md " >
2008-07-14 21:54:50 +08:00
< ? php
2017-10-13 02:43:53 +08:00
if ( $value [ 'Type' ] == 'boolean' ) {
2008-07-14 21:54:50 +08:00
?>
2016-03-16 02:43:22 +08:00
< input type = " checkbox " id = " <?php echo $name ?> " name = " newConfig[<?php echo $name ?>] " value = " 1 " < ? php if ( $value [ 'Value' ] ) { ?> checked="checked"<?php } ?><?php echo $canEdit?'':' disabled="disabled"' ?>/>
2008-07-14 21:54:50 +08:00
< ? php
2019-10-02 21:07:18 +08:00
} elseif ( is_array ( $value [ 'Hint' ]) ) {
2019-05-06 22:45:40 +08:00
echo htmlSelect ( " newConfig[ $name ] " , $value [ 'Hint' ], $value [ 'Value' ]);
} elseif ( preg_match ( '/\|/' , $value [ 'Hint' ]) ) {
2008-07-14 21:54:50 +08:00
?>
2017-10-13 02:43:53 +08:00
2008-07-14 21:54:50 +08:00
< ? php
2019-05-06 22:45:40 +08:00
$options = explode ( '|' , $value [ 'Hint' ]);
if ( count ( $options ) > 3 ) {
2008-07-14 21:54:50 +08:00
?>
2020-07-30 22:03:03 +08:00
< select class = " form-control-sm " name = " newConfig[<?php echo $name ?>] " < ? php echo $canEdit ? '' : ' disabled="disabled"' ?> >
2008-07-14 21:54:50 +08:00
< ? php
2017-09-27 05:14:27 +08:00
foreach ( $options as $option ) {
2019-05-06 22:45:40 +08:00
if ( preg_match ( '/^([^=]+)=(.+)$/' , $option , $matches ) ) {
2017-09-27 05:14:27 +08:00
$optionLabel = $matches [ 1 ];
$optionValue = $matches [ 2 ];
} else {
$optionLabel = $optionValue = $option ;
}
2008-07-14 21:54:50 +08:00
?>
2014-12-05 07:44:23 +08:00
< option value = " <?php echo $optionValue ?> " < ? php if ( $value [ 'Value' ] == $optionValue ) { echo ' selected="selected"' ; } ?> ><?php echo htmlspecialchars($optionLabel) ?></option>
2008-07-14 21:54:50 +08:00
< ? php
}
?>
</ select >
< ? php
2017-09-27 05:14:27 +08:00
} else {
foreach ( $options as $option ) {
2019-05-06 22:45:40 +08:00
if ( preg_match ( '/^([^=]+)=(.+)$/' , $option ) ) {
2017-10-13 02:43:53 +08:00
$optionLabel = $matches [ 1 ];
$optionValue = $matches [ 2 ];
} else {
$optionLabel = $optionValue = $option ;
}
2008-07-14 21:54:50 +08:00
?>
2020-07-26 02:18:09 +08:00
< label class = " font-weight-bold form-control-sm " >
2019-05-06 22:45:40 +08:00
< input type = " radio " id = " <?php echo $name .'_'.preg_replace('/[^a-zA-Z0-9]/', '', $optionValue ) ?> " name = " newConfig[<?php echo $name ?>] " value = " <?php echo $optionValue ?> " < ? php if ( $value [ 'Value' ] == $optionValue ) { ?> checked="checked"<?php } ?><?php echo $canEdit?'':' disabled="disabled"' ?>/>
2016-03-16 02:43:22 +08:00
< ? php echo htmlspecialchars ( $optionLabel ) ?>
</ label >
2008-07-14 21:54:50 +08:00
< ? php
}
}
?>
< ? php
2017-12-12 01:51:38 +08:00
} else if ( $value [ 'Type' ] == 'text' ) {
2008-07-14 21:54:50 +08:00
?>
2020-07-26 02:18:09 +08:00
< textarea class = " form-control-sm " id = " <?php echo $name ?> " name = " newConfig[<?php echo $name ?>] " rows = " 5 " cols = " 40 " < ? php echo $canEdit ? '' : ' disabled="disabled"' ?> ><?php echo validHtmlStr($value['Value']) ?></textarea>
2008-07-14 21:54:50 +08:00
< ? php
2017-12-12 01:51:38 +08:00
} else if ( $value [ 'Type' ] == 'integer' ) {
2008-07-14 21:54:50 +08:00
?>
2020-07-30 22:03:03 +08:00
< input type = " number " class = " form-control-sm " id = " <?php echo $name ?> " name = " newConfig[<?php echo $name ?>] " value = " <?php echo validHtmlStr( $value['Value'] ) ?> " < ? php echo $canEdit ? '' : ' disabled="disabled"' ?> />
2008-07-14 21:54:50 +08:00
< ? php
2017-12-12 01:51:38 +08:00
} else if ( $value [ 'Type' ] == 'hexadecimal' ) {
2008-07-14 21:54:50 +08:00
?>
2020-07-30 22:03:03 +08:00
< input type = " text " class = " form-control-sm " id = " <?php echo $name ?> " name = " newConfig[<?php echo $name ?>] " value = " <?php echo validHtmlStr( $value['Value'] ) ?> " < ? php echo $canEdit ? '' : ' disabled="disabled"' ?> />
2008-07-14 21:54:50 +08:00
< ? php
2017-12-12 01:51:38 +08:00
} else if ( $value [ 'Type' ] == 'decimal' ) {
2008-07-14 21:54:50 +08:00
?>
2020-07-30 22:03:03 +08:00
< input type = " text " class = " form-control-sm " id = " <?php echo $name ?> " name = " newConfig[<?php echo $name ?>] " value = " <?php echo validHtmlStr( $value['Value'] ) ?> " < ? php echo $canEdit ? '' : ' disabled="disabled"' ?> />
2008-07-14 21:54:50 +08:00
< ? php
2017-12-12 01:51:38 +08:00
} else {
2008-07-14 21:54:50 +08:00
?>
2020-07-30 22:03:03 +08:00
< input type = " text " class = " form-control-sm " id = " <?php echo $name ?> " name = " newConfig[<?php echo $name ?>] " value = " <?php echo validHtmlStr( $value['Value'] ) ?> " < ? php echo $canEdit ? '' : ' disabled="disabled"' ?> />
2008-07-14 21:54:50 +08:00
< ? php
}
?>
2020-09-12 02:23:14 +08:00
< span class = " form-text form-control-sm " >< ? php echo validHtmlStr ( $optionPromptText ); echo makeHelpLink ( $name ) ?> </span>
2016-03-16 02:43:22 +08:00
</ div ><!-- End . col - sm - 9 -->
</ div ><!-- End . form - group -->
2008-07-14 21:54:50 +08:00
< ? php
}
?>
2019-05-12 01:39:40 +08:00
2008-07-14 21:54:50 +08:00
< div id = " contentButtons " >
2019-09-18 00:46:11 +08:00
< button type = " submit " < ? php echo $canEdit ? '' : ' disabled="disabled"' ?> ><?php echo translate('Save') ?></button>
2008-07-14 21:54:50 +08:00
</ div >
</ form >
< ? php
}
?>
2016-03-16 03:21:28 +08:00
2019-05-12 01:39:40 +08:00
2016-03-16 03:21:28 +08:00
</ div ><!-- end #options -->
2016-04-02 02:02:19 +08:00
</ div >
</ div > <!-- end row -->
2008-07-14 21:54:50 +08:00
</ div >
2018-09-08 04:31:11 +08:00
< ? php xhtmlFooter () ?>