ajax.php 770 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. use function Hestiacp\quoteshellarg\quoteshellarg;
  3. // Main include
  4. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  5. // Check user
  6. if ($_SESSION['userContext'] != 'admin') {
  7. header('Location: /list/user');
  8. exit;
  9. }
  10. if (empty($_POST['period'])) {
  11. $period = "daily";
  12. } else {
  13. if (in_array($_POST['period'] ,array('day', 'week','month','year'))) {
  14. $period=$_POST['period'];
  15. } else {
  16. $period = "daily";
  17. }
  18. }
  19. if (empty($_POST['service'])) {
  20. $service = "la";
  21. } else {
  22. $service = $_POST['service'];
  23. }
  24. // Data
  25. exec(HESTIA_CMD."v-export-rrd ".quoteshellarg($service)." ".quoteshellarg($period), $output, $return_var);
  26. $data = json_decode(implode('', $output), true);
  27. $data['service'] = $service;
  28. echo json_encode($data);