You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
PHTML
60 lines
1.5 KiB
PHTML
18 years ago
|
<?php
|
||
17 years ago
|
/**
|
||
|
* Postfix Admin
|
||
|
*
|
||
|
* LICENSE
|
||
|
* This source file is subject to the GPL license that is bundled with
|
||
|
* this package in the file LICENSE.TXT.
|
||
|
*
|
||
11 years ago
|
* Further details on the project are available at http://postfixadmin.sf.net
|
||
17 years ago
|
*
|
||
|
* @version $Id$
|
||
|
* @license GNU GPL v2 or later.
|
||
|
*
|
||
|
* File: delete.php
|
||
11 years ago
|
* Used to delete admins, domains, mailboxes, aliases etc.
|
||
17 years ago
|
*
|
||
11 years ago
|
* Template File: none
|
||
17 years ago
|
*/
|
||
18 years ago
|
|
||
17 years ago
|
require_once('common.php');
|
||
|
|
||
11 years ago
|
if (safeget('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||
|
|
||
11 years ago
|
$username = authentication_get_username(); # enforce login
|
||
17 years ago
|
|
||
11 years ago
|
$id = safeget('delete');
|
||
|
$table = safeget('table');
|
||
17 years ago
|
|
||
11 years ago
|
$handlerclass = ucfirst($table) . 'Handler';
|
||
17 years ago
|
|
||
7 years ago
|
if ( !preg_match('/^[a-z]+$/', $table) || !file_exists(dirname(__FILE__) . "/../model/$handlerclass.php")) { # validate $table
|
||
11 years ago
|
die ("Invalid table name given!");
|
||
|
}
|
||
17 years ago
|
|
||
10 years ago
|
$is_admin = authentication_has_role('admin');
|
||
17 years ago
|
|
||
10 years ago
|
$handler = new $handlerclass(0, $username, $is_admin);
|
||
11 years ago
|
$formconf = $handler->webformConfig();
|
||
18 years ago
|
|
||
10 years ago
|
if ($is_admin) {
|
||
|
authentication_require_role($formconf['required_role']);
|
||
|
} else {
|
||
|
if (empty($formconf['user_hardcoded_field'])) {
|
||
|
die($handlerclass . ' is not available for users');
|
||
|
}
|
||
|
}
|
||
18 years ago
|
|
||
11 years ago
|
if ($handler->init($id)) { # errors will be displayed as last step anyway, no need for duplicated code ;-)
|
||
|
$handler->delete();
|
||
17 years ago
|
}
|
||
|
|
||
11 years ago
|
flash_error($handler->errormsg);
|
||
|
flash_info($handler->infomsg);
|
||
17 years ago
|
|
||
11 years ago
|
header ("Location: " . $formconf['listview']);
|
||
|
exit;
|
||
18 years ago
|
|
||
16 years ago
|
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||
18 years ago
|
?>
|