You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

93 lines
3.2 KiB

<?php
require_once('../ajax_asm.php');
ob_start();
$ACCESS = intval( $CUser->Data['access'] );
$UID = intval( $CUser->Data['id'] );
if( $UID > 1 ){
$Data = array();
$Data['status'] = 'err';
if( isset( $_POST['OPID'] ) ){
$CMD = intval( $_POST['OPID'] );
} else {
$CMD = 0;
};
if( isset( $_POST['SESSION'] ) ){
$OID = intval( $_POST['SESSION'] );
} else {
$OID = 0;
};
if( $CMD > 0 && $OID > 0 ){
switch( $CMD ){
case 1:{
if( $ACCESS > 2 ){
$QS = "SELECT * FROM `sessions` WHERE `id`={$OID}";
$RR = $DATABASE->Query( $QS );
if( count( $RR ) ){
$SD = $RR[0];
$Data['basepath'] = $SYSPath .'/lib/controller/data/reports/'.$SD['track_id'].'/'.date("Y/m/d",intval($SD['ts'] ));
if( file_exists( $Data['basepath'] )){
$RBASE = new SQLite_DB( $Data['basepath'] .'/report.db' );
$QS = "DELETE FROM `events` WHERE `session_id`={$OID}";
$RBASE->Query( $QS );
$QS = "SELECT * FROM `videos` WHERE `session_id`={$OID}";
$RR = $RBASE->Query( $QS );
foreach( $RR as $V ) unlink( $Data['basepath'] .'/'.$V['uuid'] . '.'. $V['ext'] );
$QS = "DELETE FROM `videos` WHERE `session_id`={$OID}";
$RBASE->Query( $QS );
$QS = "DELETE FROM `sessions` WHERE `id`={$OID}";
$DATABASE->Query( $QS );
//ToDo: Check if there other session if not -> delete database and report folder
$Data['status'] = 'ok';
} else {
$Data['msg']='Report DataBase is Corupted!';
};
} else {
$Data['msg']='Session is already Deleted!';
};
} else {
$Data['msg']='Wrong Access Level!';
};
};
case 2:{ // Set Session Status
$ST = intval( $_POST['OPAR'] );
if( $ST ){
if( $ST == 6 ) $ST = 4;
$QS = "UPDATE `sessions` SET `status`={$ST} WHERE `id`={$OID}";
$DATABASE->Query( $QS );
};
// Get SetStatus UI
$QS = "SELECT `status`, `final` FROM `sessions` WHERE `id`={$OID}";
$SR = $DATABASE->Query( $QS );
$CS = $SR[0];
if( $CS['final']=='Y' ){
$QS = "SELECT * FROM `session_statuses` WHERE `min_access`<={$ACCESS}";
} else {
$QS = "SELECT * FROM `session_statuses` WHERE `min_access`<={$ACCESS} AND `special`=''";
};
$SR = $DATABASE->Query( $QS );
$TDS = '';
$PPP = 100.0 / count($SR);
foreach( $SR as $S ){
$FUNC = ($S['special']!='')?$S['special']:'setSessionStatus';
if( $CS['status'] >= $S['lvl'] ){
$TDS .= "<td align=\"center\" width=\"{$PPP}%\"><span class=\"sideInfo_item passive_gray\">{$S['label']}</span></td>";
} else {
$TDS .= "<td align=\"center\" width=\"{$PPP}%\"><span class=\"sideInfo_item {$S['class']}\" onclick=\"{$FUNC}({$OID},{$S['lvl']});\" >{$S['label']}</span></td>";
};
};
$Data['content']="{ id: 'sets_ui', frame: true, html: '<table width=\"100%\" border=0><tr>{$TDS}</tr></table>'}";
$Data['status'] = 'ok';
};
};
} else {
$Data['msg']='Wrong Parameters!';
};
$Data['messages'] = ob_get_clean();
echo json_encode( $Data );
exit();
} else {
$LOG->security_treat( $_POST );
};
header('location: /');
?>