 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 // Asset upload. type=eve_logo, id=<module id>: logo of the Embed Video Encoder.
// The picture is stored as an RGBA PNG in data/assets/images/<md5>.png (the path la_mojo
// loads, relative to its working folder) and module_eve.logo_md5 is updated.
require_once('../ajax_asm.php'); if( $CUser->Data['id'] > 1 ){ $Data = array(); $Data['success'] = false; $Data['msg'] = 'Wrong Parameters'; $TYPE = isset( $_POST['type'] ) ? strval( $_POST['type'] ) : ''; $MID = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0; if( $TYPE == 'eve_logo' && $MID > 0 ){ $RR = $DATABASE->Query( "SELECT * FROM `modules` WHERE `id`={$MID} AND `type`=8", false ); if( !count( $RR ) ){ $Data['msg'] = 'Module Does Not Exists!'; } else if( !isset( $_FILES['file'] ) || $_FILES['file']['error'] != UPLOAD_ERR_OK || !is_uploaded_file( $_FILES['file']['tmp_name'] ) ){ $Data['msg'] = 'File upload failed!'; } else if( $_FILES['file']['size'] > 4 * 1024 * 1024 ){ $Data['msg'] = 'The picture is too big (max 4 MB)!'; } else if( !function_exists( 'imagecreatefromstring' ) ){ $Data['msg'] = 'PHP GD extension is missing!'; } else { $IMG = @imagecreatefromstring( file_get_contents( $_FILES['file']['tmp_name'] ) ); if( $IMG === false ){ $Data['msg'] = 'Unsupported picture format!'; } else { // normalise to a true colour picture with alpha channel (la_mojo uses alpha as mask)
$W = imagesx( $IMG ); $H = imagesy( $IMG ); $OUT = imagecreatetruecolor( $W, $H ); imagealphablending( $OUT, false ); imagesavealpha( $OUT, true ); imagefill( $OUT, 0, 0, imagecolorallocatealpha( $OUT, 0, 0, 0, 127 ) ); imagecopy( $OUT, $IMG, 0, 0, 0, 0, $W, $H ); imagedestroy( $IMG ); ob_start(); imagepng( $OUT ); $PNG = ob_get_clean(); imagedestroy( $OUT ); $MD5 = md5( $PNG ); $DIR = __DIR__.'/data/assets/images'; if( !is_dir( $DIR ) ) @mkdir( $DIR, 0775, true ); if( @file_put_contents( $DIR.'/'.$MD5.'.png', $PNG ) === false ){ $Data['msg'] = 'Unable to store the picture!'; } else { $AUX = intval( $RR[0]['aux_id'] ); $DATABASE->DBLink->exec( "UPDATE `module_eve` SET `logo_md5`='{$MD5}' WHERE `id`={$AUX}" ); $Data['success'] = true; $Data['msg'] = ''; $Data['md5'] = $MD5; $Data['url'] = '/lib/controller/data/assets/images/'.$MD5.'.png'; $Data['width'] = $W; $Data['height'] = $H; }; }; }; }; echo json_encode( $Data ); exit(); }; header( 'location: /');?>
|