PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5 KiB

  1. <?php
  2. /**
  3. * Postfix Admin
  4. *
  5. * LICENSE
  6. * This source file is subject to the GPL license that is bundled with
  7. * this package in the file LICENSE.TXT.
  8. *
  9. * Further details on the project are available at https://github.com/postfixadmin/postfixadmin
  10. *
  11. * @version $Id$
  12. * @license GNU GPL v2 or later.
  13. *
  14. * File: delete.php
  15. * Used to delete admins, domains, mailboxes, aliases etc.
  16. *
  17. * Template File: none
  18. */
  19. require_once('common.php');
  20. if (safepost('token') != $_SESSION['PFA_token']) {
  21. die('Invalid token!');
  22. }
  23. $username = authentication_get_username(); # enforce login
  24. $id = safepost('delete');
  25. $table = safepost('table');
  26. if (empty($table)) {
  27. die('Invalid call');
  28. }
  29. $handlerclass = ucfirst($table) . 'Handler';
  30. if (!preg_match('/^[a-z]+$/', $table) || !file_exists(dirname(__FILE__) . "/../model/$handlerclass.php")) { # validate $table
  31. die("Invalid table name given!");
  32. }
  33. $is_admin = authentication_has_role('admin');
  34. $handler = new $handlerclass(0, $username, $is_admin);
  35. $formconf = $handler->webformConfig();
  36. if ($is_admin) {
  37. authentication_require_role($formconf['required_role']);
  38. } else {
  39. if (empty($formconf['user_hardcoded_field'])) {
  40. die($handlerclass . ' is not available for users');
  41. }
  42. }
  43. if ($handler->init($id)) { # errors will be displayed as last step anyway, no need for duplicated code ;-)
  44. $handler->delete();
  45. }
  46. flash_error($handler->errormsg);
  47. flash_info($handler->infomsg);
  48. header("Location: " . $formconf['listview']);
  49. exit;
  50. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */