JSON for CMD_API: backup send

Version 1.61.0

Bugfix
Finished

By default, CMD_API_* calls were not designed for JSON deliveries. CMD_* calls (non-API) were setup for this, where action functions (eg: create an email account) have 2 flags: - api - json_out where api==1 for CMD_API calls and json_out=1 for &json=yes calls. As it wasn't account for in the design (CMD_API calls were coded years before we supported JSON with CMD_* calls), there are logical scenarios where combining CMD_API calls with json=yes would not give json output. This code change is a fall-back, where the unified CMD_API handler function now has a check for json=yes, such that JSON output will be sent, if CMD_API and json=yes are both set. As this is a single-level array, there might be cases where a JSON value has "name" : "some=encoded&value=url" in the even it's a double-encoded URL, so please let us know if you hit any and would like it resolved to be: "name": { "some" : "encoded", "value" : "url" } as extra checks would be needed. Not yet sure if this will even happen. --- March 18th, 2020: Also reworked the header vs body "has_sent" flags, to prevent a 2nd call from trying to send data again. This was caused by some functions sending their own data, while CMD_API calls send from outside the function, after it's exited.

Interested to try DirectAdmin? Get a 30-day Free Trial!