-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostdata.php
78 lines (71 loc) · 2.68 KB
/
postdata.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?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 = "postdata.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`;
// XHTMLとしてブラウザに認識させる
// (IE8以下はサポート対象外w)
//header('Content-Type: application/xhtml+xml; charset=utf-8');
if($_SERVER["REQUEST_METHOD"] == "POST"){
$logfile->log('['.__LINE__.']'.'$_POST[serial_id] = '.$_POST['serial_id']);
# $logfile->log('['.__LINE__.']'.'$_POST[show_data_lows] = '.$_POST['show_data_lows']);
$logfile->log('['.__LINE__.']'.'$_POST[name] = '.$_POST['name']);
$logfile->log('['.__LINE__.']'.'$_POST[datetime] = '.$_POST['datetime']);
$logfile->log('['.__LINE__.']'.'$_POST[data] = '.$_POST['data']);
# 設定ファイルの読み込み
$configfile = __DIR__. "/uploads/".$_POST['serial_id']."/config.ini";
$ini = parse_ini_file($configfile);
# 送信データに datetime がなかった場合はサーバの受信日時を設定
if (isset($_POST['datetime']) && $_POST['datetime'] != ""){
$datetime = $_POST['datetime'];
} else {
# 2016/7/3 18:59:05
$logfile->log('['.__LINE__.']'.'$datetime created. ');
$datetime = date("Y/m/d H:i:s");
}
$logfile->log('['.__LINE__.']'.'$datetime = '.$datetime);
# データを保存、もしくは転送
$fp = fopen(__DIR__. "/uploads/".$_POST['serial_id']."/".$_POST['name'].'.csv', 'a');
# fwrite($fp, $_POST['datetime'].",".$_POST['data'].PHP_EOL);
fwrite($fp, $datetime.",".$_POST['data'].PHP_EOL);
exit();
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>データアップロード</title>
</head>
<body>
<form action="" method="POST" >
serial_id<input type="text" name="serial_id" id="serial_id"/>
name<input type="text" name="name" id="name">
datetime<input type="text" name="datetime" id="datetime">
data<input type="text" name="data" id="data">
<input type="submit" value="登録">
</form>
</body>
</html>