forked from syphon1c/dracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_smtp.php
executable file
·130 lines (111 loc) · 4.39 KB
/
edit_smtp.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* Description of edit_smtp.php
* version: 1.0
* package: Dracker - Track and Trace
* copyright: Copyright (C) 2013 Gareth Phillips. All rights reserved.
* license: GNU/GPL, see license.htm.
*
* This file is part of the Dracker project.
*
* Dracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, under version 3 of the License.
*
* Dracker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dracker. If not, see <http://www.gnu.org/licenses/>.
*
* @author GPhillips
**/
include_once 'configs/DatabaseConnection.php';
include_once 'configs/EncryptionKey.php';
$include_allowed = true;
session_start();
$sessionid= session_id();
$sessionid=sanitize($sessionid);
$connection = new DatabaseConnection();
$row = $connection->getRole($sessionid);
if($row != FALSE){
}
if($row == FALSE){
header("location:login.php");
}
$connection = new DatabaseConnection();
$querySMTPdefault = $connection->executeQuery("SELECT host, port, ssl_enc, username, aes_decrypt(password, '$encrypt_key') as password, sender_email, sender_name, sys_default FROM settings_smtp WHERE sys_default = \"1\"");
while($smtpItems = mysql_fetch_array($querySMTPdefault) ){
$host = $smtpItems['host'];
$port = $smtpItems['port'];
$usernamesmtp = $smtpItems['username'];
$passwordsmtp = $smtpItems['password'];
$sendmail = $smtpItems['sender_email'];
$sendname = $smtpItems['sender_name'];
}
function cleanInput($input) {
$search_input = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments
);
$output = preg_replace($search_input, '', $input);
return $output;
}
function sanitize($input) {
if (is_array($input)) {
foreach($input as $var=>$val) {
$output[$var] = sanitize($val);
}
}
else {
if (get_magic_quotes_gpc()) {
$input = stripslashes($input);
}
$input = cleanInput($input);
$connection = new DatabaseConnection();
$output = mysql_real_escape_string($input);
}
return $output;
}
?>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h5 id="edituserModalLabel">Add SMTP Server <?echo $passwordsmtp;?></h5>
</div>
<div class="well">
<form method="POST" action="set_smtp.php">
<label>Host
<input type="text" value="<? echo $host;?>" class="input-large" autocomplete="off" id="host" name="host" required>
Port
<input type="text" value="<? echo $port;?>"class="input-small" autocomplete="off" id="port" name="port" required></label>
SSL/TLS enabled
<input type="checkbox" name="ssl"
<?php
if(isset($_SESSION['temp_smtp_ssl'])){
echo 'CHECKED';
unset($_SESSION['temp_smtp_ssl']);
}
echo '/>';
?>
</label>
<label>Username
<input type="text" value="<? echo $usernamesmtp;?>" class="input-large" autocomplete="off" id="username" name="username"></label>
<label>Password
<input type="text" value="<? echo $passwordsmtp;?>" class="input-large" autocomplete="off" id="password" name="password"></label>
<label>From Email
<input type="text" value="<? echo $sendmail;?>" class="input-large" autocomplete="off" id="sender_email" name="sender_email" required></label>
<label>Senders Name
<input type="text" value="<?echo $sendname;?>" class="input-large" autocomplete="off" id="sender_name" name="sender_name" required></label>
<input type="hidden" name="default" id="default" value="1">
</label>
<br>
<div class="modal-footer">
<button class="btn-flat gray" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button class="btn-flat primary" >Add Host</button>
</div>
</form>
</div>