feat: add privacy policy, terms, and animated landing page
This commit is contained in:
@@ -19,11 +19,14 @@ class AdminController
|
||||
private User $userModel;
|
||||
private AuditService $auditService;
|
||||
|
||||
private Database $db;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->view = App::getInstance()->getView();
|
||||
$this->userModel = new User();
|
||||
$this->auditService = new AuditService();
|
||||
$this->db = Database::getInstance();
|
||||
}
|
||||
|
||||
private function requireSuperAdmin(): void
|
||||
@@ -325,4 +328,39 @@ class AdminController
|
||||
|
||||
$this->view->json(['success' => true, 'message' => 'Notification sent successfully.' . $pushResult]);
|
||||
}
|
||||
|
||||
public function policies(): void
|
||||
{
|
||||
$this->requireSuperAdmin();
|
||||
|
||||
$configs = $this->db->fetchAll('SELECT `key`, `value` FROM app_config WHERE `key` IN (?, ?)', ['privacy_policy', 'terms_conditions']);
|
||||
$values = [];
|
||||
foreach ($configs as $row) {
|
||||
$values[$row['key']] = $row['value'];
|
||||
}
|
||||
|
||||
$this->view->display('admin.policies', [
|
||||
'title' => 'Legal Policies - ServerManager',
|
||||
'privacy' => $values['privacy_policy'] ?? '',
|
||||
'terms' => $values['terms_conditions'] ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
public function savePolicies(): void
|
||||
{
|
||||
$this->requireSuperAdmin();
|
||||
|
||||
if (isset($_POST['privacy_policy'])) {
|
||||
$this->db->update('app_config', ['value' => $_POST['privacy_policy']], '`key` = ?', ['privacy_policy']);
|
||||
}
|
||||
|
||||
if (isset($_POST['terms_conditions'])) {
|
||||
$this->db->update('app_config', ['value' => $_POST['terms_conditions']], '`key` = ?', ['terms_conditions']);
|
||||
}
|
||||
|
||||
$this->auditService->log('policies_updated', 'config', null, ['details' => 'Legal policies updated']);
|
||||
|
||||
Session::setFlash('success', 'Policies saved successfully.');
|
||||
$this->view->redirect('/admin/policies');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace ServerManager\Controllers;
|
||||
|
||||
use ServerManager\Core\App;
|
||||
use ServerManager\Core\Database;
|
||||
use ServerManager\Core\Session;
|
||||
use ServerManager\Models\Server;
|
||||
use ServerManager\Models\Notification;
|
||||
@@ -24,6 +25,28 @@ class DashboardController
|
||||
$this->auditService = new AuditService();
|
||||
}
|
||||
|
||||
public function landing(): void
|
||||
{
|
||||
if (Session::has('user_id')) {
|
||||
$this->view->redirect('/dashboard');
|
||||
}
|
||||
|
||||
$stats = [];
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
$stats['servers'] = $db->fetch('SELECT COUNT(*) as count FROM servers')['count'] ?? 0;
|
||||
$stats['users'] = $db->fetch('SELECT COUNT(*) as count FROM users')['count'] ?? 0;
|
||||
$stats['online_servers'] = $db->fetch("SELECT COUNT(*) as count FROM servers WHERE current_status = 'online'")['count'] ?? 0;
|
||||
} catch (\Throwable) {
|
||||
$stats = ['servers' => 0, 'users' => 0, 'online_servers' => 0];
|
||||
}
|
||||
|
||||
$this->view->setLayout('auth')->display('pages.landing', [
|
||||
'title' => 'ServerManager - Linux Server Management Platform',
|
||||
'stats' => $stats,
|
||||
]);
|
||||
}
|
||||
|
||||
public function index(): void
|
||||
{
|
||||
$serverModel = new Server();
|
||||
@@ -82,6 +105,30 @@ class DashboardController
|
||||
]);
|
||||
}
|
||||
|
||||
public function privacy(): void
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
$row = $db->fetch('SELECT `value` FROM app_config WHERE `key` = ?', ['privacy_policy']);
|
||||
$content = $row ? $row['value'] : '';
|
||||
|
||||
$this->view->setLayout('auth')->display('pages.privacy', [
|
||||
'title' => 'Privacy Policy - ServerManager',
|
||||
'content' => $content,
|
||||
]);
|
||||
}
|
||||
|
||||
public function terms(): void
|
||||
{
|
||||
$db = Database::getInstance();
|
||||
$row = $db->fetch('SELECT `value` FROM app_config WHERE `key` = ?', ['terms_conditions']);
|
||||
$content = $row ? $row['value'] : '';
|
||||
|
||||
$this->view->setLayout('auth')->display('pages.terms', [
|
||||
'title' => 'Terms & Conditions - ServerManager',
|
||||
'content' => $content,
|
||||
]);
|
||||
}
|
||||
|
||||
public function notifications(): void
|
||||
{
|
||||
$userId = (int) Session::get('user_id');
|
||||
|
||||
Reference in New Issue
Block a user