index.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. ob_start();
  3. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  4. // Check token
  5. verify_csrf($_POST);
  6. if (($_SESSION['userContext'] === 'admin') && (!empty($_GET['user']))) {
  7. $user = escapeshellarg($_GET['user']);
  8. $user_plain = $_GET['user'];
  9. }
  10. // Checks if API access is enabled
  11. $api_status = (!empty($_SESSION['API_SYSTEM']) && is_numeric($_SESSION['API_SYSTEM'])) ? $_SESSION['API_SYSTEM'] : 0;
  12. if (($user_plain == 'admin' && $api_status < 1) || ($user_plain != 'admin' && $api_status < 2)) {
  13. header("Location: /edit/user/");
  14. exit;
  15. }
  16. $key = $_POST['key'];
  17. $action = $_POST['action'];
  18. switch ($action) {
  19. case 'delete': $cmd='v-delete-access-key';
  20. break;
  21. default: header("Location: /list/access-key/"); exit;
  22. }
  23. foreach ($key as $value) {
  24. $v_key = escapeshellarg(trim($value));
  25. // Key data
  26. exec(HESTIA_CMD."v-list-access-key ".$v_key." json", $output, $return_var);
  27. $key_data = json_decode(implode('', $output), true);
  28. unset($output);
  29. if (!empty($key_data) && $key_data['USER'] == $user_plain) {
  30. exec(HESTIA_CMD.$cmd." ".$v_key, $output, $return_var);
  31. unset($output);
  32. }
  33. }
  34. header("Location: /list/access-key/");