edit_geophone.html 4.88 KB
<?php
	//include('cfg/file_name.php');
    $open_geophone = '/home/pi/Desktop/vAlert/bin/geophoneData';
    shell_exec("sudo chmod 777 ".$open_geophone);
	$nn = 0;
	$handle = @fopen($open_geophone, "r");
        while(($data = fgets($handle,1000)) != false){
                $output = explode(" ", $data);
                if($output[0] == "GAIN"){
                    $GAIN=$output[1];
                }
                if($output[0] == "DAMPING_RATIO"){
                    $DAMPING_RATIO=$output[1];
                }
                if($output[0] == "RESISTANCE"){
                    $RESISTANCE=$output[1];
                }
                if($output[0] == "DAMPING_RESISTOR"){
                    $DAMPING_RESISTOR=$output[1];
                }
                if($output[0] == "MASS"){
                    $MASS=$output[1];
                }                
                if($output[0] == "FREQUENCY"){
                    $FREQUENCY=$output[1];
                }
        }
	if($_SESSION['account'] == 'sanlien'){
		$action = 'php/change_geophone.php';
	}

?>				
					<main class="mn-inner">
						<div class="row">	
						<div class="card">
                            <div class="card-content">
                                <span class="card-title">GeoPhone</span><br>
                                <div class="row">
                                    <form class="col s12" id="msform" action='<?php echo $action; ?>' method="post">
										
                                        <div class="row" >

											<div class="input-field col s12">
                                                <input type="text" name="GAIN" value="<?php echo $GAIN;?>" placeholder='GAIN'/>
                                                <label for="first_name">GAIN</label>
                                            </div>
											<div class="input-field col s12">
                                                <input type="text" name="DAMPING_RATIO" value="<?php echo $DAMPING_RATIO;?>" placeholder='DAMPING_RATIO'/>
                                                <label for="first_name">DAMPING_RATIO</label>
                                            </div>
											<div class="input-field col s12">
                                                <input type="text" name="RESISTANCE" value="<?php echo $RESISTANCE;?>" placeholder='RESISTANCE'/>
                                                <label for="first_name">RESISTANCE</label>
                                            </div>
											<div class="input-field col s12">
                                                <input type="text" name="DAMPING_RESISTOR" value="<?php echo $DAMPING_RESISTOR;?>" placeholder='DAMPING_RESISTOR'/>
                                                <label for="first_name">DAMPING_RESISTOR</label>
                                            </div>
											<div class="input-field col s12">
                                                <input type="text" name="MASS" value="<?php echo $MASS;?>" placeholder='MASS'/>
                                                <label for="first_name">MASS</label>
                                            </div>
											<div class="input-field col s12">
                                                <input type="text" name="FREQUENCY" value="<?php echo $FREQUENCY;?>" placeholder='FREQUENCY'/>
                                                <label for="first_name">FREQUENCY</label>
                                            </div>
											
											
                                        </div>
										<a class="waves-effect waves-light btn m-b-xs update"><?=UPDATE?></a>
											
                                    </form>
                                </div>  
                            </div>
                        </div>
						</div>
						
					</main>
				</div>
			
        <div class="left-sidebar-hover"></div>
        
        <!-- Javascripts -->
        <script src="assets/plugins/jquery/jquery-2.2.0.min.js"></script>
        <script src="assets/plugins/materialize/js/materialize.min.js"></script>
        <script src="assets/plugins/material-preloader/js/materialPreloader.min.js"></script>
        <script src="assets/plugins/jquery-blockui/jquery.blockui.js"></script>
        <script src="assets/plugins/select2/js/select2.min.js"></script>
        <script src="assets/js/alpha.min.js"></script>
        <script src="assets/js/pages/form-select2.js"></script>
        <script>
			$('.update').click(function(){
				$.ajax( {
					  type: "POST",
					  url: $('#msform').attr( 'action' ),
					  data: $('#msform').serialize(),
					  success: function( response ) {
						if(response == '1'){
							alert('Success !');
							location.href='index.php?item=edit_geophone';
						}else{
							alert('Error !');
						}
					  }
				});
			})
		</script>
    </body>
</html>