live.php 8.33 KB
<?php
       //session_start();
      exec('cat /etc/timezone',$timezone);
      $data=array();
      $account=$_GET['account'];
      $fp=fopen('recordtime.txt','r');
      

      while(($timeString=stream_get_line($fp,16,"\n"))!==False)
      {
        $data[]=$timeString;

      }
     $product_v = @fopen("../php/version.txt","r");
    //讀檔案
    while(($pvd = fgetcsv($product_v,1000,"\n")) != false){
      foreach($pvd as $key => $value){
        if($value != ""){
          $left[] = $value;
          $i++;
        }
      }
    }

      $endtime=$data[0];
      $startTime=$data[1];
      $currentDate=date("Y-m-d H:i:s");

      

      $Unix_start=strtotime($currentDate);
       date_default_timezone_set("UTC");

      $endtime_Int=(int)$endtime;
      $time0=(int)$startTime;
      $delta=$endtime_Int-$Unix_start;
      $time_until_start=$time0-$Unix_start;

      $delta-=5; 

      $time_until_start-=5;


      

     
      //echo $account;
     exec('node ../wave/server_5000.js &');
?>

<!DOCTYPE html>
<html>
<head>
	<title>Live streaming </title>
	<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
	<link rel="stylesheet" type="text/css" href="../css/fontawesome/css/font-awesome.css">
	<link rel="stylesheet" type="text/css" href="../css/fontawesome/css/font-awesome.min.css">
	<script src="../js/jquery.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap.min.js"></script>
</head>
<body>
	<br><br>
  <table style="margin-left:90px;" border="1" width="1100px">
    <tr>
      

    <td width="300px">
     <h3 id="countdown" style="color: red;">Manual Recording  stopped Timezone:<?= $timezone[0]?></h3>
   </td>
   <td>
 <div width="800px" style="text-align: center;padding-left:20px;padding-top:25px;">
	<a  id="startrecord" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-record"></span>Start recording</a>
    <a role="button"  id="stoprecord" class="btn btn-danger"><span class="glyphicon glyphicon-stop"></span></i>Stop recording</a>
    <a role="button" id="startstreaming" class="btn btn-primary"><span class="glyphicon glyphicon-signal"></span></i> Start streaming</a>
	<a role="button"  id="stostreaming" class="btn btn-danger"><span class="glyphicon glyphicon-pause"></span>Stop streaming</a>
 <br><br>
 <p><?php?></p>

<div id="timer" style="display: none;">
  
  <form method="post" action="setcron.php">
    <label for="starttime">From</label>
    <input type="datetime-local" name="starttime" id="starttime">
    <input type="number" name="secondstart" min="0" max="59" style="width:40px;" placeholder="0" id="secondstart">
    <label for="secondstart">ss</label>
    &nbsp;&nbsp;&nbsp;
    <label for="endtime">To</label>
    <input type="datetime-local" name="endtime" id="endtime">
      <input type="number" name="secondend" min="0" max="59" style="width:40px;" placeholder="0" id="secondend">
      <label for="secondend">ss</label>
    <button id="schedule" type="submit" name="submit_button">submit</button>
   </form>
   
</div>
  
       
     
    
</div>
</td>
<?php if($left[0]=='Palert Plus S3'){?>
<td style="text-align: center;">Velocity: mm/sec</td>
<?php } ?>
</tr>
</table>
       

<object type="text/html" data="http://<?php echo $_SERVER['SERVER_ADDR'];?>:8000/socket.html" width="100%" height="300px"></object>

    
  <object type="text/html" data="http://<?php echo $_SERVER['SERVER_ADDR'];?>:8002/socket1.html" width="100%" height="300px"></object>

  <object type="text/html" data="http://<?php echo $_SERVER['SERVER_ADDR'];?>:8004/socket2.html" width="100%" height="300px"></object>


	<script type="text/javascript">
		
    $(document).ready(function(){
    	var streaming=localStorage.getItem("start_stream");

    	var recording=localStorage.getItem("start_rec");
     // var cassette=localStorage.getItem("cassette");
       var delta=<?=$delta?>;
        var start=<?=$Unix_start?>;
        var end=<?=$endtime_Int?>;
        var TimeZero=<?=$time_until_start?>;
        var time0=<?=$time0?>;

        var x=0;
        var y=0;
       
      window.onload=function(){



        if(delta<0)
        {
            //cassette=0;
            recording=0;

        }
       

      	if(streaming==1)
      	{

       $("#startstreaming").hide('slow');
       $("#stostreaming").show('slow');

      	}

      	else if(streaming==0)
      	{

       $("#stostreaming").hide('slow');
       $("#startstreaming").show('slow');

      	}
      	if(recording==1){

           $("#startrecord").hide('slow');
          $("#stoprecord").show('slow');

         document.getElementById("rec_img").style.display="block";

      	}

      	else if(recording==0)
      	{
      	 $("#stoprecord").hide('slow');
        $("#startrecord").show('slow');
         
      	}

       /* if(cassette==1)
        {

          $("#rec_img").show('slow');
        }
        else if(cassette==0)
        {

          document.getElementById("rec_img").style.display="none";
        }*/

      };

    $("#startstreaming").click(function(){

       $.post( "autostart.php" );


       $("#startstreaming").hide('slow');
       $("#stostreaming").show('slow');

       localStorage.setItem("start_stream",1);
    });
    $("#startrecord").click(function(){
         
           
    	$("#timer").show('slow');


      

      

    });
      $("#schedule").click(function(){

        $("#timer").hide('slow');
        

      });
    
    $("#stoprecord").click(function(){
       $.post( "stoprecord.php" );
        
       localStorage.setItem("start_rec", 0);
       //localStorage.setItem('cassette',0);

        $("#stoprecord").hide('slow');
        $("#startrecord").show('slow');
        clearInterval(y);
        document.getElementById("countdown").innerHTML="Manual Recording stopped";
        //document.getElementById("rec_img").style.display="none";
        $("#timer").hide('slow');

    });


    $("#stostreaming").click(function(){
       $.post( "stopstream.php" );

       localStorage.setItem("start_stream",0);

       $("#stostreaming").hide('slow');
       $("#startstreaming").show('slow');
    });

    if(delta>0)
    {
     // alert("yesy");
       var interval=delta*1000;
       if(TimeZero>0)
       {


        var countdown=TimeZero;
         // $("#countdown").show('slow');
         x=setInterval(function(){
           document.getElementById("countdown").style.color="green";
          document.getElementById("countdown").innerHTML ="Start recording in "+ countdown + " seconds";

          countdown--;
           if (countdown==0) {

            clearInterval(x);
           }
          
          
        },1000);

        var interval_to_start=TimeZero*1000;

        setTimeout(function(){
          //$("#countdown").hide();

         //$("#rec_img").show('slow');
           $("#startrecord").hide('slow');
          $("#stoprecord").show('slow');

         //document.getElementById("rec_img").style.display="block";
          localStorage.setItem("start_rec", 1);
          localStorage.setItem('cassette',1);


        var count=delta-(TimeZero +1);
        y=setInterval(function(){
        document.getElementById("countdown").style.color="red";
         document.getElementById("countdown").innerHTML="Stop Recording in "+ count + " seconds";

         count--;
         if(count==0)
          clearInterval(y);
               
        },1000);

              
             
        },interval_to_start);
       }
       if(TimeZero<=0 &&(delta-1)>0)
       {
           var count=delta-1;
          y=setInterval(function(){
         document.getElementById("countdown").style.color="red";
         document.getElementById("countdown").innerHTML="Stop Recording in "+ count + " seconds";

         count--;
         if(count==0)
          clearInterval(y);
               
        },1000);
        
       }
      setTimeout(function()
      {

         
        
       localStorage.setItem("start_rec", 0);
       //localStorage.setItem('cassette',0);

        $("#stoprecord").hide('slow');
        $("#startrecord").show('slow');
        
        document.getElementById("countdown").innerHTML="Manual Recording stopped";
        //document.getElementById("rec_img").style.display="none";
        $("#timer").hide('slow');

      },interval);
    }

});






	</script>

</body>
</html>