0 ) { if ( count($rSockets) != 1 ) { ajaxError('Bogus return from select, '.count($rSockets).' sockets available'); } } switch( $nbytes = @socket_recvfrom($socket, $msg, MSG_DATA_SIZE, 0, $remSockFile) ) { case -1 : ajaxError("socket_recvfrom( $remSockFile ) failed: ".socket_strerror(socket_last_error())); break; case 0 : ajaxError('No data to read from socket'); break; default : if ( $nbytes != MSG_DATA_SIZE ) ajaxError("Got unexpected message size, got $nbytes, expected ".MSG_DATA_SIZE); break; } $data = unpack('ltype', $msg); switch ( $data['type'] ) { case MSG_DATA_WATCH : $data = unpack('ltype/imonitor/istate/dfps/ilevel/irate/ddelay/izoom/Cdelayed/Cpaused/Cenabled/Cforced', $msg); $data['fps'] = round( $data['fps'], 2 ); $data['rate'] /= RATE_BASE; $data['delay'] = round( $data['delay'], 2 ); $data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 ); if ( ZM_OPT_USE_AUTH && (ZM_AUTH_RELAY == 'hashed') ) { $auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS); if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) { $data['auth'] = $auth_hash; ZM\Logger::Debug("including nw auth hash " . $data['auth']); } else { ZM\Logger::Debug('Not including nw auth hash becase it hashn\'t changed '.$auth_hash); } } ajaxResponse(array('status'=>$data)); break; case MSG_DATA_EVENT : if ( version_compare( phpversion(), '5.6.0', '<') ) { ZM\Logger::Debug('Using old unpack methods to handle 64bit event id'); $data = unpack('ltype/ieventlow/ieventhigh/dprogress/irate/izoom/Cpaused', $msg); $data['event'] = $data['eventhigh'] << 32 | $data['eventlow']; } else { $data = unpack('ltype/Qevent/dprogress/irate/izoom/Cpaused', $msg); } $data['rate'] /= RATE_BASE; $data['zoom'] = round($data['zoom']/SCALE_BASE, 1); if ( ZM_OPT_USE_AUTH && (ZM_AUTH_RELAY == 'hashed') ) { $auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS); if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) { $data['auth'] = $auth_hash; } } ajaxResponse(array('status'=>$data)); break; default : ajaxError("Unexpected received message type '$type'"); } sem_release($semaphore); } else { ZM\Logger::Debug('Couldn\'t get semaphore'); ajaxResponse(array()); } ajaxError('Unrecognised action or insufficient permissions in ajax/stream'); function ajaxCleanup() { global $socket, $localSocketFile; if ( !empty($socket) ) @socket_close($socket); if ( !empty($localSocketFile) ) @unlink($localSocketFile); } ?>