 Embed Video Encoder settings: working Save, logo upload, module removal
- New updateServerModuleSettings.php: saves the Embed Video Encoder
settings window (frame size, port, quality, time stamp / label / logo)
with range checks. Other module types get a clear "not supported".
- Settings window: Save button shown when the content provides
saveSettings(); the Time Stamp, Label and Logo tabs and the show
checkboxes are enabled again.
- Positions are pixel number fields (negative = from right / bottom edge,
as la_mojo uses them); font scale / thickness are number fields; line
type offers OpenCV values (normal 8, thin 4, antialiased 16, old 0/1
shown as 8/4). Hints explain positions and that the time stamp is only
drawn when the label is off.
- New uploadAsset.php: logo upload converts any GD-readable picture to an
RGBA PNG data/assets/images/<md5>.png and stores logo_md5; the preview
shows the current logo and the first upload proposes a size.
- doModuleOperation.php removal: real module type ids (2 Kafka, 6 SSDP,
8 Embed Video, 9 Modem, 12 BVMS, 13 Attention) and tables that do not
exist in the database are skipped instead of failing.
- Frame preview no longer fails when the Logo tab is not rendered yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
4 hours ago |
|
<?php // Saves the settings window of a module (getModuleSettings.php -> saveSettings()).
require_once('../ajax_asm.php'); if( $CUser->Data['id'] > 1 ){ $Data = array(); $Data['success'] = false; $Data['msg'] = 'Module Not Selected!'; $MID = isset( $_POST['MID'] ) ? intval( $_POST['MID'] ) : 0; if( $MID > 0 ){ $Data['msg'] = 'Module Does Not Exists!'; $RR = $DATABASE->Query( "SELECT * FROM `modules` WHERE `id`={$MID}", false ); if( count( $RR ) ){ $CMD = $RR[0]; $AUX = intval( $CMD['aux_id'] ); // clamp a numeric POST field to [min,max], $def when it is missing
$pInt = function( $Name, $Min, $Max, $Def ){ if( !isset( $_POST[$Name] ) || $_POST[$Name] === '' ) return $Def; return max( $Min, min( $Max, intval( $_POST[$Name] ) ) ); }; $pFloat = function( $Name, $Min, $Max, $Def ){ if( !isset( $_POST[$Name] ) || $_POST[$Name] === '' ) return $Def; return max( $Min, min( $Max, floatval( $_POST[$Name] ) ) ); }; $pBool = function( $Name ){ if( !isset( $_POST[$Name] ) ) return 0; $V = strtolower( strval( $_POST[$Name] ) ); return ( $V === 'true' || $V === '1' || $V === 'on' ) ? 1 : 0; }; // OpenCV line types la_mojo accepts (0 and 1 are old values: 8 / 4 connected)
$pLine = function( $Name ){ $V = isset( $_POST[$Name] ) ? intval( $_POST[$Name] ) : 8; return in_array( $V, array( 0, 1, 4, 8, 16 ) ) ? $V : 8; }; switch( intval( $CMD['type'] ) ){ case 8:{ // Embed Video Encoder (module_eve)
$SiW = array( 320, 640, 800, 1280, 1024, 1920 ); $SiH = array( 240, 480, 600, 720, 768, 1080 ); $SIZE = $pInt( 'SIZE', 0, count( $SiW ) - 1, 3 ); $W = $SiW[$SIZE]; $H = $SiH[$SIZE]; $F = array( 'web_port' => $pInt( 'PORT', 1, 65535, 8972 ), 'width' => $W, 'height' => $H, 'compression_quality' => $pInt( 'COMPRESSION', 0, 100, 70 ), 'show_ts' => $pBool( 'SHOW1' ), 'show_label' => $pBool( 'SHOW2' ), 'show_logo' => $pBool( 'SHOW3' ), // positions in pixels, negative values are measured from the right / bottom edge
'ts_x' => $pInt( 'TS_POSX', -$W, $W, 5 ), 'ts_y' => $pInt( 'TS_POSY', -$H, $H, 5 ), 'ts_transperant' => $pBool( 'TS_TRANS' ), 'ts_font_face' => $pInt( 'TS_FONT', 0, 7, 1 ), 'ts_font_scale' => $pFloat( 'TS_FONT_SCALE', 0.1, 4.0, 1.0 ), 'ts_font_thickness' => $pInt( 'TS_FONT_THICK', 1, 8, 1 ), 'ts_line_type' => $pLine( 'TS_LINE' ), 'label_x' => $pInt( 'LBL_POSX', -$W, $W, 5 ), 'label_y' => $pInt( 'LBL_POSY', -$H, $H, -10 ), 'label_transperant' => $pBool( 'LBL_TRANS' ), 'label_font_face' => $pInt( 'LBL_FONT', 0, 7, 1 ), 'label_font_scale' => $pFloat( 'LBL_FONT_SCALE', 0.1, 4.0, 1.0 ), 'label_font_thickness' => $pInt( 'LBL_FONT_THICK', 1, 8, 1 ), 'label_line_type' => $pLine( 'LBL_LINE' ), 'logo_x' => $pInt( 'LOG_POSX', -$W, $W, 0 ), 'logo_y' => $pInt( 'LOG_POSY', -$H, $H, 0 ), 'logo_w' => $pInt( 'LOG_W', 0, $W, 0 ), 'logo_h' => $pInt( 'LOG_H', 0, $H, 0 ) ); $SET = array(); foreach( $F as $K => $V ) $SET[] = "`{$K}`=".( is_float( $V ) ? sprintf( '%.3F', $V ) : intval( $V ) ); // exec() reports a failure instead of die() in Query()
if( $DATABASE->DBLink->exec( "UPDATE `module_eve` SET ".implode( ', ', $SET )." WHERE `id`={$AUX}" ) ){ $Data['success'] = true; $Data['msg'] = ''; } else { $Data['msg'] = 'Unable to save the settings!'; }; break; }; default: $Data['msg'] = 'Saving the settings of this module type is not supported!'; break; }; }; }; echo json_encode( $Data ); exit(); }; header( 'location: /');?>
|