-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·248 lines (235 loc) · 12.7 KB
/
index.php
File metadata and controls
executable file
·248 lines (235 loc) · 12.7 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!DOCTYPE html>
<!--
/*
* INTER-Mediator Trial Application
*
* Copyright (c) 2022-2022 INTER-Mediator Directive Committee
*/ -->
<?php
// Initialize global variables.
use INTERMediator\Data_Converter\FMDateTime;
$dbProtocol = "";
$dbServer = "";
$dbPort = "";
$dbUser = "";
$dbPassword = "";
$dbDatabase = "";
// Including params.php file.
$appRoot = dirname(__FILE__);
$imRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor'
. DIRECTORY_SEPARATOR . 'inter-mediator' . DIRECTORY_SEPARATOR . 'inter-mediator';
$currentDirParam = $appRoot . DIRECTORY_SEPARATOR . 'lib/params.php';
if (file_exists($currentDirParam)) {
include($currentDirParam);
}
// Set default timezone.
if (isset($defaultTimezone)) {
date_default_timezone_set($defaultTimezone);
} else if (ini_get('date.timezone') == null) {
date_default_timezone_set('UTC');
}
// Reading from the composer.json file.
$version = '';
$content = json_decode(file_get_contents($imRoot . DIRECTORY_SEPARATOR . 'composer.json'));
if ($content) {
$version = $content->version;
}
$filterForDate = "| grep Date: | awk '{print $2,$3,$4,$5,$6}'";
$modDate = exec("git --git-dir={$imRoot}/.git log -1 {$filterForDate}");
$imModDate = (new DateTime($modDate))->format('Y年m月d日');
$modDate = exec("git --git-dir={$imRoot}/.git log -1 -- -p dist-docs/sample_schema_mysql.txt {$filterForDate}");
$mysqlModDate = (new DateTime($modDate))->format('Y年m月d日');
$modDate = exec("git --git-dir={$imRoot}/.git log -1 -- -p dist-docs/TestDB.fmp12 {$filterForDate}");
$fmModDate = (new DateTime($modDate))->format('Y年m月d日');
?>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>INTER-Mediator <?php echo htmlspecialchars($version, ENT_QUOTES, 'UTF-8'); ?> - VM for Trial</title>
<script type="text/javascript" src="include_MySQL.php"></script>
<script type="text/javascript" src="index.js"></script>
<style>
.code {
background-color: #DDDDDD;
padding: 8px;
}
</style>
</head>
<body style="margin: 8px">
<h1>INTER-Mediator <?php echo htmlspecialchars($version, ENT_QUOTES, 'UTF-8'); ?> - VM for Trial</h1>
<h2>現在アクセスしているwebアプリケーションについて</h2>
<p>このアプリケーションは、以下のような目的で構築しました。</p>
<ul>
<li>INTER-Mediatorに含まれるサンプルプログラムを試してみる</li>
<li><a href="https://inter-mediator.com/ja/courseware.html" target="_blank">INTER-Mediatorのコースウエア</a>
などで、システム構築方法を学習する
</li>
<li>INTER-Mediatorの試用のため</li>
</ul>
<p>
このアプリケーションが使用しているINTER-Mediatorの最終更新日は
<strong><?php echo htmlspecialchars($imModDate, ENT_QUOTES, 'UTF-8'); ?></strong>
です。
</p>
<h3>アプリケーションの動作条件</h3>
<ul>
<li>
このアプリケーションよりサンプルプログラムを稼働するには、MySQLで、INTER-Mediatorに付属のサンプルデータベースが稼働していることを前提としています。
<span style="color:red">Dockerで起動した場合には、サンプルデータベースは稼働した状態になっています。</span>
ダイレクトホスティング(レポジトリのコードを直接公開)の場合は、以下の方法で、MySQLデータベースが稼働する状態にしてください。
</li>
<li>
<a href="https://raw.githubusercontent.com/INTER-Mediator/INTER-Mediator/master/dist-docs/sample_schema_mysql.txt"
target="_blank">
レポジトリ内のスキーマファイル</a>をMySQLに読み込めば、サンプルデータベースは稼働します。簡単な方法は次の通りです。
<div style="margin-left: 14px; background-color: #DDDDDD; padding: 8px">
<strong>cd IMApp_Trial</strong> # このレポジトリのルートをカレントディレクトリとする<br>
<strong>mysql -u root -p <
vendor/inter-mediator/inter-mediator/dist-docs/sample_schema_mysql.txt</strong><br>
# MacでHomebrewのようなrootパスワードが設定されていない場合は、-pを省略する
</div>
</li>
<li>
データベースへの接続は、127.0.0.1への接続で設定していますが、データベースの稼働条件が異なる場合は、lib/params.phpを変更して、データベースに合わせてください。
</li>
<li>FileMaker向けのサンプルプログラムは、FileMaker Serverが稼働しているサーバへの設定を、lib/params.phpで記述してください。
</li>
<li><strong>サンプルデータベースの最終更新日</strong>:MySQL(or MariaDB)=
<?php echo htmlspecialchars($mysqlModDate, ENT_QUOTES, 'UTF-8'); ?>、
FileMaker=<?php echo htmlspecialchars($fmModDate, ENT_QUOTES, 'UTF-8'); ?>
<br><strong>あなたがお使いのサンプルデータベース</strong>:
<span data-im-control="enclosure"><span
data-im-control="noresult">MySQL(or MariaDB)=2015年7月10日以前</span>
<span data-im-control="repeater"><span
data-im="information@lastupdated">MySQL(or MariaDB)=</span></span>
</span><?php
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, strtolower($dbProtocol) . '://' . $dbServer . ':' . $dbPort . '/fmi/xml/fmresultset.xml');
curl_setopt($ch, CURLOPT_USERPWD, $dbUser . ':' . $dbPassword);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, '-db=' . $dbDatabase . '&-lay=information&-findall&-max=1');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$xml = curl_exec($ch);
curl_close($ch);
libxml_use_internal_errors(true);
$parsedData = simplexml_load_string($xml);
$output = '';
if ($parsedData !== false) {
$output = '、FileMaker=2015年7月11日以前';
}
require "{$appRoot}" . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$converter = new FMDateTime();
error_reporting(0);
foreach ($parsedData->resultset->record->field as $key => $field) {
if ((string)$field->attributes()->name === 'lastupdated') {
$dateInfo = $converter->dateArrayFromFMDate($field->data);
$output = '、FileMaker=' . intval($dateInfo['year']) . '年' .
intval($dateInfo['month']) . '月' .
intval($dateInfo['day']) . '日';
break;
}
}
echo htmlspecialchars($output, ENT_QUOTES, 'UTF-8');
} catch (Exception $e) {
}
?>
</li>
</ul>
<h2>リンク</h2>
<h3>
<a href="./vendor/inter-mediator/samples/"
target="_blank">サンプルプログラム</a>
</h3>
<ul data-im-control="ignore_enc_rep">
<li>
INTER-Mediatorに含まれているサンプルプログラムを即座に実行できます。レポジトリの/samplesにコードがあるので、そちらも併せてご覧ください。
</li>
<li>サンプルの中にある認証ユーザー用のデータベースには、user1〜user5の5つのユーザーが定義されており、パスワードはユーザー名と同一です。
概ね、user1でログインができますが、アクセス権の設定のテストも行っており、すべてのユーザーでのログインができるとは限りません。
設定を参照の上ログインの確認や、あるいはできないことの確認をしてください。
</li>
</ul>
<h3>
<a href="./vendor/inter-mediator/inter-mediator/samples/Auth_Support/MySQL_accountmanager.html"
target="_blank">ユーザー管理ページサンプル</a></h3>
<ul>
<li>
ユーザー名、パスワード共に、user1でログインができますが、通常の利用は、利用者と別の管理者を作り、その管理者でのみログインできるようにします。
</li>
</ul>
<h3>その他のリンク</h3>
<ul>
<li><a href="info.php" target="_blank">phpinfo()関数の実行</a>
</li>
<li><a href="https://inter-mediator.com/" target="_blank">INTER-Mediator Website</a></li>
<li><a href="https://inter-mediator.info/" target="_blank">INTER-Mediator Manual Site</a></li>
<li><a href="https://inter-mediator.org/" target="_blank">INTER-Mediator Directive Committee</a></li>
</ul>
<h2>トライアル用のページファイルと定義ファイル</h2>
<p>
以下のリンクは、Webサーバのルートに配置したファイルで、ページファイルエディタと定義ファイルエディタで開いて内容を編集し、その結果を参照することができます。
いずれのリンクも、別のウインドウないしはタブを開きます。ページ更新が必要なときには手作業で行ってください。
初期状態では何も表示しないようになっています。もちろん、独自に変更を加えて、自由に使ってみてください。
.phpファイルと.yamlファイルの使い分けは、一連のリンクの下に記述しました。
</p>
<p>
従来までの「def01.phpを編集する」のリンクに相当するのは、「def01.phpを編集する」の右にある「DefEditor」のリンクです。
チュートリアルで紹介した手順で進めたい方は、DefEditorのリンクをクリックしてご利用ください。
</p>
<div style="display: flex; flex-wrap: wrap">
<table style="margin-right: 20px">
<?php
for($pn = 1; $pn <= 40; $pn += 1) {
$p = substr("0".$pn, -2);
?>
<tr>
<td><a href="./src/page<?php echo $p;?>.html" target="_blank">page<?php echo $p;?>.htmlを表示する</a></td>
<td>
<a href="./editors/pageedit.html?target=../src/page<?php echo $p;?>.html"
target="_blank">
page<?php echo $p;?>.htmlを編集する</a>
</td>
<td>
def<?php echo $p;?>.phpを編集する
[<a href="./editors/defedit.html?target=../src/def<?php echo $p;?>.php"
target="_blank">DefEditor</a>]
[<a href="./editors/pageedit.html?target=../src/def<?php echo $p;?>.php"
target="_blank">ソース</a>]
</td>
<td>
<a href="./editors/pageedit.html?target=../src/page<?php echo $p;?>.yaml"
target="_blank">
page<?php echo $p;?>.yamlを編集する</a>
</td>
</tr>
<?php
}
?>
</table>
</div>
<h3>.phpファイルと.yamlファイルの使い分けについて</h3>
<p>
上記の編集可能なファイルは、1つのページファイルと、2つの定義ファイル(.phpおよび.yaml)の編集ができます。
定義ファイルはどちらか一方を利用します。
ページファイル内のヘッダ部分の記述を以下のように書き分けて、利用したい方を参照するようにします。
いずれも、page01.htmlがページファイルの場合に、同じ番号の定義ファイルを利用する場合です。
</p>
<div class="code"><pre><code># .phpファイルを利用する場合
<script src="def01.php"></script>
# .yamlファイルを利用する場合
<script src="../vendor/inter-mediator/inter-mediator/index.php"></script>
(リンクにファイル番号がありませんが、ページファイル名と同じ名前の.yamlファイルを参照します)
</code></pre>
</div>
<h3>PHPの定義ファイルをYAMLに変換する</h3>
<p>
タイトルのようなアプリケーションを作りました。<a href="im_yaml/index.php" target="_blank">こちら</a>をクリックするとご利用できます。
なお、このアプリケーションはevalを使ってPHPベースの定義ファイルを解析しているため、セキュリティ上の問題が懸念されます。
決して、誰もがアクセスできるところにこのアプリケーションを置かないようにしてください。
ご自分で利用できる範囲内に留めておいてください。なお、このトライアル環境を、自分のデスクトップのDockerで稼働させる限りは、他の人が利用はできないはずです。
</p>
</body>
</html>