andre 7 months ago
parent
commit
12f96a188d
2 changed files with 13 additions and 6 deletions
  1. 0 3
      controllers/SiteController.php
  2. 13 3
      index.php

+ 0 - 3
controllers/SiteController.php

@@ -94,14 +94,11 @@ class SiteController {
     public static function deploy($data): void  {
         $domain = $data['domain'] ?? '';
         error_log("deploy: DEBUG: " . print_r($data, true));
-
         if (empty($domain)) {
             http_response_code(400);
             echo json_encode(['error' => 'Missing required parameter: domainname']);
             return;
         }
-        http_response_code(200);
-        echo json_encode(['result' => ['status' => 'FINISHED', 'id' => 'test123']]);
     }
 
     public static function revert($data): void {

+ 13 - 3
index.php

@@ -86,17 +86,27 @@ switch ($endpoint) {
         break;
     case 'deploy':
         error_log("Request deploy from " . get_client_ip());
-        if ($requestMethod === 'POST' && !empty($username) && !empty($domain)) {
+        if ($requestMethod == 'POST' && !empty($username) && !empty($domain)) {
             if ($GLOBALS['debug'] == true) {
                 error_log("POST: " . print_r($_POST, true));
             }
+            $error = null;
+            $id = md5($id.time());
+            header('Content-Type: application/json; charset=utf-8', true);
+            echo json_encode(array('result' => array('id' => $id, 'error' => $error)));
             SiteController::deploy(['zip' => $_POST['zip'], 'username' => $username, 'domain' => $domain]);
         }
-        if ($requestMethod === 'GET' && !empty($username) && !empty($domain)) {
+        if ($requestMethod == 'GET' && !empty($username) && !empty($domain)) {
             if ($GLOBALS['debug'] == true) {
                 error_log("GET: " . print_r($_GET, true));
             }
-            SiteController::deploy(['vars' => $_GET, 'username' => $username, 'domain' => $domain]);
+            $uri = $_SERVER['REQUEST_URI'];
+            $parts = explode('/', $uri);
+            $id = $parts[count($parts) - 1];
+            $status = 'FINISHED';
+            $error = null;
+            header('Content-Type: application/json; charset=utf-8', true);
+            echo json_encode(array('result' => array('id' => $id, 'error' => $error)));
         }
         break;
     case 'revert':