Compare commits
4 Commits
58e0f1eafd
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5ef5de9b98 | ||
![]() |
92e162283e | ||
![]() |
26fb9b54b6 | ||
![]() |
b4fcc4892c |
@@ -122,7 +122,7 @@ class NotesController
|
||||
$isAdmin = $_SESSION['role'] === 'admin';
|
||||
$userid = $_SESSION['user_id'];
|
||||
|
||||
$files = $this->notesModel->selectFiles($userid, true);
|
||||
$files = $this->notesModel->selectFiles($userid, true, $sortBy, $sortOrder);
|
||||
$this->view->setVars([
|
||||
"files" => $files
|
||||
]);
|
||||
|
@@ -224,8 +224,12 @@ class NotesModel extends Database
|
||||
$pdo = $this->linkDB();
|
||||
if (!$pdo) return ['success' => false, 'message' => 'Database error.'];
|
||||
|
||||
$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/';
|
||||
$uploadDir = __DIR__ . '/../Uploads/';
|
||||
$uploadedFileNames = [];
|
||||
|
||||
if (!file_exists($uploadDir)) {
|
||||
mkdir($uploadDir, 0777, true);
|
||||
}
|
||||
|
||||
if (isset($_FILES['attachments']) && !empty($_FILES['attachments']['name'][0])) {
|
||||
$files = $_FILES['attachments'];
|
||||
@@ -265,7 +269,7 @@ class NotesModel extends Database
|
||||
$stmt->execute([$fileId]);
|
||||
$file = $stmt->fetch();
|
||||
if ($file) {
|
||||
$filePath = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/' . $file['stored_filename'];
|
||||
$filePath = __DIR__ . '/../Uploads/' . $file['stored_filename'];
|
||||
if (file_exists($filePath)) {
|
||||
unlink($filePath);
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ include dirname(__DIR__).'/header.phtml';
|
||||
|
||||
//// Test write permissions
|
||||
//// This is the directory we will upload files to.
|
||||
//$uploadDir = $_SERVER['DOCUMENT_ROOT'] . '/EIANotesApp/Uploads/';
|
||||
//$uploadDir = __DIR__ . '/../Uploads/';
|
||||
//if (!file_exists($uploadDir)) {
|
||||
// mkdir($uploadDir, 0777, true);
|
||||
//}
|
||||
|
@@ -74,7 +74,7 @@ function sanitize($data, $flags = ENT_QUOTES, $encoding = 'UTF-8') {
|
||||
<ul>
|
||||
<?php foreach($files as $file): ?>
|
||||
<li>
|
||||
<a href="/EIANotesApp/Uploads/<?php echo $file['stored_filename']; ?>" download target="_blank"><?php echo htmlspecialchars($file['original_filename']); ?></a>
|
||||
<a href="<?php echo substr($_SERVER['PHP_SELF'], 0, -9).'Uploads/'.$file['stored_filename']; ?>" download target="_blank"><?php echo htmlspecialchars($file['original_filename']); ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
@@ -24,7 +24,7 @@
|
||||
<?php if (isset($errmsg)): ?>
|
||||
<label class="error-message"><?php echo $errmsg; ?></label>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<table class="notes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -42,7 +42,7 @@
|
||||
<?php foreach ($files as $file): ?>
|
||||
<tr>
|
||||
<td><?php echo sanitize($file['id']); ?></td>
|
||||
<td><a href="/EIANotesApp/Uploads/<?php echo $file['stored_filename']; ?>" download target="_blank"><?php echo sanitize($file['original_filename']); ?></a></td>
|
||||
<td><a href="<?php echo substr($_SERVER['PHP_SELF'], 0, -9).'Uploads/'.$file['stored_filename']; ?>"><?php echo sanitize($file['stored_filename']); ?></a></td>
|
||||
<td><?php echo sanitize($file['stored_filename']); ?></td>
|
||||
<td><?php echo sanitize($file['note_id']); ?></td>
|
||||
<td><?php echo sanitize($file['owner_username']); ?></td>
|
||||
|
@@ -33,7 +33,7 @@ $files = $this->notesModel->getUploadedFiles($note['id']);
|
||||
<ul>
|
||||
<?php foreach ($files as $file): ?>
|
||||
<li>
|
||||
<a href="/EIANotesApp/Uploads/<?php echo $file['stored_filename']; ?>" download target="_blank"><?php echo htmlspecialchars($file['original_filename']); ?></a>
|
||||
<a href="<?php echo substr($_SERVER['PHP_SELF'], 0, -9).'Uploads/'.$file['stored_filename']; ?>" download target="_blank"><?php echo htmlspecialchars($file['original_filename']); ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user