From 3e782b7265faa69dc87689f66fb4247f9d90855f Mon Sep 17 00:00:00 2001 From: davidovski Date: Wed, 9 Aug 2023 11:30:54 +0100 Subject: Add cell coord validation --- index.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 81a4b43..f7399af 100644 --- a/index.php +++ b/index.php @@ -15,9 +15,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $pos = explode(",", $_POST["cell"]); - $grid[$pos[0]][$pos[1]] = $_POST["color"]; - - file_put_contents('array.json', json_encode($grid)); + if ($pos[0] >= 0 && $pos[1] >= 0 && $pos[0] < $GRID_SIZE && $pos[1] < $GRID_SIZE) { + $grid[$pos[0]][$pos[1]] = $_POST["color"]; + file_put_contents('array.json', json_encode($grid)); + } } ?> -- cgit v1.2.1