From 93fb550644c478e8fc600389501190c0ebff98d1 Mon Sep 17 00:00:00 2001 From: Evgeny Gagua Date: Tue, 20 Sep 2022 12:20:14 +0100 Subject: [PATCH] Kafka SSL v 1 --- lib/controller/addNetworkNode.php | 3 + lib/controller/getModuleSettings.php | 154 +++++++++++++++++- lib/controller/uploadModuleKafkaData.php | 53 ++++++ .../jsapi_dynamic/rgoose_dashboard.js | 5 +- lib/javascript/jsapi_dynamic/rgoose_main.js | 80 +++++++++ lib/php/ui/UI_functions.php | 2 + style/style.css | 37 +++++ 7 files changed, 323 insertions(+), 11 deletions(-) create mode 100644 lib/controller/uploadModuleKafkaData.php diff --git a/lib/controller/addNetworkNode.php b/lib/controller/addNetworkNode.php index e68c262..29ed9d2 100644 --- a/lib/controller/addNetworkNode.php +++ b/lib/controller/addNetworkNode.php @@ -6,6 +6,9 @@ if( $CUser->Data['access'] > 5 ){ if( isset($_POST['SITEID']) ) $SiteID = intval($_POST['SITEID']); else $SiteID = 0; if( isset($_POST['SRVID']) ) $ServerID = intval($_POST['SRVID']); else $ServerID = 0; + if( $ServerID == 0 ){ + if( isset($_POST['SERVER']) ) $ServerID = intval($_POST['SERVER']); + }; if( isset($_POST['TYPE']) ) $NodeType = intval($_POST['TYPE']); else $NodeType = 0; if( $ServerID == 0 ){ if( isset($_POST['UART']) ) $ServerID = getServerIdByUartId( intval($_POST['UART']) ); diff --git a/lib/controller/getModuleSettings.php b/lib/controller/getModuleSettings.php index 5846563..d4e8828 100644 --- a/lib/controller/getModuleSettings.php +++ b/lib/controller/getModuleSettings.php @@ -100,8 +100,9 @@ $TPL =<<GetLabel('_KAFKA_BROKER_')}', - labelWidth: 200, + labelWidth: 480, labelAlign: 'right', border: false, frame: false, @@ -121,22 +122,159 @@ $TPL =<<Vault ID: {$CI['vault_md5']}

' }] },{ title: '{$Labels->GetLabel('_KAFKA_TOP_EVTS_')}', html: '' }], + listeners:{ + afterrender: function(){ + var currentSelectedFile = 0; + var up_ca = new plupload.Uploader({ + runtimes : 'html5,html4', + browse_button : Ext.getDom('ca_cert_select'), + max_file_size : '256kb', + chunk_size: '10kb', + max_retries: 0, + multi_selection: false, + max_file_count: 1, + url: '/lib/controller/uploadModuleKafkaData.php', + filters : [ + {title : "Certificate files", extensions : "pem,crt,cert,jks"} + ], + + init: { + PostInit: function() { + }, + + FilesAdded: function( up, files ) { + up_ca.start(); + }, + UploadProgress: function(up, file) { + if( file.percent == 100 ){ + alert('Umpalumpa'); + }; + }, + Error: function(up, err) { + Ext.Msg.show({ + title:'Upload Status', + msg: "Error #" + err.code + ": " + err.message, + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + } + } + }); + var up_crt = new plupload.Uploader({ + runtimes : 'html5,html4', + browse_button : Ext.getDom('cl_cert_select'), + max_file_size : '256kb', + chunk_size: '10kb', + max_retries: 0, + multi_selection: false, + max_file_count: 1, + url: '/lib/controller/uploadModuleKafkaData.php', + filters : [ + {title : "Certificate files", extensions : "pem,crt,cert,jks"} + ], + + init: { + PostInit: function() { + }, + + FilesAdded: function( up, files ) { + up_crt.start(); + }, + UploadProgress: function(up, file) { + if( file.percent == 100 ){ + alert('Umpalumpa'); + }; + }, + Error: function(up, err) { + Ext.Msg.show({ + title:'Upload Status', + msg: "Error #" + err.code + ": " + err.message, + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + } + } + }); + var up_key = new plupload.Uploader({ + runtimes : 'html5,html4', + browse_button : Ext.getDom('cl_key_select'), + max_file_size : '256kb', + chunk_size: '10kb', + max_retries: 0, + multi_selection: false, + max_file_count: 1, + url: '/lib/controller/uploadModuleKafkaData.php', + filters : [ + {title : "Certificate files", extensions : "pem,crt,cert,jks"} + ], + + init: { + PostInit: function() { + }, + + FilesAdded: function( up, files ) { + up_key.start(); + }, + UploadProgress: function(up, file) { + if( file.percent == 100 ){ + alert('Umpalumpa'); + }; + }, + Error: function(up, err) { + Ext.Msg.show({ + title:'Upload Status', + msg: "Error #" + err.code + ": " + err.message, + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.ERROR + }); + } + } + }); + up_ca.init(); + up_crt.init(); + up_key.init(); + } + }, status: 'ok', wTitle: '{$Labels->GetLabel('_KAFKA_DESC_SHO_')}' diff --git a/lib/controller/uploadModuleKafkaData.php b/lib/controller/uploadModuleKafkaData.php new file mode 100644 index 0000000..901c9f9 --- /dev/null +++ b/lib/controller/uploadModuleKafkaData.php @@ -0,0 +1,53 @@ +$ok, "info"=>$info])); + }; + // invalid upload + if( empty( $_FILES ) || $_FILES['file']['error'] ){ + verbose( 0, "Failed to move uploaded file.[" . $_FILES['file']['error'] . "]" ); + }; + // upload destination + //$filePath = __DIR__ . DIRECTORY_SEPARATOR . "../../vault/working_dir/uploads"; + $filePath = $GTEMP_DIR . '/uploads'; + if( !file_exists($filePath) ){ + if (!mkdir($filePath, 0777, true)) { + verbose(0, "Failed to create $filePath"); + }; + }; + $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : $_FILES["file"]["name"]; + $filePath = $filePath . DIRECTORY_SEPARATOR . $fileName; + // dealing with the chunks + $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; + $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0; + $out = @fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab"); + if( $out ) { + $in = @fopen($_FILES['file']['tmp_name'], "rb"); + if( $in ){ + while( $buff = fread( $in, 4096 ) ){ + fwrite($out, $buff); + }; + } else { + verbose(0, "Failed to open input stream"); + }; + @fclose($in); + @fclose($out); + @unlink($_FILES['file']['tmp_name']); + } else { + verbose(0, "Failed to open output stream"); + }; + // check if file was uploaded + if (!$chunks || $chunk == $chunks - 1) { + rename("{$filePath}.part", $filePath); + if( createNewTask( 3, $fileName, 'Handle Upload File' ) == 0 ){ + unlink( $filePath ); + verbose(0, "Failed to create new Task"); + }; + }; + verbose(1, "Upload OK"); +?> \ No newline at end of file diff --git a/lib/javascript/jsapi_dynamic/rgoose_dashboard.js b/lib/javascript/jsapi_dynamic/rgoose_dashboard.js index 29c2524..3b32c4b 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_dashboard.js +++ b/lib/javascript/jsapi_dynamic/rgoose_dashboard.js @@ -419,10 +419,9 @@ function makePtzStop( me ){ }); }; -function fullScreen( id ){ - // if already full screen; exit - // else go fullscreen +function fullScreen( id = '' ){ if( + id == '' || document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || diff --git a/lib/javascript/jsapi_dynamic/rgoose_main.js b/lib/javascript/jsapi_dynamic/rgoose_main.js index f4b330a..f372c3a 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_main.js +++ b/lib/javascript/jsapi_dynamic/rgoose_main.js @@ -15,6 +15,77 @@ var SoundEnable = Data['sound_enable']);?>; var nodeDashboardStatuses = new Array(); var nodeTHREEviewers = new Array(); var nodeTHREEanimationId = 0; +var ssTimer = null; +var ssTimeOut = 60000; //1min +var ssIsActive = false; +var ssInterval = null; + +function ssShowSS() { + ssStopTimer(); + document.removeEventListener( "mousemove", ssResetTimer ); + document.removeEventListener( "mousedown", ssResetTimer ); + document.removeEventListener( "keypress", ssResetTimer ); + document.removeEventListener( "touchmove", ssResetTimer ); + + document.addEventListener( "mousemove", ssHideSS, false ); + document.addEventListener( "mousedown", ssHideSS, false ); + document.addEventListener( "keypress", ssHideSS, false ); + document.addEventListener( "touchmove", ssHideSS, false ); + document.getElementById('ss_bg').className='ss_bg_overlay'; + document.getElementById('ss_content').className='ss_overlay'; + ssShowTime(); + if( ssInterval == null ){ + ssInterval = window.setInterval( ssShowTime, 333 ); + }; + ssIsActive = true; +}; +function ssShowTime(){ + document.getElementById('ss_content').style.fontSize = '240px'; + var currentdate = new Date(); + var cTime = (( currentdate.getHours()<10 )? '0'+currentdate.getHours(): currentdate.getHours() ) + ":" + (( currentdate.getMinutes()<10 )? '0'+currentdate.getMinutes(): currentdate.getMinutes() ) + ":" + (( currentdate.getSeconds()<10 )? '0'+currentdate.getSeconds(): currentdate.getSeconds() ); + document.getElementById('ss_content').innerHTML= cTime; +}; +function ssResetTimer() { + ssStopTimer(); + ssStartTimer(); +}; + +function ssStartTimer() { + if( ssTimer == null ){ + ssTimer = window.setTimeout( ssShowSS, ssTimeOut ); + }; +}; +function ssStopTimer() { + if( ssTimer ){ + window.clearTimeout( ssTimer ); + ssTimer = null; + }; +}; + +function ssSetupTimer() { + document.addEventListener( "mousemove", ssResetTimer, false); + document.addEventListener( "mousedown", ssResetTimer, false); + document.addEventListener( "keypress", ssResetTimer, false); + document.addEventListener( "touchmove", ssResetTimer, false); + ssStartTimer(); +}; + +function ssHideSS(){ + document.getElementById('ss_bg').className='ss_hidden'; + document.getElementById('ss_content').className='ss_hidden'; + document.removeEventListener( "mousemove", ssHideSS ); + document.removeEventListener( "mousedown", ssHideSS ); + document.removeEventListener( "keypress", ssHideSS ); + document.removeEventListener( "touchmove", ssHideSS ); + if( ssInterval != null ){ + window.clearInterval( ssInterval ); + ssInterval = null; + }; + ssSetupTimer(); + ssIsActive = false; +}; + + var sndBeep = new Howl({ src: [ @@ -169,6 +240,15 @@ Ext.onReady(function(){ NotificationStack = new PNotify.Stack({dir1: 'down', firstpos1: 25}); //window.onresize = doCheckWindowSize; Ext.QuickTips.init(); + + ssSetupTimer(); + $(window).focus(function() { + ssResetTimer(); + }); + $(window).blur(function() { + ssStopTimer(); + }); + var viewport = new Ext.Viewport({ id: 'main_viewport', layout:'border', diff --git a/lib/php/ui/UI_functions.php b/lib/php/ui/UI_functions.php index 7cda8ef..6afeb11 100644 --- a/lib/php/ui/UI_functions.php +++ b/lib/php/ui/UI_functions.php @@ -331,6 +331,8 @@ function UI_PageHeaderExt($Static_Scoop = '', $Dynamic_Scoop = ''){ function UI_PageBottomExt(){ global $Script_Start_Time, $Labels; ?> +
+
SS TEXT