-
Notifications
You must be signed in to change notification settings - Fork 4
/
functions.php
30 lines (27 loc) · 957 Bytes
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
function take_action_if_desired() {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
mkdir('/var/www');
// Store a Hello, world in /var/www/index.html.
file_put_contents('/var/www/index.html', "Hello, world!");
}
}
function getPublishingHelperOutputLines() {
// Execute the Sandstorm publishing helper.
$lines = [];
$cmd = '/opt/app/sandstorm-integration/bin/getPublicId';
$headers = apache_request_headers();
$cmd = $cmd . ' ' . $headers['X-Sandstorm-Session-Id'];
$output = exec($cmd, $lines);
// In this sample app, we leave parsing the output of this command
// to the caller. So we just return these lines as-is.
return $lines;
}
// Security note:
//
// This app has no cross-site request forgery protection. It also
// has no access control. It relies on Sandstorm for those.
//
// It also is arguably shell-injectable in the way it constructs
// $cmd. Apologies. This is PHP.
?>