mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-06-23 04:59:37 -04:00
Because this translation is used in the middle of a string, spelling rules require it to be written with a lowercase first letter.
43 lines
1.7 KiB
PHP
43 lines
1.7 KiB
PHP
<?php
|
|
ini_set('display_errors', '0');
|
|
|
|
if ( canView('Monitors') || (isset($_REQUEST['mid']) && $_REQUEST['mid'] !== '' && canView('Monitors', $_REQUEST['mid'])) ) {
|
|
$mid = isset($_REQUEST['mid']) ? $_REQUEST['mid'] : null;
|
|
if ($mid === null || $mid === '') {
|
|
ajaxError(translate('RequestMissing') . ' "mid".');
|
|
}
|
|
|
|
$action = $_REQUEST['action'] ?? '';
|
|
if ($action === '') {
|
|
ajaxError(translate('RequestMissing') . ' "action".');
|
|
}
|
|
|
|
switch ( $action ) {
|
|
case 'validateName' :
|
|
require_once('includes/Monitor.php');
|
|
$monitor = new ZM\Monitor($mid);
|
|
$filterRegexp = $monitor->getDefaults()['Name']['filter_regexp'];
|
|
$result = true;
|
|
$badChars = [];
|
|
$message = '';
|
|
|
|
if (isset($_REQUEST['monitorName']) && $_REQUEST['monitorName'] !== '') {
|
|
$monitorName = $_REQUEST['monitorName'];
|
|
$trimmedMonitorName = trim($monitorName);
|
|
$cleanedMonitorName = preg_replace($filterRegexp, '', $trimmedMonitorName);
|
|
if ($trimmedMonitorName != $cleanedMonitorName){
|
|
preg_match_all($filterRegexp, $trimmedMonitorName, $badChars);
|
|
$result = false;
|
|
$message = translate('BadNameCharsList') . ' "' . implode('","', array_unique($badChars[0])) . '".~~' . translate('BadNameChars');
|
|
}
|
|
ajaxResponse(array('response'=>$result, 'monitorName'=>$monitorName, 'cleanedMonitorName'=>$cleanedMonitorName, 'badChars'=>$badChars, 'messageBadNameChars'=>$message));
|
|
} else {
|
|
ajaxError(translate('ErrorVerifyingMonitorName'));
|
|
}
|
|
break;
|
|
} // end switch action
|
|
} // end if canView('Monitors')
|
|
|
|
ajaxError(translate('UnrecognisedAction').' "'.validHtmlStr($_REQUEST['action'] ?? '').'" '.translate('conjOr').' '.translate('insufficientPermissionsUser').' "'.validHtmlStr($user->Username()).'"');
|
|
?>
|