send database credentials to email

This commit is contained in:
Serghey Rodin 2012-12-31 00:05:28 +02:00
parent 18c7501ed3
commit ed4ae4530e
2 changed files with 29 additions and 0 deletions

View file

@ -28,6 +28,7 @@ top_panel($user,$TAB);
$v_password = escapeshellarg($_POST['v_password']);
$v_type = $_POST['v_type'];
$v_charset = $_POST['v_charset'];
if (empty($_POST['v_notify'])) $v_notify = 'off';
// Check for errors
if (!empty($errors[0])) {
@ -53,6 +54,25 @@ top_panel($user,$TAB);
unset($v_password);
unset($output);
} else {
if (empty($v_notify)) {
list($http_host, $port) = explode(':', $_SERVER["HTTP_HOST"]);
if ($_POST['v_type'] == 'mysql') $db_admin_link = "http://".$http_host."/phpMyAdmin/";
if ($_POST['v_type'] == 'pgsql') $db_admin_link = "http://".$http_host."/phpPgAdmin/";
$to = $panel[$user]['CONTACT'];
$subject = "Database Credentials";
$hostname = exec('hostname');
$from = "Vesta Control Panel <noreply@".$hostname.">";
$mailtext = "Hello ".$panel[$user]['FNAME']." ".$panel[$user]['LNAME'].",\n";
$mailtext .= "your ".$_POST['v_type']." database has been created successfully.\n\n";
$mailtext .= "database: ".$user."_".$_POST['v_database']."\n";
$mailtext .= "username: ".$user."_".$_POST['v_dbuser']."\n";
$mailtext .= "password: ".$_POST['v_password']."\n\n";
$mailtext .= $db_admin_link."\n\n";
$mailtext .= "--\nVesta Control Panel\n";
send_email($to, $subject, $mailtext, $from);
}
$_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.";
unset($v_database);
unset($v_dbuser);

View file

@ -162,6 +162,15 @@
<option value=eucjpms <?php if ((!empty($v_charset)) && ( $v_charset == 'eucjpms')) echo 'selected';?> >eucjpms</option>
</select>
</td>
<tr>
<td class="vst-text" style="padding: 10px 0 0 2px;">
Send credentials to <?php echo $panel[$user]['CONTACT'] ?>
</td>
</tr>
<tr>
<td>
<input type="checkbox" size="20" class="vst-checkbox" name="v_notify" <?php if (empty($v_notify)) echo "checked=yes"; ?>>
</td>
</tr>
<tr>
<td style="padding: 24px 0 0 0;">