Web UI for ARGUS server
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.
 
 
 
 

67 lines
2.7 KiB

<?php
require_once('../ajax_asm.php');
if( $CUser->Data['id'] > 1 ){
$SiteID = intval($_POST['NID']);
$SSID = intval($_POST['SOSID']);
$SEID = intval($_POST['SOEID']);
$N1ID = intval($_POST['SNID']);
$N2ID = intval($_POST['ENID']);
$QS = "SELECT * FROM `sockets` WHERE `id`={$SSID}";
$result1 = $DATABASE->Query( $QS, false );
$QS = "SELECT * FROM `sockets` WHERE `id`={$SEID}";
$result2 = $DATABASE->Query( $QS, false );
if( count( $result1 ) && count( $result2 ) ){
$node1 = $result1[0];
$node2 = $result2[0];
$t1 = intval( $node1['type'] ); $m1 = intval( $node1['mode'] ); $n1 = intval( $node1['node_id'] ); $a1 = intval( $node1['aux_id'] ); $d1=intval( $node1['multidrop'] );
$t2 = intval( $node2['type'] ); $m2 = intval( $node2['mode'] ); $n2 = intval( $node2['node_id'] ); $a2 = intval( $node2['aux_id'] ); $d2=intval( $node2['multidrop'] );
if( $t1 && $t2 && $m1 && $m2 ){
if( $m2 == 1 || $m1 == 2 ){
// from 1 to 2
$QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$n1}, `from_aux`={$a1}, `to`={$n2}, `to_aux`={$a2}, `type`={$t1}";
$DATABASE->Query( $QS, false );
} else {
// from 2 to 1
$QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$n2}, `from_aux`={$a2}, `to`={$n1}, `to_aux`={$a1}, `type`={$t2}";
$DATABASE->Query( $QS, false );
};
// Check for Media Channels
if( $t1==6 || $t1 ==7 || $t1==4 || $t1==9 ){
if( $t1==7 || $t1 == 9 ){
// 1 is Media Server
// $QS="UPDATE media_streams SET binded=1, destination_id={$a1} WHERE id={$a2}";
//$DATABASE->Query( $QS, false );
$QS="INSERT INTO `media_server_streams` SET `site_id`={$SiteID}, `media_server_id`={$a1}, `media_stream_id`={$a2}";
$DATABASE->Query( $QS, false );
} else {
// 2 is Media Server
//$QS="UPDATE media_streams SET binded=1, destination_id={$a2} WHERE id={$a1}";
//$DATABASE->Query( $QS, false );
$QS="INSERT INTO `media_server_streams` SET `site_id`={$SiteID}, `media_server_id`={$a2}, `media_stream_id`={$a1}";
$DATABASE->Query( $QS, false );
};
};
if( $d1==0 ){
$QS="UPDATE `sockets` SET `binded`=1 WHERE id={$SSID}";
$DATABASE->Query( $QS, false );
};
if( $d2==0 ){
$QS="UPDATE `sockets` SET `binded`=1 WHERE id={$SEID}";
$DATABASE->Query( $QS, false );
};
$RetVal['status'] = true;
$RetVal['edge'] = array('from'=>$N1ID, 'to'=>$N2ID, 'color'=>'red' );
} else {
$RetVal['status'] = false;
$RetVal['message']='No Possibillty to Make such Connection!';
};
} else {
$RetVal['status'] = false;
$RetVal['message']='No Possibillty to Make such Connection!';
};
echo json_encode( $RetVal );
} else {
header('location: /');
};
?>