add env var support
All checks were successful
/ docker (push) Successful in 1m45s

This commit is contained in:
Lee
2023-07-05 01:49:59 +01:00
parent e18239d5bf
commit 79f4b8ee3a
3 changed files with 37 additions and 12 deletions

View File

@ -10,19 +10,29 @@ header('Content-type:application/json;charset=utf-8'); // Set the response conte
/**
* Configuration
*/
$uploadSecrets;
// Check if the environment variable UPLOAD_SECRETS is set
if (getenv('UPLOAD_SECRETS')) {
$uploadSecrets = explode(",", getenv('UPLOAD_SECRETS'));
if (getenv('DOCKER')) { // If the script is running in a Docker container
$uploadSecrets = explode(",", getenv('UPLOAD_SECRETS')); // The upload secrets
$uploadDir = getenv('UPLOAD_DIR'); // The upload directory
$useRandomFileNames = getenv('USE_RANDOM_FILE_NAMES'); // Use random file names instead of the original file name
$shouldConvertToWebp = getenv('SHOULD_CONVERT_TO_WEBP'); // Should the script convert images to webp?
$webpQuality = getenv('WEBP_QUALITY'); // The quality of the webp image (0-100)
$webpThreadhold = getenv('WEBP_THREADHOLD'); // The minimum file size for converting to webp (in bytes)
$fileNameLength = getenv('FILE_NAME_LENGTH'); // The length of the random file name
} else {
$uploadSecrets = array("set me"); // Use this if you are not using environment variables (eg: Not using Docker)
/**
* !!!
* USE THIS IF YOU ARE NOT USING DOCKER
* !!!
*/
$uploadSecrets = array("set me"); // The upload secrets
$uploadDir = "./"; // The upload directory
$useRandomFileNames = false; // Use random file names instead of the original file name
$shouldConvertToWebp = true; // Should the script convert images to webp?
$webpQuality = 95; // The quality of the webp image (0-100)
$webpThreadhold = 1048576; // 1MB - The minimum file size for converting to webp (in bytes)
$fileNameLength = 8; // The length of the random file name
}
$uploadDir = "./"; // The upload directory
$useRandomFileNames = false; // Use random file names instead of the original file name
$shouldConvertToWebp = true; // Should the script convert images to webp?
$webpQuality = 95; // The quality of the webp image (0-100)
$fileNameLength = 8; // The length of the random file name
$webpThreadhold = 1048576; // 1MB - The minimum file size for converting to webp (in bytes)
/**
* Check if the given secret is valid