Changes to api path
parent
dfee8efa97
commit
8f213e8df9
|
@ -18,10 +18,9 @@ server {
|
||||||
access_log /var/log/nginx/access.log;
|
access_log /var/log/nginx/access.log;
|
||||||
root /web;
|
root /web;
|
||||||
|
|
||||||
location /api/v1/ {
|
location ~ ^/api/v1/(.*)$ {
|
||||||
try_files $uri $uri/ /json_api.php?$args;
|
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/ {
|
location ^~ /.well-known/acme-challenge/ {
|
||||||
allow all;
|
allow all;
|
||||||
|
@ -167,10 +166,9 @@ server {
|
||||||
access_log /var/log/nginx/access.log;
|
access_log /var/log/nginx/access.log;
|
||||||
root /web;
|
root /web;
|
||||||
|
|
||||||
location /api/v1/ {
|
location ~ ^/api/v1/(.*)$ {
|
||||||
try_files $uri $uri/ /json_api.php?$args;
|
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/ {
|
location ^~ /.well-known/acme-challenge/ {
|
||||||
allow all;
|
allow all;
|
||||||
|
|
|
@ -306,7 +306,7 @@ $(document).ready(function() {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: { "address": JSON.stringify(selected_aliases), "active": "1" },
|
data: { "address": JSON.stringify(selected_aliases), "active": "1" },
|
||||||
url: '/api/v1/edit/alias/post',
|
url: '/api/v1/edit/alias',
|
||||||
jsonp: false,
|
jsonp: false,
|
||||||
complete: function (data) {
|
complete: function (data) {
|
||||||
location.reload();
|
location.reload();
|
||||||
|
@ -322,7 +322,7 @@ $(document).ready(function() {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: { "address": JSON.stringify(selected_aliases), "active": "0" },
|
data: { "address": JSON.stringify(selected_aliases), "active": "0" },
|
||||||
url: '/api/v1/edit/alias/post',
|
url: '/api/v1/edit/alias',
|
||||||
jsonp: false,
|
jsonp: false,
|
||||||
complete: function (data) {
|
complete: function (data) {
|
||||||
location.reload();
|
location.reload();
|
||||||
|
@ -349,7 +349,7 @@ $(document).ready(function() {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: { "address": JSON.stringify(selected_aliases) },
|
data: { "address": JSON.stringify(selected_aliases) },
|
||||||
url: '/api/v1/delete/alias/post',
|
url: '/api/v1/delete/alias',
|
||||||
jsonp: false,
|
jsonp: false,
|
||||||
complete: function (data) {
|
complete: function (data) {
|
||||||
location.reload();
|
location.reload();
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
<?php
|
<?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';
|
require_once 'inc/prerequisites.inc.php';
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_username'])) {
|
if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_username'])) {
|
||||||
if (isset($_GET['action']) && isset($_GET['cat'])) {
|
if (isset($_GET['query'])) {
|
||||||
$category = filter_input(INPUT_GET, 'cat', FILTER_SANITIZE_STRING);
|
|
||||||
$action = filter_input(INPUT_GET, 'action', FILTER_SANITIZE_STRING);
|
|
||||||
|
|
||||||
if (isset($_GET['object'])) {
|
$query = explode('/', $_GET['query']);
|
||||||
$object = filter_input(INPUT_GET, 'object', FILTER_SANITIZE_STRING);
|
$action = (isset($query[0])) ? $query[0] : null;
|
||||||
}
|
$category = (isset($query[1])) ? $query[1] : null;
|
||||||
|
$object = (isset($query[2])) ? $query[2] : null;
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case "get":
|
case "get":
|
||||||
|
|
Loading…
Reference in New Issue