Merge pull request #2706 from connortechnology/fix_2705

Fix 2705
This commit is contained in:
Isaac Connor 2019-09-15 12:20:47 -04:00 committed by GitHub
commit 845d0a0be3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 25 deletions

View File

@ -22,10 +22,6 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <sys/time.h>
#include <syslog.h>
#include <signal.h>
#include <stdarg.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
@ -45,8 +41,20 @@ FileCamera::FileCamera(
int p_hue, int p_hue,
int p_colour, int p_colour,
bool p_capture, bool p_capture,
bool p_record_audio bool p_record_audio)
) : Camera( p_id, FILE_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ) : Camera(
p_id,
FILE_SRC,
p_width,
p_height,
p_colours,
ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours),
p_brightness,
p_contrast,
p_hue,
p_colour,
p_capture,
p_record_audio)
{ {
strncpy( path, p_path, sizeof(path)-1 ); strncpy( path, p_path, sizeof(path)-1 );
if ( capture ) { if ( capture ) {
@ -62,8 +70,7 @@ FileCamera::~FileCamera() {
void FileCamera::Initialise() { void FileCamera::Initialise() {
if ( !path[0] ) { if ( !path[0] ) {
Error( "No path specified for file image" ); Fatal("No path specified for file image");
exit( -1 );
} }
} }
@ -72,21 +79,25 @@ void FileCamera::Terminate() {
int FileCamera::PreCapture() { int FileCamera::PreCapture() {
struct stat statbuf; struct stat statbuf;
if ( stat( path, &statbuf ) < 0 ) { if ( stat(path, &statbuf) < 0 ) {
Error( "Can't stat %s: %s", path, strerror(errno) ); Error("Can't stat %s: %s", path, strerror(errno));
return( -1 ); return -1;
} }
bytes += statbuf.st_size;
// This waits until 1 second has passed since it was modified. Effectively limiting fps to 60.
// Which is kinda bogus. If we were writing to this jpg constantly faster than we are monitoring it here
// we would never break out of this loop
while ( (time(0) - statbuf.st_mtime) < 1 ) { while ( (time(0) - statbuf.st_mtime) < 1 ) {
usleep( 100000 ); usleep(100000);
} }
return( 0 ); return 0;
} }
int FileCamera::Capture( Image &image ) { int FileCamera::Capture(Image &image) {
return( image.ReadJpeg( path, colours, subpixelorder )?1:-1 ); return image.ReadJpeg(path, colours, subpixelorder)?1:-1;
} }
int FileCamera::PostCapture() { int FileCamera::PostCapture() {
return( 0 ); return 0;
} }

View File

@ -37,7 +37,6 @@ if ( $action == 'user' ) {
if ( $_REQUEST['newUser']['Password'] ) { if ( $_REQUEST['newUser']['Password'] ) {
$changes['Password'] = 'Password = '.$pass_hash; $changes['Password'] = 'Password = '.$pass_hash;
ZM\Info('PASS CMD='.$changes['Password']);
} else { } else {
unset($changes['Password']); unset($changes['Password']);
} }
@ -47,7 +46,7 @@ if ( $action == 'user' ) {
dbQuery('UPDATE Users SET '.implode(', ', $changes).' WHERE Id = ?', array($_REQUEST['uid'])); dbQuery('UPDATE Users SET '.implode(', ', $changes).' WHERE Id = ?', array($_REQUEST['uid']));
# If we are updating the logged in user, then update our session user data. # If we are updating the logged in user, then update our session user data.
if ( $user and ( $dbUser['Username'] == $user['Username'] ) ) if ( $user and ( $dbUser['Username'] == $user['Username'] ) )
userLogin($dbUser['Username'], $dbUser['Password']); generateAuthHash(ZM_AUTH_HASH_IPS);
} else { } else {
dbQuery('INSERT INTO Users SET '.implode(', ', $changes)); dbQuery('INSERT INTO Users SET '.implode(', ', $changes));
} }
@ -71,13 +70,13 @@ if ( $action == 'user' ) {
if ( !empty($_REQUEST['newUser']['Password']) ) { if ( !empty($_REQUEST['newUser']['Password']) ) {
$changes['Password'] = 'Password = '.$pass_hash; $changes['Password'] = 'Password = '.$pass_hash;
} } else {
else
unset($changes['Password']); unset($changes['Password']);
}
if ( count($changes) ) { if ( count($changes) ) {
dbQuery('UPDATE Users SET '.implode(', ', $changes).' WHERE Id=?', array($uid)); dbQuery('UPDATE Users SET '.implode(', ', $changes).' WHERE Id=?', array($uid));
$refreshParent = true; $refreshParent = true;
generateAuthHash(ZM_AUTH_HASH_IPS);
} }
$view = 'none'; $view = 'none';
} }