index.php 1.2 KB

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