require_once '../../../../init.php';
use WHMCS\Database\Capsule;
session_start();
if (!isset($_SESSION['adminid'])) {
header('Location: /admin/login.php?redirect=addonmodules.php%3Fmodule%3Dticketspamcheck');
exit;
}
function get_ticket_language_setting() {
$result = Capsule::table('tblticketspamcheckdashboardsettings')
->select('language')
->first();
return $result ? $result->language : 'en';
}
function load_translation($language) {
$filePath = _DIR_ . "/translations/{$language}.php";
if (file_exists($filePath)) {
return include $filePath;
}
return include _DIR_ . "/translations/en.php";
}
$language = get_ticket_language_setting();
$translations = load_translation($language);
$settingsTitle = $translations['settings_title'];
$home = $translations['home'];
$spamReports = $translations['spam_reports'];
$settings = $translations['settings'];
$settingsHeader = $translations['settings_header'];
$select_language = $translations['select_language'];
$saveSettings = $translations['save_settings'];
$saveUpdatemessage = $translations['settings_update_message'];
$leaveDashboard = $translations['leave_dashboard'];
$currentSetting = Capsule::table('tblticketspamcheckdashboardsettings')->first();
$currentLanguage = $currentSetting ? $currentSetting->language : 'en';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$language = $_POST['language'] ?? 'en';
if ($currentSetting) {
Capsule::table('tblticketspamcheckdashboardsettings')
->where('id', $currentSetting->id)
->update(['language' => $language]);
} else {
Capsule::table('tblticketspamcheckdashboardsettings')->insert(['language' => $language]);
}
header('Location: settings.php?success=1');
exit;
}
<!DOCTYPE html>
<html lang="echo $currentLanguage;">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>echo htmlspecialchars($settingsTitle);</title>
<link rel="icon" href="https://i.imgur.com/9ssrqfO.png" type="image/png">
<style>
:root {
--bg-color: #f0f0f0;
--text-color: #333;
--sidebar-bg-color: #333;
--sidebar-text-color: white;
--link-hover-color: #575757;
--button-bg-color: #007BFF;
--header-bg-color: #fff;
--header-text-color: #333;
--container-bg-color: white;
--container-border-color: #ccc;
}
.dark-theme {
--bg-color: #121212;
--text-color: #fff;
--sidebar-bg-color: #1e1e1e;
--sidebar-text-color: #bbb;
--link-hover-color: #3e3e3e;
--button-bg-color: #1e90ff;
--header-bg-color: #1e1e1e;
--header-text-color: #fff;
--container-bg-color: #1e1e1e;
--container-border-color: #444;
}
body {
font-family: Arial, sans-serif;
margin: 0;
height: 100vh;
display: flex;
background-color: var(--bg-color);
color: var(--text-color);
transition: background-color 0.3s, color 0.3s;
}
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 60px;
background-color: var(--header-bg-color);
color: var(--header-text-color);
padding: 0 20px;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s, color 0.3s;
z-index: 1000;
}
.header h1 {
margin: 0;
font-size: 22px;
}
.theme-toggle {
cursor: pointer;
padding: 10px;
background-color: transparent;
border: none;
font-size: 24px;
color: var(--header-text-color);
transition: color 0.3s;
}
.sidebar {
position: fixed;
top: 60px;
left: 0;
bottom: 0;
width: 250px;
background-color: var(--sidebar-bg-color);
color: var(--sidebar-text-color);
padding: 20px;
display: flex;
flex-direction: column;
transition: background-color 0.3s, color 0.3s;
z-index: 999;
}
.sidebar a {
color: var(--sidebar-text-color);
text-decoration: none;
padding: 10px 15px;
margin-bottom: 10px;
border-radius: 4px;
display: flex;
align-items: center;
transition: background 0.3s, color 0.3s;
}
.sidebar a:hover {
background-color: var(--link-hover-color);
}
.sidebar a i {
margin-right: 10px;
}
.content {
margin-left: 300px;
margin-top: 80px;
padding: 20px;
flex-grow: 1;
transition: background-color 0.3s, color 0.3s;
}
.form-container {
background-color: var(--container-bg-color);
border: 1px solid var(--container-border-color);
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 20px;
width: 100%;
max-width: 600px;
margin-top: 20px;
}
label {
display: block;
margin-bottom: 5px;
}
select {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border-radius: 4px;
border: 1px solid #ccc;
transition: border-color 0.3s, box-shadow 0.3s;
background-color: #fff;
appearance: none;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
background-repeat: no-repeat;
background-position: right 10px center;
background-size: 10px;
}
select:focus {
border-color: #007BFF;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
outline: none;
}
.save-button {
padding: 10px 15px;
background-color: var(--button-bg-color);
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
width: 100%;
}
.save-button:hover {
background-color: #0056b3;
}
.success-message {
margin: 10px 0;
padding: 10px;
background-color: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
border-radius: 4px;
display: block;
}
.dark-theme .success-message {
background-color: #3c763d;
color: #fff;
border-color: #d6e9c6;
}
.footer {
background-color: var(--header-bg-color);
color: var(--header-text-color);
text-align: center;
padding: 10px;
font-size: 14px;
position: fixed;
bottom: 0;
left: 0;
right: 0;
box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
<div class="header">
<h1>echo htmlspecialchars($settingsTitle);</h1>
<button class="theme-toggle" onclick="toggleTheme()">
<i id="theme-icon" class="fas fa-moon"></i>
</button>
</div>
<div class="sidebar">
<a href="/modules/addons/ticketspamcheck/dashboard/home.php">echo htmlspecialchars($home);</a>
<a href="/modules/addons/ticketspamcheck/dashboard/spamreports.php">echo htmlspecialchars($spamReports);</a>
<a href="/modules/addons/ticketspamcheck/dashboard/settings.php">echo htmlspecialchars($settings);</a>
<a href="/admin/addonmodules.php?module=ticketspamcheck">echo htmlspecialchars($leaveDashboard);</a>
</div>
<div class="content">
<h1>echo htmlspecialchars($settingsHeader);</h1>
if (isset($_GET['success']) && $_GET['success'] == 1):
<div class="success-message" id="success-message">echo htmlspecialchars($saveUpdatemessage);</div>
endif;
<div class="form-container">
<form method="post">
<label for="language">echo htmlspecialchars($select_language);</label>
<select name="language" id="language">
foreach ($languages as $langCode => $langName):
<option value="echo htmlspecialchars($langCode);" echo $currentLanguage === $langCode ? 'selected' : '';>
echo htmlspecialchars($langName);
</option>
endforeach;
</select>
<button type="submit" class="save-button">echo htmlspecialchars($saveSettings);</button>
</form>
</div>
</div>
<div class="footer">
<p>© 2024 - echo date('Y'); Ricardo Neud. All rights reserved.</p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/js/all.min.js"></script>
<script>
setTimeout(function() {
const successMessage = document.getElementById('success-message');
if (successMessage) {
successMessage.style.display = 'none';
}
}, 5000);
</script>
<script>
function toggleTheme() {
const themeIcon = document.getElementById('theme-icon');
let theme = 'light';
if (localStorage.getItem('theme') === 'dark') {
document.body.classList.remove('dark-theme');
themeIcon.classList.remove('fa-sun');
themeIcon.classList.add('fa-moon');
theme = 'light';
} else {
document.body.classList.add('dark-theme');
themeIcon.classList.remove('fa-moon');
themeIcon.classList.add('fa-sun');
theme = 'dark';
}
localStorage.setItem('theme', theme);
fetch('', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
'theme': theme
})
})
.then(response => response.json())
.then(data => {
console.log('Theme updated:', data.theme);
})
.catch(error => {
console.error('Error updating theme:', error);
});
}
document.addEventListener('DOMContentLoaded', () => {
const savedTheme = localStorage.getItem('theme');
const themeIcon = document.getElementById('theme-icon');
if (savedTheme === 'dark') {
document.body.classList.add('dark-theme');
themeIcon.classList.remove('fa-moon');
themeIcon.classList.add('fa-sun');
} else {
document.body.classList.remove('dark-theme');
themeIcon.classList.remove('fa-sun');
themeIcon.classList.add('fa-moon');
}
});
</script>
</body>
</html>
© 2023 Quttera Ltd. All rights reserved.