| Server IP : 27.254.66.5 / Your IP : 216.73.217.39 Web Server : Apache/2 System : Linux cs82.hostneverdie.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : technic2 ( 1951) PHP Version : 7.4.30 Disable Function : apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd,exec, fp, fput, highlight_file, ini_alter, ini_restore, inject_code, passthru,phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid,posix_setuid, posix_setuid, posix_uname,proc_open,proc_close, proc_get_status, proc_nice, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,sleep,pcntl_exec,virtual,suexec,dbmopen,dl,symlink,disk_free_space,diskfreespace,leak MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/technic2/domains/technicrayong.ac.th/public_html/rytc/tobe/admin/ |
Upload File : |
<?php
require_once __DIR__ . '/auth.php';
if (!empty($_GET['delete'])) {
$id = (int)$_GET['delete'];
$stmt = $pdo->prepare('SELECT image FROM activities WHERE id=?');
$stmt->execute([$id]);
$old = $stmt->fetchColumn();
if ($old && file_exists(__DIR__ . '/../uploads/activities/' . $old)) unlink(__DIR__ . '/../uploads/activities/' . $old);
$pdo->prepare('DELETE FROM activities WHERE id=?')->execute([$id]);
redirect('activity_list.php?deleted=1');
}
$rows = $pdo->query('SELECT * FROM activities ORDER BY created_at DESC')->fetchAll();
include __DIR__ . '/header.php';
?>
<div class="page-header"><div class="container"><h1 class="fw-bold">จัดการกิจกรรม</h1><p class="mb-0">เพิ่ม แก้ไข และลบข้อมูลกิจกรรมที่แสดงหน้าเว็บไซต์</p></div></div>
<div class="container mb-5">
<?php if (!empty($_GET['saved'])): ?><div class="alert alert-success rounded-4">บันทึกข้อมูลเรียบร้อยแล้ว</div><?php endif; ?>
<?php if (!empty($_GET['deleted'])): ?><div class="alert alert-warning rounded-4">ลบข้อมูลเรียบร้อยแล้ว</div><?php endif; ?>
<div class="content-card p-4">
<div class="d-flex justify-content-between align-items-center mb-3"><h4 class="fw-bold mb-0">รายการกิจกรรม</h4><a href="activity_form.php" class="btn btn-gradient"><i class="bi bi-plus-circle me-1"></i> เพิ่มกิจกรรม</a></div>
<div class="table-responsive"><table class="table align-middle"><thead><tr><th>รูป</th><th>ชื่อกิจกรรม</th><th>หมวดหมู่</th><th>วันที่</th><th></th></tr></thead><tbody>
<?php foreach($rows as $r): ?><tr>
<td style="width:110px"><?php if($r['image']): ?><img src="../uploads/activities/<?= e($r['image']) ?>" class="img-fluid rounded-3" style="height:70px;width:100px;object-fit:cover"><?php else: ?><div class="rounded-3 text-center text-white p-3" style="background:linear-gradient(90deg,#e50920,#0067ff)"><i class="bi bi-image fs-3"></i></div><?php endif; ?></td>
<td><strong><?= e($r['title']) ?></strong><br><small class="text-muted"><?= e(mb_strimwidth($r['detail'],0,80,'...')) ?></small></td>
<td><?= e($r['category']) ?></td><td><?= e($r['created_at']) ?></td>
<td class="text-end"><a class="btn btn-sm btn-outline-primary rounded-pill" href="activity_form.php?id=<?= (int)$r['id'] ?>">แก้ไข</a> <a class="btn btn-sm btn-outline-danger rounded-pill" onclick="return confirm('ยืนยันการลบข้อมูลนี้?')" href="activity_list.php?delete=<?= (int)$r['id'] ?>">ลบ</a></td>
</tr><?php endforeach; ?>
<?php if(!$rows): ?><tr><td colspan="5" class="text-center text-muted">ยังไม่มีข้อมูล</td></tr><?php endif; ?>
</tbody></table></div>
</div>
</div>
<?php include __DIR__ . '/footer.php'; ?>