-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
121 lines (109 loc) · 4.43 KB
/
Copy pathdashboard.php
File metadata and controls
121 lines (109 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
require_once 'includes/config.php';
require_once 'includes/auth-functions.php';
require_once 'includes/file-functions.php';
require_once 'includes/log-functions.php';
require_once 'includes/json-functions.php';
require_once 'includes/user-functions.php';
// Start session and check authentication
session_start();
require_authentication();
$current_user = get_current_user();
$user_role = $current_user['role'] ?? 'user';
// Get dashboard statistics
$all_files = read_json_file('files.json');
$total_files = is_array($all_files) ? count($all_files) : 0;
$user_files = get_user_files($current_user['id']);
$total_uploads = is_array($user_files) ? count($user_files) : 0;
$total_size = calculate_user_storage($current_user['id']);
// Get recent activity
$recent_files = array_slice(array_reverse($user_files), 0, 5);
// Log dashboard access
log_access("Dashboard viewed by user: " . $current_user['username']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - FileServer</title>
<link rel="stylesheet" href="assets/css/main.css">
<link rel="stylesheet" href="assets/css/forms.css">
</head>
<body>
<?php include 'templates/header.html'; ?>
<?php include 'templates/navigation.html'; ?>
<div class="container">
<div class="dashboard-header">
<h1>Welcome, <?php echo htmlspecialchars($current_user['username']); ?>!</h1>
<p class="user-role">Role: <?php echo ucfirst(htmlspecialchars($user_role)); ?></p>
</div>
<div class="dashboard-stats">
<div class="stat-card">
<h3>Your Files</h3>
<div class="stat-number"><?php echo $total_uploads; ?></div>
<p>Files uploaded</p>
</div>
<div class="stat-card">
<h3>Storage Used</h3>
<div class="stat-number"><?php echo format_file_size($total_size); ?></div>
<p>Total storage</p>
</div>
<?php if ($user_role === 'admin'): ?>
<div class="stat-card">
<h3>Total Files</h3>
<div class="stat-number"><?php echo $total_files; ?></div>
<p>System-wide</p>
</div>
<?php endif; ?>
</div>
<div class="dashboard-actions">
<h2>Quick Actions</h2>
<div class="action-buttons">
<a href="upload.php" class="btn btn-primary">
<span class="icon">📁</span>
Upload Files
</a>
<a href="file-browser.php" class="btn btn-secondary">
<span class="icon">🗂️</span>
Browse Files
</a>
<a href="search.php" class="btn btn-secondary">
<span class="icon">🔍</span>
Search Files
</a>
<?php if ($user_role === 'admin'): ?>
<a href="admin.php" class="btn btn-warning">
<span class="icon">⚙️</span>
Admin Panel
</a>
<?php endif; ?>
</div>
</div>
<?php if (!empty($recent_files)): ?>
<div class="recent-files">
<h2>Recent Files</h2>
<div class="file-list">
<?php foreach ($recent_files as $file): ?>
<div class="file-item">
<div class="file-info">
<span class="file-name"><?php echo htmlspecialchars($file['name']); ?></span>
<span class="file-size"><?php echo format_file_size($file['size']); ?></span>
</div>
<div class="file-date">
<?php echo date('M j, Y g:i A', strtotime($file['uploaded_at'])); ?>
</div>
<div class="file-actions">
<a href="api/download.php?id=<?php echo $file['id']; ?>" class="btn-small">Download</a>
<a href="file-browser.php?id=<?php echo $file['id']; ?>" class="btn-small">Details</a>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
<?php include 'templates/footer.html'; ?>
<script src="assets/js/main.js"></script>
</body>
</html>