Add the ability to include javascript

This commit is contained in:
Jacob 2023-09-30 20:31:01 +02:00
parent 4a4978cb27
commit 8af14ad90d
5 changed files with 59 additions and 35 deletions

View file

@ -4,6 +4,7 @@
* Licensed under the GNU Affero General Public License version 3.0
*/
include "core.php";
include "config.php";
include "create-table.php";
@ -16,17 +17,8 @@ $Authorized = 0;
$Database = createTables($sqlDB);
$DatabaseQuery = $Database->query('SELECT * FROM admins');
$html .= "<!DOCTYPE html>\n";
$html .= "<html>\n";
$html .= "\t<head>\n";
$html .= "\t\t<meta name=\"description\" content=\"Site administration\">\n";
$html .= "\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n";
$html .= "\t\t<link rel=\"icon\" href=\"$Icon\" />\n";
$html .= "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"$Stylesheet\"/>\n";
$html .= "\t\t<title>Administration - $instanceName</title>\n";
$html .= "\t</head>\n";
$html .= "\t<body>\n";
$html .= "\t\t<div class=\"content\">\n";
$html = "";
$html = printHead($html);
if (isset($_REQUEST['key'])) {
$Key = $_REQUEST['key'];
@ -88,9 +80,7 @@ if (isset($_REQUEST['key'])) {
}
}
$html .= "\t\t</div>\n";
$html .= "\t</body>\n";
$html .= "</html>\n";
$html = printFooter($html);
print "$html";

View file

@ -1,6 +1,7 @@
[html]
instance_name = curload
css = index.css
javascript = index.js
favicon = favicon.svg
[upload]

View file

@ -6,6 +6,7 @@
$configFile = "config.ini";
$Stylesheet = "index.css";
$javaScript = "index.js";
$Icon = "favicon.svg";
$uploadDir = "uploads/";
$maxFileSize = "100";
@ -52,4 +53,5 @@ $enableAdminKeys = $configEntries['enable_admin_keys'];
$enableTemporaryKeys = $configEntries['enable_temporary_keys'];
$enableUploadRemoval = $configEntries['enable_upload_removal'];
$enableKeyUploadRemoval = $configEntries['enable_key_upload_removal'];
$javaScript = $configEntries['javascript'];
?>

38
core.php Normal file
View file

@ -0,0 +1,38 @@
<?php
/* curload
* Simple file uploading using POST requests and temporary keys
* Licensed under the GNU Affero General Public License version 3.0
*/
function printHead($html) {
include "config.php";
$html .= "<!DOCTYPE html>\n";
$html .= "<html>\n";
$html .= "\t<head>\n";
$html .= "\t\t<meta name=\"description\" content=\"$instanceName is a simple file uploading site allowing users to upload files by authenticating using a key.\">\n";
$html .= "\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n";
if (file_exists($Icon)) $html .= "\t\t<link rel=\"icon\" href=\"$Icon\" />\n";
if (file_exists($Stylesheet)) $html .= "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"$Stylesheet\"/>\n";
if (file_exists($javaScript)) $html .= "\t\t<script src=\"$javaScript\"></script>\n";
$html .= "\t\t<title>$instanceName</title>\n";
$html .= "\t</head>\n";
$html .= "\t<body>\n";
$html .= "\t\t<div class=\"content\">\n";
return "$html";
}
function printFooter($html) {
include "config.php";
$html .= "\t\t</div>\n";
$html .= "\t</body>\n";
$html .= "</html>\n";
return "$html";
}
?>

View file

@ -4,30 +4,23 @@
* Licensed under the GNU Affero General Public License version 3.0
*/
include "config.php";
function main() {
include "config.php";
include "core.php";
$html = "";
$html .= "<!DOCTYPE html>\n";
$html .= "<html>\n";
$html .= "\t<head>\n";
$html .= "\t\t<meta name=\"description\" content=\"$instanceName is a simple file uploading site allowing users to upload files by authenticating using a key.\">\n";
$html .= "\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n";
$html .= "\t\t<link rel=\"icon\" href=\"$Icon\" />\n";
$html .= "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"$Stylesheet\"/>\n";
$html .= "\t\t<title>$instanceName</title>\n";
$html .= "\t</head>\n";
$html .= "\t<body>\n";
$html .= "\t\t<div class=\"content\">\n";
$html = "";
$html = printHead($html);
$html .= "\t\t\t<h1>speedie's super awesome file uploader junk</h1>\n";
$html .= "\t\t\t<form action=\"upload.php\" method=\"post\" enctype=\"multipart/form-data\">Select file to upload<br><input type=\"file\" name=\"file\" id=\"file\"><br><input type=\"text\" name=\"key\" placeholder=\"Upload key here\"><br><input type=\"submit\" value=\"Upload selected file\" name=\"web\"></form>\n";
$html .= "\t\t\t<p>Max file size: $maxFileSize MB</p>\n";
$html .= "\t\t\t<a href=\"https://git.speedie.site/speedie/curload\">source code</a>\n";
$html .= "\t\t\t<h1>speedie's super awesome file uploader junk</h1>\n";
$html .= "\t\t\t<form action=\"upload.php\" method=\"post\" enctype=\"multipart/form-data\">Select file to upload<br><input type=\"file\" name=\"file\" id=\"file\"><br><input type=\"text\" name=\"key\" placeholder=\"Upload key here\"><br><input type=\"submit\" value=\"Upload selected file\" name=\"web\"></form>\n";
$html .= "\t\t\t<p>Max file size: $maxFileSize MB</p>\n";
$html .= "\t\t\t<a href=\"https://git.speedie.site/speedie/curload\">source code</a>\n";
$html .= "\t\t</div>\n";
$html .= "\t</body>\n";
$html .= "</html>\n";
$html = printFooter($html);
print "$html";
print "$html";
}
main();
?>