summaryrefslogtreecommitdiff
path: root/include/common.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-14 14:17:18 +0300
committerAndrew Dolgov <[email protected]>2021-03-14 14:17:18 +0300
commit1c9afba5f058adace5e005b51fc533882f9af0fa (patch)
tree99f4a228acf9f969d5411048c210338ba0fd126a /include/common.php
parent2b8b845abe7c13ecbb266613910484310cffe8e1 (diff)
* add CSRF protection to xhr requests
* force ORM to use SQLITE WAL * add .editorconfig * cleanup a few things
Diffstat (limited to 'include/common.php')
-rw-r--r--include/common.php4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/common.php b/include/common.php
index 8f57b91..ee3921b 100644
--- a/include/common.php
+++ b/include/common.php
@@ -13,6 +13,10 @@
return sprintf(...$args);
}
+ function validate_csrf($csrf_token) {
+ return isset($csrf_token) && hash_equals($_SESSION['csrf_token'] ?? "", $csrf_token);
+ }
+
function sql_bool_to_bool($s) {
return $s && ($s !== "f" && $s !== "false"); //no-op for PDO, backwards compat for legacy layer
}