浏览代码

[Web] Write API logs when format is data binary

andryyy 6 年之前
父节点
当前提交
06193ca625
共有 1 个文件被更改,包括 7 次插入12 次删除
  1. 7 12
      data/web/json_api.php

+ 7 - 12
data/web/json_api.php

@@ -53,8 +53,6 @@ function api_log($_data) {
   }
 }
 
-api_log($_POST);
-
 if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_username'])) {
   if (isset($_GET['query'])) {
 
@@ -70,7 +68,7 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
       $requestDecoded = json_decode($request, true);
 
       // check for valid json
-      if($action != 'get' && $requestDecoded === null) {
+      if ($action != 'get' && $requestDecoded === null) {
         echo json_encode(array(
             'type' => 'error',
             'msg' => 'Request body doesn\'t contain valid json!'
@@ -79,30 +77,27 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u
       }
 
       // add
-      if($action == 'add') {
+      if ($action == 'add') {
         $_POST['attr'] = $request;
       }
 
       // edit
-      if($action == 'edit') {
+      if ($action == 'edit') {
         $_POST['attr']  = json_encode($requestDecoded['attr']);
         $_POST['items'] = json_encode($requestDecoded['items']);
       }
 
       // delete
-      if($action == 'delete') {
+      if ($action == 'delete') {
         $_POST['items'] = $request;
       }
 
-      unset($_SESSION['return']);
-      unset($_SESSION['success']);
-      unset($_SESSION['danger']);
-      unset($_SESSION['error']);
     }
+    api_log($_POST);
 
     $request_incomplete = json_encode(array(
-    'type' => 'error',
-    'msg' => 'Cannot find attributes in post data'
+      'type' => 'error',
+      'msg' => 'Cannot find attributes in post data'
     ));
 
     switch ($action) {