0 ) { if ( count($rSockets) != 1 ) { Error( "Bogus return from select, ".count($rSockets).' sockets available' ); 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 ); Logger::Debug("FPS: " . $data['fps'] ); $data['fps'] = round( $data['fps'], 2 ); Logger::Debug("FPS: " . $data['fps'] ); $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' ) { session_start(); $time = time(); // Regenerate auth hash after half the lifetime of the hash if ( (!isset($_SESSION['AuthHashGeneratedAt'])) or ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) ) { $data['auth'] = generateAuthHash( ZM_AUTH_HASH_IPS ); } session_write_close(); } ajaxResponse( array( 'status'=>$data ) ); break; } case MSG_DATA_EVENT : { $data = unpack( "ltype/ievent/iprogress/irate/izoom/Cpaused", $msg ); //$data['progress'] = sprintf( "%.2f", $data['progress'] ); $data['rate'] /= RATE_BASE; $data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 ); if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == 'hashed' ) { session_start(); $time = time(); // Regenerate auth hash after half the lifetime of the hash if ( (!isset($_SESSION['AuthHashGeneratedAt'])) or ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) ) { $data['auth'] = generateAuthHash( ZM_AUTH_HASH_IPS ); } session_write_close(); } ajaxResponse( array( 'status'=>$data ) ); break; } default : { ajaxError( "Unexpected received message type '$type'" ); } } ajaxError( 'Unrecognised action or insufficient permissions' ); function ajaxCleanup() { global $socket, $locSockFile; if ( !empty( $socket ) ) @socket_close( $socket ); if ( !empty( $locSockFile ) ) @unlink( $locSockFile ); } ?>