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.

delete.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 http://postfixadmin.sf.net
  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 (safeget('token') != $_SESSION['PFA_token']) {
  21. die('Invalid token!');
  22. }
  23. $username = authentication_get_username(); # enforce login
  24. $id = safeget('delete');
  25. $table = safeget('table');
  26. $handlerclass = ucfirst($table) . 'Handler';
  27. if (!preg_match('/^[a-z]+$/', $table) || !file_exists(dirname(__FILE__) . "/../model/$handlerclass.php")) { # validate $table
  28. die("Invalid table name given!");
  29. }
  30. $is_admin = authentication_has_role('admin');
  31. $handler = new $handlerclass(0, $username, $is_admin);
  32. $formconf = $handler->webformConfig();
  33. if ($is_admin) {
  34. authentication_require_role($formconf['required_role']);
  35. } else {
  36. if (empty($formconf['user_hardcoded_field'])) {
  37. die($handlerclass . ' is not available for users');
  38. }
  39. }
  40. if ($handler->init($id)) { # errors will be displayed as last step anyway, no need for duplicated code ;-)
  41. $handler->delete();
  42. }
  43. flash_error($handler->errormsg);
  44. flash_info($handler->infomsg);
  45. header("Location: " . $formconf['listview']);
  46. exit;
  47. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */