diff --git a/PodcastGenerator/admin/pg_config.php b/PodcastGenerator/admin/pg_config.php index e708454b..179533af 100644 --- a/PodcastGenerator/admin/pg_config.php +++ b/PodcastGenerator/admin/pg_config.php @@ -11,6 +11,7 @@ require '../core/include_admin.php'; if (isset($_GET['edit'])) { + checkToken(); foreach ($_POST as $key => $value) { updateConfig('../config.php', $key, $value); } @@ -61,9 +62,10 @@


+ " class="btn btn-success">
- \ No newline at end of file + diff --git a/PodcastGenerator/core/misc/functions.php b/PodcastGenerator/core/misc/functions.php index 9f6ba65d..58749fe8 100644 --- a/PodcastGenerator/core/misc/functions.php +++ b/PodcastGenerator/core/misc/functions.php @@ -60,4 +60,21 @@ function getUsers() { global $config; return json_decode($config['users_json'], true); -} \ No newline at end of file +} + +function randomString($length = 8) +{ + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; +} + +function checkToken() +{ + if(!isset($_POST['token']) || ($_POST['token'] != $_SESSION['token'])) + die("Potential CSRF attack"); +}