Change some basic things
This commit is contained in:
parent
2ab18cfe2e
commit
9907eb9b72
17
add-keys.php
17
add-keys.php
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/* curload
|
||||
* Simple file uploading using POST requests and temporary keys
|
||||
* Licensed under the GNU Affero General Public License version 3.0
|
||||
*/
|
||||
|
||||
include "create-table.php";
|
||||
|
||||
function getIPAddress() {
|
||||
|
@ -68,13 +73,13 @@
|
|||
$Database->exec("INSERT INTO tkeys(key, numberofuploads, uploadsleft, lastused, issued, ip, useragent) VALUES('$Value', '$numberOfUploads', '$uploadsLeft', '$lastUsed', '$Issued', '$ip', '$userAgent')");
|
||||
}
|
||||
|
||||
// TEMPORARY FUNCTION: TO BE REMOVED
|
||||
function addAdminKey($Value) {
|
||||
function addAdminKey($adminKey, $Value, $Primary) {
|
||||
include "config.php";
|
||||
|
||||
$Database = createTables($sqlDB);
|
||||
$DatabaseQuery = $Database->query('SELECT * FROM admins');
|
||||
$DatabaseQuery = $Database->query('SELECT * FROM keys');
|
||||
|
||||
$numberOfUploads = 0;
|
||||
$lastUsed = date($dateFormat);
|
||||
$Issued = date($dateFormat);
|
||||
$ip = "";
|
||||
|
@ -88,10 +93,6 @@
|
|||
$ip = getIPAddress();
|
||||
}
|
||||
|
||||
if ($storeAgent || $storeAgent == "true") {
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||
}
|
||||
|
||||
$Database->exec("INSERT INTO admins(id, key, lastused, issued, ip, useragent) VALUES('$Value', '$lastUsed', '$Issued', '$ip', '$userAgent')");
|
||||
$Database->exec("INSERT INTO admins(key, primary, numberofuploads, lastused, issued, ip, useragent) VALUES('$Value', '$Primary', '$numberOfUploads', '$lastUsed', '$Issued', '$ip', '$userAgent')");
|
||||
}
|
||||
?>
|
||||
|
|
31
admin.php
Normal file
31
admin.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/* curload
|
||||
* Simple file uploading using POST requests and temporary keys
|
||||
* Licensed under the GNU Affero General Public License version 3.0
|
||||
*/
|
||||
|
||||
include "config.php"?;
|
||||
include "create-table.php";
|
||||
|
||||
$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";
|
||||
|
||||
if (isset($_REQUEST['key'])) {
|
||||
$Key = $_REQUEST['key'];
|
||||
} else {
|
||||
$Authorized = 0;
|
||||
}
|
||||
?>
|
|
@ -1,4 +1,5 @@
|
|||
[html]
|
||||
instance_name = curload
|
||||
css = index.css
|
||||
favicon = favicon.svg
|
||||
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/* curload
|
||||
* Simple file uploading using POST requests and temporary keys
|
||||
* Licensed under the GNU Affero General Public License version 3.0
|
||||
*/
|
||||
|
||||
$Stylesheet = "index.css";
|
||||
$Icon = "favicon.svg";
|
||||
$uploadDir = "uploads/";
|
||||
|
@ -12,6 +17,7 @@
|
|||
$storeIssued = true;
|
||||
$storeLastUsage = true;
|
||||
$dateFormat = "Y/m/d";
|
||||
$instanceName = "curload";
|
||||
|
||||
define('CONFIG_FILE', 'config.ini');
|
||||
|
||||
|
@ -34,4 +40,5 @@
|
|||
$storeIssued = $configEntries['store_issued'];
|
||||
$storeLastUsage = $configEntries['store_last_usage'];
|
||||
$dateFormat = $configEntries['date_format'];
|
||||
$instanceName = $configEntries['instance_name'];
|
||||
?>
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
<?php
|
||||
/* curload
|
||||
* Simple file uploading using POST requests and temporary keys
|
||||
* Licensed under the GNU Affero General Public License version 3.0
|
||||
*/
|
||||
|
||||
function createTables($sqlDB) {
|
||||
$Database = new SQLite3($sqlDB);
|
||||
|
||||
/* administrator table
|
||||
* id (INTEGER PRIMARY KEY)
|
||||
* key (TEXT)
|
||||
* primary (INT)
|
||||
* lastused (TEXT)
|
||||
* issued (TEXT)
|
||||
* ip (TEXT)
|
||||
* useragent (TEXT)
|
||||
*/
|
||||
$Database->exec(
|
||||
"CREATE TABLE IF NOT EXISTS admins(id INTEGER PRIMARY KEY, key TEXT, lastused TEXT, issued TEXT, ip TEXT, useragent TEXT)"
|
||||
);
|
||||
$Database->exec("CREATE TABLE IF NOT EXISTS admins(id INTEGER PRIMARY KEY, key TEXT, primary INT, numberofuploads INT, lastused TEXT, issued TEXT, ip TEXT, useragent TEXT)");
|
||||
|
||||
/* keys table
|
||||
* id (INTEGER PRIMARY KEY)
|
||||
|
@ -42,9 +46,9 @@
|
|||
* file (TEXT)
|
||||
* uploaddate (TEXT)
|
||||
* keyid (INT) (THIS IS THE ID OF THE KEY USED TO UPLOAD THE FILE)
|
||||
* tempkey (INT)
|
||||
* keytype (INT)
|
||||
*/
|
||||
$Database->exec("CREATE TABLE IF NOT EXISTS uploads(id INTEGER PRIMARY KEY, file TEXT, uploaddate TEXT, keyid INT, tempkey INT)");
|
||||
$Database->exec("CREATE TABLE IF NOT EXISTS uploads(id INTEGER PRIMARY KEY, file TEXT, uploaddate TEXT, keyid INT, keytype INT)");
|
||||
|
||||
return $Database;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
}
|
||||
|
||||
if ($Type == "Admin") {
|
||||
addAdminKey($Data);
|
||||
addAdminKey($Key, $Data, 0);
|
||||
} else if ($Type == "Temporary") {
|
||||
addTempKey($Key, $Data, $Uploads);
|
||||
} else if ($Type == "Key") {
|
||||
|
|
68
index.php
68
index.php
|
@ -4,51 +4,37 @@
|
|||
* Licensed under the GNU Affero General Public License version 3.0
|
||||
*/
|
||||
|
||||
function printHeader($title, $description, $Icon, $Stylesheet) {
|
||||
print "<!DOCTYPE html>\n";
|
||||
print "<html>\n";
|
||||
print "\t<head>\n";
|
||||
print "\t\t<meta name=\"description\" content=\"$description\">\n";
|
||||
print "\t\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n";
|
||||
print "\t\t<link rel=\"icon\" href=\"$Icon\" />\n";
|
||||
print "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"$Stylesheet\"/>\n";
|
||||
print "\t\t<title>$title</title>\n";
|
||||
print "\t</head>\n";
|
||||
print "\t<body>\n";
|
||||
print "\t\t<div class=\"content\">\n";
|
||||
}
|
||||
|
||||
function printFooter() {
|
||||
print "\t\t</div>\n";
|
||||
print "\t</body>\n";
|
||||
print "</html>\n";
|
||||
}
|
||||
|
||||
function initServer() {
|
||||
}
|
||||
|
||||
function main() {
|
||||
include "config.php";
|
||||
|
||||
printHeader("curload", "Simply upload files", $Icon, $Stylesheet);
|
||||
$html .= "<!DOCTYPE html>\n";
|
||||
$html .= "<html>\n";
|
||||
$html .= "\t<head>\n";
|
||||
$html .= "\t\t<meta name=\"description\" content=\"$primaryTitle\">\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>$primaryTitle</title>\n";
|
||||
$html .= "\t</head>\n";
|
||||
$html .= "\t<body>\n";
|
||||
$html .= "\t\t<div class=\"content\">\n";
|
||||
|
||||
print "\t\t\t<h1>speedie's super awesome file uploader junk</h1>\n";
|
||||
print "\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";
|
||||
print "\t\t\t<p>Max file size: $maxFileSize MB</p>\n";
|
||||
print "\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\t<h2>oops i leaked admin tools</h2>\n";
|
||||
$html .= "\t\t\t<form action=\"create.php\" method=\"post\">\n";
|
||||
$html .= "\t\t\t\t<input type=\"text\" name=\"data\" placeholder=\"key name\">\n";
|
||||
$html .= "\t\t\t\t<input type=\"text\" name=\"type\" placeholder=\"type\">\n";
|
||||
$html .= "\t\t\t\t<input type=\"text\" name=\"key\" placeholder=\"admin key\">\n";
|
||||
$html .= "\t\t\t\t<input type=\"text\" name=\"uploads\" placeholder=\"max uploads\">\n";
|
||||
$html .= "\t\t\t\t<input type=\"submit\" value=\"make\">\n";
|
||||
$html .= "\t\t\t</form>\n";
|
||||
|
||||
print "\t\t\t<h2>oops i leaked admin tools</h2>\n";
|
||||
print "\t\t\t<form action=\"create.php\" method=\"post\">\n";
|
||||
print "\t\t\t\t<input type=\"text\" name=\"data\" placeholder=\"key name\">\n";
|
||||
print "\t\t\t\t<input type=\"text\" name=\"type\" placeholder=\"type\">\n";
|
||||
print "\t\t\t\t<input type=\"text\" name=\"key\" placeholder=\"admin key\">\n";
|
||||
print "\t\t\t\t<input type=\"text\" name=\"uploads\" placeholder=\"max uploads\">\n";
|
||||
print "\t\t\t\t<input type=\"submit\" value=\"make\">\n";
|
||||
print "\t\t\t</form>\n";
|
||||
$html .= "\t\t</div>\n";
|
||||
$html .= "\t</body>\n";
|
||||
$html .= "</html>\n";
|
||||
|
||||
printFooter();
|
||||
}
|
||||
|
||||
main();
|
||||
print "$html";
|
||||
|
||||
?>
|
||||
|
|
62
upload.php
62
upload.php
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/* curload
|
||||
* Simple file uploading using POST requests and temporary keys
|
||||
* Licensed under the GNU Affero General Public License version 3.0
|
||||
*/
|
||||
|
||||
include "config.php";
|
||||
include "create-table.php";
|
||||
|
||||
|
@ -11,7 +16,7 @@
|
|||
|
||||
$Status = 0;
|
||||
$Authorized = 0;
|
||||
$tempKeyUsed = 0;
|
||||
$keyType = 0;
|
||||
$uploadLimit = $maxFileSize * 1000000;
|
||||
$keyID = 0;
|
||||
$self = dirname($_SERVER['PHP_SELF']);
|
||||
|
@ -54,7 +59,7 @@
|
|||
}
|
||||
|
||||
$Authorized = 1;
|
||||
$tempKeyUsed = 0;
|
||||
$keyType = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +96,45 @@
|
|||
}
|
||||
|
||||
$Authorized = 1;
|
||||
$tempKeyUsed = 1;
|
||||
$keyType = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// maybe admin?
|
||||
if ($Authorized != 1) {
|
||||
$DatabaseQuery = $Database->query('SELECT * FROM admins');
|
||||
|
||||
while ($line = $DatabaseQuery->fetchArray()) {
|
||||
if ($line['key'] == $Key && $Key != "" && $line['key'] != "") {
|
||||
$id = $line['id'];
|
||||
$keyID = $id;
|
||||
$numberOfUploads = $line['numberofuploads'] + 1;
|
||||
$lastUsed = date($dateFormat);
|
||||
|
||||
$Database->exec("UPDATE keys SET lastused='$lastUsed' WHERE id='$id'");
|
||||
$Database->exec("UPDATE keys SET numberofuploads='$numberOfUploads' WHERE id='$id'");
|
||||
|
||||
if ($storeIP || $storeIP == "true") {
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} else {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
$Database->exec("UPDATE keys SET ip='$ip' WHERE id='$id'");
|
||||
}
|
||||
|
||||
if ($storeAgent || $storeAgent == "true") {
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||
$Database->exec("UPDATE keys SET useragent='$userAgent' WHERE id='$id'");
|
||||
}
|
||||
|
||||
$Authorized = 1;
|
||||
$keyType = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +151,7 @@
|
|||
foreach ($validKeys as $ValidKey) {
|
||||
if ($Key == $ValidKey && $Key != "" && $ValidKey != "") {
|
||||
$Authorized = 1;
|
||||
$tempKeyUsed = 0;
|
||||
$keyType = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -121,7 +164,7 @@
|
|||
foreach ($tempValidKeys as $ValidKey) {
|
||||
if ($Key == $ValidKey && $Key != "" && $ValidKey != "") {
|
||||
$Authorized = 1;
|
||||
$tempKeyUsed = 1; // key should be considered invalid after this use.
|
||||
$keyType = 1; // key should be considered invalid after this use.
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -165,10 +208,10 @@
|
|||
if ($sql || $sql == "true") {
|
||||
$lastUsed = date($dateFormat);
|
||||
$DatabaseQuery = $Database->query('SELECT * FROM uploads');
|
||||
$Database->exec("INSERT INTO uploads(file, uploaddate, keyid, tempkey) VALUES('$uploadedFile', '$lastUsed', '$keyID', '$tempKeyUsed')");
|
||||
$Database->exec("INSERT INTO uploads(file, uploaddate, keyid, keytype) VALUES('$uploadedFile', '$lastUsed', '$keyID', '$keyType')");
|
||||
}
|
||||
|
||||
if ($tempKeyUsed) { // Remove temporary key
|
||||
if ($keyType == 1) { // Remove temporary key
|
||||
$file = file_get_contents($tempKeyFile);
|
||||
$file = preg_replace("/\b$Key\b/", "", $file);
|
||||
file_put_contents($tempKeyFile, $file);
|
||||
|
@ -182,10 +225,7 @@
|
|||
}
|
||||
} else {
|
||||
print "Failed to upload file.";
|
||||
|
||||
if ($_FILES['file']['error'] == 1) {
|
||||
print "Is the upload_max_filesize set up properly?";
|
||||
}
|
||||
print $_FILES['file']['error'];
|
||||
die();
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue