added API key support

This commit is contained in:
hnhx 2022-05-29 20:42:01 +02:00
parent b5226eebaa
commit 36d585fdb6
3 changed files with 15 additions and 3 deletions

3
config.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$api_keys = array("857db8bac39d3a6374fe57635a21ce09024403def203e01bc0906ebe4e4fdff21c74afcc1ed5315258b23cdf33c90a2368fe");
?>

3
config.php.example Normal file
View File

@ -0,0 +1,3 @@
<?php
$api_keys = array();
?>

View File

@ -13,6 +13,8 @@
<a href="./index.php">Upload</a>
<?php
require("config.php");
$content = NULL;
if (isset($_REQUEST["p"]))
@ -55,7 +57,7 @@
}
if (!isset($_REQUEST["content"]) || !isset($_REQUEST["captcha"]))
if (!isset($_REQUEST["content"]))
die();
session_start();
@ -64,8 +66,12 @@
if ($_SESSION["captcha"] != strtoupper($_REQUEST["captcha"]))
{
$valid_upload = false;
echo "<p>Invalid captcha!</p>";
if (!in_array($_REQUEST["api_key"], $api_keys))
{
$valid_upload = false;
echo "<p>Invalid captcha!</p>";
}
}
$content_len = strlen($content);