forked from goautodial/v4.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settingssmtp.php
245 lines (226 loc) · 11.2 KB
/
settingssmtp.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
require_once('./php/UIHandler.php');
require_once('./php/CRMDefaults.php');
require_once('./php/LanguageHandler.php');
include('./php/Session.php');
require_once('./php/goCRMAPISettings.php');
$ui = \creamy\UIHandler::getInstance();
$lh = \creamy\LanguageHandler::getInstance();
$user = \creamy\CreamyUser::currentUser();
?>
<html>
<head>
<meta charset="UTF-8">
<title><?php $lh->translateText('portal_title'); ?> - <?php $lh->translateText("smtp_settings"); ?></title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php print $ui->standardizedThemeCSS(); ?>
<?php print $ui->creamyThemeCSS(); ?>
</head>
<?php print $ui->creamyBody(); ?>
<div class="wrapper">
<!-- header logo: style can be found in header.less -->
<?php print $ui->creamyHeader($user); ?>
<!-- Left side column. contains the logo and sidebar -->
<?php print $ui->getSidebar($user->getUserId(), $user->getUserName(), $user->getUserRole(), $user->getUserAvatar()); ?>
<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<?php $lh->translateText("settings"); ?>
<small><?php $lh->translateText("smtp_settings"); ?></small>
</h1>
<ol class="breadcrumb">
<li><a href="./index.php"><i class="fa fa-phone"></i> <?php $lh->translateText("home"); ?></a></li>
<li><?php $lh->translateText("settings"); ?></li>
<li class="active"><?php $lh->translateText("smtp_settings"); ?>
</ol>
</section>
<!-- Main content -->
<section class="content">
<?php if ($user->userHasAdminPermission()) { ?>
<div class="panel panel-default">
<div class="panel-body">
<legend><?php $lh->translateText("smtp_settings"); ?></legend>
<?php
// API to get SMTP Credentials
$url = gourl."/goSMTP/goAPI.php"; #URL to GoAutoDial API. (required)
$postfields["goUser"] = goUser; #Username goes here. (required)
$postfields["goPass"] = goPass; #Password goes here. (required)
$postfields["goAction"] = "goGetSMTPSettings"; #action performed by the [[API:Functions]]. (required)
$postfields["responsetype"] = responsetype; #json. (required)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$data = curl_exec($ch);
curl_close($ch);
$output = json_decode($data);
//var_dump($output);
//if($output->result == "success"){
?>
<form id="modifyform">
<input type="hidden" name="log_user" value="<?=$_SESSION['user']?>" />
<input type="hidden" name="log_group" value="<?=$_SESSION['usergroup']?>" />
<fieldset>
<div class="form-group mt">
<div class="row">
<div class="col-sm-6">
<label for="host" class="col-sm-2 control-label"><i class="fa fa-info-circle" title="<?php $lh->translateText("smtp_host_info"); ?>"></i> <?php $lh->translateText("host"); ?></label>
<div class="col-sm-10 mb">
<input type="text" class="form-control" name="host" id="host" placeholder="<?php $lh->translateText("host"); ?>" value="<?php echo $output->data->host;?>" required />
</div>
</div>
<div class="col-sm-6">
<label for="port" class="col-sm-2 control-label"><i class="fa fa-info-circle" title="<?php $lh->translateText("smtp_port_info"); ?>"></i> <?php $lh->translateText("port"); ?></label>
<div class="col-sm-10 mb">
<input type="number" class="form-control" name="port" id="port" placeholder="<?php $lh->translateText("port"); ?>" value="<?php echo $output->data->port;?>" min="22" maxlength="4" required />
</div>
</div>
</div>
</div>
<div class="form-group mt">
<div class="row">
<div class="col-sm-6">
<label for="username" class="col-sm-2 control-label"><?php $lh->translateText("username"); ?></label>
<div class="col-sm-10 mb">
<input type="email" class="form-control" name="username" id="username" placeholder="<?php $lh->translateText("username"); ?>" value="<?php echo $output->data->username;?>" required />
</div>
</div>
<div class="col-sm-6">
<label for="password" class="col-sm-2 control-label"><?php $lh->translateText("password"); ?></label>
<div class="col-sm-10 mb">
<input type="password" class="form-control" name="password" id="password" placeholder="<?php $lh->translateText("password"); ?>" value="" />
</div>
</div>
</div>
</div>
<div class="form-group mt">
<div class="col-sm-6 mb">
<div class="col-md-4">
<label for="ipv6_support"><i class="fa fa-info-circle" title="<?php $lh->translateText("ipv6_support_info"); ?>"></i> <?php $lh->translateText("ipv6_support"); ?></label>
</div>
<div class="col-md-6">
<label class="checkbox-inline c-checkbox" for="ipv6_support">
<input id="ipv6_support" name="ipv6_support" type="checkbox" <?php if($output->data->ipv6_support == 1)echo "checked";?> >
<span class="fa fa-check"></span>
</label>
</div>
</div>
</div>
</fieldset>
<fieldset>
<div class="form-group mt">
<label for="host" class="col-sm-2 control-label"><i class="fa fa-info-circle" title="<?php $lh->translateText("debug_info"); ?>"></i> <?php $lh->translateText("debug"); ?></label>
<div class="col-sm-10 mb">
<select class="form-control" name="debug" id="debug">
<option value="0">OFF - Production use</option>
<option value="1">Client Messages</option>
<option value="2">Client and Server Messages</option>
<option value="3">Timeout + Client and Server Messages</option>
</select>
</div>
</div>
<div class="form-group mt">
<label for="smtp_security" class="col-sm-2 control-label"><i class="fa fa-info-circle" title="<?php $lh->translateText("smtp_security_info"); ?>"></i> <?php $lh->translateText("smtp_security"); ?></label>
<div class="col-sm-10 mb">
<select class="form-control" name="smtp_security" id="smtp_security">
<option value="tls">TLS</option>
<option value="ssl">SSL</option>
</select>
</div>
</div>
<div class="form-group mt">
<div class="col-sm-6 mb">
<div class="col-md-4">
<label for="smtp_auth"><i class="fa fa-info-circle" title="<?php $lh->translateText("smtp_auth_info"); ?>"></i> <?php $lh->translateText("smtp_auth"); ?></label>
</div>
<div class="col-md-6">
<label class="checkbox-inline c-checkbox" for="smtp_auth">
<input id="smtp_auth" name="smtp_auth" type="checkbox" <?php if($output->data->smtp_auth == 1)echo "checked";?> >
<span class="fa fa-check"></span>
</label>
</div>
</div>
</div>
</fieldset>
<fieldset>
<div class="col-sm-4 pull-right">
<a href="index.php" type="button" id="cancel" class="btn btn-danger"><i class="fa fa-close"></i> <?php $lh->translateText('cancel'); ?> </a>
<button type="submit" class="btn btn-primary" id="modifyOkButton" href=""> <span id="update_button"><i class="fa fa-check"></i> <?php $lh->translateText('update'); ?> </span></button>
</div>
</fieldset>
</form>
<?php //} ?>
</div>
</div>
<!-- /fila con acciones, formularios y demás -->
<?php
} else {
print $ui->calloutErrorMessage($lh->translationFor("you_dont_have_permission"));
}
?>
</section><!-- /.content -->
</aside><!-- /.right-side -->
<?php print $ui->getRightSidebar($user->getUserId(), $user->getUserName(), $user->getUserAvatar()); ?>
</div><!-- ./wrapper -->
<!-- Forms and actions -->
<?php print $ui->standardizedThemeJS(); ?>
<script type="text/javascript">
$(document).ready(function() {
/*********************
** INITIALIZATION
*********************/
<?php
if($output->result == 'success'){
$url = "./php/ModifySMTPSetting.php";
}else{
$url = "./php/AddSMTPSetting.php";
}
?>
var url = '<?php echo $url; ?>';
$("#modifyform").validate({
submitHandler: function() {
//submit the form
$('#update_button').html("<i class='fa fa-edit'></i> <?php $lh->translateText("updating"); ?>");
$('#modifyOkButton').prop("disabled", true);
$.post(url, //post
$("#modifyform").serialize(),
function(data){
//if message is sent
console.log($("#modifyvoicemail").serialize());
$('#update_button').html("<i class='fa fa-check'></i> <?php $lh->translateText("update"); ?>");
$('#modifyOkButton').prop("disabled", false);
if (data == "success") {
swal({title: "<?php $lh->translateText("success"); ?>",text: "<?php $lh->translateText("smtp_modify_success"); ?>",type: "success"},function(){window.location.href = 'settingssmtp.php';});
} else {
sweetAlert("<?php $lh->translateText("oups"); ?>", "<?php $lh->translateText("something_went_wrong"); ?>"+data, "error");
}
});
return false; //don't let the form refresh the page...
}
});
/*********************
** FILTERS
*********************/
// disable special characters on Usergroup ID
$('#host').bind('keypress', function (event) {
var regex = new RegExp("^[A-Za-z0-9.]+$");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
if (!regex.test(key)) {
event.preventDefault();
return false;
}
});
/********************
** DROPDOWN VALUES **
********************/
$('#debug option[value="<?php echo $output->data->debug; ?>"]').attr('selected', 'selected');
$('#smtp_security option[value="<?php echo $output->data->smtp_security; ?>"]').attr('selected', 'selected');
}); // end of document ready
</script>
<?php print $ui->creamyFooter();?>
</body>
</html>