diff --git a/README.md b/README.md index 5ce1f3f..83d7791 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,10 @@ The second section is plugins. This lets you upload plugins or delete them. As t 3/14/23 - Improved admin styles - Code Optimizations +4/12/23 +- Fixed plugin table sorting order +- Cleaned up code +- Added WAF ### To-Do List diff --git a/update-api/.user.ini b/update-api/.user.ini new file mode 100644 index 0000000..06f798d --- /dev/null +++ b/update-api/.user.ini @@ -0,0 +1 @@ +auto_prepend_file = '~/public_html/waf.php' \ No newline at end of file diff --git a/update-api/app/form-helper.php b/update-api/app/form-helper.php new file mode 100644 index 0000000..37f1d01 --- /dev/null +++ b/update-api/app/form-helper.php @@ -0,0 +1,76 @@ +Error uploading file.

'; + } elseif (!in_array($file_extension, $allowed_extensions)) { + $_SESSION['upload_messages'][] = '

Invalid file type. Only .zip files are allowed.

'; + } else { + $plugin_path = '../plugins/' . $_FILES['plugin_file']['name']; + if (file_exists($plugin_path)) { + $_SESSION['upload_messages'][] = '

File already exists.

'; + } else { + // ... + $_SESSION['upload_messages'][] = '

File uploaded successfully.

'; + } + } +} + +// Check if a plugin was deleted +if (isset($_POST['delete_plugin'])) { + $plugin_name = $_POST['plugin_name']; + + if (file_exists($plugin_name)) { + if (unlink($plugin_name)) { + echo ''; + } else { + echo ''; + } + } else { + echo ''; + } +} \ No newline at end of file diff --git a/update-api/app/host-box.inc.php b/update-api/app/host-box.inc.php new file mode 100644 index 0000000..be3c29f --- /dev/null +++ b/update-api/app/host-box.inc.php @@ -0,0 +1,110 @@ + + +
+

Allowed Hosts

+ +
+
+ + + + + + + + + + $entry) { + $fields = explode(' ', $entry); + $domain = isset($fields[0]) ? $fields[0] : ''; + $key = isset($fields[1]) ? $fields[1] : ''; + if ($i % 2 == 0) { + ?> + + + + + + + + + + +
DomainKeyActions
+ + +
+
+
+ + + + + + + + + + $entry) { + $fields = explode(' ', $entry); + $domain = isset($fields[0]) ? $fields[0] : ''; + $key = isset($fields[1]) ? $fields[1] : ''; + if ($i % 2 != 0) { + ?> + + + + + + + + + + +
DomainKeyActions
+ + +
+
+
+
+

Add Entry

+
+
+ + +
+
+ + +
+
+ +
+
+
+
\ No newline at end of file diff --git a/update-api/app/plugins-box.inc.php b/update-api/app/plugins-box.inc.php new file mode 100644 index 0000000..5e1100e --- /dev/null +++ b/update-api/app/plugins-box.inc.php @@ -0,0 +1,96 @@ + + +
+

Plugins

+
+ + ' . $plugin_name . ' + +
+ + +
+ + '; + } + + // Reverse the plugins array + $plugins = array_reverse($plugins); + + if (count($plugins) > 0) { + // Split plugins array into two halves + $half_count = ceil(count($plugins) / 2); + $plugins_column1 = array_slice($plugins, 0, $half_count); + $plugins_column2 = array_slice($plugins, $half_count); + + $table_html = '
+ + + + + + + + '; + foreach ($plugins_column1 as $plugin) { + $plugin_name = basename($plugin); + $table_html .= generateTableRow($plugin, $plugin_name); + } + $table_html .= '
Plugin NameDelete
+ + + + + + + '; + foreach ($plugins_column2 as $plugin) { + $plugin_name = basename($plugin); + $table_html .= generateTableRow($plugin, $plugin_name); + } + $table_html .= '
Plugin NameDelete
'; + } else { + $table_html = "No plugins found."; + } + + echo $table_html; + + ?> + +
+ +
+

Upload Plugin

+
" method="POST" enctype="multipart/form-data"> + + +
+ '; + foreach ($_SESSION['upload_messages'] as $message) { + echo '

' . $message . '

'; + } + echo '
'; + unset($_SESSION['upload_messages']); + } + ?> +
+ \ No newline at end of file diff --git a/update-api/public/static/img/background.png b/update-api/public/assets/background.png similarity index 100% rename from update-api/public/static/img/background.png rename to update-api/public/assets/background.png diff --git a/update-api/public/static/css/index.css b/update-api/public/assets/index.css similarity index 97% rename from update-api/public/static/css/index.css rename to update-api/public/assets/index.css index 1c32665..574fa28 100644 --- a/update-api/public/static/css/index.css +++ b/update-api/public/assets/index.css @@ -7,7 +7,7 @@ body { width: 100%; overflow-x: hidden; background-color: #f1f1f1; - background-image: url("../img/background.png"); + background-image: url("../assets/background.png"); background-repeat: repeat; margin: 0; font-size: 16px; @@ -136,7 +136,6 @@ width: 100%; } form > input[type="submit"] { - margin-top: 20px; width: 100%!important; } diff --git a/update-api/public/static/css/index.php b/update-api/public/assets/index.php similarity index 100% rename from update-api/public/static/css/index.php rename to update-api/public/assets/index.php diff --git a/update-api/public/static/css/login.css b/update-api/public/assets/login.css similarity index 100% rename from update-api/public/static/css/login.css rename to update-api/public/assets/login.css diff --git a/update-api/public/static/img/login.jpg b/update-api/public/assets/login.jpg similarity index 100% rename from update-api/public/static/img/login.jpg rename to update-api/public/assets/login.jpg diff --git a/update-api/public/static/img/logo.png b/update-api/public/assets/logo.png similarity index 100% rename from update-api/public/static/img/logo.png rename to update-api/public/assets/logo.png diff --git a/update-api/public/static/css/plugins_table.css b/update-api/public/assets/plugins_table.css similarity index 100% rename from update-api/public/static/css/plugins_table.css rename to update-api/public/assets/plugins_table.css diff --git a/update-api/public/static/img/index.php b/update-api/public/assets/scripts.js similarity index 100% rename from update-api/public/static/img/index.php rename to update-api/public/assets/scripts.js diff --git a/update-api/public/index.php b/update-api/public/index.php index 7cb17a0..be08ad1 100644 --- a/update-api/public/index.php +++ b/update-api/public/index.php @@ -1,13 +1,15 @@ @@ -19,222 +21,20 @@ require_once "../app/auth-helper.php"; API Admin Page - + +
- Lego + Lego
" method="POST">
-
-

Allowed Hosts

- -
-
- - - - - - - - - - $entry) { - $fields = explode(' ', $entry); - $domain = $fields[0]; - $key = $fields[1]; - if ($i % 2 == 0) { - ?> - - - - - - - - - - -
DomainKeyActions
- - -
-
-
- - - - - - - - - - $entry) { - $fields = explode(' ', $entry); - $domain = $fields[0]; - $key = $fields[1]; - if ($i % 2 != 0) { - ?> - - - - - - - - - - -
DomainKeyActions
- - -
-
-
-
-

Add Entry

-
-
- - -
-
- - -
-
- -
-
-
-
-
-

Plugins

-
- -
- -
-

Upload Plugin

-
- - -
-
-
- -
+ +

Access Logs

diff --git a/update-api/public/login.php b/update-api/public/login.php index a014088..58ce568 100644 --- a/update-api/public/login.php +++ b/update-api/public/login.php @@ -19,12 +19,12 @@ require_once '../app/auth-helper.php'; API Update Admin Login - +