diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..b19604c
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+*.env linguist-language=ENV
+./* linguist-documentation
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index db8aa01..2694a56 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,7 @@
-# Composer
-/vendor/
-composer.json
+# Project Files
+.gitattributes
+#snyk.sarif
-# Project based
+# QuickBlaze Security
/Modules/Database.env
/Modules/InstallationStatus.json
-
-# Github
-snyk.sarif
\ No newline at end of file
diff --git a/.htaccess b/.htaccess
index ed4e26b..57648c9 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,7 +1,16 @@
+# URL handling
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule ^.* /index.php [L,QSA]
+RewriteRule ^.* index.php [L,QSA]
+# Error handling
ErrorDocument 404 /404
+ErrorDocument 403 /403
ErrorDocument 500 /500
+
+# File security
+
+Order allow,deny
+Deny from all
+
\ No newline at end of file
diff --git a/.version b/.version
index d3f8aa1..8c955e1 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-{"VERSION":"1.0.4"}
\ No newline at end of file
+{ "BRANCH": "dev", "VERSION":"1.0.5-dev" }
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index bf1bf1f..c3f7d79 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2022 Axton
+Copyright (c) 2022 axtonprice.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+SOFTWARE.
\ No newline at end of file
diff --git a/Modules/.htaccess b/Modules/.htaccess
new file mode 100644
index 0000000..3418e55
--- /dev/null
+++ b/Modules/.htaccess
@@ -0,0 +1 @@
+deny from all
\ No newline at end of file
diff --git a/Modules/Database_example.env b/Modules/Database_example.env
index f421735..0e551e1 100644
--- a/Modules/Database_example.env
+++ b/Modules/Database_example.env
@@ -1,7 +1,6 @@
-
{
"HOSTNAME": "",
"USERNAME": "",
"PASSWORD": "",
"DATABASE": ""
-}
\ No newline at end of file
+}
diff --git a/Modules/Functions.php b/Modules/Functions.php
index 5936a05..62f97c3 100644
--- a/Modules/Functions.php
+++ b/Modules/Functions.php
@@ -20,7 +20,7 @@ function processData($data)
function ifTextBoxDisabled()
{
sanitizeXSS(); // Sanitize Script
- if ($_GET["submitted"]) {
+ if (isset($_GET["submitted"])) {
echo "disabled";
}
}
@@ -57,12 +57,13 @@ function determineSubmissionFooter()
}
function determineSystemVersion()
{
- $latestVersion = json_decode(file_get_contents("https://raw.githubusercontent.com/axtonprice-dev/quickblaze-encrypt/main/.version", true), true);
if (!file_exists("./.version")) {
- file_put_contents("./.version", json_encode(array("version" => $latestVersion["VERSION"])));
touch("./.version");
+ $latestVersion = json_decode(file_get_contents("https://raw.githubusercontent.com/axtonprice-dev/quickblaze-encrypt/main/.version", true), true);
+ file_put_contents("./.version", json_encode(array("BRANCH" => $latestVersion["BRANCH"], "VERSION" => $latestVersion["VERSION"])));
}
$thisVersion = json_decode(file_get_contents("./.version", true), true);
+ $latestVersion = json_decode(file_get_contents("https://raw.githubusercontent.com/axtonprice-dev/quickblaze-encrypt/" . $thisVersion["BRANCH"] . "/.version", true), true);
if ($thisVersion["VERSION"] != $latestVersion["VERSION"]) {
return 'v' . $thisVersion["VERSION"] . ' (Outdated!)';
} else {
@@ -99,16 +100,18 @@ function decryptData($encryption_key) // getRecord("encrypted_contents", $dataKe
function setupDatabase()
{
sanitizeXSS(); // Sanitize Script
+ error_reporting(0); // disable error reporting
if (!file_exists("./Modules/InstallationStatus.json")) {
touch("./Modules/InstallationStatus.json");
- file_put_contents("./Modules/InstallationStatus.json", json_encode(array("INSTALLED" => "true")));
+ file_put_contents("./Modules/InstallationStatus.json", json_encode(array("INSTALLED" => "false")));
}
$json = json_decode(file_get_contents("./Modules/InstallationStatus.json", true), true);
- if ($json["INSTALLED"] == "false") {
+ if ($json["INSTALLED"] == "false" || $json["INSTALLED"] == "") {
$json = json_decode(file_get_contents("./Modules/Database.env", true), true);
- $mysqli = new mysqli($json["HOSTNAME"], $json["USERNAME"], $json["PASSWORD"], $json["DATABASE"]);
- if ($mysqli->connect_errno) {
- return $mysqli->connect_errno;
+ try { // attempt database connection
+ $mysqli = new mysqli($json["HOSTNAME"], $json["USERNAME"], $json["PASSWORD"], $json["DATABASE"]);
+ } catch (mysqli_sql_exception $e) {
+ die(file_get_contents("./Public/Error/DatabaseCredentials.html")); // throw error page if invalid credentials
}
$tableCreateSQL = "CREATE TABLE IF NOT EXISTS `quickblaze_records` (`record_id` int(11) NOT NULL,`encrypted_contents` longtext NOT NULL,`encryption_token` varchar(128) NOT NULL,`source_ip` varchar(100) NOT NULL, `record_date` timestamp(5) NOT NULL DEFAULT current_timestamp(5)) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$addPrimaryKeySQL = "ALTER TABLE `quickblaze_records` ADD PRIMARY KEY (`record_id`);";
@@ -130,6 +133,18 @@ function setupDatabase()
$mysqli->close();
}
+ error_reporting(E_ALL); // enable error reporting
+}
+function checkDatabase()
+{
+ if (!file_exists("./Modules/Database.env")) {
+ die(file_get_contents("./Public/Error/DatabaseConfig.html"));
+ } else {
+ $json = json_decode(file_get_contents("./Modules/Database.env", true), true);
+ if ($json["DATABASE"] == "" || $json["HOSTNAME"] == "") {
+ die(file_get_contents("./Public/Error/DatabaseConfig.html"));
+ }
+ }
}
function insertRecord($encrypted_contents, $encryption_token)
diff --git a/Public/Error/403.html b/Public/Error/403.html
new file mode 100644
index 0000000..2fe0698
--- /dev/null
+++ b/Public/Error/403.html
@@ -0,0 +1,127 @@
+
+
+
+
+
+
+
+
+ QuickBlaze
+
+
+
+
+
+
+
+
+
+
+
+
+
Access to this page is restricted
+
Please check with the site admin if you believe this is a mistake.
+
+
+
+
\ No newline at end of file
diff --git a/Public/Error/404.html b/Public/Error/404.html
index 1b9bfb9..28b9b99 100644
--- a/Public/Error/404.html
+++ b/Public/Error/404.html
@@ -27,10 +27,26 @@
This page does not exist. It was most likely removed!