#!/usr/bin/php -q
<?php
## Autor: Knut Herter
## Datum: 06.10.2009
## Web : http://www.systemtechnics.de
##
## Usage: decrypt_mailpw.php |grep whatever_you_want
##
## Example: decrypt_mailpw.php |grep admin
###
# FIRST CHANGE THIS VALUES !
###
$SQLHST = "localhost";
$SQLUSR = "root";
$ISPCPDB = "ispcp";
# if error_reporting on, you see some session errors at cli
error_reporting(0);
#################################
#### Do not change from here ####
echo "MySQL password for $SQLUSR@$SQLHST: ";
system('stty -echo');
$SQLPW = trim(fgets(STDIN));
system('stty echo');
##### E-Mails ###########
$QUERY = "
SELECT `mail_users`.mail_acc,
`mail_users`.mail_pass,
`domain`.domain_name
FROM `domain`
INNER JOIN `mail_users` ON (`mail_users`.domain_id = `domain`.domain_id)
WHERE `mail_type` LIKE 'normal_mail' OR `mail_type` LIKE 'normal_mail,normal_forward'";
require '/var/www/ispcp/gui/include/ispcp-lib.php';
$link = mysql_connect( $SQLHST, $SQLUSR, $SQLPW);
if (!$link) {
die('keine Verbindung möglich: ' . mysql_error());
}
mysql_select_db( $ISPCPDB, $link) or die('Could not select database.');
$result = mysql_query($QUERY);
if (!$result) {
die('Ungültige Abfrage: ' . mysql_error());
}
printf ("\n");
$FORMAT = "Domain MailAdr: [ %s@%s ] Passwort: [ %s ]\n";
while ($row = mysql_fetch_row($result)) {
printf ( $FORMAT, $row[0], $row[2], decrypt_db_password ($row[1]));
}
printf ("\n");
mysql_close($link);
####### DOMAINALIASE
$QUERY = "
SELECT `mail_users`.mail_acc,
`mail_users`.mail_pass,
`domain_aliasses`.alias_name
FROM `domain_aliasses`
INNER JOIN `mail_users` ON (`mail_users`.sub_id = `domain_aliasses`.alias_id)
WHERE `mail_type` LIKE 'alias_mail' OR `mail_type` LIKE 'alias_mail,alias_forward'";
$link = mysql_connect( $SQLHST, $SQLUSR, $SQLPW);
if (!$link) {
die('keine Verbindung möglich: ' . mysql_error());
}
mysql_select_db( $ISPCPDB, $link) or die('Could not select database.');
$result = mysql_query($QUERY);
if (!$result) {
die('Ungültige Abfrage: ' . mysql_error());
}
$FORMAT = "Aliasdomain MailAdr: [ %s@%s ] Passwort: [ %s ]\n";
while ($row = mysql_fetch_row($result)) {
printf ( $FORMAT, $row[0], $row[2], decrypt_db_password ($row[1]));
}
printf ("\n");
mysql_close($link);
####### Benutzer
$QUERY = "
SELECT `admin`.admin_name,
`admin`.admin_pass
FROM `admin`";
$link = mysql_connect( $SQLHST, $SQLUSR, $SQLPW);
if (!$link) {
die('keine Verbindung möglich: ' . mysql_error());
}
mysql_select_db( $ISPCPDB, $link) or die('Could not select database.');
$result = mysql_query($QUERY);
if (!$result) {
die('Ungültige Abfrage: ' . mysql_error());
}
$FORMAT = "Domain-Benutzer: [ %s ] Passwort: [ %s ]\n";
while ($row = mysql_fetch_row($result)) {
printf ( $FORMAT, $row[0], decrypt_db_password ($row[1]));
}
printf ("\n");
mysql_close($link);
######## FTP-User #######
$QUERY = "
SELECT `ftp_users`.userid,
`ftp_users`.passwd,
`domain`.domain_name
FROM `domain`
INNER JOIN `ftp_users` ON (`ftp_users`.uid = `domain`.domain_uid)";
#### WHERE `mail_type` LIKE 'normal_mail' OR `mail_type` LIKE 'normal_mail,normal_forward'"
# require '/var/www/ispcp/gui/include/ispcp-lib.php';
$link = mysql_connect( $SQLHST, $SQLUSR, $SQLPW);
if (!$link) {
die('keine Verbindung möglich: ' . mysql_error());
}
mysql_select_db( $ISPCPDB, $link) or die('Could not select database.');
$result = mysql_query($QUERY);
if (!$result) {
die('Ungültige Abfrage: ' . mysql_error());
}
printf ("\n");
$FORMAT = "Domain Adr: [ %s ] User: [ %s ] Passwort: [ %s ]\n";
while ($row = mysql_fetch_row($result)) {
printf ( $FORMAT, $row[2], $row[0], decrypt_db_password ($row[1]));
}
printf ("\n");
mysql_close($link);
?>