diff options
author | davidovski <david@davidovski.xyz> | 2023-08-09 11:30:54 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2023-08-09 11:30:54 +0100 |
commit | 3e782b7265faa69dc87689f66fb4247f9d90855f (patch) | |
tree | 93ccb9316f2130358b889f9f968adadaf50bbba3 /index.php | |
parent | 085415092d6310a6fc87dfa5002a72f1cce6c376 (diff) |
Add cell coord validation
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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)); + } } ?> |