public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
Changes to api path
8f213e8d
data/conf/nginx/site.conf | 10 ++++------
data/web/js/mailbox.js | 6 +++---
data/web/json_api.php | 27 ++++++++++++++++++++-------
3 files changed, 27 insertions(+), 16 deletions(-)
Diff
diff --git a/data/conf/nginx/site.conf b/data/conf/nginx/site.conf
index 181a802b..685e1fc7 100644
--- a/data/conf/nginx/site.conf
+++ b/data/conf/nginx/site.conf
@@ -18,10 +18,9 @@ server {
access_log /var/log/nginx/access.log;
root /web;
- location /api/v1/ {
- try_files $uri $uri/ /json_api.php?$args;
+ location ~ ^/api/v1/(.*)$ {
+ try_files $uri $uri/ /json_api.php?query=$1;
}
- rewrite ^/api/v1/([^/]+)/([^/]+)/([^/]+)/?$ /json_api.php?action=$1&cat=$2&object=$3? last;
location ^~ /.well-known/acme-challenge/ {
allow all;
@@ -167,10 +166,9 @@ server {
access_log /var/log/nginx/access.log;
root /web;
- location /api/v1/ {
- try_files $uri $uri/ /json_api.php?$args;
+ location ~ ^/api/v1/(.*)$ {
+ try_files $uri $uri/ /json_api.php?query=$1;
}
- rewrite ^/api/v1/([^/]+)/([^/]+)/([^/]+)/?$ /json_api.php?action=$1&cat=$2&object=$3? last;
location ^~ /.well-known/acme-challenge/ {
allow all;
diff --git a/data/web/js/mailbox.js b/data/web/js/mailbox.js
index 9e1da2ac..0f0b4098 100644
--- a/data/web/js/mailbox.js
+++ b/data/web/js/mailbox.js
@@ -306,7 +306,7 @@ $(document).ready(function() {
type: "POST",
dataType: "json",
data: { "address": JSON.stringify(selected_aliases), "active": "1" },
- url: '/api/v1/edit/alias/post',
+ url: '/api/v1/edit/alias',
jsonp: false,
complete: function (data) {
location.reload();
@@ -322,7 +322,7 @@ $(document).ready(function() {
type: "POST",
dataType: "json",
data: { "address": JSON.stringify(selected_aliases), "active": "0" },
- url: '/api/v1/edit/alias/post',
+ url: '/api/v1/edit/alias',
jsonp: false,
complete: function (data) {
location.reload();
@@ -349,7 +349,7 @@ $(document).ready(function() {
type: "POST",
dataType: "json",
data: { "address": JSON.stringify(selected_aliases) },
- url: '/api/v1/delete/alias/post',
+ url: '/api/v1/delete/alias',
jsonp: false,
complete: function (data) {
location.reload();
diff --git a/data/web/json_api.php b/data/web/json_api.php
index b09caa67..44e7d934 100644
--- a/data/web/json_api.php
+++ b/data/web/json_api.php
@@ -1,14 +1,27 @@
<?php
+/*
+edit/alias => POST data:
+ {
+ address: {a, b, c}, (where a, b, c represent alias addresses)
+ active: 1 (0 or 1)
+ }
+
+delete/alias => POST data:
+ {
+ address: {a, b, c}, (where a, b, c represent alias addresses)
+ }
+
+*/
+header('Content-Type: application/json');
require_once 'inc/prerequisites.inc.php';
error_reporting(E_ALL);
if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_username'])) {
- if (isset($_GET['action']) && isset($_GET['cat'])) {
- $category = filter_input(INPUT_GET, 'cat', FILTER_SANITIZE_STRING);
- $action = filter_input(INPUT_GET, 'action', FILTER_SANITIZE_STRING);
-
- if (isset($_GET['object'])) {
- $object = filter_input(INPUT_GET, 'object', FILTER_SANITIZE_STRING);
- }
+ if (isset($_GET['query'])) {
+
+ $query = explode('/', $_GET['query']);
+ $action = (isset($query[0])) ? $query[0] : null;
+ $category = (isset($query[1])) ? $query[1] : null;
+ $object = (isset($query[2])) ? $query[2] : null;
switch ($action) {
case "get":