From cb9ca2b735b9fedc479799e88ddb731251b35b08 Mon Sep 17 00:00:00 2001
From: Fibinger Ádám <adam.fibinger@wup.hu>
Date: Sun, 10 Nov 2019 13:27:28 +0100
Subject: [PATCH] ESL Api alapján JSON-ból felhúzni a csapatokat gyors kiegészítésre

---
 save-teams.php |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/save-teams.php b/save-teams.php
index 0d2fde4..d9906c1 100644
--- a/save-teams.php
+++ b/save-teams.php
@@ -2,19 +2,34 @@
 
 include_once "common/base.php";
 
-if (empty($_POST['json'])) {
-    header('Location: /generator/form.php', true, 302);
+if (empty($_POST['json']))
+{
+	header('Location: /generator/form.php', true, 302);
 }
 $teams = new \EOG\Models\TeamList();
 
+if (!$teams->fromJson($_POST['json']))
+{
+	echo "Nincs benne becsekkolt csapat.";
+	return;
+
+}
+
 $success = false;
 
-if ($teams->fromJson($_POST['json'])) {
-    $success = file_put_contents(OVERLAY_DIR . 'teams.json', $teams->getJson());
+$success = file_put_contents(TEAMS_JSON, $teams->getJson());
+
+if (!$success)
+{
+	var_dump($teams->getJson());
+	var_dump(is_writable(TEAMS_JSON));
 }
 
-if ($success) {
-    header('Location: /generator/form.php', true, 302);
-} else {
-    echo "Szar van a palacsintában";
+if ($success)
+{
+	header('Location: /generator/form.php', true, 302);
 }
+else
+{
+	echo "Szar van a palacsintában: " . TEAMS_JSON;
+}
\ No newline at end of file

--
Gitblit v1.8.0