Change some basic things
This commit is contained in:
parent
2ab18cfe2e
commit
9907eb9b72
161
add-keys.php
161
add-keys.php
|
@ -1,97 +1,98 @@
|
||||||
<?php
|
<?php
|
||||||
include "create-table.php";
|
/* curload
|
||||||
|
* Simple file uploading using POST requests and temporary keys
|
||||||
|
* Licensed under the GNU Affero General Public License version 3.0
|
||||||
|
*/
|
||||||
|
|
||||||
function getIPAddress() {
|
include "create-table.php";
|
||||||
include "config.php";
|
|
||||||
|
|
||||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
function getIPAddress() {
|
||||||
return $_SERVER['HTTP_CLIENT_IP'];
|
include "config.php";
|
||||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
|
||||||
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||||
} else {
|
return $_SERVER['HTTP_CLIENT_IP'];
|
||||||
return $_SERVER['REMOTE_ADDR'];
|
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||||
}
|
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
|
} else {
|
||||||
|
return $_SERVER['REMOTE_ADDR'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUserAgent() {
|
||||||
|
return $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Hash passwords
|
||||||
|
function addKey($adminKey, $Value) {
|
||||||
|
include "config.php";
|
||||||
|
|
||||||
|
$Database = createTables($sqlDB);
|
||||||
|
$DatabaseQuery = $Database->query('SELECT * FROM keys');
|
||||||
|
|
||||||
|
$numberOfUploads = 0;
|
||||||
|
$lastUsed = date($dateFormat);
|
||||||
|
$Issued = date($dateFormat);
|
||||||
|
$ip = "";
|
||||||
|
$userAgent = "";
|
||||||
|
|
||||||
|
if ($storeAgent || $storeAgent == "true") {
|
||||||
|
$userAgent = getUserAgent();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserAgent() {
|
if ($storeIP || $storeIP == "true") {
|
||||||
return $_SERVER['HTTP_USER_AGENT'];
|
$ip = getIPAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Hash passwords
|
$Database->exec("INSERT INTO keys(key, numberofuploads, lastused, issued, ip, useragent) VALUES('$Value', '$numberOfUploads', '$lastUsed', '$Issued', '$ip', '$userAgent')");
|
||||||
function addKey($adminKey, $Value) {
|
}
|
||||||
include "config.php";
|
|
||||||
|
|
||||||
$Database = createTables($sqlDB);
|
function addTempKey($adminKey, $Value, $uploadsLeft) {
|
||||||
$DatabaseQuery = $Database->query('SELECT * FROM keys');
|
include "config.php";
|
||||||
|
|
||||||
$numberOfUploads = 0;
|
$Database = createTables($sqlDB);
|
||||||
$lastUsed = date($dateFormat);
|
$DatabaseQuery = $Database->query('SELECT * FROM tkeys');
|
||||||
$Issued = date($dateFormat);
|
|
||||||
$ip = "";
|
|
||||||
$userAgent = "";
|
|
||||||
|
|
||||||
if ($storeAgent || $storeAgent == "true") {
|
$numberOfUploads = 0;
|
||||||
$userAgent = getUserAgent();
|
$lastUsed = date($dateFormat);
|
||||||
}
|
$Issued = date($dateFormat);
|
||||||
|
$ip = "";
|
||||||
|
$userAgent = "";
|
||||||
|
|
||||||
if ($storeIP || $storeIP == "true") {
|
if ($storeAgent || $storeAgent == "true") {
|
||||||
$ip = getIPAddress();
|
$userAgent = getUserAgent();
|
||||||
}
|
|
||||||
|
|
||||||
$Database->exec("INSERT INTO keys(key, numberofuploads, lastused, issued, ip, useragent) VALUES('$Value', '$numberOfUploads', '$lastUsed', '$Issued', '$ip', '$userAgent')");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTempKey($adminKey, $Value, $uploadsLeft) {
|
if ($storeIP || $storeIP == "true") {
|
||||||
include "config.php";
|
$ip = getIPAddress();
|
||||||
|
|
||||||
$Database = createTables($sqlDB);
|
|
||||||
$DatabaseQuery = $Database->query('SELECT * FROM tkeys');
|
|
||||||
|
|
||||||
$numberOfUploads = 0;
|
|
||||||
$lastUsed = date($dateFormat);
|
|
||||||
$Issued = date($dateFormat);
|
|
||||||
$ip = "";
|
|
||||||
$userAgent = "";
|
|
||||||
|
|
||||||
if ($storeAgent || $storeAgent == "true") {
|
|
||||||
$userAgent = getUserAgent();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($storeIP || $storeIP == "true") {
|
|
||||||
$ip = getIPAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($storeAgent || $storeAgent == "true") {
|
|
||||||
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$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
|
if ($storeAgent || $storeAgent == "true") {
|
||||||
function addAdminKey($Value) {
|
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||||
include "config.php";
|
|
||||||
|
|
||||||
$Database = createTables($sqlDB);
|
|
||||||
$DatabaseQuery = $Database->query('SELECT * FROM admins');
|
|
||||||
|
|
||||||
$lastUsed = date($dateFormat);
|
|
||||||
$Issued = date($dateFormat);
|
|
||||||
$ip = "";
|
|
||||||
$userAgent = "";
|
|
||||||
|
|
||||||
if ($storeAgent || $storeAgent == "true") {
|
|
||||||
$userAgent = getUserAgent();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($storeIP || $storeIP == "true") {
|
|
||||||
$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 tkeys(key, numberofuploads, uploadsleft, lastused, issued, ip, useragent) VALUES('$Value', '$numberOfUploads', '$uploadsLeft', '$lastUsed', '$Issued', '$ip', '$userAgent')");
|
||||||
|
}
|
||||||
|
|
||||||
|
function addAdminKey($adminKey, $Value, $Primary) {
|
||||||
|
include "config.php";
|
||||||
|
|
||||||
|
$Database = createTables($sqlDB);
|
||||||
|
$DatabaseQuery = $Database->query('SELECT * FROM keys');
|
||||||
|
|
||||||
|
$numberOfUploads = 0;
|
||||||
|
$lastUsed = date($dateFormat);
|
||||||
|
$Issued = date($dateFormat);
|
||||||
|
$ip = "";
|
||||||
|
$userAgent = "";
|
||||||
|
|
||||||
|
if ($storeAgent || $storeAgent == "true") {
|
||||||
|
$userAgent = getUserAgent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($storeIP || $storeIP == "true") {
|
||||||
|
$ip = getIPAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
$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]
|
[html]
|
||||||
|
instance_name = curload
|
||||||
css = index.css
|
css = index.css
|
||||||
favicon = favicon.svg
|
favicon = favicon.svg
|
||||||
|
|
||||||
|
|
71
config.php
71
config.php
|
@ -1,37 +1,44 @@
|
||||||
<?php
|
<?php
|
||||||
$Stylesheet = "index.css";
|
/* curload
|
||||||
$Icon = "favicon.svg";
|
* Simple file uploading using POST requests and temporary keys
|
||||||
$uploadDir = "uploads/";
|
* Licensed under the GNU Affero General Public License version 3.0
|
||||||
$keyFile = "passwords.txt";
|
*/
|
||||||
$tempKeyFile = "temporary_passwords.txt";
|
|
||||||
$maxFileSize = "100";
|
|
||||||
$sql = true;
|
|
||||||
$sqlDB = "curload.db";
|
|
||||||
$storeIP = true;
|
|
||||||
$storeAgent = true;
|
|
||||||
$storeIssued = true;
|
|
||||||
$storeLastUsage = true;
|
|
||||||
$dateFormat = "Y/m/d";
|
|
||||||
|
|
||||||
define('CONFIG_FILE', 'config.ini');
|
$Stylesheet = "index.css";
|
||||||
|
$Icon = "favicon.svg";
|
||||||
|
$uploadDir = "uploads/";
|
||||||
|
$keyFile = "passwords.txt";
|
||||||
|
$tempKeyFile = "temporary_passwords.txt";
|
||||||
|
$maxFileSize = "100";
|
||||||
|
$sql = true;
|
||||||
|
$sqlDB = "curload.db";
|
||||||
|
$storeIP = true;
|
||||||
|
$storeAgent = true;
|
||||||
|
$storeIssued = true;
|
||||||
|
$storeLastUsage = true;
|
||||||
|
$dateFormat = "Y/m/d";
|
||||||
|
$instanceName = "curload";
|
||||||
|
|
||||||
if (!file_exists(CONFIG_FILE)) {
|
define('CONFIG_FILE', 'config.ini');
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* load config file */
|
if (!file_exists(CONFIG_FILE)) {
|
||||||
$configEntries = parse_ini_file(CONFIG_FILE);
|
return;
|
||||||
$Stylesheet = $configEntries['css'];
|
}
|
||||||
$Icon = $configEntries['favicon'];
|
|
||||||
$uploadDir = $configEntries['upload_dir'];
|
/* load config file */
|
||||||
$keyFile = $configEntries['key_file'];
|
$configEntries = parse_ini_file(CONFIG_FILE);
|
||||||
$tempKeyFile = $configEntries['temp_key_file'];
|
$Stylesheet = $configEntries['css'];
|
||||||
$maxFileSize = $configEntries['max_size'];
|
$Icon = $configEntries['favicon'];
|
||||||
$sql = $configEntries['sql'];
|
$uploadDir = $configEntries['upload_dir'];
|
||||||
$sqlDB = $configEntries['sqldb'];
|
$keyFile = $configEntries['key_file'];
|
||||||
$storeIP = $configEntries['store_ip'];
|
$tempKeyFile = $configEntries['temp_key_file'];
|
||||||
$storeAgent = $configEntries['store_user_agent'];
|
$maxFileSize = $configEntries['max_size'];
|
||||||
$storeIssued = $configEntries['store_issued'];
|
$sql = $configEntries['sql'];
|
||||||
$storeLastUsage = $configEntries['store_last_usage'];
|
$sqlDB = $configEntries['sqldb'];
|
||||||
$dateFormat = $configEntries['date_format'];
|
$storeIP = $configEntries['store_ip'];
|
||||||
|
$storeAgent = $configEntries['store_user_agent'];
|
||||||
|
$storeIssued = $configEntries['store_issued'];
|
||||||
|
$storeLastUsage = $configEntries['store_last_usage'];
|
||||||
|
$dateFormat = $configEntries['date_format'];
|
||||||
|
$instanceName = $configEntries['instance_name'];
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,51 +1,55 @@
|
||||||
<?php
|
<?php
|
||||||
function createTables($sqlDB) {
|
/* curload
|
||||||
$Database = new SQLite3($sqlDB);
|
* Simple file uploading using POST requests and temporary keys
|
||||||
|
* Licensed under the GNU Affero General Public License version 3.0
|
||||||
|
*/
|
||||||
|
|
||||||
/* administrator table
|
function createTables($sqlDB) {
|
||||||
* id (INTEGER PRIMARY KEY)
|
$Database = new SQLite3($sqlDB);
|
||||||
* key (TEXT)
|
|
||||||
* 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)"
|
|
||||||
);
|
|
||||||
|
|
||||||
/* keys table
|
/* administrator table
|
||||||
* id (INTEGER PRIMARY KEY)
|
* id (INTEGER PRIMARY KEY)
|
||||||
* key (TEXT)
|
* key (TEXT)
|
||||||
* numberofuploads (INT)
|
* primary (INT)
|
||||||
* lastused (INT)
|
* lastused (TEXT)
|
||||||
* issued (TEXT)
|
* issued (TEXT)
|
||||||
* ip (TEXT)
|
* ip (TEXT)
|
||||||
* useragent (TEXT)
|
* useragent (TEXT)
|
||||||
*/
|
*/
|
||||||
$Database->exec("CREATE TABLE IF NOT EXISTS keys(id INTEGER PRIMARY KEY, key TEXT, numberofuploads INT, 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)");
|
||||||
|
|
||||||
/* temporary keys table
|
/* keys table
|
||||||
* id (INTEGER PRIMARY KEY)
|
* id (INTEGER PRIMARY KEY)
|
||||||
* key (TEXT)
|
* key (TEXT)
|
||||||
* numberofuploads (INT)
|
* numberofuploads (INT)
|
||||||
* uploadsleft (INT)
|
* lastused (INT)
|
||||||
* lastused (TEXT)
|
* issued (TEXT)
|
||||||
* issued (TEXT)
|
* ip (TEXT)
|
||||||
* ip (TEXT)
|
* useragent (TEXT)
|
||||||
* useragent (TEXT)
|
*/
|
||||||
*/
|
$Database->exec("CREATE TABLE IF NOT EXISTS keys(id INTEGER PRIMARY KEY, key TEXT, numberofuploads INT, lastused TEXT, issued TEXT, ip TEXT, useragent TEXT)");
|
||||||
$Database->exec("CREATE TABLE IF NOT EXISTS tkeys(id INTEGER PRIMARY KEY, key TEXT, numberofuploads INT, uploadsleft INT, lastused TEXT, issued TEXT, ip TEXT, useragent TEXT)");
|
|
||||||
|
|
||||||
/* uploads table
|
/* temporary keys table
|
||||||
* id (INTEGER PRIMARY KEY)
|
* id (INTEGER PRIMARY KEY)
|
||||||
* file (TEXT)
|
* key (TEXT)
|
||||||
* uploaddate (TEXT)
|
* numberofuploads (INT)
|
||||||
* keyid (INT) (THIS IS THE ID OF THE KEY USED TO UPLOAD THE FILE)
|
* uploadsleft (INT)
|
||||||
* tempkey (INT)
|
* lastused (TEXT)
|
||||||
*/
|
* issued (TEXT)
|
||||||
$Database->exec("CREATE TABLE IF NOT EXISTS uploads(id INTEGER PRIMARY KEY, file TEXT, uploaddate TEXT, keyid INT, tempkey INT)");
|
* ip (TEXT)
|
||||||
|
* useragent (TEXT)
|
||||||
|
*/
|
||||||
|
$Database->exec("CREATE TABLE IF NOT EXISTS tkeys(id INTEGER PRIMARY KEY, key TEXT, numberofuploads INT, uploadsleft INT, lastused TEXT, issued TEXT, ip TEXT, useragent TEXT)");
|
||||||
|
|
||||||
return $Database;
|
/* uploads table
|
||||||
}
|
* id (INTEGER PRIMARY KEY)
|
||||||
|
* file (TEXT)
|
||||||
|
* uploaddate (TEXT)
|
||||||
|
* keyid (INT) (THIS IS THE ID OF THE KEY USED TO UPLOAD THE FILE)
|
||||||
|
* keytype (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") {
|
if ($Type == "Admin") {
|
||||||
addAdminKey($Data);
|
addAdminKey($Key, $Data, 0);
|
||||||
} else if ($Type == "Temporary") {
|
} else if ($Type == "Temporary") {
|
||||||
addTempKey($Key, $Data, $Uploads);
|
addTempKey($Key, $Data, $Uploads);
|
||||||
} else if ($Type == "Key") {
|
} else if ($Type == "Key") {
|
||||||
|
|
70
index.php
70
index.php
|
@ -4,51 +4,37 @@
|
||||||
* Licensed under the GNU Affero General Public License version 3.0
|
* Licensed under the GNU Affero General Public License version 3.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function printHeader($title, $description, $Icon, $Stylesheet) {
|
include "config.php";
|
||||||
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() {
|
$html .= "<!DOCTYPE html>\n";
|
||||||
print "\t\t</div>\n";
|
$html .= "<html>\n";
|
||||||
print "\t</body>\n";
|
$html .= "\t<head>\n";
|
||||||
print "</html>\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";
|
||||||
|
|
||||||
function initServer() {
|
$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";
|
||||||
|
|
||||||
function main() {
|
$html .= "\t\t</div>\n";
|
||||||
include "config.php";
|
$html .= "\t</body>\n";
|
||||||
|
$html .= "</html>\n";
|
||||||
|
|
||||||
printHeader("curload", "Simply upload files", $Icon, $Stylesheet);
|
print "$html";
|
||||||
|
|
||||||
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";
|
|
||||||
|
|
||||||
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";
|
|
||||||
|
|
||||||
printFooter();
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
308
upload.php
308
upload.php
|
@ -1,31 +1,111 @@
|
||||||
<?php
|
<?php
|
||||||
include "config.php";
|
/* curload
|
||||||
include "create-table.php";
|
* Simple file uploading using POST requests and temporary keys
|
||||||
|
* Licensed under the GNU Affero General Public License version 3.0
|
||||||
|
*/
|
||||||
|
|
||||||
if (isset($_REQUEST['key'])) {
|
include "config.php";
|
||||||
$Key = $_REQUEST['key'];
|
include "create-table.php";
|
||||||
} else {
|
|
||||||
print "No key specified.";
|
if (isset($_REQUEST['key'])) {
|
||||||
die();
|
$Key = $_REQUEST['key'];
|
||||||
|
} else {
|
||||||
|
print "No key specified.";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$Status = 0;
|
||||||
|
$Authorized = 0;
|
||||||
|
$keyType = 0;
|
||||||
|
$uploadLimit = $maxFileSize * 1000000;
|
||||||
|
$keyID = 0;
|
||||||
|
$self = dirname($_SERVER['PHP_SELF']);
|
||||||
|
|
||||||
|
if (!isset($_FILES['file']['name'])) {
|
||||||
|
print "You didn't specify a file.";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
// init database
|
||||||
|
if ($sql == "true" || $sql) {
|
||||||
|
$Database = createTables($sqlDB);
|
||||||
|
|
||||||
|
$DatabaseQuery = $Database->query('SELECT * FROM keys');
|
||||||
|
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 = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$Status = 0;
|
if ($Authorized != 1) {
|
||||||
$Authorized = 0;
|
$DatabaseQuery = $Database->query('SELECT * FROM tkeys');
|
||||||
$tempKeyUsed = 0;
|
while ($line = $DatabaseQuery->fetchArray()) {
|
||||||
$uploadLimit = $maxFileSize * 1000000;
|
if ($line['key'] == $Key && $Key != "" && $line['key'] != "" && $line['uploadsleft'] != 0) {
|
||||||
$keyID = 0;
|
$uploadsLeft = $line['uploadsleft'] - 1;
|
||||||
$self = dirname($_SERVER['PHP_SELF']);
|
$numberOfUploads = $line['numberofuploads'] + 1;
|
||||||
|
$lastUsed = date($dateFormat);
|
||||||
|
$id = $line['id'];
|
||||||
|
$keyID = $id;
|
||||||
|
|
||||||
if (!isset($_FILES['file']['name'])) {
|
$Database->exec("UPDATE tkeys SET uploadsleft='$uploadsLeft' WHERE id='$id'");
|
||||||
print "You didn't specify a file.";
|
$Database->exec("UPDATE tkeys SET lastused='$lastUsed' WHERE id='$id'");
|
||||||
die();
|
$Database->exec("UPDATE tkeys 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 tkeys SET ip='$ip' WHERE id='$id'");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($storeAgent || $storeAgent == "true") {
|
||||||
|
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
$Database->exec("UPDATE tkeys SET useragent='$userAgent' WHERE id='$id'");
|
||||||
|
}
|
||||||
|
|
||||||
|
$Authorized = 1;
|
||||||
|
$keyType = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// init database
|
// maybe admin?
|
||||||
if ($sql == "true" || $sql) {
|
if ($Authorized != 1) {
|
||||||
$Database = createTables($sqlDB);
|
$DatabaseQuery = $Database->query('SELECT * FROM admins');
|
||||||
|
|
||||||
$DatabaseQuery = $Database->query('SELECT * FROM keys');
|
|
||||||
while ($line = $DatabaseQuery->fetchArray()) {
|
while ($line = $DatabaseQuery->fetchArray()) {
|
||||||
if ($line['key'] == $Key && $Key != "" && $line['key'] != "") {
|
if ($line['key'] == $Key && $Key != "" && $line['key'] != "") {
|
||||||
$id = $line['id'];
|
$id = $line['id'];
|
||||||
|
@ -54,138 +134,98 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$Authorized = 1;
|
$Authorized = 1;
|
||||||
$tempKeyUsed = 0;
|
$keyType = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else { // no sql version
|
||||||
|
// All normal keys will be considered valid
|
||||||
|
if (file_exists($keyFile)) {
|
||||||
|
$validKeys = explode("\n", file_get_contents($keyFile));
|
||||||
|
} else { // one master key must exist
|
||||||
|
print("Error: No valid keys found.");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
if ($Authorized != 1) {
|
foreach ($validKeys as $ValidKey) {
|
||||||
$DatabaseQuery = $Database->query('SELECT * FROM tkeys');
|
if ($Key == $ValidKey && $Key != "" && $ValidKey != "") {
|
||||||
while ($line = $DatabaseQuery->fetchArray()) {
|
$Authorized = 1;
|
||||||
if ($line['key'] == $Key && $Key != "" && $line['key'] != "" && $line['uploadsleft'] != 0) {
|
$keyType = 0;
|
||||||
$uploadsLeft = $line['uploadsleft'] - 1;
|
|
||||||
$numberOfUploads = $line['numberofuploads'] + 1;
|
|
||||||
$lastUsed = date($dateFormat);
|
|
||||||
$id = $line['id'];
|
|
||||||
$keyID = $id;
|
|
||||||
|
|
||||||
$Database->exec("UPDATE tkeys SET uploadsleft='$uploadsLeft' WHERE id='$id'");
|
break;
|
||||||
$Database->exec("UPDATE tkeys SET lastused='$lastUsed' WHERE id='$id'");
|
|
||||||
$Database->exec("UPDATE tkeys 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 tkeys SET ip='$ip' WHERE id='$id'");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($storeAgent || $storeAgent == "true") {
|
|
||||||
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
|
||||||
$Database->exec("UPDATE tkeys SET useragent='$userAgent' WHERE id='$id'");
|
|
||||||
}
|
|
||||||
|
|
||||||
$Authorized = 1;
|
|
||||||
$tempKeyUsed = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // no sql version
|
|
||||||
// All normal keys will be considered valid
|
|
||||||
if (file_exists($keyFile)) {
|
|
||||||
$validKeys = explode("\n", file_get_contents($keyFile));
|
|
||||||
} else { // one master key must exist
|
|
||||||
print("Error: No valid keys found.");
|
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($validKeys as $ValidKey) {
|
// Temporary keys as well
|
||||||
|
if (file_exists($tempKeyFile)) {
|
||||||
|
$tempValidKeys = explode("\n", file_get_contents($tempKeyFile));
|
||||||
|
|
||||||
|
foreach ($tempValidKeys as $ValidKey) {
|
||||||
if ($Key == $ValidKey && $Key != "" && $ValidKey != "") {
|
if ($Key == $ValidKey && $Key != "" && $ValidKey != "") {
|
||||||
$Authorized = 1;
|
$Authorized = 1;
|
||||||
$tempKeyUsed = 0;
|
$keyType = 1; // key should be considered invalid after this use.
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary keys as well
|
|
||||||
if (file_exists($tempKeyFile)) {
|
|
||||||
$tempValidKeys = explode("\n", file_get_contents($tempKeyFile));
|
|
||||||
|
|
||||||
foreach ($tempValidKeys as $ValidKey) {
|
|
||||||
if ($Key == $ValidKey && $Key != "" && $ValidKey != "") {
|
|
||||||
$Authorized = 1;
|
|
||||||
$tempKeyUsed = 1; // key should be considered invalid after this use.
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Not an authorized key
|
// Not an authorized key
|
||||||
if ($Authorized == 0) {
|
if ($Authorized == 0) {
|
||||||
print "Not authorized: Key '$Key' is invalid.";
|
print "Not authorized: Key '$Key' is invalid.";
|
||||||
die();
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_FILES['file']['size'] > $uploadLimit) {
|
||||||
|
print "File is too big. Max file size is $maxFileSize" . "MB";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_dir($uploadDir)) {
|
||||||
|
mkdir($uploadDir, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$destinationFile = $uploadDir . basename($_FILES['file']['name']);
|
||||||
|
|
||||||
|
if (file_exists($destinationFile)) { // rename file to distinguish it from existing file
|
||||||
|
$fileExtension = strtolower(pathinfo(basename($_FILES['file']['name']),PATHINFO_EXTENSION));
|
||||||
|
if (isset($fileExtension)) {
|
||||||
|
$extension = "." . $fileExtension;
|
||||||
}
|
}
|
||||||
|
$destinationFile = $uploadDir . rand(1000,100000) . $extension;
|
||||||
|
|
||||||
if ($_FILES['file']['size'] > $uploadLimit) {
|
if (file_exists($destinationFile)) { // wtf
|
||||||
print "File is too big. Max file size is $maxFileSize" . "MB";
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_dir($uploadDir)) {
|
|
||||||
mkdir($uploadDir, 0777, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$destinationFile = $uploadDir . basename($_FILES['file']['name']);
|
|
||||||
|
|
||||||
if (file_exists($destinationFile)) { // rename file to distinguish it from existing file
|
|
||||||
$fileExtension = strtolower(pathinfo(basename($_FILES['file']['name']),PATHINFO_EXTENSION));
|
|
||||||
if (isset($fileExtension)) {
|
|
||||||
$extension = "." . $fileExtension;
|
|
||||||
}
|
|
||||||
$destinationFile = $uploadDir . rand(1000,100000) . $extension;
|
|
||||||
|
|
||||||
if (file_exists($destinationFile)) { // wtf
|
|
||||||
print "Failed to upload file.";
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (move_uploaded_file($_FILES['file']['tmp_name'], $destinationFile)) {
|
|
||||||
$uploadedFile = dirname($_SERVER['PHP_SELF']) . $destinationFile;
|
|
||||||
|
|
||||||
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')");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($tempKeyUsed) { // Remove temporary key
|
|
||||||
$file = file_get_contents($tempKeyFile);
|
|
||||||
$file = preg_replace("/\b$Key\b/", "", $file);
|
|
||||||
file_put_contents($tempKeyFile, $file);
|
|
||||||
}
|
|
||||||
|
|
||||||
print "$uploadedFile";
|
|
||||||
|
|
||||||
if (isset($_REQUEST['web'])) { // redirect back to index
|
|
||||||
print "<p><a href=\"$uploadedFile\">Your link</a></p>\n";
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print "Failed to upload file.";
|
print "Failed to upload file.";
|
||||||
|
|
||||||
if ($_FILES['file']['error'] == 1) {
|
|
||||||
print "Is the upload_max_filesize set up properly?";
|
|
||||||
}
|
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (move_uploaded_file($_FILES['file']['tmp_name'], $destinationFile)) {
|
||||||
|
$uploadedFile = dirname($_SERVER['PHP_SELF']) . $destinationFile;
|
||||||
|
|
||||||
|
if ($sql || $sql == "true") {
|
||||||
|
$lastUsed = date($dateFormat);
|
||||||
|
$DatabaseQuery = $Database->query('SELECT * FROM uploads');
|
||||||
|
$Database->exec("INSERT INTO uploads(file, uploaddate, keyid, keytype) VALUES('$uploadedFile', '$lastUsed', '$keyID', '$keyType')");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($keyType == 1) { // Remove temporary key
|
||||||
|
$file = file_get_contents($tempKeyFile);
|
||||||
|
$file = preg_replace("/\b$Key\b/", "", $file);
|
||||||
|
file_put_contents($tempKeyFile, $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
print "$uploadedFile";
|
||||||
|
|
||||||
|
if (isset($_REQUEST['web'])) { // redirect back to index
|
||||||
|
print "<p><a href=\"$uploadedFile\">Your link</a></p>\n";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print "Failed to upload file.";
|
||||||
|
print $_FILES['file']['error'];
|
||||||
|
die();
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue