-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.php
106 lines (88 loc) · 4.06 KB
/
mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
require "php/db.php";
include_once "php/functions.php";
if (array_key_exists('logged_user', $_SESSION) and $_SESSION['logged_user']->user_status < 3) {
$data_get = $_GET;
$data_post = $_POST;
$errors = array();
if (isset($data_post['do_send'])) {
if ($data_post['subject'] == '')
$errors[] = 'Має бути написана тема повідомлення';
if ($data_post['message'] == '')
$errors[] = 'Повідомлення не може бути пустим';
if (!$errors) {
$user = R::findOne('users', 'id = ?', array($data_post['to']));
mail($user['email'], $data_post['subject'], $data_post['message'], 'From: [email protected]');
echo "<script>window.close()</script>>";
}
} elseif (!array_key_exists('id', $data_get)) {
header("location: index.php");
}
} else {
header("location: index.php");
}
?>
<!DOCTYPE html>
<html lang="ua">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Відправити Email | StepHub</title>
<link rel="shortcut icon" href="favicon.ico">
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Google Material Design Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Font Awesome Icons -->
<link href="vendor/fontawesome-free-5.9.0-web/css/all.css" rel="stylesheet">
<!--load all styles -->
<link href="css/main.css" rel="stylesheet">
</head>
<body class="text-center">
<!-- Preloader -->
<?php include_once 'templates/preloader.html'; ?>
<!-- Navigation -->
<?php include_once 'templates/navbar.php'; ?>
<!-- Errors -->
<?php include_once "templates/errors.php"; ?>
<!-- Page Content -->
<div class="container pt-5 d-none d-md-block">
<div class="card mt-0 shadow-sm">
<form action="mail.php" method="POST" class="form-group mb-0">
<div class="card-header diagonal-gradient-gray my-color-dark border-bottom-0">
<div class="container">
<div class="row pb-2 pt-sm-2">
<input type="text" name="to" class="form-control" value="<?= $data_get ? $data_get['id'] : $data_post['to'] ?>" hidden>
<input type="text" name="subject" id="mail_subject" value="<?= $data_post ? $data_post['subject'] : '' ?>" class="form-control form-control-lg my-bg-light my-color-dark" placeholder="Заголовок">
</div>
</div>
</div>
<div class="card-body">
<textarea name="message" id="mail_message" cols="30" rows="10" class="form-control" value="<?= $data_post ? $data_post['message'] : '' ?>" placeholder="Повідомлення"></textarea>
</div>
<div class="card-footer p-3">
<div class="row px-3">
<button type="submit" name="do_send" class="btn my-btn-dark ml-auto">Відправити</button>
</div>
</div>
</form>
</div>
</div>
<!-- Mobile Does not Suppported -->
<div class="container-fluid d-md-none p-3">
<div class="alert alert-danger shadow-sm" role="alert">
<p>Сторінка відправки листа не доступна в мобільній версії сайту.</p>
<a href="index.php"> Повернутись на головну сторінку</a>
</div>
</div>
<!-- Footer -->
<?php include_once 'templates/footer.php'; ?>
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Main sctipt -->
<script src="js/script.js"></script>
</body>
</html>