summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2023-02-25 19:06:54 +0100
committerMaksymilian Jopek <maks@jopek.eu>2023-03-26 20:04:17 +0200
commit19218d758d4fc0f8f5db5a97eb9dcfdb5086f844 (patch)
tree9a5e956cd6561e7d1919e19e5d080c69017763c2 /api
parent3df4ebc26d93afed16670e37edb26aa3b5a17317 (diff)
downloadmlos-19218d758d4fc0f8f5db5a97eb9dcfdb5086f844.tar.gz
mlos-19218d758d4fc0f8f5db5a97eb9dcfdb5086f844.tar.zst
mlos-19218d758d4fc0f8f5db5a97eb9dcfdb5086f844.zip
Remove path from repo
Add start script
Diffstat (limited to 'api')
-rw-r--r--api/add.php4
-rw-r--r--api/change-order.php4
-rw-r--r--api/export.php22
-rw-r--r--api/remove.php20
4 files changed, 33 insertions, 17 deletions
diff --git a/api/add.php b/api/add.php
index 780a3b4..7edeb3b 100644
--- a/api/add.php
+++ b/api/add.php
@@ -8,8 +8,8 @@ foreach ($req_keys as $key) {
exit(0);
}
}
-$path = "/home/maks/school/clientApps/mlos/src/db.xml";
-require_once "/home/maks/school/clientApps/mlos/src/data.php";
+$path = "%PWD%src/db.xml";
+require_once "%PWD%src/data.php";
$name = $_POST["name"];
$author = $_POST["author"];
diff --git a/api/change-order.php b/api/change-order.php
index b498605..8901187 100644
--- a/api/change-order.php
+++ b/api/change-order.php
@@ -4,8 +4,8 @@ if (empty($_POST["old-order"]) || empty($_POST["new-order"])) {
error_log("not enough post");
exit(0);
}
-$path = "/home/maks/school/clientApps/mlos/src/db.xml";
-require_once "/home/maks/school/clientApps/mlos/src/data.php";
+$path = "%PWD%src/db.xml";
+require_once "%PWD%src/data.php";
$old_order = $_POST["old-order"];
$new_order = $_POST["new-order"];
diff --git a/api/export.php b/api/export.php
index 77e36a2..625283e 100644
--- a/api/export.php
+++ b/api/export.php
@@ -1,6 +1,6 @@
<?php
-require_once '../vendor/autoload.php';
-require_once '../src/data.php';
+require_once '%PWD%vendor/autoload.php';
+require_once '%PWD%src/data.php';
[$data, $count] = get_data();
@@ -22,15 +22,17 @@ $row = 2;
foreach ($data as $d) {
$active_sheet->setCellValue('A' . $row, $d["name"]);
- $drawing = new Drawing();
- $drawing->setName($d["name"]);
- $drawing->setPath("../imgs/" . $d["thumbnail"]);
- $drawing->setHeight(200);
-
- $comment = $active_sheet->getComment('A' . $row);
- $comment->setBackgroundImage($drawing);
- $comment->setSizeAsBackgroundImage();
+ $path = "%PWD%imgs/" . $d["thumbnail"];
+ if(file_exists($path)) {
+ $drawing = new Drawing();
+ $drawing->setName($d["name"]);
+ $drawing->setPath($path);
+ $drawing->setHeight(200);
+ $comment = $active_sheet->getComment('A' . $row);
+ $comment->setBackgroundImage($drawing);
+ $comment->setSizeAsBackgroundImage();
+ }
$active_sheet->setCellValue('B' . $row, $d["author"]);
$active_sheet->setCellValue('C' . $row, $d["magazine"]);
diff --git a/api/remove.php b/api/remove.php
index 65f1a82..0ef23e5 100644
--- a/api/remove.php
+++ b/api/remove.php
@@ -1,10 +1,11 @@
<?php
+
if (empty($_POST["id"])) {
http_response_code(400);
exit(0);
}
-$path = "/home/maks/school/clientApps/mlos/src/db.xml";
-require_once "/home/maks/school/clientApps/mlos/src/data.php";
+$path = "%PWD%src/db.xml";
+require_once "%PWD%src/data.php";
$id = $_POST["id"];
$doc = get_doc();
@@ -13,7 +14,20 @@ $game = $xpath->query('//game[@id="' . $id . '"]')->item(0);
$game->parentNode->removeChild($game);
$count = $doc->getElementsByTagName("count")->item(0);
-$count->nodeValue = intval($count->nodeValue) - 1;
+$icount = intval($count->nodeValue) - 1;
+$count->nodeValue = $icount;
+
+
+[$data, $_] = get_data();
+$i = 1;
+foreach($data as $d) {
+ if($d["id"] === $id) continue;
+ $g = $xpath->query('//game[@id="' . $d["id"] . '"]')->item(0);
+ var_dump('//game[@id="' . $d["id"] . '"]');
+ $g->setAttribute("order", $i);
+ $i++;
+}
$doc->save($path);
header("Location: " . $_SERVER["HTTP_REFERER"]);
+