Skip to content

Commit ed4ae45

Browse files
committed
send database credentials to email
1 parent 18c7501 commit ed4ae45

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

web/add/db/index.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
$v_password = escapeshellarg($_POST['v_password']);
2929
$v_type = $_POST['v_type'];
3030
$v_charset = $_POST['v_charset'];
31+
if (empty($_POST['v_notify'])) $v_notify = 'off';
3132

3233
// Check for errors
3334
if (!empty($errors[0])) {
@@ -53,6 +54,25 @@
5354
unset($v_password);
5455
unset($output);
5556
} else {
57+
if (empty($v_notify)) {
58+
list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]);
59+
if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/";
60+
if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/";
61+
62+
$to = $panel[$user]['CONTACT'];
63+
$subject = "Database Credentials";
64+
$hostname = exec('hostname');
65+
$from = "Vesta Control Panel <noreply@".$hostname.">";
66+
$mailtext = "Hello ".$panel[$user]['FNAME']." ".$panel[$user]['LNAME'].",\n";
67+
$mailtext .= "your ".$_POST['v_type']." database has been created successfully.\n\n";
68+
$mailtext .= "database: ".$user."_".$_POST['v_database']."\n";
69+
$mailtext .= "username: ".$user."_".$_POST['v_dbuser']."\n";
70+
$mailtext .= "password: ".$_POST['v_password']."\n\n";
71+
$mailtext .= $db_admin_link."\n\n";
72+
73+
$mailtext .= "--\nVesta Control Panel\n";
74+
send_email($to, $subject, $mailtext, $from);
75+
}
5676
$_SESSION['ok_msg'] = "OK: database <a href='/edit/db/?database=".$user."_".$_POST['v_database']."'><b>".$user."_".$_POST['v_database']."</b></a> has been created successfully.";
5777
unset($v_database);
5878
unset($v_dbuser);

web/templates/admin/add_db.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@
162162
<option value=eucjpms <?php if ((!empty($v_charset)) && ( $v_charset == 'eucjpms')) echo 'selected';?> >eucjpms</option>
163163
</select>
164164
</td>
165+
<tr>
166+
<td class="vst-text" style="padding: 10px 0 0 2px;">
167+
Send credentials to <?php echo $panel[$user]['CONTACT'] ?>
168+
</td>
169+
</tr>
170+
<tr>
171+
<td>
172+
<input type="checkbox" size="20" class="vst-checkbox" name="v_notify" <?php if (empty($v_notify)) echo "checked=yes"; ?>>
173+
</td>
165174
</tr>
166175
<tr>
167176
<td style="padding: 24px 0 0 0;">

0 commit comments

Comments
 (0)