-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin.php
More file actions
executable file
·153 lines (130 loc) · 5.03 KB
/
admin.php
File metadata and controls
executable file
·153 lines (130 loc) · 5.03 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
// Directory where profile pictures are stored
$pfpDir = $_SERVER['DOCUMENT_ROOT'] . '/assets/images/';
// Possible extensions
$extensions = ['png', 'jpg', 'jpeg', 'gif'];
// Default PFP URL if none found
$pfpUrl = 'https://canadian-gamer.com/assets/images/default-pfp.png';
// Find the first matching PFP file
foreach ($extensions as $ext) {
$files = glob($pfpDir . 'pfp.' . $ext);
if (!empty($files)) {
// Use the first match
$pfpFile = basename($files[0]);
$pfpUrl = 'https://canadian-gamer.com/assets/images/' . $pfpFile;
break;
}
}
$pfp = $pfpUrl;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="/images/favicon.png" type="image/png">
<title>Admin Dashboard</title>
<!-- Tailwind -->
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="themes/blue.css">
<link rel="stylesheet" href="style.css">
<link rel="alternate" type="application/rss+xml"
title="Canadian Gamer RSS Feed"
href="https://canadian-gamer.com/rss.php">
</head>
<script type="module" src= "/components/login.js"> </script>
<script type="module" src= "/components/footer.js"> </script>
<body>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 p-6 max-w-6xl mx-auto">
<!-- Sidebar (same style as public pages) -->
<aside class="md:col-span-1">
<div id="sidebar" class=" border-2 p-4 space-y-6">
<!-- Profile -->
<div class="text-center">
<img id="profile-pfp" src="<?= $pfp ?>" alt="Profile Picture" class="rounded-2xl w-full mb-2">
<h2 class="text-xl font-bold">CanadianGamer</h2>
<p class="text-sm text-gray-600">Admin Panel</p>
<!-- Upload button -->
<form id="upload-pfp-form" class="mt-2" enctype="multipart/form-data">
<input type="file" name="pfp" accept="image/png, image/jpeg, image/jpg, image/gif" class="hidden" id="pfp-input">
<button type="button" id="change-pfp-btn" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
Change Profile Picture
</button>
</form>
</div>
<!-- Quick Links -->
<div>
<h3 class="font-bold mb-2 border-b pb-1">Admin Links</h3>
<ul class="space-y-1">
<li><a href="index.php" class="text-blue-600 underline">View Site</a></li>
<li><a href="admin.php" class="text-blue-600 underline">Dashboard</a></li>
<li><a href="about.php" class="text-blue-600 underline">About</a></li>
<li><a href="videos.php" class="text-blue-600 underline">Videos</a></li>
<li><a href="gallery.php" class="text-blue-600 underline">Gallery</a></li>
<li><a href="blogs.php" class="text-blue-600 underline">Writings</a></li>
<li><a href = "live.php" class="text-blue-600 underline" > Live Streams </a></li>
<li><a href = "write_blogs.php" class="text-blue-600 underline" > Write Blogs </a></li>
<li><a href = "edit_blogs.php" class="text-blue-600 underline" > Manage Blogs </a></li>
</ul>
</div>
</div>
</aside>
<!-- Main admin content -->
<main class="md:col-span-2 p-6 ">
<h1 class="text-2xl font-bold mb-4">Admin Dashboard</h1>
<div class="space-y-4">
<admin-content-manager></admin-content-manager>
<!-- Site Customization -->
<!-- <div class="border p-4 rounded-md">
<h2 class="font-semibold mb-2">Site Theme</h2>
<div class="flex gap-2">
<button onclick="setTheme('white')"
class="bg-gray-200 hover:bg-gray-300 text-black px-4 py-2 rounded">
White
</button>
<button onclick="setTheme('blue')"
class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded">
Blue
</button>
<button onclick="setTheme('black')"
class="bg-gray-800 hover:bg-gray-900 text-white px-4 py-2 rounded">
Black
</button>
</div>
<p class="mt-2 text-sm">Current theme:
<span id="theme-status" class="font-bold text-blue-600"></span>
</p>
</div> -->
</div>
</main>
</div>
<script type="module" src="/components/post.js"></script>
<script>
const btn = document.getElementById('change-pfp-btn');
const input = document.getElementById('pfp-input');
const form = document.getElementById('upload-pfp-form');
const profilePfp = document.getElementById('profile-pfp');
btn.addEventListener('click', () => input.click());
input.addEventListener('change', async () => {
const file = input.files[0];
if (!file) return;
const formData = new FormData();
formData.append('pfp', file);
const response = await fetch('upload_pfp.php', {
method: 'POST',
body: formData
});
const data = await response.json();
if (data.status === 'success') {
// Update the profile image instantly
profilePfp.src = data.file + '?t=' + new Date().getTime(); // prevent cache
alert('Profile picture updated!');
} else {
alert('Error: ' + data.error);
console.log(data);
}
});
</script>
</body>
<my-footer></my-footer>
</html>