The Json class provides useful functions for servicing AJAX requests.
In the simplest form, this class is used in the following manner:
postResults($results);</code>
To run a arbitrary system command, the following represents the simplest form:
exec('ls -al /tmp 2>&1');
$json->postResults($results);</code>
See: wui/php/wireless/wireless-json.php for a more advanced example.
Located in /lib/Json.php (line 47)
| Class | Description |
|---|---|
| NstFileStorage | This class provides a file based implementation remote storage support for the NstRemoteStorage JavaScript class. |
| JsonAdnsresfilter | Extend the base Json class with andsresfilter specific methods. |
Set header information for JSON response.
Run a system command and return results in a associative array.
This method runs a arbitrary system command and returns the results in a associative array (which can then be posted).
The following example shows how one might use this to allow a directory listing on a directory which is specified in a POST/GET request (or defaults to "/tmp" if not in request).
getCommand('ls');
$dir = escapeshellcmd($json->getValue('dir', '/tmp');
$results = json->exec("{$ls} -al {$dir} 2>&1");
$json->postResults($results);
?></code>
Build standard looking 'exec' results.
Get full path to a program to run.
Get access to a CommandLine instance for execing commands.
Get request parameter value (or default).
Post PHP entity as JSON encoded object.
Documentation generated on Sun, 11 Feb 2018 07:41:02 -0500 by phpDocumentor 1.4.4