Browse Source

Kafka SSL v 1

master
Evgeny Gagua 4 years ago
parent
commit
93fb550644
  1. 3
      lib/controller/addNetworkNode.php
  2. 154
      lib/controller/getModuleSettings.php
  3. 53
      lib/controller/uploadModuleKafkaData.php
  4. 5
      lib/javascript/jsapi_dynamic/rgoose_dashboard.js
  5. 80
      lib/javascript/jsapi_dynamic/rgoose_main.js
  6. 2
      lib/php/ui/UI_functions.php
  7. 37
      style/style.css

3
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']) );

154
lib/controller/getModuleSettings.php

@ -100,8 +100,9 @@ $TPL =<<<EFUFU
activeTab: 0,
items:[{
xtype: 'form',
id: 'ks_fp_ms',
title: '{$Labels->GetLabel('_KAFKA_BROKER_')}',
labelWidth: 200,
labelWidth: 480,
labelAlign: 'right',
border: false,
frame: false,
@ -121,22 +122,159 @@ $TPL =<<<EFUFU
fieldLabel: 'Use SSL',
checked: {$USSL}
},{
xtype: 'panel',
html: 'CA certificate file for verifying the broker\'s certificate [cert]'
xtype: 'button',
id: 'cl_cert_select',
fieldLabel: 'CA Root certificate to verify the broker\'s certificate [truststore]',
text: 'Upload New',
handler: function(){
currentSelectedFile = 1;
}
},{
xtype: 'panel',
html: 'Client\'s certificate [pem]'
xtype: 'button',
id: 'ca_cert_select',
fieldLabel: 'Client\'s certificate [keystore]',
text: 'Upload New',
handler: function(){
currentSelectedFile = 1;
}
},{
xtype: 'panel',
html: 'Client\'s key [key]'
xtype: 'button',
id: 'cl_key_select',
fieldLabel: 'Client\'s key [key]',
text: 'Upload New',
handler: function(){
currentSelectedFile = 1;
}
},{
xtype: 'textfield',
fieldLabel: 'Access Username',
value: '{$CI['cred_username']}'
},{
xtype: 'textfield',
fieldLabel: 'Access Password',
value: '{$CI['cred_password']}'
},{
xtype: 'panel',
html: 'Key password, if any'
id: 'validator',
html: '<p>Vault ID: {$CI['vault_md5']}</p>'
}]
},{
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_')}'

53
lib/controller/uploadModuleKafkaData.php

@ -0,0 +1,53 @@
<?php
require_once('../ajax_asm.php');
// the response function
function verbose( $ok=1,$info=""){
// failure to upload throws 400 error
if( $ok==0 ){
//http_response_code(400);
};
die(json_encode(["ok"=>$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");
?>

5
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 ||

80
lib/javascript/jsapi_dynamic/rgoose_main.js

@ -15,6 +15,77 @@ var SoundEnable = <?=intval($CUser->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',

2
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;
?></center>
<div id="ss_bg" class="ss_hidden"></div>
<div id="ss_content" class="ss_hidden">SS TEXT</div>
</body>
</html>
<?php

37
style/style.css

@ -710,4 +710,41 @@ A.CalendarDS:hover {
background-position: 17px 15px;
background-size: 220px 220px;
}
.ss_bg_overlay{
display: block;
cursor: none;
opacity: 1;/*0.8;*/
background-color:#000;
position:fixed;
width:100%;
height:100%;
top:0px;
left:0px;
z-index:999;
}
.ss_overlay{
dsisplay: block;
cursor: none;
opacity: 1;
text-align: center;
font-family: monospace;
display: flex;
justify-content: center;
align-items: center;
color: silver;
text-shadow: 2px 2px #000000;
position:fixed;
width:100%;
height:100%;
top:0px;
left:0px;
z-index:1000;
}
.ss_hidden{
display: none;
top:0px;
left:0px;
cursor: auto;
z-index:-1000;
}
Loading…
Cancel
Save