summaryrefslogtreecommitdiff
path: root/resources/views
diff options
context:
space:
mode:
Diffstat (limited to 'resources/views')
-rw-r--r--resources/views/f_cursor_0221.blade.php136
-rw-r--r--resources/views/f_v1.blade.php79
-rwxr-xr-xresources/views/home.blade.php8
-rwxr-xr-xresources/views/template.blade.php2
-rw-r--r--resources/views/writings/index.blade.php5
5 files changed, 226 insertions, 4 deletions
diff --git a/resources/views/f_cursor_0221.blade.php b/resources/views/f_cursor_0221.blade.php
new file mode 100644
index 0000000..fe9c9f0
--- /dev/null
+++ b/resources/views/f_cursor_0221.blade.php
@@ -0,0 +1,136 @@
+@extends('template')
+<?php
+ $baseDir = 'storage/uploads/';
+ $currentDir = $baseDir;
+
+ //use this if want to require auth
+ /*$valid_username = 'admin'; // Set your username
+ $valid_password = 'password'; // Set your password
+ if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
+ $_SERVER['PHP_AUTH_USER'] != $valid_username || $_SERVER['PHP_AUTH_PW'] != $valid_password) {
+ header('WWW-Authenticate: Basic realm="Secure Directory"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo 'Authentication required';
+ exit;
+ }*/
+
+ // check if requested file or directory
+ if (isset($_GET['file'])) {
+ $fileRequested = $_GET['file'];
+ $filePath = realpath($fileRequested);
+
+ if (file_exists($filePath) && is_file($filePath)) {
+ // Set headers to force download
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename="' . basename($filePath) . '"');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate');
+ header('Pragma: public');
+ header('Content-Length: ' . filesize($filePath));
+ readfile($filePath);
+ exit;
+ } else {
+ echo "File not found.";
+ exit;
+ }
+ } else if (isset($_GET['dir'])) {
+ $dir = $_GET['dir'];
+ if (strpos($dir, '..') !== false || strpos($dir, '/') !== false || strpos($dir, '\\') !== false) {
+ echo 'Access Denied';
+ exit;
+ }
+ $dir= basename($dir); // Ensuring the folder name is isolated
+ if (!is_dir("${baseDir}/${dir}")) {
+ echo 'Directory not found';
+ exit;
+ }
+ $currentDir = "${baseDir}/${dir}";
+ }
+
+ // Extracting the name of the current directory
+ $currentDirName = basename($currentDir);
+
+ // Determine the depth of the current directory relative to the base directory
+ $depth = substr_count(str_replace($baseDir, '', $currentDir), '/');
+
+ $contents = scandir($currentDir);
+
+ $files = []; // Array to hold file details
+?>
+ @foreach ($contents as $item)
+ @if ($item !== "." && $item !== "..")
+ @php
+ $filePath = $currentDir . '/' . $item;
+ $fileInfo = [
+ 'name' => htmlspecialchars($item),
+ 'size' => is_file($filePath) ? filesize($filePath) : 0,
+ 'date' => is_file($filePath) ? date("F d Y H:i:s.", filemtime($filePath)) : '',
+ 'is_dir' => is_dir($filePath)
+ ];
+ $files[] = $fileInfo; // Add file info to the array
+ @endphp
+ <li>
+ @if ($fileInfo['is_dir'])
+ <strong>Directory:</strong> <a href="?dir={{ $item }}">{{ $fileInfo['name'] }}</a>
+ @else
+ <a href="/f/{{ $fileInfo['name'] }}">{{ $fileInfo['name'] }}</a>
+ <span>(Size: {{ $fileInfo['size'] }} bytes, Date: {{ $fileInfo['date'] }})</span>
+ @endif
+ </li>
+ @endif
+ @endforeach
+
+ // Add sorting functionality
+ @if (isset($_GET['sort']))
+ @php
+ $sort = $_GET['sort'];
+ usort($files, function($a, $b) use ($sort) {
+ if ($sort === 'size') {
+ return $a['size'] <=> $b['size'];
+ } elseif ($sort === 'date') {
+ return $a['date'] <=> $b['date'];
+ } else { // Default to sorting by name
+ return strcmp($a['name'], $b['name']);
+ }
+ });
+ @endphp
+ @endif
+
+ <ul>
+ @foreach ($files as $fileInfo)
+ <li>
+ @if ($fileInfo['is_dir'])
+ <strong>Directory:</strong> <a href="?dir={{ $fileInfo['name'] }}">{{ $fileInfo['name'] }}</a>
+ @else
+ <a href="/f/{{ $fileInfo['name'] }}">{{ $fileInfo['name'] }}</a>
+ <span>(Size: {{ $fileInfo['size'] }} bytes, Date: {{ $fileInfo['date'] }})</span>
+ @endif
+ </li>
+ @endforeach
+ @if ($currentDir != $baseDir)
+ <li><a href="/f?dir={{ $currentDirName }}">Go Up</a></li>
+ @endif
+ </ul>
+
+@section('body')
+<main>
+ <!--<p><b>Contents of:</b> <em> {{ $currentDir }}</em></p>-->
+ <p><b>{{ htmlspecialchars(ucfirst($currentDirName)) }}</b></p>
+ <ul>
+ @foreach ($files as $fileInfo)
+ <li>
+ @if ($fileInfo['is_dir'])
+ <strong>Directory:</strong> <a href="?dir={{ $fileInfo['name'] }}">{{ $fileInfo['name'] }}</a>
+ @else
+ <a href="/f/{{ $fileInfo['name'] }}">{{ $fileInfo['name'] }}</a>
+ <span>(Size: {{ $fileInfo['size'] }} bytes, Date: {{ $fileInfo['date'] }})</span>
+ @endif
+ </li>
+ @endforeach
+ @if ($currentDir != $baseDir)
+ <li><a href="/f?dir={{ $currentDirName }}">Go Up</a></li>
+ @endif
+ </ul>
+</main>
+@endsection \ No newline at end of file
diff --git a/resources/views/f_v1.blade.php b/resources/views/f_v1.blade.php
new file mode 100644
index 0000000..cff2a4f
--- /dev/null
+++ b/resources/views/f_v1.blade.php
@@ -0,0 +1,79 @@
+@extends('template')
+<?php
+ $baseDir = 'storage/uploads/';
+ $currentDir = $baseDir;
+
+ //use this if want to require auth
+ /*$valid_username = 'admin'; // Set your username
+ $valid_password = 'password'; // Set your password
+ if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
+ $_SERVER['PHP_AUTH_USER'] != $valid_username || $_SERVER['PHP_AUTH_PW'] != $valid_password) {
+ header('WWW-Authenticate: Basic realm="Secure Directory"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo 'Authentication required';
+ exit;
+ }*/
+
+ // check if requested file or directory
+ if (isset($_GET['file'])) {
+ $fileRequested = $_GET['file'];
+ $filePath = realpath($fileRequested);
+
+ if (file_exists($filePath) && is_file($filePath)) {
+ // Set headers to force download
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/octet-stream');
+ header('Content-Disposition: attachment; filename="' . basename($filePath) . '"');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate');
+ header('Pragma: public');
+ header('Content-Length: ' . filesize($filePath));
+ readfile($filePath);
+ exit;
+ } else {
+ echo "File not found.";
+ exit;
+ }
+ } else if (isset($_GET['dir'])) {
+ $dir = $_GET['dir'];
+ if (strpos($dir, '..') !== false || strpos($dir, '/') !== false || strpos($dir, '\\') !== false) {
+ echo 'Access Denied';
+ exit;
+ }
+ $dir= basename($dir); // Ensuring the folder name is isolated
+ if (!is_dir("${baseDir}/${dir}")) {
+ echo 'Directory not found';
+ exit;
+ }
+ $currentDir = "${baseDir}/${dir}";
+ }
+
+ // Extracting the name of the current directory
+ $currentDirName = basename($currentDir);
+
+ // Determine the depth of the current directory relative to the base directory
+ $depth = substr_count(str_replace($baseDir, '', $currentDir), '/');
+
+ $contents = scandir($currentDir);
+?>
+@section('body')
+<main>
+ <!--<p><b>Contents of:</b> <em> {{ $currentDir }}</em></p>-->
+ <p><b>{{ htmlspecialchars(ucfirst($currentDirName)) }}</b></p>
+ <ul>
+ @foreach ($contents as $item)
+ @if ($item !== "." && $item !== "..")
+ <li>
+ @if (is_dir($currentDir . '/' . $item))
+ <strong>Directory:</strong> <a href="?dir={{ $item }}">{{ htmlspecialchars($item) }}</a>
+ @else
+ <a href="/f/{{ $item }}">{{ htmlspecialchars($item) }}</a>
+ @endif
+ </li>
+ @endif
+ @endforeach
+ @if ($currentDir != $baseDir)
+ <li><a href="/f?dir={{ $currentDirName }}">Go Up</a></li>
+ @endif
+</main>
+@endsection \ No newline at end of file
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php
index 7598045..dcfe2de 100755
--- a/resources/views/home.blade.php
+++ b/resources/views/home.blade.php
@@ -6,11 +6,13 @@
<header>
<h1>A friendly webserver</h1>
- <h2>in Iowa</h2>
+ <h2></h2>
<p>
Welcome
</p>
- <div id = "seeker-status">
+ <div id = "site-status">
+ <h6>Current Status</h6>
+ <p></p>
<p>Number of friends connected: <b id = "numFriendsConnected"></b></p> <!-- show number of other connections to webserver -->
<br>
<p>Who are you?</p><input type = "text" id = "input_who" />
@@ -92,4 +94,4 @@
</section> --}}
-@endsection \ No newline at end of file
+@endsection
diff --git a/resources/views/template.blade.php b/resources/views/template.blade.php
index 2043d47..6678d87 100755
--- a/resources/views/template.blade.php
+++ b/resources/views/template.blade.php
@@ -27,6 +27,8 @@
Home
</a>
@yield('nav')
+ <a href = "/settings" /><small>Settings, Info</small></a><!-- auth-agnostic settings -->
+ <div id = "database-info">Checking connection to database...</div>
@if (Auth::user() == null)
<a href="{{ route('login') }}" class = "form-button" style="margin-left: auto; margin-right: 1rem;">
{{ __('Log In') }}
diff --git a/resources/views/writings/index.blade.php b/resources/views/writings/index.blade.php
index 36cb735..a9c2f54 100644
--- a/resources/views/writings/index.blade.php
+++ b/resources/views/writings/index.blade.php
@@ -1,4 +1,7 @@
@extends('template')
+@section('head')
+@vite(['resources/js/writing_index.js'])
+@endsection
@section('body')
<main>
<div >
@@ -9,7 +12,7 @@
<!-- TODO search -->
<div class = "sidebar">
<legend>Sort by: </legend>
- <select name = "sort_method">
+ <select name = "sort_method" id = "sort_method">
<option value = "date">Date</option>
<option value = "user">Author</option>
<option value = "title">Title</option>