From ea4937b75e3c2eaf5c0ea23149dac9955a7f40cb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 23 Jan 2018 17:47:24 -0500 Subject: [PATCH 01/14] put back missing s --- web/skins/classic/views/js/monitor.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/monitor.js.php b/web/skins/classic/views/js/monitor.js.php index 16c7ee438..8871de840 100644 --- a/web/skins/classic/views/js/monitor.js.php +++ b/web/skins/classic/views/js/monitor.js.php @@ -36,7 +36,7 @@ controlOptions[][] = ' From 9f89ccfa32ad06c19827ee7d16b933d04eb16682 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Jan 2018 07:46:56 -0500 Subject: [PATCH 02/14] revert issue with AUTH_HASH_LOGINS --- web/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index 51884f1d0..b2afc8681 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -148,7 +148,7 @@ function getAuthUser( $auth ) { } // end getAuthUser($auth) function generateAuthHash( $useRemoteAddr ) { - if ( ZM_OPT_USE_AUTH and ZM_AUTH_HASH_LOGINS and ZM_AUTH_RELAY == 'hashed' and isset($_SESSION['username']) and $_SESSION['passwordHash'] ) { + if ( ZM_OPT_USE_AUTH and ZM_AUTH_RELAY == 'hashed' and isset($_SESSION['username']) and $_SESSION['passwordHash'] ) { # regenerate a hash at half the liftetime of a hash, an hour is 3600 so half is 1800 $time = time(); if ( ( ! isset($_SESSION['AuthHash']) ) or ( $_SESSION['AuthHashGeneratedAt'] < ( $time - ( ZM_AUTH_HASH_TTL * 1800 ) ) ) ) { From c7ecd580c1fc9512ebecc08f2f604934b0af52f1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Jan 2018 10:27:01 -0500 Subject: [PATCH 03/14] Fix #81 by testing for non-numeric characters in LIMIT. Change type of input to number, making it harder to enter non-numeric characters --- web/skins/classic/views/filter.php | 2 +- web/skins/classic/views/js/filter.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index d01204d91..9d4d6094e 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -334,7 +334,7 @@ echo htmlSelect( 'filter[Query][sort_asc]', $sort_dirns, $filter->sort_asc() ); - + diff --git a/web/skins/classic/views/js/filter.js b/web/skins/classic/views/js/filter.js index 4f574507d..c8e6749a4 100644 --- a/web/skins/classic/views/js/filter.js +++ b/web/skins/classic/views/js/filter.js @@ -16,6 +16,11 @@ function validateForm ( form ) { alert( errorBrackets ); return false; } + var numbers_reg = /\D/; + if ( numbers_reg.test( form.elements['filter[Query][limit]'].value ) ) { + alert( "There appear to be non-numeric characters in your limit. Limit must be a positive integer value or empty." ); + return false; + } return true; } From a271f1776d35e0ed352ab4f96d76765fb71118db Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Jan 2018 10:35:22 -0500 Subject: [PATCH 04/14] Fix #80 don't escape NULL value when building SQL --- web/includes/functions.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index b2afc8681..2214d1cff 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -1236,31 +1236,38 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) { case 'ServerId': if ( $value == 'ZM_SERVER_ID' ) { $value = ZM_SERVER_ID; + } else if ( $value == 'NULL' ) { + } else { $value = dbEscape($value); } break; case 'StorageId': $StorageArea = new Storage( $value ); - $value = dbEscape($value); + if ( $value != 'NULL' ) + $value = dbEscape($value); break; case 'DateTime': case 'StartDateTime': case 'EndDateTime': - $value = "'".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."'"; + if ( $value != 'NULL' ) + $value = "'".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."'"; break; case 'Date': case 'StartDate': case 'EndDate': - $value = "to_days( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )"; + if ( $value != 'NULL' ) + $value = "to_days( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )"; break; case 'Time': case 'StartTime': case 'EndTime': + if ( $value != 'NULL' ) $value = "extract( hour_second from '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )"; break; default : - $value = dbEscape($value); + if ( $value != 'NULL' ) + $value = dbEscape($value); break; } $valueList[] = $value; From cf4ac74d02beeae8104159862371811ca1d6ead0 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Jan 2018 10:45:42 -0500 Subject: [PATCH 05/14] If failed to delete from Frames or Stats, return instead of deleting the event. --- scripts/ZoneMinder/lib/ZoneMinder/Event.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index 43bff549e..530aa4f5c 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -357,6 +357,9 @@ sub delete { my $res = $sth->execute( $event->{Id} ) or Error( "Can't execute '$sql': ".$sth->errstr() ); $sth->finish(); + if ( $ZoneMinder::Database::dbh->errstr() ) { + return; + } $sql = 'DELETE FROM Stats WHERE EventId=?'; $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql ) @@ -364,6 +367,9 @@ sub delete { $res = $sth->execute( $event->{Id} ) or Error( "Can't execute '$sql': ".$sth->errstr() ); $sth->finish(); + if ( $ZoneMinder::Database::dbh->errstr() ) { + return; + } $event->delete_files( ); } else { From 50fc4a2d94c2ed5e9406105b0673e1dd3dfbd554 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Jan 2018 11:51:11 -0500 Subject: [PATCH 06/14] Use a memory table called Monitor_Status to store FPS and Status info for Monitors. This is to reduce locking and updates on the main Monitors table. --- db/zm_create.sql.in | 11 ++-- db/zm_update-1.31.28.sql | 57 ++++++++++++++++++++ src/zm_ffmpeg_camera.cpp | 7 +-- src/zm_monitor.cpp | 4 +- src/zmc.cpp | 2 +- version | 2 +- web/skins/classic/views/_monitor_filters.php | 2 +- web/skins/classic/views/console.php | 13 ++++- 8 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 db/zm_update-1.31.28.sql diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 92d133e0f..2ff2de208 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -608,9 +608,6 @@ CREATE TABLE `Monitors` ( `WebColour` varchar(32) NOT NULL default 'red', `Exif` tinyint(1) unsigned NOT NULL default '0', `Sequence` smallint(5) unsigned default NULL, - `Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown', - `CaptureFPS` DECIMAL(10,2) NOT NULL default 0, - `AnalysisFPS` DECIMAL(5,2) NOT NULL default 0, `TotalEvents` int(10) unsigned, `TotalEventDiskSpace` bigint unsigned, `HourEvents` int(10) unsigned, @@ -629,6 +626,14 @@ CREATE TABLE `Monitors` ( CREATE INDEX `Monitors_ServerId_idx` ON `Monitors` (`ServerId`); +DROP TABLE IF EXISTS `Monitor_Status`; +CREATE TABLE `Monitor_Status` ( + `Id` int(10) unsigned NOT NULL, + `Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown', + `CaptureFPS` DECIMAL(10,2) NOT NULL default 0, + `AnalysisFPS` DECIMAL(5,2) NOT NULL default 0, + PRIMARY KEY (`Id`) +) ENGINE=MEMORY; -- -- Table structure for table `States` -- PP - Added IsActive to track custom run states diff --git a/db/zm_update-1.31.28.sql b/db/zm_update-1.31.28.sql new file mode 100644 index 000000000..ce540b545 --- /dev/null +++ b/db/zm_update-1.31.28.sql @@ -0,0 +1,57 @@ +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitor_Status' + ) > 0 + , + "SELECT 'Monitor_Status Already exists'", + " +CREATE TABLE `Monitor_Status` ( + `Id` int(10) unsigned NOT NULL, + `Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown', + `CaptureFPS` DECIMAL(10,2) NOT NULL default 0, + `AnalysisFPS` DECIMAL(5,2) NOT NULL default 0, + PRIMARY KEY (`Id`) +) ENGINE=MEMORY" + )); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'Status' + ) > 0 + , + "ALTER TABLE Monitors DROP COLUMN Status" + "SELECT 'Monitor Status already removed.'", + )); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'CaptureFPS' + ) > 0 + , + "ALTER TABLE Monitors DROP COLUMN CaptureFPS" + "SELECT 'Monitor CaptureFPS already removed.'", + )); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'AnalysisFPS' + ) > 0 + , + "ALTER TABLE Monitors DROP COLUMN AnalysisFPS" + "SELECT 'Monitor AnalysisFPS already removed.'", + )); + +PREPARE stmt FROM @s; +EXECUTE stmt; diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 25e96e5a7..069d68b63 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -738,7 +738,8 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event int ret; static char errbuf[AV_ERROR_MAX_STRING_SIZE]; - // If the reopen thread has a value, but mCanCapture != 0, then we have just reopened the connection to the ffmpeg device, and we can clean up the thread. + // If the reopen thread has a value, but mCanCapture != 0, then we have just reopened + // the connection to the ffmpeg device, and we can clean up the thread. if ( mReopenThread != 0 ) { void *retval = 0; @@ -751,7 +752,6 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event mReopenThread = 0; } - int frameComplete = false; while ( ! frameComplete ) { av_init_packet( &packet ); @@ -774,7 +774,7 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event } int keyframe = packet.flags & AV_PKT_FLAG_KEY; -dumpPacket(&packet); + dumpPacket(&packet); //Video recording if ( recording.tv_sec ) { @@ -836,6 +836,7 @@ dumpPacket(&packet); startTime, this->getMonitor()); } // end if record_audio + if ( ! videoStore->open() ) { delete videoStore; videoStore = NULL; diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index dc097d1ab..980a41645 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1205,7 +1205,7 @@ bool Monitor::Analyse() { fps = double(fps_report_interval)/(now.tv_sec - last_fps_time); Info( "%s: %d - Analysing at %.2f fps", name, image_count, fps ); static char sql[ZM_SQL_SML_BUFSIZ]; - snprintf( sql, sizeof(sql), "UPDATE Monitors SET AnalysisFPS = '%.2lf' WHERE Id = '%d'", fps, id ); + snprintf( sql, sizeof(sql), "INSERT INTO Monitor_Status (Id,AnalysisFPS) VALUES (%d, %.2lf) ON DUPLICATE KEY UPDATE AnalysisFPS = %.2lf", id, fps, fps ); if ( mysql_query( &dbconn, sql ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) ); } @@ -3022,7 +3022,7 @@ Debug(4, "Return from Capture (%d)", captureResult); Info( "%s: images:%d - Capturing at %.2lf fps", name, image_count, fps ); last_fps_time = now; static char sql[ZM_SQL_SML_BUFSIZ]; - snprintf( sql, sizeof(sql), "UPDATE Monitors SET CaptureFPS='%.2lf' WHERE Id=%d", fps, id ); + snprintf( sql, sizeof(sql), "INSERT INTO Monitor_Status (Id,CaptureFPS) VALUES (%d, %.2lf) ON DUPLICATE KEY UPDATE CaptureFPS = %.2lf", id, fps, fps ); if ( mysql_query( &dbconn, sql ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) ); } diff --git a/src/zmc.cpp b/src/zmc.cpp index a58e04a86..5169b0699 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -223,7 +223,7 @@ int main(int argc, char *argv[]) { Info("Starting Capture version %s", ZM_VERSION); static char sql[ZM_SQL_SML_BUFSIZ]; for ( int i = 0; i < n_monitors; i ++ ) { - snprintf( sql, sizeof(sql), "UPDATE Monitors SET Status = 'Running' WHERE Id = '%d'", monitors[i]->Id() ); + snprintf( sql, sizeof(sql), "REPLACE INTO Monitor_Status (Id, Status ) VALUES ('%d','Running')", monitors[i]->Id() ); if ( mysql_query( &dbconn, sql ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) ); } diff --git a/version b/version index 060b0a197..9e60186a4 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.31.27 +1.31.28 diff --git a/web/skins/classic/views/_monitor_filters.php b/web/skins/classic/views/_monitor_filters.php index d2564f7a5..7633200ea 100644 --- a/web/skins/classic/views/_monitor_filters.php +++ b/web/skins/classic/views/_monitor_filters.php @@ -89,7 +89,7 @@ if ( ! is_array( $selected_monitor_ids ) ) { $values += $ids; } - $sql = 'SELECT * FROM Monitors' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC'; + $sql = 'SELECT *,S.Status AS Status, S.CaptureFPS AS CaptureFPS FROM Monitors AS M LEFT JOIN Monitor_Status AS S ON S.Id=M.Id ' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC'; $monitors = dbFetchAll( $sql, null, $values ); $displayMonitors = array(); $monitors_dropdown = array(); diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index a4731d649..d3350ff96 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -215,7 +215,18 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { ' : '>') . $monitor['Name'] ?> '.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'', canEdit( 'Monitors' ) ) ?>
- + From b821d665bfc07d536e89fe4036aca38e17c66ceb Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Jan 2018 12:16:18 -0500 Subject: [PATCH 07/14] Fix commas --- db/zm_update-1.31.28.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/zm_update-1.31.28.sql b/db/zm_update-1.31.28.sql index ce540b545..096b020c9 100644 --- a/db/zm_update-1.31.28.sql +++ b/db/zm_update-1.31.28.sql @@ -23,8 +23,8 @@ SET @s = (SELECT IF( AND column_name = 'Status' ) > 0 , - "ALTER TABLE Monitors DROP COLUMN Status" - "SELECT 'Monitor Status already removed.'", + "ALTER TABLE Monitors DROP COLUMN Status", + "SELECT 'Monitor Status already removed.'" )); PREPARE stmt FROM @s; @@ -36,8 +36,8 @@ SET @s = (SELECT IF( AND column_name = 'CaptureFPS' ) > 0 , - "ALTER TABLE Monitors DROP COLUMN CaptureFPS" - "SELECT 'Monitor CaptureFPS already removed.'", + "ALTER TABLE Monitors DROP COLUMN CaptureFPS", + "SELECT 'Monitor CaptureFPS already removed.'" )); PREPARE stmt FROM @s; @@ -49,8 +49,8 @@ SET @s = (SELECT IF( AND column_name = 'AnalysisFPS' ) > 0 , - "ALTER TABLE Monitors DROP COLUMN AnalysisFPS" - "SELECT 'Monitor AnalysisFPS already removed.'", + "ALTER TABLE Monitors DROP COLUMN AnalysisFPS", + "SELECT 'Monitor AnalysisFPS already removed.'" )); PREPARE stmt FROM @s; From 1800c6fcf0a691195a9aac156b3302c289590b51 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Jan 2018 12:16:34 -0500 Subject: [PATCH 08/14] Add locking around Event deletion --- scripts/ZoneMinder/lib/ZoneMinder/Event.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm index 530aa4f5c..766436a84 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Event.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Event.pm @@ -350,6 +350,9 @@ sub delete { Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime}\n" ); $ZoneMinder::Database::dbh->ping(); + $ZoneMinder::Database::dbh->begin_work(); + $event->lock_and_load(); + if ( ! $Config{ZM_OPT_FAST_DELETE} ) { my $sql = 'DELETE FROM Frames WHERE EventId=?'; my $sth = $ZoneMinder::Database::dbh->prepare_cached( $sql ) @@ -358,6 +361,7 @@ sub delete { or Error( "Can't execute '$sql': ".$sth->errstr() ); $sth->finish(); if ( $ZoneMinder::Database::dbh->errstr() ) { + $ZoneMinder::Database::dbh->commit(); return; } @@ -368,6 +372,7 @@ sub delete { or Error( "Can't execute '$sql': ".$sth->errstr() ); $sth->finish(); if ( $ZoneMinder::Database::dbh->errstr() ) { + $ZoneMinder::Database::dbh->commit(); return; } @@ -382,6 +387,7 @@ sub delete { my $res = $sth->execute( $event->{Id} ) or Error( "Can't execute '$sql': ".$sth->errstr() ); $sth->finish(); + $ZoneMinder::Database::dbh->commit(); } # end sub delete sub delete_files { @@ -520,7 +526,10 @@ sub MoveTo { } } } - return $error if $error; + if ( $error ) { + $ZoneMinder::Database::dbh->commit(); + return $error; + } my @files = glob("$OldPath/*"); for my $file (@files) { From e4c900a8688960310f74b59de8944dc005ed4a57 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Jan 2018 12:15:35 -0500 Subject: [PATCH 09/14] Use a LEFT JOIN on Storage WHEN Running Filters --- scripts/ZoneMinder/lib/ZoneMinder/Filter.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm index ed5779b2b..cd8b76a62 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Filter.pm @@ -140,7 +140,7 @@ sub Sql { M.DefaultScale FROM Events as E INNER JOIN Monitors as M on M.Id = E.MonitorId - INNER JOIN Storage as S on S.Id = E.StorageId + LEFT JOIN Storage as S on S.Id = E.StorageId '; $self->{Sql} = ''; From c930a7cce650acd6c490bba4eb07b68cbde1d19c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 Jan 2018 15:29:49 -0500 Subject: [PATCH 10/14] fix crash --- scripts/zmaudit.pl.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/zmaudit.pl.in b/scripts/zmaudit.pl.in index 78373c2c8..519e80851 100644 --- a/scripts/zmaudit.pl.in +++ b/scripts/zmaudit.pl.in @@ -395,11 +395,11 @@ MAIN: while( $loop ) { while ( my ( $db_event, $age ) = each( %$db_events ) ) { if ( ! defined( $fs_events->{$db_event} ) ) { my $Event = ZoneMinder::Event->find_one( Id=>$db_event ); - Debug("Event $db_event is not in fs. Should have been at ".$Event->Path()); if ( ! $Event ) { Debug("Event $db_event is no longer in db. Filter probably deleted it while we were auditing."); next; } + Debug("Event $db_event is not in fs. Should have been at ".$Event->Path()); if ( ! $Event->StartTime() ) { Info("Event $$Event{Id} has no start time. deleting it."); if ( confirm() ) { From e364a541d4f34fea9cf64e7cf7fda5c572f62e13 Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 24 Jan 2018 22:21:43 +0100 Subject: [PATCH 11/14] Whitespace and use ZM_DIR_EXPORT instead of ZM_DIR_TMP --- web/views/archive.php | 59 +++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/web/views/archive.php b/web/views/archive.php index ce4e1b274..9238a925e 100644 --- a/web/views/archive.php +++ b/web/views/archive.php @@ -18,45 +18,44 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -if ( !canView( 'Events' ) ) -{ - $view = "error"; - return; +if ( !canView( 'Events' ) ) { + $view = 'error'; + return; } $archivetype = $_REQUEST['type']; if ( $archivetype ) { - switch ($archivetype) { - case "tar": - $mimetype = "gzip"; - $file_ext = "tar.gz"; - break; - case "zip": - $mimetype = "zip"; - $file_ext = "zip"; - break; - default: - $mimetype = NULL; - $file_ext = NULL; - } + switch ($archivetype) { + case 'tar': + $mimetype = 'gzip'; + $file_ext = 'tar.gz'; + break; + case 'zip': + $mimetype = 'zip'; + $file_ext = 'zip'; + break; + default: + $mimetype = NULL; + $file_ext = NULL; + } - if ( $mimetype ) { - $filename = "zmExport.$file_ext"; - $filename_path = ZM_DIR_TEMP."/".$filename; - if ( is_readable($filename_path) ) { - header( "Content-type: application/$mimetype" ); - header( "Content-Disposition: attachment; filename=$filename"); - set_time_limit(0); - readfile( $filename_path ); - } else { - Error("$filename_path does not exist or is not readable."); - } + if ( $mimetype ) { + $filename = "zmExport.$file_ext"; + $filename_path = ZM_DIR_EXPORTS.'/'.$filename; + if ( is_readable($filename_path) ) { + header( "Content-type: application/$mimetype" ); + header( "Content-Disposition: attachment; filename=$filename"); + set_time_limit(0); + readfile( $filename_path ); } else { - Error("Unsupported archive type specified. Supported archives are tar and zip"); + Error("$filename_path does not exist or is not readable."); } + } else { + Error("Unsupported archive type specified. Supported archives are tar and zip"); + } } else { - Error("No archive type given to archive.php. Please specify a tar or zip archive."); + Error("No archive type given to archive.php. Please specify a tar or zip archive."); } ?> From 5865bbfb1290657b577788f03f7595100108787e Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 24 Jan 2018 23:07:21 +0100 Subject: [PATCH 12/14] turn off debugging --- web/index.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/web/index.php b/web/index.php index c3f2269fe..3ebc58a98 100644 --- a/web/index.php +++ b/web/index.php @@ -174,17 +174,13 @@ foreach ( getSkinIncludes( 'skin.php' ) as $includeFile ) require_once $includeFile; if ( ZM_OPT_USE_AUTH && ZM_AUTH_HASH_LOGINS ) { - Logger::Debug("Useing hash"); if ( empty($user) && ! empty($_REQUEST['auth']) ) { if ( $authUser = getAuthUser( $_REQUEST['auth'] ) ) { userLogin( $authUser['Username'], $authUser['Password'], true ); } } else if ( ! empty($user) ) { - Logger::Debug("generating hash"); // generate it once here, while session is open. Value will be cached in session and return when called later on generateAuthHash( ZM_AUTH_HASH_IPS ); - } else { - Logger::Debug(" not generating hash"); } } From e4c28150fe066a17b739e50672b5c0a8732ff423 Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 24 Jan 2018 23:07:57 +0100 Subject: [PATCH 13/14] cleanup, code style, quotes. Include jquery source instead of trying to link to it --- .../classic/includes/export_functions.php | 391 ++++++++---------- 1 file changed, 171 insertions(+), 220 deletions(-) diff --git a/web/skins/classic/includes/export_functions.php b/web/skins/classic/includes/export_functions.php index f384594da..8a53394fa 100644 --- a/web/skins/classic/includes/export_functions.php +++ b/web/skins/classic/includes/export_functions.php @@ -71,7 +71,9 @@ html ul.tabs li.active, html ul.tabs li.active a:hover { } --> - +