-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostdata2.php
55 lines (49 loc) · 1.86 KB
/
postdata2.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
<?php
/**
* [API] Post one line data.
*
* Add a line to the file.
* Using for:
* vmstat infos of slider.
*
* Requires $_POST['serial_id']
* $_POST['filename']
* $_POST['textstr']
*
* @author Dr. Takeyuki UEDA
* @copyright Copyright© Atelier UEDA 2016 - All rights reserved.
*
*/
require_once("Log.php");
$logfilename = "postdata2.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[filename] = '.$_POST['filename']);
$logfile->log('['.__LINE__.']'.'$_POST[textstr] = '.$_POST['textstr']);
# 設定ファイルの読み込み
$configfile = "uploads/".$_POST['serial_id']."/config.ini";
$ini = parse_ini_file($configfile);
# データを保存、もしくは転送
$recordfilename = "./uploads/".$_POST['serial_id']."/".$_POST['filename'];
$logfile->log('['.__LINE__.']'.'$recordfilename = '.$recordfilename);
$fp = fopen($recordfilename, 'a');
fwrite($fp, $_POST['textstr'].PHP_EOL);
// 必用に応じてコンパクションを行う
$p=pathinfo($_SERVER['SCRIPT_FILENAME']);
$command = "".$p['dirname']."/compaction.sh ".$recordfilename;
$logfile->log('['.__LINE__.']'.'$command = '.$command);
`$command`;
# }
}
?>