s3
This commit is contained in:
86
admin/index.php
Normal file
86
admin/index.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
require('../.hta_header.php');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>PocketBase Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="my-5">
|
||||
<form id="loginForm" style="display: flex; flex-direction: column; justify-content: center; align-items: center;">
|
||||
<div style="display: flex; flex-direction: column; max-width: 500px; width: 400px; gap: 10px; background-color: #ffddcc; padding: 30px; border-radius: 10px;">
|
||||
<h3 style="text-align: center; color: #402517; line-height: 0;">Login</h3>
|
||||
<hr style="border-top: 2px solid #402517;">
|
||||
<input type="text" id="userName" placeholder="Username or Email" style="padding: 10px;" />
|
||||
<input type="password" id="password" placeholder="Password" style="padding: 10px;" />
|
||||
<button type="submit" style="padding: 10px;">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
import PocketBase from 'https://cdn.jsdelivr.net/npm/pocketbase@0.15.0';
|
||||
const pb = new PocketBase('http://127.0.0.1:8090');
|
||||
|
||||
// Handle login form submission
|
||||
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault(); // Prevent the default form submission
|
||||
|
||||
const usernameOrEmail = document.getElementById('userName').value;
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
try {
|
||||
// Authenticate user
|
||||
const authData = await pb.collection('users').authWithPassword(usernameOrEmail, password);
|
||||
|
||||
console.log('Authentication successful!');
|
||||
console.log('Is Auth Valid:', pb.authStore.isValid);
|
||||
console.log('Auth Token:', pb.authStore.token);
|
||||
console.log('User ID:', pb.authStore.model.id);
|
||||
|
||||
alert('Login successful!');
|
||||
} catch (error) {
|
||||
console.error('Login failed:', error);
|
||||
alert('Login failed. Please check your credentials.');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!-- <script> -->
|
||||
|
||||
<!-- // after the above you can also access the auth data from the authStore
|
||||
|
||||
// // Attach event listener to the form
|
||||
// document.getElementById('loginForm').addEventListener('submit', function (e) {
|
||||
// e.preventDefault(); // Prevent the form from reloading the page
|
||||
|
||||
// let userData = {
|
||||
// "identity": document.getElementById('userName').value,
|
||||
// "password": document.getElementById('password').value
|
||||
// };
|
||||
|
||||
// fetch('http://192.168.1.197:8090/api/collections/users/auth-with-password', {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json'
|
||||
// },
|
||||
// body: JSON.stringify(userData)
|
||||
// })
|
||||
// .then(res => res.json())
|
||||
// .then(data => {
|
||||
// console.log(data);
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.error(error);
|
||||
// });
|
||||
// }); -->
|
||||
<!-- </script> -->
|
||||
|
||||
<?php
|
||||
require_once('../.hta_footer.php');
|
||||
?>
|
||||
@@ -1,9 +1,32 @@
|
||||
<?php
|
||||
require('../.hta_config/env.php');
|
||||
require('../.hta_header.php');
|
||||
require('../.hta_admin_header.php');
|
||||
$current_date_time = date("Y-m-d H:i:s");
|
||||
require('../.hta_config/env.php');
|
||||
require('../.hta_header.php');
|
||||
require('../.hta_admin_header.php');
|
||||
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
// Define the number of results per page
|
||||
$results_per_page = 30;
|
||||
|
||||
// Get the current page number from the URL (default to page 1)
|
||||
$page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$offset = ($page - 1) * $results_per_page;
|
||||
|
||||
// Get total number of records
|
||||
$total_stmt = $conn->prepare("SELECT COUNT(*) AS total FROM `scc24`");
|
||||
$total_stmt->execute();
|
||||
$total_rows = $total_stmt->fetch(PDO::FETCH_ASSOC)['total'];
|
||||
$total_pages = ceil($total_rows / $results_per_page);
|
||||
|
||||
// Fetch paginated records
|
||||
$stmt = $conn->prepare("SELECT * FROM `scc24` ORDER BY id DESC LIMIT :limit OFFSET :offset");
|
||||
$stmt->bindValue(':limit', $results_per_page, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$content = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
?>
|
||||
|
||||
<p style="font-size: 25px; text-align: center; margin-top: 10px;">Page Content List</p>
|
||||
<div class="table-container">
|
||||
<table class="responsive-table">
|
||||
@@ -16,31 +39,46 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$stmt = $conn->prepare("SELECT * FROM `scc24` WHERE type != 'faculty' ORDER BY id DESC ");
|
||||
$stmt->execute();
|
||||
$content = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach($content as $pageData){ ?>
|
||||
<?php foreach ($content as $pageData) { ?>
|
||||
<tr>
|
||||
<td style="border: 2px solid #7a7a7a;"><?php echo $pageData['id']; ?></td>
|
||||
<td style="border: 2px solid #7a7a7a;"><?php echo $pageData['type']; ?></td>
|
||||
<td style="border: 2px solid #7a7a7a;"><?php echo $pageData['title']; ?></td>
|
||||
<td style="border: 2px solid #7a7a7a;">
|
||||
<div style="display: flex; flex-direction: row; justify-content: center; color: blue;">
|
||||
<a href="edit-content.php?id=<?php echo $pageData['id'] . '&slug=' . $pageData['slug'] . '&type=' . $pageData['type']; ?>">Edit</a>
|
||||
<a target="_blank" href="<?php if($pageData['type'] === 'notice'){echo '/notice/'.$pageData['slug'].'.html';} elseif($pageData['type'] === 'page'){echo '/'.$pageData['slug'].'.html';}?>">View</a>
|
||||
<a href="edit-content.php?id=<?php echo $pageData['id'] . '&slug=' . $pageData['slug'] . '&type=' . $pageData['type']; ?>">Edit</a>
|
||||
<a target="_blank" href="<?php
|
||||
if ($pageData['type'] === 'notice') {
|
||||
echo '/notice/' . $pageData['slug'] . '.html';
|
||||
} elseif ($pageData['type'] === 'page') {
|
||||
echo '/' . $pageData['slug'] . '.html';
|
||||
}
|
||||
?>">View</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
require('../.hta_footer.php');
|
||||
?>
|
||||
|
||||
<!-- Pagination Links -->
|
||||
<div style="text-align: center; margin-top: 20px; display: flex; flex-direction: row; gap: 20px; justify-content: center;">
|
||||
<?php if ($page > 1): ?>
|
||||
<a href="?page=1">First</a>
|
||||
<a href="?page=<?php echo $page - 1; ?>">Prev</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<span>Page <?php echo $page; ?> of <?php echo $total_pages; ?></span>
|
||||
|
||||
<?php if ($page < $total_pages): ?>
|
||||
<a href="?page=<?php echo $page + 1; ?>">Next</a>
|
||||
<a href="?page=<?php echo $total_pages; ?>">Last</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php require('../.hta_footer.php'); ?>
|
||||
|
||||
<style>
|
||||
.table-container {
|
||||
margin: 20px auto;
|
||||
|
||||
Reference in New Issue
Block a user