Revision 3e115dbf
Added by Stephen Beaver over 9 years ago
src/usr/local/www/exec.php | ||
---|---|---|
275 | 275 |
</div> |
276 | 276 |
</div> |
277 | 277 |
<?php |
278 |
// Experimentl version. Writes the user's php code to a file and executes it via a new instance of PHP |
|
279 |
// THis is intended to prevent bad code from breaking the GUI |
|
278 | 280 |
if (!isBlank($_POST['txtPHPCommand'])) { |
279 | 281 |
puts("<div class=\"panel panel-success responsive\"><div class=\"panel-heading\">PHP response</div>"); |
280 | 282 |
puts("<pre>"); |
281 |
require_once("config.inc"); |
|
282 |
require_once("functions.inc"); |
|
283 |
echo eval($_POST['txtPHPCommand']); |
|
283 |
$phpfile = fopen("/tmp/phpfile", "w"); |
|
284 |
fwrite($phpfile, "<?php\n"); |
|
285 |
fwrite($phpfile, "require_once(\"/etc/inc/config.inc\");\n"); |
|
286 |
fwrite($phpfile, "require_once(\"/etc/inc/functions.inc\");\n\n"); |
|
287 |
fwrite($phpfile, $_POST['txtPHPCommand'] . "\n"); |
|
288 |
fwrite($phpfile, "?>\n"); |
|
289 |
fclose($phpfile); |
|
290 |
|
|
291 |
exec("/usr/local/bin/php /tmp/phpfile", $output); |
|
292 |
|
|
293 |
for ($i=0; $i < count($output); $i++) { |
|
294 |
print($output[$i] . "\n"); |
|
295 |
} |
|
296 |
|
|
297 |
unlink("/tmp/phpfile"); |
|
298 |
|
|
299 |
// echo eval($_POST['txtPHPCommand']); |
|
284 | 300 |
puts(" </pre>"); |
285 | 301 |
puts("</div>"); |
286 | 302 |
?> |
Also available in: Unified diff
Experimental: Fixes #5288