-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.php
331 lines (305 loc) · 12.8 KB
/
settings.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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<?php include('init.php'); if (!$userid) { header('Location: login.php'); } ?>
<?php
// form processing
if ($_POST) {
i('+', 'settings', $_POST);
if ($_POST['action'] == 'site') {
if (!valid('text', $_POST['name'])) {
n('+', 'settings', 'error', 'You must input a site name.');
}
if (!valid('url', $_POST['main_url'])) {
n('+', 'settings', 'error', 'Main URL must be a valid URL.');
}
if (!valid('url', $_POST['admin_url'])) {
n('+', 'settings', 'error', 'Admin URL must be a valid URL.');
}
if (!valid('email', $_POST['email'])) {
n('+', 'settings', 'error', 'Site email must be a valid email address.');
}
if (isset($_POST['send_mail_method'])) {
if (!valid('text', $_POST['smtp_username'])) {
n('+', 'settings', 'error', 'Please provide a valid SMTP Username.');
}
if (!valid('text', $_POST['smtp_password'])) {
n('+', 'settings', 'error', 'Please provide a valid SMTP Password.');
}
if (!valid('url', $_POST['smtp_host'])) {
n('+', 'settings', 'error', 'Please provide a valid SMTP Host.');
}
if (!valid('int', $_POST['smtp_port'], 0)) {
n('+', 'settings', 'error', 'Please provide a valid SMTP Port.');
}
}
if (!n('?', 'settings', 'error')) {
$send_mail_method = (isset($_POST['send_mail_method'])) ? ('smtp') : ('php');
$new_settings = array(
'email' => $_POST['email'],
'main_url' => $_POST['main_url'],
'admin_url' => $_POST['admin_url'],
'name' => htmlspecialchars($_POST['name']),
'description' => htmlspecialchars($_POST['description']),
'send_mail_method' => $send_mail_method,
'smtp_username' => $_POST['smtp_username'],
'smtp_password' => $_POST['smtp_password'],
'smtp_host' => $_POST['smtp_host'],
'smtp_port' => $_POST['smtp_port']
);
settings('^', $new_settings, $settings['id']);
$settings = settings('@');
n('+', 'settings', 'success', 'Website settings have been updated.');
}
}
if ($_POST['action'] == 'user') {
if (isset($_POST['send_welcome_email'])) {
$send_welcome_email = 1;
}
else { $send_welcome_email = 0; }
if (!n('?', 'settings', 'error')) {
$new_settings = array(
'default_new_user_group_id' => $_POST['default_new_user_group_id'],
'send_welcome_email' => $send_welcome_email,
'send_welcome_email_subject' => htmlspecialchars($_POST['send_welcome_email_subject']),
'send_welcome_email_body' => htmlspecialchars($_POST['send_welcome_email_body']),
'send_reset_link_email_subject' => htmlspecialchars($_POST['send_reset_link_email_subject']),
'send_reset_link_email_body' => htmlspecialchars($_POST['send_reset_link_email_body']),
'send_random_password_subject' => htmlspecialchars($_POST['send_random_password_subject']),
'send_random_password_body' => htmlspecialchars($_POST['send_random_password_body']),
'send_new_user_info_subject' => htmlspecialchars($_POST['send_new_user_info_subject']),
'send_new_user_info_body' => htmlspecialchars($_POST['send_new_user_info_body'])
);
settings('^', $new_settings, $settings['id']);
$settings = settings('@');
n('+', 'settings', 'success', 'User settings have been updated.');
}
}
}
?>
<?php include('header.php'); include('sidebar.php'); ?>
<div id="page-wrapper">
<div class="container-fluid">
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<?php foreach (n('|', 'settings', 'error') as $k => $message) { ?>
<div>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Error:</strong> <?= $message; ?>
</div>
</div>
<?php } ?>
<?php foreach (n('|', 'settings', 'success') as $k => $message) { ?>
<div>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success:</strong> <?= $message; ?>
</div>
</div>
<?php } ?>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div id="header-tabs" class="">
<ul class="nav nav-tabs navbar-right">
<li<?= (!$_GET || $_GET['section'] == 'site') ? (' class="active"') : (''); ?>><a href="settings.php?section=site">
<i class="fa fa-desktop"></i> Website</a>
</li>
<li<?= ($_GET && $_GET['section'] == 'user') ? (' class="active"') : (''); ?>><a href="settings.php?section=user">
<i class="fa fa-users"></i> User</a>
</li>
</ul>
</div>
<h1 class="page-header">
Settings
</h1>
</div>
</div>
<!-- /.row -->
<?php if (!$_GET || $_GET['section'] == 'site') { ?>
<div class="row top-buffer">
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Website Settings</h3>
</div>
<div class="panel-body">
<form role="form" action="" method="post">
<input type="hidden" name="action" value="site">
<div class="form-group">
<label>Site Name</label>
<input name="name" value="<?= $settings['name']; ?>" class="form-control">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="form-group">
<label>Site Description</label>
<textarea class="form-control" rows="3" name="description"><?= $settings['description']; ?></textarea>
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="form-group">
<label>Main URL</label>
<input name="main_url" value="<?= $settings['main_url']; ?>" class="form-control">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="form-group">
<label>Administration URL</label>
<input name="admin_url" value="<?= $settings['admin_url']; ?>" class="form-control">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="form-group">
<label>Email</label>
<input name="email" value="<?= $settings['email']; ?>" class="form-control">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="form-group">
<label>Send Mail Method</label>
<input type="checkbox" name="send_mail_method" value="1" class="send-mail-method-checkbox"<?= ($settings['send_mail_method'] == 'smtp' || isset($_POST['send_mail_method'])) ? (' checked="checked"') : (''); ?>>
</div>
<div class="smtp-section well well-sm">
<div class="form-group top-buffer">
<div class="form-group col-lg-6 col-md-6 col-sm-6">
<label>SMTP Username</label>
<input type="text" class="form-control" name="smtp_username" value="<?= $settings['smtp_username']; ?>">
<!--<p class="help-block">Example block-level help text here.</p>-->
</div>
<div class="form-group col-lg-6 col-md-6 col-sm-6">
<label>SMTP Password</label>
<input type="text" class="form-control" name="smtp_password" value="<?= $settings['smtp_password']; ?>">
<!--<p class="help-block">Example block-level help text here.</p>-->
</div>
</div>
<div class="form-group bottom-buffer">
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-9">
<label>SMTP Host</label>
<input name="smtp_host" value="<?= $settings['smtp_host']; ?>" type="text" class="form-control">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-3">
<label> </label>
<input name="smtp_port" value="<?= $settings['smtp_port']; ?>" type="text" class="form-control" placeholder="Port">
</div>
</div>
<div class="clearfix"></div>
</div><!-- /.smtp-section -->
<div class="clearfix"></div>
<hr />
<div class="form-group col-lg-12">
<input type="submit" class="btn btn-primary" value="Save Settings" />
</div>
</form>
</div>
</div>
</div>
</div>
<!-- /.row -->
<?php } ?>
<?php if ($_GET && $_GET['section'] == 'user') { ?>
<div class="row top-buffer">
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">User Settings</h3>
</div>
<div class="panel-body">
<form role="form" action="" method="post">
<input type="hidden" name="action" value="user">
<div class="form-group">
<label>Default New User Group</label>
<select name="default_new_user_group_id" class="selectpicker" data-width="125px">
<?php
$groups = '
SELECT
`id`,
`name`
FROM
`user_groups`
ORDER BY
`id`
ASC
';
$group_result = $conn->query($groups) OR die('Error in query: '. mysqli_error($conn));
if ($group_result->num_rows > 0) {
while ($group = $group_result->fetch_assoc()) {
?>
<option value="<?= $group['id']; ?>"<?= ($settings['default_new_user_group_id'] == $group['id']) ? (' selected') : (''); ?>><?= $group['name']; ?></option>
<?php
}
}
?>
</select>
<!--<p class="help-block">Example block-level help text here.</p>-->
</div>
<hr />
<div class="form-group">
<label>New Registered Users</label>
<input type="checkbox" name="send_welcome_email" value="1" class="send-welcome-email-checkbox"<?= (!empty($settings['send_welcome_email'])) ? (' checked="checked"') : (''); ?>>
</div>
<div class="welcome-email-section well well-sm">
<div class="form-group bottom-buffer">
<div class="col-lg-12">
<label>Welcome Email Subject</label>
<input name="send_welcome_email_subject" value="<?= $settings['send_welcome_email_subject']; ?>" type="text" class="form-control">
</div>
<div class="col-lg-12 top-buffer">
<label>Welcome Email Body</label>
<textarea class="form-control" rows="5" name="send_welcome_email_body"><?= $settings['send_welcome_email_body']; ?></textarea>
<p class="help-block">Example block-level help text here.</p>
</div>
</div>
<div class="clearfix"></div>
</div><!-- /.welcome-email-section -->
<hr />
<div class="form-group">
<label>Reset Link Subject</label>
<input name="send_reset_link_email_subject" value="<?= $settings['send_reset_link_email_subject']; ?>" type="text" class="form-control">
</div>
<div class="form-group">
<label>Reset Link Body</label>
<textarea class="form-control" rows="5" name="send_reset_link_email_body"><?= $settings['send_reset_link_email_body']; ?></textarea>
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="clearfix"></div>
<hr />
<div class="form-group">
<label>Random Password Subject</label>
<input name="send_random_password_subject" value="<?= $settings['send_random_password_subject']; ?>" type="text" class="form-control">
</div>
<div class="form-group">
<label>Random Password Body</label>
<textarea class="form-control" rows="5" name="send_random_password_body"><?= $settings['send_random_password_body']; ?></textarea>
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="clearfix"></div>
<hr />
<div class="form-group">
<label>New User Info Subject</label>
<input name="send_new_user_info_subject" value="<?= $settings['send_new_user_info_subject']; ?>" type="text" class="form-control">
</div>
<div class="form-group">
<label>New User Info Body</label>
<textarea class="form-control" rows="5" name="send_new_user_info_body"><?= $settings['send_new_user_info_body']; ?></textarea>
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="clearfix"></div>
<hr />
<div class="form-group col-lg-12">
<input type="submit" class="btn btn-primary" value="Save Settings" />
</div>
</form>
</div>
</div>
</div>
</div>
<!-- /.row -->
<?php } ?>
</div>
<!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
<?php include('footer.php'); ?>
<?php n('-', 'settings'); ?>
<?php i('-', 'users', 'where'); ?>
<?php i('-', 'users', 'search'); ?>
<?php i('-', 'users', 'search_by'); ?>
<?php i('-', 'users', 'sort'); ?>
<?php i('-', 'users', 'sort_direction'); ?>