diff --git a/web/includes/actions/filter.php b/web/includes/actions/filter.php index 4067bdf9c..782d93885 100644 --- a/web/includes/actions/filter.php +++ b/web/includes/actions/filter.php @@ -19,63 +19,64 @@ // // Event scope actions, view permissions only required -if ( canView('Events') ) { +if ( !canView('Events') ) { + Warning('You do not have permission to view Events.'); + return; +} - if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) { - if ( $action == 'addterm' ) { - $_REQUEST['filter'] = addFilterTerm($_REQUEST['filter'], $_REQUEST['line']); - } elseif ( $action == 'delterm' ) { - $_REQUEST['filter'] = delFilterTerm($_REQUEST['filter'], $_REQUEST['line']); - } else if ( canEdit('Events') ) { - if ( $action == 'delete' ) { - if ( ! empty($_REQUEST['Id']) ) { - dbQuery('DELETE FROM Filters WHERE Id=?', array($_REQUEST['Id'])); - } - } else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) ) { - # or ( $action == 'submit' ) ) { +if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) { + if ( $action == 'addterm' ) { + $_REQUEST['filter'] = addFilterTerm($_REQUEST['filter'], $_REQUEST['line']); + } elseif ( $action == 'delterm' ) { + $_REQUEST['filter'] = delFilterTerm($_REQUEST['filter'], $_REQUEST['line']); + } else if ( canEdit('Events') ) { + if ( $action == 'delete' ) { + if ( !empty($_REQUEST['Id']) ) { + dbQuery('DELETE FROM Filters WHERE Id=?', array($_REQUEST['Id'])); + } + } else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) ) { - $sql = ''; - $_REQUEST['filter']['Query']['sort_field'] = validStr($_REQUEST['filter']['Query']['sort_field']); - $_REQUEST['filter']['Query']['sort_asc'] = validStr($_REQUEST['filter']['Query']['sort_asc']); - $_REQUEST['filter']['Query']['limit'] = validInt($_REQUEST['filter']['Query']['limit']); - if ( $action == 'execute' ) { - $tempFilterName = '_TempFilter'.time(); - $sql .= ' Name = \''.$tempFilterName.'\''; - } else { - $sql .= ' Name = '.dbEscape($_REQUEST['filter']['Name']); - } - $sql .= ', Query = '.dbEscape(jsonEncode($_REQUEST['filter']['Query'])); - $sql .= ', AutoArchive = '.(!empty($_REQUEST['filter']['AutoArchive']) ? 1 : 0); - $sql .= ', AutoVideo = '. ( !empty($_REQUEST['filter']['AutoVideo']) ? 1 : 0); - $sql .= ', AutoUpload = '. ( !empty($_REQUEST['filter']['AutoUpload']) ? 1 : 0); - $sql .= ', AutoEmail = '. ( !empty($_REQUEST['filter']['AutoEmail']) ? 1 : 0); - $sql .= ', AutoMessage = '. ( !empty($_REQUEST['filter']['AutoMessage']) ? 1 : 0); - $sql .= ', AutoExecute = '. ( !empty($_REQUEST['filter']['AutoExecute']) ? 1 : 0); - $sql .= ', AutoExecuteCmd = '.dbEscape($_REQUEST['filter']['AutoExecuteCmd']); - $sql .= ', AutoDelete = '. ( !empty($_REQUEST['filter']['AutoDelete']) ? 1 : 0); - if ( !empty($_REQUEST['filter']['AutoMove']) ? 1 : 0) { - $sql .= ', AutoMove = 1, AutoMoveTo='. validInt($_REQUEST['filter']['AutoMoveTo']); - } else { - $sql .= ', AutoMove = 0'; - } - $sql .= ', UpdateDiskSpace = '. ( !empty($_REQUEST['filter']['UpdateDiskSpace']) ? 1 : 0); - $sql .= ', Background = '. ( !empty($_REQUEST['filter']['Background']) ? 1 : 0); - $sql .= ', Concurrent = '. ( !empty($_REQUEST['filter']['Concurrent']) ? 1 : 0); + $sql = ''; + $_REQUEST['filter']['Query']['sort_field'] = validStr($_REQUEST['filter']['Query']['sort_field']); + $_REQUEST['filter']['Query']['sort_asc'] = validStr($_REQUEST['filter']['Query']['sort_asc']); + $_REQUEST['filter']['Query']['limit'] = validInt($_REQUEST['filter']['Query']['limit']); + if ( $action == 'execute' ) { + $tempFilterName = '_TempFilter'.time(); + $sql .= ' Name = \''.$tempFilterName.'\''; + } else { + $sql .= ' Name = '.dbEscape($_REQUEST['filter']['Name']); + } + $sql .= ', Query = '.dbEscape(jsonEncode($_REQUEST['filter']['Query'])); + $sql .= ', AutoArchive = '.(!empty($_REQUEST['filter']['AutoArchive']) ? 1 : 0); + $sql .= ', AutoVideo = '. ( !empty($_REQUEST['filter']['AutoVideo']) ? 1 : 0); + $sql .= ', AutoUpload = '. ( !empty($_REQUEST['filter']['AutoUpload']) ? 1 : 0); + $sql .= ', AutoEmail = '. ( !empty($_REQUEST['filter']['AutoEmail']) ? 1 : 0); + $sql .= ', AutoMessage = '. ( !empty($_REQUEST['filter']['AutoMessage']) ? 1 : 0); + $sql .= ', AutoExecute = '. ( !empty($_REQUEST['filter']['AutoExecute']) ? 1 : 0); + $sql .= ', AutoExecuteCmd = '.dbEscape($_REQUEST['filter']['AutoExecuteCmd']); + $sql .= ', AutoDelete = '. ( !empty($_REQUEST['filter']['AutoDelete']) ? 1 : 0); + if ( !empty($_REQUEST['filter']['AutoMove']) ? 1 : 0) { + $sql .= ', AutoMove = 1, AutoMoveTo='. validInt($_REQUEST['filter']['AutoMoveTo']); + } else { + $sql .= ', AutoMove = 0'; + } + $sql .= ', UpdateDiskSpace = '. ( !empty($_REQUEST['filter']['UpdateDiskSpace']) ? 1 : 0); + $sql .= ', Background = '. ( !empty($_REQUEST['filter']['Background']) ? 1 : 0); + $sql .= ', Concurrent = '. ( !empty($_REQUEST['filter']['Concurrent']) ? 1 : 0); - if ( $_REQUEST['Id'] and ( $action == 'Save' ) ) { - dbQuery('UPDATE Filters SET ' . $sql. ' WHERE Id=?', array($_REQUEST['Id'])); - } else { - dbQuery('INSERT INTO Filters SET' . $sql); - $_REQUEST['Id'] = dbInsertId(); - } - if ( $action == 'execute' ) { - executeFilter( $tempFilterName ); - } + if ( $_REQUEST['Id'] and ( $action == 'Save' ) ) { + dbQuery('UPDATE Filters SET '.$sql.' WHERE Id=?', array($_REQUEST['Id'])); + } else { + dbQuery('INSERT INTO Filters SET'.$sql); + $_REQUEST['Id'] = dbInsertId(); + } + if ( $action == 'execute' ) { + executeFilter($_REQUEST['Id']); + $view = 'events'; + } - } // end if save or execute - } // end if canEdit(Events) - return; - } // end if object == filter -} // end canView(Events) + } // end if save or execute + } // end if canEdit(Events) +} // end if object == filter ?> diff --git a/web/includes/functions.php b/web/includes/functions.php index 154a26046..77cd1ca47 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -958,11 +958,11 @@ Logger::Debug("generating Video $command: result($result outptu:(".implode("\n", return( $status?"":rtrim($result) ); } -function executeFilter( $filter ) { - $command = ZM_PATH_BIN."/zmfilter.pl --filter ".escapeshellarg($filter); - $result = exec( $command, $output, $status ); - dbQuery( "delete from Filters where Name like '_TempFilter%'" ); - return( $status ); +function executeFilter( $filter_id ) { + $command = ZM_PATH_BIN.'/zmfilter.pl --filter_id '.escapeshellarg($filter_id); + $result = exec($command, $output, $status); + dbQuery('DELETE FROM Filters WHERE Id=?', array($filter_id)); + return $status; } # This takes more than one scale amount, so it runs through each and alters dimension. diff --git a/web/index.php b/web/index.php index 7d13e9ce1..5190fad65 100644 --- a/web/index.php +++ b/web/index.php @@ -51,7 +51,6 @@ require_once('includes/Event.php'); require_once('includes/Group.php'); require_once('includes/Monitor.php'); - if ( (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') or @@ -118,12 +117,12 @@ $skinBase[] = $skin; $currentCookieParams = session_get_cookie_params(); //Logger::Debug('Setting cookie parameters to lifetime('.$currentCookieParams['lifetime'].') path('.$currentCookieParams['path'].') domain ('.$currentCookieParams['domain'].') secure('.$currentCookieParams['secure'].') httpOnly(1)'); session_set_cookie_params( - $currentCookieParams['lifetime'], - $currentCookieParams['path'], - $currentCookieParams['domain'], - $currentCookieParams['secure'], - true -); + $currentCookieParams['lifetime'], + $currentCookieParams['path'], + $currentCookieParams['domain'], + $currentCookieParams['secure'], + true +); ini_set('session.name', 'ZMSESSID'); @@ -166,6 +165,7 @@ if ( !is_writable(ZM_DIR_EVENTS) ) { } # Globals +$action = null; $error_message = null; $redirect = null; $view = null; @@ -185,9 +185,9 @@ foreach ( getSkinIncludes('skin.php') as $includeFile ) # User Login will be performed in auth.php require_once('includes/auth.php'); -if ( isset($_REQUEST['action']) ) { +if ( isset($_REQUEST['action']) ) $action = detaintPath($_REQUEST['action']); -} + # The only variable we really need to set is action. The others are informal. isset($view) || $view = NULL; @@ -244,27 +244,27 @@ if ( $request ) { require_once $includeFile; } return; -} else { - if ( $includeFiles = getSkinIncludes('views/'.$view.'.php', true, true) ) { - foreach ( $includeFiles as $includeFile ) { - if ( !file_exists($includeFile) ) - Fatal("View '$view' does not exist"); - require_once $includeFile; - } - // If the view overrides $view to 'error', and the user is not logged in, then the - // issue is probably resolvable by logging in, so provide the opportunity to do so. - // The login view should handle redirecting to the correct location afterward. - if ( $view == 'error' && !isset($user) ) { - $view = 'login'; - foreach ( getSkinIncludes('views/login.php', true, true) as $includeFile ) - require_once $includeFile; - } +} + +if ( $includeFiles = getSkinIncludes('views/'.$view.'.php', true, true) ) { + foreach ( $includeFiles as $includeFile ) { + if ( !file_exists($includeFile) ) + Fatal("View '$view' does not exist"); + require_once $includeFile; } - // If the view is missing or the view still returned error with the user logged in, - // then it is not recoverable. - if ( !$includeFiles || $view == 'error' ) { - foreach ( getSkinIncludes('views/error.php', true, true) as $includeFile ) + // If the view overrides $view to 'error', and the user is not logged in, then the + // issue is probably resolvable by logging in, so provide the opportunity to do so. + // The login view should handle redirecting to the correct location afterward. + if ( $view == 'error' && !isset($user) ) { + $view = 'login'; + foreach ( getSkinIncludes('views/login.php', true, true) as $includeFile ) require_once $includeFile; } } +// If the view is missing or the view still returned error with the user logged in, +// then it is not recoverable. +if ( !$includeFiles || $view == 'error' ) { + foreach ( getSkinIncludes('views/error.php', true, true) as $includeFile ) + require_once $includeFile; +} ?> diff --git a/web/skins/classic/js/base.js b/web/skins/classic/js/base.js index b77b350ef..41bec4ed9 100644 --- a/web/skins/classic/js/base.js +++ b/web/skins/classic/js/base.js @@ -64,7 +64,7 @@ var popupSizes = { 'stats': {'width': 840, 'height': 200}, 'storage': {'width': 600, 'height': 405}, 'timeline': {'width': 760, 'height': 540}, - 'user': {'width': 360, 'height': 720}, + 'user': {'width': 460, 'height': 720}, 'version': {'width': 360, 'height': 185}, 'video': {'width': 420, 'height': 360}, 'videoview': {'addWidth': 48, 'addHeight': 80}, diff --git a/web/skins/classic/views/events.php b/web/skins/classic/views/events.php index 1ae446b9e..885924e64 100644 --- a/web/skins/classic/views/events.php +++ b/web/skins/classic/views/events.php @@ -79,7 +79,9 @@ $pagination = getPagination($pages, $page, $maxShortcuts, $filterQuery.$sortQuer $focusWindow = true; if ( $_POST ) { - header('Location: ' . $_SERVER['REQUEST_URI'].htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page); + // I think this is basically so that a refresh doesn't repost + Logger::Debug("Redirecting to " . $_SERVER['REQUEST_URI']); + header('Location: ?view=' . $view.htmlspecialchars_decode($filterQuery).htmlspecialchars_decode($sortQuery).$limitQuery.'&page='.$page); exit(); } diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index bbce2973d..403a9b440 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -50,7 +50,7 @@ if ( isset($_REQUEST['sort_field']) && isset($_REQUEST['filter']) ) { } if ( isset($_REQUEST['filter']) ) { - $filter->set( $_REQUEST['filter'] ); + $filter->set($_REQUEST['filter']); # Update our filter object with whatever changes we have made before saving } @@ -58,7 +58,7 @@ $conjunctionTypes = getFilterQueryConjunctionTypes(); $obracketTypes = array(); $cbracketTypes = array(); -if (count($filter->terms()) > 0) { +if ( count($filter->terms()) > 0 ) { $terms = $filter->terms(); } else { $terms[] = array(); @@ -177,9 +177,9 @@ if ( (null !== $filter->Concurrent()) and $filter->Concurrent() ) ?> -