]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Add able to change background on overview
authorValerie Pond <redacted>
Sun, 7 Jul 2024 23:30:27 +0000 (07:30 +0800)
committerValerie Pond <redacted>
Sun, 7 Jul 2024 23:30:27 +0000 (07:30 +0800)
img/wallpaper.jpg [new file with mode: 0644]
index.php
settings/general.php

diff --git a/img/wallpaper.jpg b/img/wallpaper.jpg
new file mode 100644 (file)
index 0000000..0fbfcbd
Binary files /dev/null and b/img/wallpaper.jpg differ
index 4d856a23222cd7b2aa362f3d8834a038ecfd9bef..aa0a7d058863e919553e4fbf20886b69e6ad298b 100644 (file)
--- a/index.php
+++ b/index.php
@@ -53,7 +53,7 @@ if (isset($current_user->user_meta['hibp']))
                border-radius: 16px;
        }
        body {
-               background-image: url('https://cdn.wallpapersafari.com/34/98/yznZmQ.jpg');
+               background-image: url('img/wallpaper.jpg');
                background-size: cover;
        }
        .card-container .card-body i {
index f035ba69133fa5bca6f5b720411be91ec4234501..0cee9c833a77fd6a42c96611824b9172e92fe8bc 100644 (file)
@@ -18,16 +18,55 @@ if (isset($_POST['submit']) && $canEdit)
     if ($config['debug'] != $dbug) // we just toggled
         Message::Info("Debug Mode is now ".(($config['debug']) ? "enabled" : "disabled"));
 
+
+    if (!empty($_FILES['customFile']))
+    {
+        $cwd = getcwd();
+        $a = split($cwd,'/');
+        $a[sizeof($a) - 1] = NULL;
+        $cwd = glue($a,'/');
+        $target_dir = "$cwd/img/";
+        $target_file = "/$target_dir/wallpaper.jpg";
+        $uploadOk = 1;
+        $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
+        $check = getimagesize($_FILES["customFile"]["tmp_name"]);
+        $errs = [];
+
+        if($check == false)
+        {
+            $errs[] = "File is not an image.";
+            $uploadOk = 0;
+        }
+        else if ($_FILES["customFile"]["size"] > 500000) {
+            $errs[] = "File is too large.";
+            $uploadOk = 0;
+        }
+        elseif($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
+        && $imageFileType != "gif" )
+        {
+            $errs[] = "Only JPG, JPEG, PNG & GIF files are allowed.";
+            $uploadOk = 0;
+        }
+        if ($uploadOk != 0) {
+            if (file_exists($target_file))
+                unlink($target_file);
+            move_uploaded_file($_FILES["customFile"]["tmp_name"], $target_file);
+            Message::Success("Updloaded file: $target_file");
+        }
+        else Message::Fail($errs);
+    }
+
     write_config();
     unset($_POST['debug'], $_POST['submit'], $_POST['hibp']);
     Hook::run(HOOKTYPE_GENERAL_SETTINGS_POST, $_POST);
 }
 
 do_log("\$_POST", $_POST);
+do_log("\$_FILES", $_FILES);
 ?>
 <h4>General Settings</h4>
 <br>
-<form method="post">
+<form method="post" enctype="multipart/form-data">
 <div class="card m-1" style="padding-left:20px;padding-right:20px;padding-top:5px;padding-bottom:10px;max-width:fit-content">
     <h6>Password Data Leak Checks</h6>
     <div class="custom-control custom-switch">
@@ -44,7 +83,27 @@ do_log("\$_POST", $_POST);
     </div>
     <i>Enabling this will likely make your webpanel more difficult to use</i>
 </div>
+<script>
+    const iframe =document.getElementById('frame');
+    iframe.contentWindow.location.reload(true);
+</script>
 
+<style>
+#wrap { 
+    border: none;
+    padding: 0;
+margin:0;}
+#frame { transform:none; zoom: 0.8; -moz-transform: scale(0.8); -moz-transform-origin: 0 0; transform-origin: 3%; border:none;}
+</style>
+<div class="card mb-2" style="padding-left:20px;padding-right:20px;padding-top:5px;padding-bottom:10px;max-width:fit-content;max-height:fit-content">
+    <h6>Overview Background Image</h6>
+    <div class="" id="wrap">
+        <label class="form-label" for="customFile">Upload an image</label>
+        <input type="file" class="form-control" name="customFile" id="customFile" /> Might not show current image if caching is used. You'll notice the changes soon.
+
+        <iframe width="100%" height="500vh" id="frame" style="pointer-events: none;position:relative;margin-top:10px" src="<?php echo get_config('base_url'); ?>">Loading Live Preview</iframe>
+    </div>
+</div>
 <?php $a = []; Hook::run(HOOKTYPE_GENERAL_SETTINGS, $a); ?>
 <br><br>
 <button type="post" name="submit" class="btn btn-primary">Save</div>