Blame view
php/change_comcfg.php
1.01 KB
cf76164e6 20190709 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
<?php //include('../cfg/file_name.php'); $open_file = '/home/pi/Desktop/vAlert/bin/vAlert8Common.cfg'; shell_exec("sudo chmod 777 ".$open_file); $versionTXT='version.txt'; $handle2 = @fopen($versionTXT,"r"); //讀檔案 $Device=array(); while(($data = fgetcsv($handle2,1000," ")) != false){ foreach($data as $key => $value){ if($value != ""){ $Device[]=$value; } } } switch ($Device[0]) { case 'Palert Plus S3': break; case 'Palert Plus': $mypost=explode(" ",$_POST['config']); $source=explode(" ",$_POST['source']); $index=0; $diff=array_diff($source,$mypost); //$handle=fopen($open_file_test,'w') or die("cannot open file"); //var_dump($source); for($i=0;$i<count($source);) { $source[$i]=$mypost[$index]; $index++; $i++; } $inputStr=implode(" ",$source); //echo $inputStr; file_put_contents($open_file,$_POST['config']); break; default: echo 2; break; } ?> |