mirror of
https://github.com/DanWin/mail-hosting.git
synced 2024-11-21 23:20:25 +00:00
Add more cleanups
This commit is contained in:
parent
8d54b307ca
commit
3f6cfe7c14
2 changed files with 41 additions and 0 deletions
8
cron.php
8
cron.php
|
@ -32,6 +32,10 @@ while ( $tmp = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
|
|||
if ( file_exists( $mail_files ) ) {
|
||||
exec( 'rm -r ' . escapeshellarg( $mail_files ) );
|
||||
}
|
||||
$snapmail_files = '/var/local/snappymail/_data_/_default_/storage/' . $domain_basename . '/' . $local_basename;
|
||||
if ( file_exists( $snapmail_files ) ) {
|
||||
exec( 'rm -r ' . escapeshellarg( $snapmail_files ) );
|
||||
}
|
||||
$files = glob( '/var/local/squirrelmail/data/' . $local_basename . '@' . $domain_basename . '.{pref,abook,sig}', GLOB_BRACE );
|
||||
if ( $tmp[ 'domain' ] === 'danwin1210.de' ) {
|
||||
$files = array_merge( $files, glob( '/var/local/squirrelmail/data/' . $local_basename . '{@danielas3rtn54uwmofdo3x2bsdifr47huasnmbgqzfrec5ubupvtpid.onion,}.{pref,abook,sig}', GLOB_BRACE ) );
|
||||
|
@ -66,6 +70,10 @@ while ( $tmp = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
|
|||
if ( file_exists( $mail_files ) ) {
|
||||
exec( 'rm -r ' . escapeshellarg( $mail_files ) );
|
||||
}
|
||||
$snapmail_files = '/var/local/snappymail/_data_/_default_/storage/' . $domain_basename . '/';
|
||||
if ( file_exists( $snapmail_files ) ) {
|
||||
exec( 'rm -r ' . escapeshellarg( $snapmail_files ) );
|
||||
}
|
||||
if ( is_array( $files ) ) {
|
||||
foreach ( $files as $file ) {
|
||||
@unlink( $file );
|
||||
|
|
|
@ -25,3 +25,36 @@ foreach ( $domains as $domain ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
$domains = array_diff( scandir( '/var/local/snappymail/_data_/_default_/storage/' ), array( '..', '.', '__nobody__' ) );
|
||||
$dirs = [];
|
||||
foreach ( $domains as $domain ) {
|
||||
if ( is_dir( '/var/local/snappymail/_data_/_default_/storage/' . basename( $domain ) ) ) {
|
||||
if ( ! isset( $mailboxes[ $domain ] ) ) {
|
||||
echo sprintf(_('%s does not seem to have any accounts, but has a snappymail directory. Consider deleting it.'), $domain).PHP_EOL;
|
||||
} else {
|
||||
$accounts = array_diff( scandir( '/var/local/snappymail/_data_/_default_/storage/' . basename( $domain ) ), array( '..', '.' ) );
|
||||
foreach ( $accounts as $account ) {
|
||||
if ( ! isset( $mailboxes[ $domain ][ $account ] ) && is_dir( '/var/local/snappymail/_data_/_default_/storage/' . basename( $domain ) . '/' . basename( $account ) ) ) {
|
||||
exec( 'rm -r ' . escapeshellarg('/var/local/snappymail/_data_/_default_/storage/' . basename( $domain ) . '/' . basename( $account )));
|
||||
echo sprintf(_('Deleted: %s'), '/var/local/snappymail/_data_/_default_/storage/' . basename( $domain ) . '/' . basename( $account )) . PHP_EOL;
|
||||
} elseif( is_file('/var/local/snappymail/_data_/_default_/storage/' . basename( $domain ) . '/' . basename( $account ))){
|
||||
echo sprintf(_('File found in mail directory location: "%s". Consider deleting it.'), '/var/local/snappymail/_data_/_default_/storage/'. basename( $domain ) . '/' . basename( $account ) ) . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$accout_files = array_diff( scandir( '/var/local/squirrelmail/data/' ), array( '..', '.' ) );
|
||||
foreach( $accout_files as $file ){
|
||||
if(preg_match( '/^(.+?)(@(.+))?\.(pref|abook|sig)$/', $file, $matches )){
|
||||
$domain = $matches[ 3 ];
|
||||
if(in_array($domain, ['', 'danielas3rtn54uwmofdo3x2bsdifr47huasnmbgqzfrec5ubupvtpid.onion'], true)){
|
||||
$domain = 'danwin1210.de';
|
||||
}
|
||||
$account = $matches[ 1 ];
|
||||
if ( ! isset( $mailboxes[ $domain ][ $account ] )){
|
||||
unlink('/var/local/squirrelmail/data/' . $file);
|
||||
echo sprintf(_('Deleted: %s'), '/var/local/squirrelmail/data/' . $file) . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue