From bf7852bccce954aff2d7c94161f4d301a0f29684 Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Wed, 16 Mar 2022 23:20:59 +0100 Subject: Initial commit w/ v1.0.0 --- api/add.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 api/add.php (limited to 'api/add.php') diff --git a/api/add.php b/api/add.php new file mode 100644 index 0000000..b2e4c2d --- /dev/null +++ b/api/add.php @@ -0,0 +1,55 @@ +query('//game[@id="' . $id . '"]')->item(0); + var_dump($game); + var_dump($game->getElementsByTagName); + $xpath->query('//game[@id="' . $id . '"]/name')->item(0)->nodeValue = $name; + $xpath->query('//game[@id="' . $id . '"]/author')->item(0)->nodeValue = $author; + $xpath->query('//game[@id="' . $id . '"]/thumbnail')->item(0)->nodeValue = $thumbnail; + $xpath->query('//game[@id="' . $id . '"]/magazine')->item(0)->nodeValue = $magazine; +} else { + $root = $doc->getElementsByTagName("root")->item(0); + $game = $doc->createElement("game", ""); + + $mid = $doc->getElementsByTagName("mid")->item(0); + $game->setAttribute("id", $mid->nodeValue); + $mid->nodeValue = intval($mid->nodeValue) + 1; + + $count = $doc->getElementsByTagName("count")->item(0); + $count->nodeValue = intval($count->nodeValue) + 1; + $game->setAttribute("order", $count->nodeValue); + + $name = $doc->createElement("name", $name); + $author = $doc->createElement("author", $author); + $thumbnail = $doc->createElement("thumbnail", $thumbnail); + $magazine = $doc->createElement("magazine", $magazine); + $game->append($name); + $game->append($author); + $game->append($thumbnail); + $game->append($magazine); + + $root->appendChild($game); +} + +$doc->save($path); -- cgit v1.3.1