Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/PHPExpress/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ var engine = function (filePath, opts, callback) {

query = opts.query || querystring.stringify(get),
body = opts.body || querystring.stringify(post),
server = opts.server || {},

env = {
REQUEST_METHOD: method,
CONTENT_LENGTH: body.length,
QUERY_STRING: query
QUERY_STRING: query,
};

Object.keys(server).forEach(key => {
env[key] = server[key]
});

var command = util.format(
'%s %s %s %s',
(body ? util.format('echo "%s" | ', body) : '') + binPath,
Expand Down
7 changes: 5 additions & 2 deletions lib/PHPExpress/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module.exports = function(req, res) {
res.render(req.path.slice(1), {
method: req.method,
get: req.query,
post: req.body
post: req.body,
server: {
REQUEST_URI: req.url
}
});
};
};
29 changes: 18 additions & 11 deletions page_runner.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<?php
//parse the command line into the $_GET variable
if ( isset($_SERVER) && array_key_exists('QUERY_STRING', $_SERVER) ) {

$REQUEST_METHOD = isset($_SERVER['REQUEST_METHOD'])
? $_SERVER['REQUEST_METHOD'] : 'GET';

$CONTENT_LENGTH = isset($_SERVER['CONTENT_LENGTH'])
? $_SERVER['CONTENT_LENGTH'] : 0;

//parse the command line into the $_GET variable
if (isset($_SERVER) && array_key_exists('QUERY_STRING', $_SERVER) ) {
parse_str($_SERVER['QUERY_STRING'], $_GET);
}
}

//parse the standard input into the $_POST variable
if (($_SERVER['REQUEST_METHOD'] === 'POST')
&& ($_SERVER['CONTENT_LENGTH'] > 0))
{
parse_str(fread(STDIN, $_SERVER['CONTENT_LENGTH']), $_POST);
}
//parse the standard input into the $_POST variable
if (($REQUEST_METHOD === 'POST')
&& ($CONTENT_LENGTH > 0)
) {
parse_str(fread(STDIN, $CONTENT_LENGTH), $_POST);
}

chdir($argv[1]);
require_once $argv[2];
chdir($argv[1]);
require_once $argv[2];