andre 8 месяцев назад
Родитель
Сommit
5076df0b60
2 измененных файлов с 21 добавлено и 3 удалено
  1. 1 1
      controllers/QuotaController.php
  2. 20 2
      index.php

+ 1 - 1
controllers/QuotaController.php

@@ -23,7 +23,7 @@ class QuotaController {
         }
         echo $userOutput;
     }
-    public static function getStats($data): void {
+    public static function getStats(): void {
         // get all quotas
         if ($GLOBALS['debug'] == true) {error_log("Getting Quota Stats"); }
         exec("sudo xfs_quota -x -c 'report -u' /home | tail -n +7 | column -t -n quota -N user,used,soft,hard,limit,grace -H 5 -J 2>&1", $userOutput, $userReturnCode);

+ 20 - 2
index.php

@@ -17,13 +17,13 @@ require_once __DIR__ . '/controllers/BackupController.php';
 require_once __DIR__ . '/controllers/DeployDevController.php';
 require_once __DIR__ . '/controllers/GetSSLDaysController.php';
 require_once __DIR__ . '/controllers/ProdController.php';
+require_once __DIR__ . '/controllers/QuotaController.php';
 
 use application\controllers\BackupController;
 use application\controllers\DeployDevController;
 use application\controllers\GetSSLDaysController;
 use application\controllers\ProdController;
-
-
+use application\controllers\QuotaController;
 
 const API_PASSWORD = 'your-secure-password';
 
@@ -141,6 +141,24 @@ switch ($endpoint) {
         error_log("Request ping from " . get_client_ip());
         echo json_encode(['answer' => 'pong']);
         break;
+    case 'getQuota':
+        error_log("Request getquota from " . get_client_ip());
+        if ($requestMethod === 'GET' && !empty($username)) {
+            QuotaController::getQuota(['username' => $username]);
+        }
+        break;
+    case 'getStats':
+        error_log("Request getstats from " . get_client_ip());
+        if ($requestMethod === 'GET') {
+            QuotaController::getStats();
+        }
+        break;
+    case 'setQuota':
+        error_log("Request setquota from " . get_client_ip());
+        if ($requestMethod === 'POST' && !empty($username)) {
+            QuotaController::setQuota(array_merge($parameters, ['username' => $username]));
+        }
+        break;
     default:
         error_log("Error Request: " . $endpoint . " / " . $username ." / " . $domain);
         http_response_code(404);