-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
34 lines (25 loc) · 817 Bytes
/
index.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
31
32
33
34
<?php
$str = '';
$java = `which java`;
$java = 'java';
$dir = realpath('./');
$jslint = $dir.'/lib/jslint/jslint-console.js';
$fulljslint = $dir.'/lib/jslint/fulljslint.js';
$rhino = $dir.'/lib/rhino/js.jar';
if ($_POST['source']) {
$str = $_POST['source'];
$tempName = tempnam(sys_get_temp_dir(), 'jslint-');
file_put_contents($tempName, stripslashes($str));
}
if ($tempName) {
$cmd = $java.' -jar '.escapeshellarg($rhino).' '.escapeshellarg($jslint).' '.escapeshellarg($fulljslint).' '.escapeshellarg($tempName).' 2>&1'; //This redirects error and out to out so we get it..
$out = exec($cmd);
echo($out);
unlink($tempName);
} else {
$json = new stdclass();
$json->status = 'ERROR';
$json->errors = Array('No javascript to lint.');
echo(json_encode($json));
}
?>