📁 File Manager
Editing:
/home/wvl7mof7402e/www/chem/admin/page_revisions.php
<?php /* |-------------------------------------------------------------------------- | PURE CHEMICAL ADMIN - PAGE REVISIONS |-------------------------------------------------------------------------- | File : admin/page_revisions.php | Table : page_revisions | | Existing database only. | No new tables. | No dummy data. |-------------------------------------------------------------------------- */ if (session_status() !== PHP_SESSION_ACTIVE) { session_start(); } require_once __DIR__ . '/includes/db.php'; if (file_exists(__DIR__ . '/includes/auth.php')) { require_once __DIR__ . '/includes/auth.php'; } if (function_exists('requireAdmin')) { requireAdmin(); } /* |-------------------------------------------------------------------------- | Helpers |-------------------------------------------------------------------------- */ function pr_e($value) { return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8'); } function pr_redirect($url = 'page_revisions.php') { header('Location: ' . $url); exit; } function pr_flash($type, $message) { $_SESSION['pr_flash'] = [ 'type' => $type, 'message' => $message ]; } function pr_get_flash() { $flash = $_SESSION['pr_flash'] ?? null; unset($_SESSION['pr_flash']); return $flash; } /* |-------------------------------------------------------------------------- | CSRF |-------------------------------------------------------------------------- */ if (empty($_SESSION['pr_csrf'])) { $_SESSION['pr_csrf'] = bin2hex(random_bytes(32)); } $csrfToken = $_SESSION['pr_csrf']; function pr_verify_csrf() { $token = $_POST['csrf_token'] ?? ''; if ( empty($_SESSION['pr_csrf']) || empty($token) || !hash_equals($_SESSION['pr_csrf'], $token) ) { pr_flash( 'error', 'Security verification failed. Please try again.' ); pr_redirect(); } } /* |-------------------------------------------------------------------------- | Existing Pages |-------------------------------------------------------------------------- */ $pages = []; try { $pages = $pdo->query(" SELECT id, title, slug FROM pages ORDER BY title ASC, id ASC ")->fetchAll(); } catch (Throwable $e) { $pages = []; error_log( 'Page Revisions Pages Load Error: ' . $e->getMessage() ); } /* |-------------------------------------------------------------------------- | Existing Users |-------------------------------------------------------------------------- | | user_id is nullable, therefore "System / Unknown" is also supported. |-------------------------------------------------------------------------- */ $users = []; try { $users = $pdo->query(" SELECT id, name, email FROM users ORDER BY name ASC, id ASC ")->fetchAll(); } catch (Throwable $e) { $users = []; /* |-------------------------------------------------------------------------- | Fallback if users table doesn't contain name |-------------------------------------------------------------------------- */ try { $users = $pdo->query(" SELECT id, email FROM users ORDER BY id ASC ")->fetchAll(); } catch (Throwable $ignored) { $users = []; } } /* |-------------------------------------------------------------------------- | POST ACTIONS |-------------------------------------------------------------------------- */ if ($_SERVER['REQUEST_METHOD'] === 'POST') { pr_verify_csrf(); $action = $_POST['action'] ?? ''; /* |-------------------------------------------------------------------------- | SAVE REVISION |-------------------------------------------------------------------------- */ if ($action === 'save') { $id = (int)($_POST['id'] ?? 0); $pageId = (int)($_POST['page_id'] ?? 0); $userIdRaw = $_POST['user_id'] ?? ''; $userId = ($userIdRaw !== '' && (int)$userIdRaw > 0) ? (int)$userIdRaw : null; $title = trim($_POST['title'] ?? ''); $content = $_POST['content'] ?? ''; $sectionsSnapshot = $_POST['sections_snapshot'] ?? ''; $revisionNote = trim($_POST['revision_note'] ?? ''); /* |-------------------------------------------------------------------------- | Validation |-------------------------------------------------------------------------- */ if ($pageId <= 0) { pr_flash( 'error', 'Please select a page.' ); pr_redirect(); } if ($title !== '' && mb_strlen($title) > 255) { pr_flash( 'error', 'Revision title cannot exceed 255 characters.' ); pr_redirect(); } if ($revisionNote !== '' && mb_strlen($revisionNote) > 500) { pr_flash( 'error', 'Revision note cannot exceed 500 characters.' ); pr_redirect(); } try { /* |-------------------------------------------------------------------------- | Verify Page |-------------------------------------------------------------------------- */ $stmt = $pdo->prepare(" SELECT id FROM pages WHERE id = ? LIMIT 1 "); $stmt->execute([$pageId]); if (!$stmt->fetchColumn()) { pr_flash( 'error', 'Selected page does not exist.' ); pr_redirect(); } /* |-------------------------------------------------------------------------- | Verify User |-------------------------------------------------------------------------- */ if ($userId !== null) { $stmt = $pdo->prepare(" SELECT id FROM users WHERE id = ? LIMIT 1 "); $stmt->execute([$userId]); if (!$stmt->fetchColumn()) { pr_flash( 'error', 'Selected user does not exist.' ); pr_redirect(); } } /* |-------------------------------------------------------------------------- | UPDATE |-------------------------------------------------------------------------- */ if ($id > 0) { $stmt = $pdo->prepare(" UPDATE page_revisions SET page_id = ?, user_id = ?, title = ?, content = ?, sections_snapshot = ?, revision_note = ? WHERE id = ? LIMIT 1 "); $stmt->execute([ $pageId, $userId, $title !== '' ? $title : null, $content !== '' ? $content : null, $sectionsSnapshot !== '' ? $sectionsSnapshot : null, $revisionNote !== '' ? $revisionNote : null, $id ]); pr_flash( 'success', 'Page revision updated successfully.' ); } else { /* |-------------------------------------------------------------------------- | INSERT |-------------------------------------------------------------------------- */ $stmt = $pdo->prepare(" INSERT INTO page_revisions ( page_id, user_id, title, content, sections_snapshot, revision_note ) VALUES (?, ?, ?, ?, ?, ?) "); $stmt->execute([ $pageId, $userId, $title !== '' ? $title : null, $content !== '' ? $content : null, $sectionsSnapshot !== '' ? $sectionsSnapshot : null, $revisionNote !== '' ? $revisionNote : null ]); pr_flash( 'success', 'Page revision created successfully.' ); } } catch (Throwable $e) { error_log( 'Page Revision Save Error: ' . $e->getMessage() ); pr_flash( 'error', 'Unable to save the page revision.' ); } pr_redirect(); } /* |-------------------------------------------------------------------------- | DELETE |-------------------------------------------------------------------------- */ if ($action === 'delete') { $id = (int)($_POST['id'] ?? 0); if ($id <= 0) { pr_flash( 'error', 'Invalid revision ID.' ); pr_redirect(); } try { $stmt = $pdo->prepare(" DELETE FROM page_revisions WHERE id = ? LIMIT 1 "); $stmt->execute([$id]); if ($stmt->rowCount() > 0) { pr_flash( 'success', 'Page revision deleted successfully.' ); } else { pr_flash( 'error', 'Page revision was not found.' ); } } catch (Throwable $e) { error_log( 'Page Revision Delete Error: ' . $e->getMessage() ); pr_flash( 'error', 'Unable to delete this page revision.' ); } pr_redirect(); } } /* |-------------------------------------------------------------------------- | EDIT RECORD |-------------------------------------------------------------------------- */ $editId = (int)($_GET['edit'] ?? 0); $editRecord = null; if ($editId > 0) { try { $stmt = $pdo->prepare(" SELECT * FROM page_revisions WHERE id = ? LIMIT 1 "); $stmt->execute([$editId]); $editRecord = $stmt->fetch(); } catch (Throwable $e) { $editRecord = null; error_log( 'Page Revision Edit Load Error: ' . $e->getMessage() ); } } /* |-------------------------------------------------------------------------- | VIEW RECORD |-------------------------------------------------------------------------- */ $viewId = (int)($_GET['view'] ?? 0); $viewRecord = null; if ($viewId > 0) { try { $stmt = $pdo->prepare(" SELECT pr.*, p.title AS page_title, p.slug AS page_slug, u.name AS user_name, u.email AS user_email FROM page_revisions pr INNER JOIN pages p ON p.id = pr.page_id LEFT JOIN users u ON u.id = pr.user_id WHERE pr.id = ? LIMIT 1 "); $stmt->execute([$viewId]); $viewRecord = $stmt->fetch(); } catch (Throwable $e) { $viewRecord = null; error_log( 'Page Revision View Error: ' . $e->getMessage() ); } } /* |-------------------------------------------------------------------------- | FILTERS |-------------------------------------------------------------------------- */ $search = trim($_GET['search'] ?? ''); $filterPage = (int)($_GET['page_id'] ?? 0); $filterUser = (int)($_GET['user_id'] ?? 0); $dateFrom = trim($_GET['date_from'] ?? ''); $dateTo = trim($_GET['date_to'] ?? ''); /* |-------------------------------------------------------------------------- | Pagination |-------------------------------------------------------------------------- */ $perPageOptions = [10, 20, 50, 100]; $perPage = (int)($_GET['per_page'] ?? 20); if (!in_array($perPage, $perPageOptions, true)) { $perPage = 20; } $currentPage = max( 1, (int)($_GET['p'] ?? 1) ); /* |-------------------------------------------------------------------------- | WHERE |-------------------------------------------------------------------------- */ $where = []; $params = []; /* |-------------------------------------------------------------------------- | Search |-------------------------------------------------------------------------- */ if ($search !== '') { $where[] = " ( pr.title LIKE ? OR pr.revision_note LIKE ? OR pr.content LIKE ? OR p.title LIKE ? OR p.slug LIKE ? OR u.name LIKE ? OR u.email LIKE ? ) "; $searchLike = '%' . $search . '%'; $params[] = $searchLike; $params[] = $searchLike; $params[] = $searchLike; $params[] = $searchLike; $params[] = $searchLike; $params[] = $searchLike; $params[] = $searchLike; } /* |-------------------------------------------------------------------------- | Page filter |-------------------------------------------------------------------------- */ if ($filterPage > 0) { $where[] = "pr.page_id = ?"; $params[] = $filterPage; } /* |-------------------------------------------------------------------------- | User filter |-------------------------------------------------------------------------- */ if ($filterUser > 0) { $where[] = "pr.user_id = ?"; $params[] = $filterUser; } /* |-------------------------------------------------------------------------- | Date From |-------------------------------------------------------------------------- */ if ($dateFrom !== '') { $dateFromObj = DateTime::createFromFormat( 'Y-m-d', $dateFrom ); if ( $dateFromObj && $dateFromObj->format('Y-m-d') === $dateFrom ) { $where[] = "pr.created_at >= ?"; $params[] = $dateFrom . ' 00:00:00'; } } /* |-------------------------------------------------------------------------- | Date To |-------------------------------------------------------------------------- */ if ($dateTo !== '') { $dateToObj = DateTime::createFromFormat( 'Y-m-d', $dateTo ); if ( $dateToObj && $dateToObj->format('Y-m-d') === $dateTo ) { $where[] = "pr.created_at <= ?"; $params[] = $dateTo . ' 23:59:59'; } } $whereSql = ''; if (!empty($where)) { $whereSql = 'WHERE ' . implode(' AND ', $where); } /* |-------------------------------------------------------------------------- | COUNT |-------------------------------------------------------------------------- */ $totalRows = 0; try { $countSql = " SELECT COUNT(*) FROM page_revisions pr INNER JOIN pages p ON p.id = pr.page_id LEFT JOIN users u ON u.id = pr.user_id {$whereSql} "; $stmt = $pdo->prepare($countSql); $stmt->execute($params); $totalRows = (int)$stmt->fetchColumn(); } catch (Throwable $e) { $totalRows = 0; error_log( 'Page Revision Count Error: ' . $e->getMessage() ); } /* |-------------------------------------------------------------------------- | TOTAL PAGES |-------------------------------------------------------------------------- */ $totalPages = max( 1, (int)ceil($totalRows / $perPage) ); if ($currentPage > $totalPages) { $currentPage = $totalPages; } $offset = ( $currentPage - 1 ) * $perPage; /* |-------------------------------------------------------------------------- | LIST |-------------------------------------------------------------------------- */ $records = []; try { $sql = " SELECT pr.*, p.title AS page_title, p.slug AS page_slug, u.name AS user_name, u.email AS user_email FROM page_revisions pr INNER JOIN pages p ON p.id = pr.page_id LEFT JOIN users u ON u.id = pr.user_id {$whereSql} ORDER BY pr.id DESC LIMIT {$perPage} OFFSET {$offset} "; $stmt = $pdo->prepare($sql); $stmt->execute($params); $records = $stmt->fetchAll(); } catch (Throwable $e) { $records = []; error_log( 'Page Revision Listing Error: ' . $e->getMessage() ); } /* |-------------------------------------------------------------------------- | STATISTICS |-------------------------------------------------------------------------- */ $stats = [ 'total' => 0, 'pages' => 0, 'users' => 0, 'today' => 0 ]; try { $stats['total'] = (int)$pdo ->query(" SELECT COUNT(*) FROM page_revisions ") ->fetchColumn(); $stats['pages'] = (int)$pdo ->query(" SELECT COUNT(DISTINCT page_id) FROM page_revisions ") ->fetchColumn(); $stats['users'] = (int)$pdo ->query(" SELECT COUNT(DISTINCT user_id) FROM page_revisions WHERE user_id IS NOT NULL ") ->fetchColumn(); $stats['today'] = (int)$pdo ->query(" SELECT COUNT(*) FROM page_revisions WHERE created_at >= CURDATE() AND created_at < CURDATE() + INTERVAL 1 DAY ") ->fetchColumn(); } catch (Throwable $e) { // Keep defaults. } $flash = pr_get_flash(); /* |-------------------------------------------------------------------------- | Helpers |-------------------------------------------------------------------------- */ function pr_content_excerpt($content, $length = 120) { $content = trim(strip_tags((string)$content)); if ($content === '') { return 'No content snapshot'; } if (mb_strlen($content) <= $length) { return $content; } return mb_substr($content, 0, $length) . '...'; } function pr_json_pretty($value) { if ($value === null || $value === '') { return ''; } $decoded = json_decode( $value, true ); if (json_last_error() === JSON_ERROR_NONE) { return json_encode( $decoded, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); } return $value; } function pr_format_date($date) { if (!$date) { return '—'; } $timestamp = strtotime($date); if (!$timestamp) { return $date; } return date( 'd M Y, h:i A', $timestamp ); } function pr_page_url_params(array $extra = []) { $base = $_GET; foreach ($extra as $key => $value) { if ($value === null || $value === '') { unset($base[$key]); } else { $base[$key] = $value; } } return http_build_query($base); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0" > <title> Page Revisions | Pure Chemical Admin </title> <meta name="description" content="Manage page revisions for Pure Chemical website" > <link rel="preconnect" href="https://fonts.googleapis.com" > <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin > <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" > <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" > <style> :root { --pr-primary: #0f766e; --pr-primary-dark: #115e59; --pr-primary-soft: #ecfdf5; --pr-bg: #f6f8fb; --pr-card: #ffffff; --pr-text: #172033; --pr-muted: #6b7280; --pr-border: #e7ebf0; --pr-success: #15803d; --pr-danger: #dc2626; --pr-warning: #d97706; --pr-radius: 18px; --pr-shadow: 0 12px 35px rgba(15, 23, 42, .07); --pr-sidebar-width: 285px; } * { box-sizing: border-box; } html { scroll-behavior: smooth; } body { margin: 0; background: var(--pr-bg); color: var(--pr-text); font-family: "Inter", sans-serif; font-size: 14px; } button, input, select, textarea { font-family: inherit; } a { color: inherit; text-decoration: none; } /* ============================================================ PAGE LAYOUT ============================================================ */ .pr-page { margin-left: var(--pr-sidebar-width); min-height: 100vh; } .pr-topbar { position: sticky; top: 0; z-index: 900; height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(16px); border-bottom: 1px solid var(--pr-border); } .pr-topbar-left { display: flex; align-items: center; gap: 15px; } .pr-page-icon { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 13px; background: var(--pr-primary-soft); color: var(--pr-primary); font-size: 18px; } .pr-heading h1 { margin: 0; font-size: 19px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; } .pr-heading span { display: block; margin-top: 4px; color: var(--pr-muted); font-size: 12px; } .pr-topbar-right { display: flex; align-items: center; gap: 10px; } .pr-admin-badge { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 999px; background: #f0fdf4; color: #15803d; font-size: 12px; font-weight: 700; } .pr-admin-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .12); } /* ============================================================ CONTENT ============================================================ */ .pr-content { padding: 30px; max-width: 1750px; margin: 0 auto; } /* ============================================================ STATS ============================================================ */ .pr-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; } .pr-stat { position: relative; overflow: hidden; padding: 21px; background: var(--pr-card); border: 1px solid var(--pr-border); border-radius: var(--pr-radius); box-shadow: var(--pr-shadow); } .pr-stat::after { content: ""; position: absolute; right: -35px; bottom: -45px; width: 110px; height: 110px; border-radius: 50%; background: var(--pr-primary-soft); } .pr-stat-icon { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; border-radius: 13px; background: var(--pr-primary-soft); color: var(--pr-primary); font-size: 17px; } .pr-stat-value { margin-top: 15px; font-size: 28px; font-weight: 800; letter-spacing: -.04em; } .pr-stat-label { margin-top: 4px; color: var(--pr-muted); font-size: 12px; font-weight: 600; } /* ============================================================ ALERT ============================================================ */ .pr-alert { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; padding: 14px 17px; border-radius: 14px; font-size: 13px; font-weight: 600; } .pr-alert.success { background: #ecfdf3; color: #166534; border: 1px solid #bbf7d0; } .pr-alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; } .pr-alert button { margin-left: auto; border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 16px; } /* ============================================================ CARD ============================================================ */ .pr-card { margin-bottom: 22px; overflow: hidden; background: var(--pr-card); border: 1px solid var(--pr-border); border-radius: var(--pr-radius); box-shadow: var(--pr-shadow); } .pr-card-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--pr-border); } .pr-card-title { display: flex; align-items: center; gap: 11px; } .pr-card-title-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 11px; background: #f1f5f9; color: var(--pr-primary); } .pr-card-title h2 { margin: 0; font-size: 15px; font-weight: 800; } .pr-card-title p { margin: 3px 0 0; color: var(--pr-muted); font-size: 11px; } /* ============================================================ FORM ============================================================ */ .pr-form { padding: 24px; } .pr-form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; } .pr-field { grid-column: span 4; } .pr-field.span-6 { grid-column: span 6; } .pr-field.span-8 { grid-column: span 8; } .pr-field.span-12 { grid-column: span 12; } .pr-field label { display: block; margin-bottom: 7px; color: #374151; font-size: 12px; font-weight: 700; } .pr-required { color: var(--pr-danger); } .pr-input, .pr-select, .pr-textarea { width: 100%; border: 1px solid #dce2e9; border-radius: 11px; background: #fff; color: var(--pr-text); outline: none; transition: border-color .2s ease, box-shadow .2s ease; } .pr-input, .pr-select { height: 45px; padding: 0 13px; } .pr-textarea { min-height: 130px; padding: 12px 13px; resize: vertical; line-height: 1.55; } .pr-textarea.large { min-height: 230px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; } .pr-input:focus, .pr-select:focus, .pr-textarea:focus { border-color: var(--pr-primary); box-shadow: 0 0 0 4px rgba(15, 118, 110, .09); } .pr-help { margin-top: 6px; color: #8a94a6; font-size: 11px; line-height: 1.5; } .pr-form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--pr-border); } /* ============================================================ BUTTONS ============================================================ */ .pr-btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-size: 12px; font-weight: 700; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; } .pr-btn:hover { transform: translateY(-1px); } .pr-btn-primary { background: var(--pr-primary); color: #fff; box-shadow: 0 7px 18px rgba(15, 118, 110, .18); } .pr-btn-primary:hover { background: var(--pr-primary-dark); } .pr-btn-light { background: #fff; color: #374151; border: 1px solid var(--pr-border); } .pr-btn-danger { background: #fff1f2; color: #be123c; border: 1px solid #ffe4e6; } .pr-btn-sm { min-height: 34px; padding: 0 10px; font-size: 11px; } /* ============================================================ FILTER ============================================================ */ .pr-filter { padding: 18px 24px; background: #fbfcfe; border-bottom: 1px solid var(--pr-border); } .pr-filter-grid { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(170px, 1fr) minmax(160px, 1fr) minmax(145px, 1fr) auto; gap: 10px; } .pr-search { position: relative; } .pr-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #9ca3af; pointer-events: none; } .pr-search .pr-input { padding-left: 38px; } /* ============================================================ TABLE ============================================================ */ .pr-table-wrap { overflow-x: auto; } .pr-table { width: 100%; min-width: 1200px; border-collapse: collapse; } .pr-table th { padding: 13px 17px; background: #fafbfc; color: #6b7280; border-bottom: 1px solid var(--pr-border); text-align: left; white-space: nowrap; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; } .pr-table td { padding: 15px 17px; border-bottom: 1px solid #edf0f4; vertical-align: middle; color: #374151; font-size: 12px; } .pr-table tbody tr { transition: background .15s ease; } .pr-table tbody tr:hover { background: #fbfefd; } .pr-id { color: #9ca3af; font-weight: 700; } .pr-page-cell { display: flex; align-items: center; gap: 10px; } .pr-page-icon-small { width: 39px; height: 39px; flex: 0 0 39px; display: flex; align-items: center; justify-content: center; border-radius: 11px; background: var(--pr-primary-soft); color: var(--pr-primary); } .pr-page-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #1f2937; font-weight: 700; } .pr-slug { max-width: 220px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #9ca3af; font-size: 10px; } .pr-revision-title { max-width: 230px; color: #1f2937; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .pr-content-preview { max-width: 260px; margin-top: 4px; color: #8a94a6; font-size: 10px; line-height: 1.4; } .pr-user { display: flex; align-items: center; gap: 8px; } .pr-user-avatar { width: 30px; height: 30px; flex: 0 0 30px; display: flex; align-items: center; justify-content: center; border-radius: 9px; background: #f1f5f9; color: #64748b; font-size: 11px; } .pr-user-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; } .pr-user-email { max-width: 150px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #9ca3af; font-size: 9px; } .pr-note { max-width: 210px; color: #475569; line-height: 1.4; } .pr-date { white-space: nowrap; color: #64748b; font-size: 10px; font-weight: 600; } .pr-actions { display: flex; align-items: center; gap: 6px; } .pr-icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--pr-border); border-radius: 9px; background: #fff; color: #64748b; cursor: pointer; transition: .15s ease; } .pr-icon-btn:hover { border-color: #cbd5e1; color: var(--pr-primary); background: #f8fafc; } .pr-icon-btn.danger:hover { color: var(--pr-danger); background: #fff1f2; border-color: #fecdd3; } /* ============================================================ EMPTY ============================================================ */ .pr-empty { padding: 65px 20px; text-align: center; } .pr-empty-icon { width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; margin: 0 auto 15px; border-radius: 18px; background: #f1f5f9; color: #94a3b8; font-size: 23px; } .pr-empty h3 { margin: 0; font-size: 15px; } .pr-empty p { margin: 7px 0 0; color: var(--pr-muted); font-size: 12px; } /* ============================================================ PAGINATION ============================================================ */ .pr-pagination { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 17px 24px; border-top: 1px solid var(--pr-border); } .pr-pagination-info { color: var(--pr-muted); font-size: 11px; font-weight: 600; } .pr-pagination-links { display: flex; align-items: center; gap: 5px; } .pr-page-link { min-width: 34px; height: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--pr-border); border-radius: 8px; background: #fff; color: #64748b; font-size: 11px; font-weight: 700; } .pr-page-link:hover, .pr-page-link.active { color: #fff; background: var(--pr-primary); border-color: var(--pr-primary); } .pr-page-link.disabled { opacity: .45; pointer-events: none; } /* ============================================================ VIEW MODAL ============================================================ */ .pr-modal { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(15, 23, 42, .58); backdrop-filter: blur(5px); } .pr-modal.show { display: flex; } .pr-modal-box { width: min(1050px, 100%); max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 20px; box-shadow: 0 30px 80px rgba(15, 23, 42, .22); } .pr-modal-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 19px 21px; background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); border-bottom: 1px solid var(--pr-border); } .pr-modal-header h3 { margin: 0; font-size: 15px; } .pr-modal-close { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 9px; background: #f1f5f9; color: #64748b; cursor: pointer; } .pr-modal-body { padding: 22px; } .pr-view-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; } .pr-view-item { padding: 14px; background: #f8fafc; border: 1px solid #edf0f4; border-radius: 12px; } .pr-view-label { margin-bottom: 5px; color: #94a3b8; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; } .pr-view-value { color: #1f2937; font-size: 12px; font-weight: 700; line-height: 1.5; word-break: break-word; } .pr-view-section { margin-top: 18px; } .pr-view-section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; color: #334155; font-size: 12px; font-weight: 800; } .pr-code { max-height: 340px; overflow: auto; padding: 16px; border: 1px solid #e2e8f0; border-radius: 12px; background: #0f172a; color: #e2e8f0; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; line-height: 1.65; } .pr-content-box { max-height: 350px; overflow: auto; padding: 17px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fbfcfe; color: #334155; line-height: 1.65; font-size: 12px; word-break: break-word; } /* ============================================================ RESPONSIVE ============================================================ */ @media (max-width: 1250px) { .pr-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pr-filter-grid { grid-template-columns: 1fr 1fr; } } @media (max-width: 991px) { .pr-page { margin-left: 0; } .pr-topbar { height: 68px; padding: 0 18px; } .pr-content { padding: 20px 16px; } .pr-admin-badge { display: none; } } @media (max-width: 700px) { .pr-stats { grid-template-columns: 1fr; } .pr-filter-grid { grid-template-columns: 1fr; } .pr-field, .pr-field.span-6, .pr-field.span-8, .pr-field.span-12 { grid-column: span 12; } .pr-card-header { align-items: flex-start; flex-direction: column; } .pr-form-actions { flex-direction: column-reverse; align-items: stretch; } .pr-form-actions .pr-btn { width: 100%; } .pr-pagination { flex-direction: column; align-items: stretch; } .pr-pagination-links { justify-content: center; flex-wrap: wrap; } .pr-heading span { display: none; } .pr-view-grid { grid-template-columns: 1fr; } } </style> </head> <body> <?php /* |-------------------------------------------------------------------------- | EXISTING ADMIN SIDEBAR |-------------------------------------------------------------------------- */ require_once __DIR__ . '/sidebar.php'; ?> <div class="pr-page"> <!-- ================================================================ TOPBAR ================================================================= --> <header class="pr-topbar"> <div class="pr-topbar-left"> <div class="pr-page-icon"> <i class="fa-solid fa-clock-rotate-left"></i> </div> <div class="pr-heading"> <h1> Page Revisions </h1> <span> Manage saved versions and revision history </span> </div> </div> <div class="pr-topbar-right"> <div class="pr-admin-badge"> <span class="pr-admin-dot"></span> Admin Panel </div> </div> </header> <!-- ================================================================ CONTENT ================================================================= --> <main class="pr-content"> <!-- ============================================================ FLASH ============================================================= --> <?php if ($flash): ?> <div class="pr-alert <?= pr_e($flash['type']) ?>"> <i class="fa-solid <?= $flash['type'] === 'success' ? 'fa-circle-check' : 'fa-circle-exclamation' ?>"> </i> <span> <?= pr_e($flash['message']) ?> </span> <button type="button" onclick="this.parentElement.remove()" > <i class="fa-solid fa-xmark"></i> </button> </div> <?php endif; ?> <!-- ============================================================ STATS ============================================================= --> <section class="pr-stats"> <div class="pr-stat"> <div class="pr-stat-icon"> <i class="fa-solid fa-clock-rotate-left"></i> </div> <div class="pr-stat-value"> <?= number_format($stats['total']) ?> </div> <div class="pr-stat-label"> Total Revisions </div> </div> <div class="pr-stat"> <div class="pr-stat-icon"> <i class="fa-solid fa-file-lines"></i> </div> <div class="pr-stat-value"> <?= number_format($stats['pages']) ?> </div> <div class="pr-stat-label"> Pages With Revisions </div> </div> <div class="pr-stat"> <div class="pr-stat-icon"> <i class="fa-solid fa-users"></i> </div> <div class="pr-stat-value"> <?= number_format($stats['users']) ?> </div> <div class="pr-stat-label"> Revision Users </div> </div> <div class="pr-stat"> <div class="pr-stat-icon"> <i class="fa-solid fa-calendar-day"></i> </div> <div class="pr-stat-value"> <?= number_format($stats['today']) ?> </div> <div class="pr-stat-label"> Created Today </div> </div> </section> <!-- ============================================================ ADD / EDIT ============================================================= --> <section class="pr-card"> <div class="pr-card-header"> <div class="pr-card-title"> <div class="pr-card-title-icon"> <i class="fa-solid <?= $editRecord ? 'fa-pen-to-square' : 'fa-plus' ?>"> </i> </div> <div> <h2> <?= $editRecord ? 'Edit Page Revision' : 'Create Page Revision' ?> </h2> <p> Save a page version and its section snapshot </p> </div> </div> <?php if ($editRecord): ?> <a href="page_revisions.php" class="pr-btn pr-btn-light" > <i class="fa-solid fa-xmark"></i> Cancel Edit </a> <?php endif; ?> </div> <form method="post" action="page_revisions.php" class="pr-form" > <input type="hidden" name="csrf_token" value="<?= pr_e($csrfToken) ?>" > <input type="hidden" name="action" value="save" > <input type="hidden" name="id" value="<?= $editRecord ? (int)$editRecord['id'] : 0 ?>" > <div class="pr-form-grid"> <!-- PAGE --> <div class="pr-field span-6"> <label> Page <span class="pr-required">*</span> </label> <select name="page_id" class="pr-select" required > <option value=""> Select Page </option> <?php foreach ($pages as $page): ?> <option value="<?= (int)$page['id'] ?>" <?= ( $editRecord && (int)$editRecord['page_id'] === (int)$page['id'] ) ? 'selected' : '' ?> > <?= pr_e($page['title']) ?> <?php if (!empty($page['slug'])): ?> — <?= pr_e($page['slug']) ?> <?php endif; ?> </option> <?php endforeach; ?> </select> <div class="pr-help"> The revision will belong to this existing page. </div> </div> <!-- USER --> <div class="pr-field span-6"> <label> Revision User </label> <select name="user_id" class="pr-select" > <option value=""> System / No User </option> <?php foreach ($users as $user): ?> <option value="<?= (int)$user['id'] ?>" <?= ( $editRecord && $editRecord['user_id'] !== null && (int)$editRecord['user_id'] === (int)$user['id'] ) ? 'selected' : '' ?> > <?php $displayUser = ''; if (!empty($user['name'])) { $displayUser = $user['name']; } elseif (!empty($user['email'])) { $displayUser = $user['email']; } else { $displayUser = 'User #' . (int)$user['id']; } ?> <?= pr_e($displayUser) ?> <?php if ( !empty($user['email']) && !empty($user['name']) ): ?> — <?= pr_e($user['email']) ?> <?php endif; ?> </option> <?php endforeach; ?> </select> <div class="pr-help"> Optional. Links this revision to an existing user. </div> </div> <!-- TITLE --> <div class="pr-field span-8"> <label> Revision Title </label> <input type="text" name="title" class="pr-input" maxlength="255" value="<?= pr_e( $editRecord['title'] ?? '' ) ?>" placeholder="Example: Homepage content update" > </div> <!-- NOTE --> <div class="pr-field span-4"> <label> Revision Note </label> <input type="text" name="revision_note" class="pr-input" maxlength="500" value="<?= pr_e( $editRecord['revision_note'] ?? '' ) ?>" placeholder="What changed?" > </div> <!-- CONTENT --> <div class="pr-field span-12"> <label> Content Snapshot </label> <textarea name="content" class="pr-textarea large" placeholder="Enter the page content snapshot..." ><?= pr_e( $editRecord['content'] ?? '' ) ?></textarea> <div class="pr-help"> Stored in the existing <strong>content</strong> LONGTEXT column. </div> </div> <!-- SECTIONS SNAPSHOT --> <div class="pr-field span-12"> <label> Sections Snapshot </label> <textarea name="sections_snapshot" class="pr-textarea large" placeholder='Optional JSON or text snapshot of page sections...' ><?= pr_e( $editRecord['sections_snapshot'] ?? '' ) ?></textarea> <div class="pr-help"> Existing <strong>sections_snapshot</strong> LONGTEXT column. JSON is supported but not required. </div> </div> </div> <div class="pr-form-actions"> <?php if ($editRecord): ?> <a href="page_revisions.php" class="pr-btn pr-btn-light" > <i class="fa-solid fa-rotate-left"></i> Reset </a> <?php endif; ?> <button type="submit" class="pr-btn pr-btn-primary" > <i class="fa-solid <?= $editRecord ? 'fa-floppy-disk' : 'fa-plus' ?>"> </i> <?= $editRecord ? 'Update Revision' : 'Create Revision' ?> </button> </div> </form> </section> <!-- ============================================================ LIST ============================================================= --> <section class="pr-card"> <div class="pr-card-header"> <div class="pr-card-title"> <div class="pr-card-title-icon"> <i class="fa-solid fa-list"></i> </div> <div> <h2> Revision History </h2> <p> <?= number_format($totalRows) ?> matching revision<?= $totalRows == 1 ? '' : 's' ?> </p> </div> </div> </div> <!-- ======================================================== FILTERS ========================================================= --> <form method="get" action="page_revisions.php" class="pr-filter" > <div class="pr-filter-grid"> <!-- SEARCH --> <div class="pr-search"> <i class="fa-solid fa-magnifying-glass"></i> <input type="text" name="search" class="pr-input" value="<?= pr_e($search) ?>" placeholder="Search page, revision, user, content..." > </div> <!-- PAGE --> <select name="page_id" class="pr-select" > <option value=""> All Pages </option> <?php foreach ($pages as $page): ?> <option value="<?= (int)$page['id'] ?>" <?= $filterPage === (int)$page['id'] ? 'selected' : '' ?> > <?= pr_e($page['title']) ?> </option> <?php endforeach; ?> </select> <!-- USER --> <select name="user_id" class="pr-select" > <option value=""> All Users </option> <?php foreach ($users as $user): ?> <?php $userLabel = ''; if (!empty($user['name'])) { $userLabel = $user['name']; } elseif (!empty($user['email'])) { $userLabel = $user['email']; } else { $userLabel = 'User #' . (int)$user['id']; } ?> <option value="<?= (int)$user['id'] ?>" <?= $filterUser === (int)$user['id'] ? 'selected' : '' ?> > <?= pr_e($userLabel) ?> </option> <?php endforeach; ?> </select> <!-- DATE FROM --> <input type="date" name="date_from" class="pr-input" value="<?= pr_e($dateFrom) ?>" title="Created from" > <!-- ACTIONS --> <div style="display:flex;gap:7px;"> <button type="submit" class="pr-btn pr-btn-primary" > <i class="fa-solid fa-filter"></i> Filter </button> <a href="page_revisions.php" class="pr-btn pr-btn-light" title="Reset filters" > <i class="fa-solid fa-rotate-left"></i> </a> </div> </div> <!-- DATE TO --> <div style=" display:flex; justify-content:flex-end; margin-top:10px; " > <div style=" width:calc(25% - 8px); min-width:160px; " > <input type="date" name="date_to" class="pr-input" value="<?= pr_e($dateTo) ?>" title="Created to" > </div> </div> </form> <!-- ======================================================== TABLE ========================================================= --> <?php if (!empty($records)): ?> <div class="pr-table-wrap"> <table class="pr-table"> <thead> <tr> <th> ID </th> <th> Page </th> <th> Revision </th> <th> User </th> <th> Revision Note </th> <th> Created </th> <th> Actions </th> </tr> </thead> <tbody> <?php foreach ($records as $record): ?> <tr> <!-- ID --> <td> <span class="pr-id"> #<?= (int)$record['id'] ?> </span> </td> <!-- PAGE --> <td> <div class="pr-page-cell"> <div class="pr-page-icon-small"> <i class="fa-solid fa-file-lines"></i> </div> <div> <div class="pr-page-name"> <?= pr_e( $record['page_title'] ?? 'Untitled Page' ) ?> </div> <?php if ( !empty($record['page_slug']) ): ?> <div class="pr-slug"> / <?= pr_e( ltrim( $record['page_slug'], '/' ) ) ?> </div> <?php endif; ?> </div> </div> </td> <!-- REVISION --> <td> <div class="pr-revision-title"> <?= pr_e( $record['title'] ?: 'Untitled Revision' ) ?> </div> <div class="pr-content-preview"> <?= pr_e( pr_content_excerpt( $record['content'] ?? '', 115 ) ) ?> </div> </td> <!-- USER --> <td> <div class="pr-user"> <div class="pr-user-avatar"> <i class="fa-solid fa-user"></i> </div> <div> <?php if ( !empty($record['user_name']) ): ?> <div class="pr-user-name"> <?= pr_e( $record['user_name'] ) ?> </div> <?php if ( !empty( $record['user_email'] ) ): ?> <div class="pr-user-email"> <?= pr_e( $record['user_email'] ) ?> </div> <?php endif; ?> <?php elseif ( !empty($record['user_email']) ): ?> <div class="pr-user-name"> <?= pr_e( $record['user_email'] ) ?> </div> <?php else: ?> <div class="pr-user-name"> System </div> <div class="pr-user-email"> No user linked </div> <?php endif; ?> </div> </div> </td> <!-- NOTE --> <td> <div class="pr-note"> <?= pr_e( $record['revision_note'] ?: 'No revision note' ) ?> </div> </td> <!-- CREATED --> <td> <div class="pr-date"> <?= pr_e( pr_format_date( $record['created_at'] ) ) ?> </div> </td> <!-- ACTIONS --> <td> <div class="pr-actions"> <!-- VIEW --> <a href="page_revisions.php?view=<?= (int)$record['id'] ?>" class="pr-icon-btn" title="View revision" > <i class="fa-solid fa-eye"></i> </a> <!-- EDIT --> <a href="page_revisions.php?edit=<?= (int)$record['id'] ?>" class="pr-icon-btn" title="Edit revision" > <i class="fa-solid fa-pen"></i> </a> <!-- DELETE --> <form method="post" style="display:inline;" onsubmit="return confirmRevisionDelete();" > <input type="hidden" name="csrf_token" value="<?= pr_e( $csrfToken ) ?>" > <input type="hidden" name="action" value="delete" > <input type="hidden" name="id" value="<?= (int)$record['id'] ?>" > <button type="submit" class="pr-icon-btn danger" title="Delete revision" > <i class="fa-solid fa-trash"></i> </button> </form> </div> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <!-- ==================================================== PAGINATION ===================================================== --> <div class="pr-pagination"> <div class="pr-pagination-info"> Showing <strong> <?= $totalRows > 0 ? number_format($offset + 1) : 0 ?> </strong> to <strong> <?= min( $offset + $perPage, $totalRows ) ?> </strong> of <strong> <?= number_format($totalRows) ?> </strong> revisions </div> <div class="pr-pagination-links"> <?php $prevQuery = pr_page_url_params([ 'p' => max( 1, $currentPage - 1 ) ]); ?> <a href="?<?= pr_e($prevQuery) ?>" class="pr-page-link <?= $currentPage <= 1 ? 'disabled' : '' ?>" > <i class="fa-solid fa-chevron-left"></i> </a> <?php $startPage = max( 1, $currentPage - 2 ); $endPage = min( $totalPages, $currentPage + 2 ); for ( $pageNumber = $startPage; $pageNumber <= $endPage; $pageNumber++ ): $pageQuery = pr_page_url_params([ 'p' => $pageNumber ]); ?> <a href="?<?= pr_e($pageQuery) ?>" class="pr-page-link <?= $pageNumber === $currentPage ? 'active' : '' ?>" > <?= $pageNumber ?> </a> <?php endfor; ?> <?php $nextQuery = pr_page_url_params([ 'p' => min( $totalPages, $currentPage + 1 ) ]); ?> <a href="?<?= pr_e($nextQuery) ?>" class="pr-page-link <?= $currentPage >= $totalPages ? 'disabled' : '' ?>" > <i class="fa-solid fa-chevron-right"></i> </a> </div> </div> <?php else: ?> <!-- ==================================================== EMPTY ===================================================== --> <div class="pr-empty"> <div class="pr-empty-icon"> <i class="fa-solid fa-clock-rotate-left"></i> </div> <h3> No page revisions found </h3> <p> Create your first page revision using the form above. </p> </div> <?php endif; ?> </section> </main> </div> <!-- ================================================================ VIEW REVISION MODAL ================================================================= --> <?php if ($viewRecord): ?> <div class="pr-modal show" id="revisionViewModal" onclick="closeRevisionModal(event)" > <div class="pr-modal-box" onclick="event.stopPropagation()" > <div class="pr-modal-header"> <div> <h3> <i class="fa-solid fa-clock-rotate-left" style=" color:var(--pr-primary); margin-right:7px; " ></i> Revision #<?= (int)$viewRecord['id'] ?> </h3> </div> <button type="button" class="pr-modal-close" onclick="closeRevisionModal()" > <i class="fa-solid fa-xmark"></i> </button> </div> <div class="pr-modal-body"> <div class="pr-view-grid"> <!-- PAGE --> <div class="pr-view-item"> <div class="pr-view-label"> Page </div> <div class="pr-view-value"> <?= pr_e( $viewRecord['page_title'] ?? 'Untitled Page' ) ?> </div> </div> <!-- SLUG --> <div class="pr-view-item"> <div class="pr-view-label"> Slug </div> <div class="pr-view-value"> <?= $viewRecord['page_slug'] ? '/' . pr_e( ltrim( $viewRecord['page_slug'], '/' ) ) : '—' ?> </div> </div> <!-- TITLE --> <div class="pr-view-item"> <div class="pr-view-label"> Revision Title </div> <div class="pr-view-value"> <?= pr_e( $viewRecord['title'] ?: 'Untitled Revision' ) ?> </div> </div> <!-- USER --> <div class="pr-view-item"> <div class="pr-view-label"> Created By </div> <div class="pr-view-value"> <?php if ( !empty($viewRecord['user_name']) ): ?> <?= pr_e( $viewRecord['user_name'] ) ?> <?php if ( !empty( $viewRecord['user_email'] ) ): ?> <span style=" color:#94a3b8; font-weight:500; " > — <?= pr_e( $viewRecord['user_email'] ) ?> </span> <?php endif; ?> <?php elseif ( !empty($viewRecord['user_email']) ): ?> <?= pr_e( $viewRecord['user_email'] ) ?> <?php else: ?> System / No User <?php endif; ?> </div> </div> <!-- DATE --> <div class="pr-view-item"> <div class="pr-view-label"> Created At </div> <div class="pr-view-value"> <?= pr_e( pr_format_date( $viewRecord['created_at'] ) ) ?> </div> </div> <!-- NOTE --> <div class="pr-view-item"> <div class="pr-view-label"> Revision Note </div> <div class="pr-view-value"> <?= pr_e( $viewRecord['revision_note'] ?: 'No revision note' ) ?> </div> </div> </div> <!-- CONTENT --> <div class="pr-view-section"> <div class="pr-view-section-title"> <i class="fa-solid fa-file-lines"></i> Content Snapshot </div> <?php if ( !empty($viewRecord['content']) ): ?> <div class="pr-content-box"> <?= nl2br( pr_e( $viewRecord['content'] ) ) ?> </div> <?php else: ?> <div class="pr-content-box"> No content snapshot stored. </div> <?php endif; ?> </div> <!-- SECTIONS --> <div class="pr-view-section"> <div class="pr-view-section-title"> <i class="fa-solid fa-layer-group"></i> Sections Snapshot </div> <?php if ( !empty( $viewRecord['sections_snapshot'] ) ): ?> <?php $prettySections = pr_json_pretty( $viewRecord['sections_snapshot'] ); ?> <pre class="pr-code"><?= pr_e( $prettySections ) ?></pre> <?php else: ?> <div class="pr-content-box"> No sections snapshot stored. </div> <?php endif; ?> </div> </div> </div> </div> <?php endif; ?> <!-- ================================================================ JAVASCRIPT ================================================================= --> <script> /* |-------------------------------------------------------------------------- | Delete confirmation |-------------------------------------------------------------------------- */ function confirmRevisionDelete() { return confirm( "Are you sure you want to delete this page revision?\n\n" + "This action cannot be undone." ); } /* |-------------------------------------------------------------------------- | Modal close |-------------------------------------------------------------------------- */ function closeRevisionModal(event) { if ( event && event.target && event.target.id !== 'revisionViewModal' ) { return; } window.location.href = 'page_revisions.php' + window.location.search .replace( /([?&])view=\d+/, '' ) .replace( /^&/, '?' ); } /* |-------------------------------------------------------------------------- | Escape key |-------------------------------------------------------------------------- */ document.addEventListener( 'keydown', function(event) { if ( event.key === 'Escape' ) { const modal = document.getElementById( 'revisionViewModal' ); if (modal) { closeRevisionModal(); } } } ); /* |-------------------------------------------------------------------------- | Auto-hide flash |-------------------------------------------------------------------------- */ setTimeout( function() { const alert = document.querySelector( '.pr-alert' ); if (!alert) { return; } alert.style.transition = 'opacity .3s ease, transform .3s ease'; alert.style.opacity = '0'; alert.style.transform = 'translateY(-5px)'; setTimeout( function() { if (alert.parentNode) { alert.remove(); } }, 320 ); }, 4500 ); </script> </body> </html>
Save
Cancel