Initial commit
This commit is contained in:
1 parent
b903cae554
commit
db919af915
14 files changed
+791
No files matched your search
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/* Mailadminscript
|
||||
Copyright (C) 2019 Paul Schürholz contact AT roteserver . de
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
$config = parse_ini_file('../../private/config.ini');
|
||||
try {
|
||||
$dbh = new PDO('mysql:host=' . $config['dbservername'] . ';dbname=' . $config['dbname'], $config['dbusername'], $config['dbpassword'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
|
||||
} catch (PDOException $e) {
|
||||
//echo 'Connection failled: '. $e->getMessage(); // Errormessage kann Sicherheitsrelevantes enthalen
|
||||
echo 'Connection failed';
|
||||
}
|
||||
function delete_directory($dirname)
|
||||
{
|
||||
if (is_dir($dirname))
|
||||
$dir_handle = opendir($dirname);
|
||||
if (!$dir_handle)
|
||||
return false;
|
||||
while ($file = readdir($dir_handle)) {
|
||||
if ($file != "." && $file != "..") {
|
||||
if (!is_dir($dirname . "/" . $file))
|
||||
unlink($dirname . "/" . $file);
|
||||
else
|
||||
delete_directory($dirname . '/' . $file);
|
||||
}
|
||||
}
|
||||
closedir($dir_handle);
|
||||
rmdir($dirname);
|
||||
return true;
|
||||
}
|
||||
session_start();
|
||||
if ($_SESSION['log'] == 1) {
|
||||
if ($_SESSION['admin'] == 1) {
|
||||
$mailuserID = $_POST['mailuserID'];
|
||||
}
|
||||
else {
|
||||
$mailuserID = $_SESSION['mailID'];
|
||||
}
|
||||
$abfrage = "SELECT `username` FROM `virtual_users` WHERE `id` = :mailuserID";
|
||||
$sth = $dbh->prepare($abfrage);
|
||||
$sth->execute(array('mailuserID' => $mailuserID));
|
||||
$result = $sth->fetchAll();
|
||||
$eintrag = "DELETE FROM `mailserver`.`virtual_users` WHERE `id` LIKE :mailuserID";
|
||||
$sth = $dbh->prepare($eintrag);
|
||||
$sth->execute(array(':mailuserID' => $mailuserID));
|
||||
$maildirpath = $config['mailfolderpath'] . $result[0]['username'];
|
||||
delete_directory($maildirpath);
|
||||
header("Location: ../admin.php?success=1");
|
||||
exit;
|
||||
}
|
||||
header("Location: ../index.php");
|
||||
?>
|
||||
Reference in new issue
Block a user