Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 5m27s
129 lines
4.6 KiB
PHP
129 lines
4.6 KiB
PHP
<?php
|
|
require_once 'includes/globals.php';
|
|
|
|
// Initialize auto-fill variables
|
|
$userName = '';
|
|
$userEmail = '';
|
|
|
|
// Check if user details are available in the session
|
|
if (isset($_SESSION['user'])) {
|
|
$userName = $_SESSION['user']['firstName'] . ' ' . $_SESSION['user']['lastName'];
|
|
$userEmail = $_SESSION['user']['email'];
|
|
}
|
|
|
|
require_once 'vendor/autoload.php';
|
|
|
|
use DJMixHosting\Telegram;
|
|
|
|
if ($_POST) {
|
|
$formName = $_POST['name'];
|
|
if ($formName != $userName) {
|
|
$name = $userName . " (Orig: " . $formName . ")";
|
|
} else {
|
|
$name = $formName;
|
|
}
|
|
$formEmail = $_POST['email'];
|
|
if ($formEmail != $userEmail) {
|
|
$email = $userEmail . " (Orig: " . $formEmail . ")";
|
|
} else {
|
|
$email = $userEmail;
|
|
}
|
|
$message = $_POST['message'];
|
|
$ipAddress = $_SERVER['REMOTE_ADDR'];
|
|
require_once 'classes/Telegram.php';
|
|
$telegram = new Telegram($config['notifications']['telegram']['token'], $config['notifications']['telegram']['chat_id']);
|
|
$result = $telegram->send_message("Name: $name\nEmail: $email\nIP Address: $ipAddress\nMessage: $message");
|
|
}
|
|
$title = $locale['contactus'];
|
|
require_once 'includes/header.php';
|
|
?>
|
|
|
|
<!-- Custom CSS -->
|
|
<style>
|
|
|
|
.contact-form {
|
|
border-radius: 15px;
|
|
box-shadow: 0 0 20px rgba(0,0,0,0.1);
|
|
padding: 2rem;
|
|
}
|
|
|
|
.form-control:focus {
|
|
border-color: #0d6efd;
|
|
box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
|
|
}
|
|
|
|
.social-links a {
|
|
color: #6c757d;
|
|
margin: 0 10px;
|
|
transition: color 0.3s ease;
|
|
}
|
|
|
|
.social-links a:hover {
|
|
color: #0d6efd;
|
|
}
|
|
|
|
</style>
|
|
|
|
<?php if ($_POST): ?>
|
|
<div class="position-fixed top-0 start-50 translate-middle-x p-3" style="z-index: 1000">
|
|
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
|
|
<div class="toast-header <?php echo $result['ok'] ? 'bg-success' : 'bg-danger'; ?> text-white">
|
|
<strong class="me-auto">Notification</strong>
|
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
</div>
|
|
<div class="toast-body">
|
|
<?php echo $result['ok'] ? $locale['messageSentSuccess'] : $locale['messageSentError']; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Breadcrumb -->
|
|
<section>
|
|
<div class="container py-3">
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb mb-0">
|
|
<li class="breadcrumb-item"><a href="/" class="text-decoration-none"><?php echo $locale['home']; ?></a></li>
|
|
<li class="breadcrumb-item active"><?php echo $locale['contactus']; ?></li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Contact Section -->
|
|
<div class="container py-5">
|
|
<!-- Header -->
|
|
<div class="row mb-5 text-center">
|
|
<div class="col-lg-8 mx-auto">
|
|
<h1 class="display-4 mb-3"><?php echo $locale['contactus']; ?></h1>
|
|
<p class="lead text-muted"><?php echo $locale['contactUs2']; ?></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<!-- Contact Form -->
|
|
<div class="col mb-lg-0">
|
|
<div class="contact-form">
|
|
<h3 class="mb-4"><?php echo $locale['messageSendUs']; ?></h3>
|
|
<form action="/contact" method="post">
|
|
<div class="mb-4">
|
|
<label for="name" class="form-label"><?php echo $locale['name']; ?></label>
|
|
<input type="text" class="form-control form-control-lg" id="name" name="name" value="<?php echo htmlspecialchars($userName); ?>" required>
|
|
</div>
|
|
<div class="mb-4">
|
|
<label for="email" class="form-label"><?php echo $locale['email']; ?></label>
|
|
<input type="email" class="form-control form-control-lg" id="email" name="email" value="<?php echo htmlspecialchars($userEmail); ?>" required>
|
|
</div>
|
|
<div class="mb-4">
|
|
<label for="message" class="form-label"><?php echo $locale['message']; ?></label>
|
|
<textarea class="form-control form-control-lg" id="message" name="message" rows="5" required></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary btn-lg px-5"><?php echo $locale['messageSend']; ?></button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once 'includes/footer.php'; ?>
|