Version 1
[yaffs-website] / vendor / caxy / php-htmldiff / demo / load_table_diff.php
diff --git a/vendor/caxy/php-htmldiff/demo/load_table_diff.php b/vendor/caxy/php-htmldiff/demo/load_table_diff.php
new file mode 100644 (file)
index 0000000..c2180ad
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+$requestBody = file_get_contents('php://input');
+
+$requestJson = json_decode($requestBody, true);
+
+if (empty($requestJson['index'])) {
+    throw new \Exception('index is required.');
+}
+
+$jsonFile = __DIR__.'/tablediffs.json';
+
+$demoStorage = json_decode(file_get_contents($jsonFile), true);
+
+if (!array_key_exists($requestJson['index'], $demoStorage)) {
+    throw new \Exception('index not found.');
+}
+
+$targetDemo = $demoStorage[$requestJson['index']];
+
+header('Content-Type: application/json');
+echo json_encode($targetDemo);