'; } function processFirstBlock(type,flags,time,data) { recFileProtocol=0; if((type !=1) || (flags !=0)) { cleanup(); return; } try { recFileMetadata=JSON.parse(data) } catch (ex) { cleanup(); return; } if((recFileMetadata==null) || (recFileMetadata.magic !='MeshCentralRelaySession') || (recFileMetadata.ver !=1)) { cleanup(); return; } var x=''; x +=addInfo("Temps",recFileMetadata.time); if(recFileEndTime !=0) { var secs=Math.floor((recFileEndTime - time) / 1000); x +=addInfo("Duration", format("{0} second{1}",secs,(secs > 1)?'s' : '')); } x +=addInfo("Nom d'utilisateur",recFileMetadata.username); x +=addInfo("Identifiant d'utilisateur",recFileMetadata.userid); x +=addInfo("SessionID",recFileMetadata.sessionid); if(recFileMetadata.ipaddr1 && recFileMetadata.ipaddr2) { x +=addInfo("Addresses", format("{0} to {1}",recFileMetadata.ipaddr1,recFileMetadata.ipaddr2)); } if(recFileMetadata.devicename) { x +=addInfo("DeviceName",recFileMetadata.devicename); } x +=addInfo("NodeID",recFileMetadata.nodeid); if(recFileMetadata.protocol) { var p=recFileMetadata.protocol; if(p==1) { p="MeshCentral Terminal"; } else if(p==2) { p="MeshCentral Desktop"; } else if(p==100) { p="Intel® AMT WSMAN"; } else if(p==101) { p="Intel® AMT Redirection"; } x +=addInfoNoEsc("Protocol",p); } QV('DeskParent',true); QV('TermParent',false); if(recFileMetadata.protocol==1) { recFileProtocol=1; x +='
' + #73# + ''; QE('PlayButton',true); QE('PauseButton',false); QE('RestartButton',false); recFileStartTime=recFileLastTime=time; } else if(recFileMetadata.protocol==2) { recFileProtocol=2; x +='
' + #74# + ''; QE('PlayButton',true); QE('PauseButton',false); QE('RestartButton',false); recFileStartTime=recFileLastTime=time; agentDesktop=CreateAgentRemoteDesktop('Desk'); agentDesktop.onScreenSizeChange=deskAdjust; agentDesktop.State=3; deskAdjust(); } else if(recFileMetadata.protocol==101) { recFileProtocol=101; x +='
Press [space] to play/pause.'; QE('PlayButton',true); QE('PauseButton',false); QE('RestartButton',false); recFileStartTime=recFileLastTime=time; amtDesktop=CreateAmtRemoteDesktop('Desk'); amtDesktop.onScreenSizeChange=deskAdjust; amtDesktop.State=3; amtDesktop.Start(); deskAdjust(); } QV('metadatadiv',true); QH('metadatadiv',x); QH('deskstatus',recFile.name); } function processBlock(type,flags,time,data) { if(type < 0) { pause(); return; } var waitTime=Math.round((time - recFileLastTime) * parseFloat(Q('PlaySpeed').value)); if(waitTime < 5) { processBlockEx(type,flags,time,data); } else { waitTimerArgs=[type,flags,time,data] waitTimer=setTimeout(function () { waitTimer=null; processBlockEx(waitTimerArgs[0],waitTimerArgs[1],waitTimerArgs[2],waitTimerArgs[3]); },waitTime); } } function processBlockEx(type,flags,time,data) { if(playing==false) return; var flagBinary=(flags & 1) !=0,flagUser=(flags & 2) !=0; var deltaTimeTotalSec=Math.floor((time - recFileStartTime) / 1000); if(currentDeltaTimeTotalSec !=deltaTimeTotalSec) { currentDeltaTimeTotalSec=deltaTimeTotalSec; var deltaTimeHours=Math.floor(deltaTimeTotalSec / 3600); deltaTimeTotalSec -=(deltaTimeHours * 3600) var deltaTimeMinutes=Math.floor(deltaTimeTotalSec / 60); deltaTimeTotalSec -=(deltaTimeHours * 60) var deltaTimeSeconds=Math.floor(deltaTimeTotalSec); QH('timespan', pad2(deltaTimeHours) + ':' + pad2(deltaTimeMinutes) + ':' + pad2(deltaTimeSeconds)) } if((type==2) && flagBinary && !flagUser) { if(recFileProtocol==1) { agentTerminal.ProcessData(data); } else if(recFileProtocol==2) { agentDesktop.ProcessData(data); } else if(recFileProtocol==101) { if((readState==0) && (rstr2hex(data)=='4100000000000000')) { readState=1; if(data.length > 8) { amtDesktop.ProcessData(data.substring(8)); } } else if(readState==1) { amtDesktop.ProcessData(data); } } } else if((type==2) && flagBinary && flagUser) { if(recFileProtocol==101) { if(rstr2hex(data)=='0000000008080001000700070003050200000000') { amtDesktop.bpp=1; } } } recFileLastTime=time; if(playing) { readNextBlock(processBlock); } } function cleanup() { recFile=null; recFilePtr=0; recFileMetadata=null; playing=false; if(agentDesktop !=null) { agentDesktop.Canvas.clearRect(0,0,agentDesktop.CanvasId.width,agentDesktop.CanvasId.height); agentDesktop=null; } if(amtDesktop !=null) { amtDesktop.canvas.clearRect(0,0,amtDesktop.CanvasId.width,amtDesktop.CanvasId.height); amtDesktop=null; } readState=0; waitTimerArgs=null; currentDeltaTimeTotalSec=0; recFileEndTime=0; agentTerminal=null; if(waitTimer !=null) { clearTimeout(waitTimer); waitTimer=null; } QH('deskstatus', ''); QE('PlayButton',false); QE('PauseButton',false); QE('RestartButton',false); QS('progressbar').width = '0px'; QH('timespan', '00:00:00'); QV('metadatadiv',true); QH('metadatadiv', ''); QV('DeskParent',true); QV('TermParent',false); } function ondrop(e) { haltEvent(e); QV('bigfail',false); QV('bigok',false); if(e.dataTransfer==null) return; var files=[]; for (var i in e.dataTransfer.files) { if((e.dataTransfer.files[i].type !=null) && (e.dataTransfer.files[i].size !=null) && (e.dataTransfer.files[i].size !=0) && (e.dataTransfer.files[i].name.endsWith('.mcrec'))) { files.push(e.dataTransfer.files[i]); } } if(files.length==0) return; cleanup(); recFile=files[0]; recFilePtr=0; readNextBlock(processFirstBlock); readLastBlock(function (type,flags,time) { if(type==3) { recFileEndTime=time; } else { recFileEndTime=0; } }); } var dragtimer=null; function ondragover(e) { haltEvent(e); if(dragtimer !=null) { clearTimeout(dragtimer); dragtimer=null; } var ac=true; QV('bigok',ac); QV('bigfail',!ac); } function ondragleave(e) { haltEvent(e); dragtimer=setTimeout(function () { QV('bigfail', false); QV('bigok',false); dragtimer=null; },10); } function onkeypress(e) { if(xxdialogMode) return; if(e.key==' ') { togglePause(); haltEvent(e); } if(e.key=='1') { Q('PlaySpeed').value=4; haltEvent(e); } if(e.key=='2') { Q('PlaySpeed').value=2; haltEvent(e); } if(e.key=='3') { Q('PlaySpeed').value=1; haltEvent(e); } if(e.key=='4') { Q('PlaySpeed').value=0.5; haltEvent(e); } if(e.key=='5') { Q('PlaySpeed').value=0.25; haltEvent(e); } if(e.key=='6') { Q('PlaySpeed').value=0.1; haltEvent(e); } if(e.key=='0') { pause(); restart(); haltEvent(e); } } function openfile() { var x=''; setDialogMode(2,"Open File...",3,openfileEx,x); QE('idx_dlgOkButton',false); } function openfileEx() { var xfiles=Q('p2fileinput').files; if(xfiles !=null) { var files=[]; for (var i in xfiles) { if((xfiles[i].type !=null) && (xfiles[i].size !=null) && (xfiles[i].size !=0) && (xfiles[i].name.endsWith('.mcrec'))) { files.push(xfiles[i]); } } } if(files.length==0) return; cleanup(); recFile=files[0]; recFilePtr=0; readNextBlock(processFirstBlock); readLastBlock(function (type,flags,time) { if(type==3) { recFileEndTime=time; } else { recFileEndTime=0; } }); Q('OpenFileButton').blur(); } function openfileChanged() { var xfiles=Q('p2fileinput').files; if(xfiles !=null) { var files=[]; for (var i in xfiles) { if((xfiles[i].type !=null) && (xfiles[i].size !=null) && (xfiles[i].size !=0) && (xfiles[i].name.endsWith('.mcrec'))) { files.push(xfiles[i]); } } } QE('idx_dlgOkButton',files.length==1); } function togglePause() { if(recFile !=null) { if(playing==true) { pause(); } else { if(recFilePtr !=recFile.size) { play(); } } } return false; } function play() { Q('PlayButton').blur(); if((playing==true) || (recFileProtocol==0)) return; playing=true; QV('metadatadiv',false); QE('PlayButton',false); QE('PauseButton',true); QE('RestartButton',false); if((recFileProtocol==1) && (agentTerminal==null)) { QV('DeskParent',false); QV('TermParent',true); agentTerminal=CreateAmtRemoteTerminal('Term',{}); agentTerminal.State=3; } readNextBlock(processBlock); } function pause() { Q('PauseButton').blur(); if(playing==false) return; playing=false; QE('PlayButton',recFilePtr !=recFile.size); QE('PauseButton',false); QE('RestartButton',recFilePtr !=0); if(waitTimer !=null) { clearTimeout(waitTimer); waitTimer=null; processBlockEx(waitTimerArgs[0],waitTimerArgs[1],waitTimerArgs[2],waitTimerArgs[3]); waitTimerArgs=null; } } function restart() { Q('RestartButton').blur(); if(playing==true) return; recFilePtr=0; readState=0; currentDeltaTimeTotalSec=0; QV('metadatadiv',true); QE('PlayButton',true); QE('PauseButton',false); QE('RestartButton',false); QS('progressbar').width = '0px'; QH('timespan', '00:00:00'); QV('DeskParent',true); QV('TermParent',false); if(agentDesktop) { agentDesktop.Canvas.clearRect(0,0,agentDesktop.CanvasId.width,agentDesktop.CanvasId.height); } else if(amtDesktop) { amtDesktop.canvas.clearRect(0,0,amtDesktop.CanvasId.width,amtDesktop.CanvasId.height); amtDesktop=CreateAmtRemoteDesktop('Desk'); amtDesktop.onScreenSizeChange=deskAdjust; amtDesktop.State=3; amtDesktop.Start(); } else if(agentTerminal) { agentTerminal=null; } } function clearConsoleMsg() { QH('p11DeskConsoleMsg', ''); } function toggleAspectRatio(toggle) { if(toggle===1) { deskAspectRatio=((deskAspectRatio + 1) % 3); } deskAdjust(); } function deskAdjust() { var parentH=Q('DeskParent').clientHeight, parentW = Q('DeskParent').clientWidth; var deskH=Q('Desk').height, deskW = Q('Desk').width; if(deskAspectRatio==2) { QS('Desk')['margin-top']=null; QS('Desk').height = '100%'; QS('Desk').width = '100%'; QS('DeskParent').overflow = 'hidden'; } else if(deskAspectRatio==1) { QS('Desk')['margin-top'] = '0px'; QS('Desk').height = deskH + 'px'; QS('Desk').width = deskW + 'px'; QS('DeskParent').overflow = 'scroll'; } else { if((parentH / parentW) > (deskH / deskW)) { var hNew=((deskH * parentW) / deskW) + 'px'; QS('Desk').height=hNew; QS('Desk').width = '100%'; } else { var wNew=((deskW * parentH) / deskH) + 'px'; QS('Desk').height = '100%'; QS('Desk').width=wNew; } QS('Desk')['margin-top']=null; QS('DeskParent').overflow = 'hidden'; } } var xxdialogMode; var xxdialogFunc; var xxdialogButtons; var xxdialogTag; var xxcurrentView=-1; function setDialogMode(x,y,b,f,c,tag) { xxdialogMode=x; xxdialogFunc=f; xxdialogButtons=b; xxdialogTag=tag; QE('idx_dlgOkButton',true); QV('idx_dlgOkButton',b & 1); QV('idx_dlgCancelButton',b & 2); QV('id_dialogclose',(b & 2) || (b & 8)); QV('idx_dlgDeleteButton',b & 4); QV('idx_dlgButtonBar',b & 7); if(y) QH('id_dialogtitle',y); for (var i=1; i < 3; i++) { QV('dialog' + i,i==x); } QV('dialog',x); if(c) { if(x==2) { QH('id_dialogOptions', c); } else { QH('id_dialogMessage',c); } } } function dialogclose(x) { var f=xxdialogFunc,b=xxdialogButtons,t=xxdialogTag; setDialogMode(); if(((b & 8) || x) && f) f(x,t); } function messagebox(t,m) { setSessionActivity(); QH('id_dialogMessage',m); setDialogMode(1,t,1); } function statusbox(t,m) { setSessionActivity(); QH('id_dialogMessage',m); setDialogMode(1,t); } function haltEvent(e) { if(e.preventDefault) e.preventDefault(); if(e.stopPropagation) e.stopPropagation(); return false; } function pad2(num) { var s='00' + num; return s.substr(s.length - 2); } function format(format) { var args=Array.prototype.slice.call(arguments,1); return format.replace(/{(\d+)}/g,function (match,number) { return typeof args[number] !='undefined'?args[number]:match; }); }; start();