-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalart.php
59 lines (51 loc) · 1.77 KB
/
alart.php
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
50
51
52
53
54
55
56
57
58
59
<?php
/**
* [API] Post data.
*
* Use HTTP POST method for posting data from slider to the monitor.
*
* Requires $_POST['serial_id']
* $_POST['name']
* $_POST['data']
*
* Option $_POST['datetime'] server time is used in case not specified.
*
* @author Dr. Takeyuki UEDA
* @copyright Copyright© Atelier UEDA 2016 - All rights reserved.
*
*/
require_once("vendor/autoload.php");
#require_once("Log.php");
$logfilename = "alart.out.log";
$logfile = &Log::factory('file', $logfilename, 'TEST');
$logfile->log('['.__LINE__.']'.'*** STARTED ***');
// 必用に応じて log ファイルのコンパクションを行う
$p=pathinfo($_SERVER['SCRIPT_FILENAME']);
$logfile->log('['.__LINE__.']'.'$_SERVER[SCRIPT_FILENAME] = '.$_SERVER['SCRIPT_FILENAME']);
$command = "".$p['dirname']."/compaction.sh ".$logfilename;
$logfile->log('['.__LINE__.']'.'$command = '.$command);
`$command`;
if($_SERVER["REQUEST_METHOD"] == "POST"){
# confirm post parameters.
if (isset($_POST['serial_id'])){
$logfile->log('['.__LINE__.']'.'$_POST[serial_id] = '.$_POST['serial_id']);
} else {exit;}
$alarm_ini_file = __DIR__. "/uploads/".$_POST['serial_id']."/alart.ini";
//$logfile->log('['.__LINE__.']'.'alart.ini file = '.$alarm_ini_file);
# confirm alarm.ini file existance and read/write ability.
if (!is_readable($alarm_ini_file)) {exit;}
//$logfile->log('['.__LINE__.']'.'alart.ini is readable.');
# read alarm.ini
$ini = parse_ini_file($alarm_ini_file);
# 設定値の json への設定
foreach ($ini as $k => $i){
$json[$k]=$i;
}
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
$json_str = json_encode( $json );
// $logfile->log('['.__LINE__.']'.'$json_str = '.$json_str);
echo $json_str;
exit;
}
?>