PHP Notepad
The PHP Notepad is still currently under development. It probably still has some vulnerabilities, but I am working to resolve them. The finalized version is coming soon, but feel free to use it! I would like to thank everyone for testing this beta version, especially the reddit PHP community.
The PHP Notepad executes your PHP code online.
It is true that certain PHP functions have been restricted on the PHP Notepad. Ok, many functions have been restricted as PHP has a few thousand functions. The most useful functions are enabled, but the functions you could use to take down this website are not, but hopefully, you did not want to hack my site anyway. If you want to do file manipulation, printing server variables, etc., you will probably need to open your own offline editor.
Have you ever wanted to try to execute some PHP code really quick? It is very annoying to open a text editor, write the code, upload the file, and then navigate to its address. That is a lot of steps just to see your PHP code. Why not use test your php code right here in the PHP Notepad?
The PHP Notepad can take 3 types of input:
However, the PHP Notepad will not let you use PHP codes inside HTML without PHP tags. This is because how can you determine PHP inside HTML without PHP tags? You can't. Therefore, it will display as regular HTML.
Problems with the PHP Notepad?
The PHP Notepad is in beta testing, but is slowly moving into production. If you find any issues with the PHP Notepad or cannot figure out how to use it, please use the comments form below to tell me about any issues. Don't hesitate; I really want to make it better and help you learn! Of course, you can also send suggestions on how to improve how you can test your PHP code. The PHP Notepad is only for practice and quick executions.
After Hours Programming






Comment or Suggestion?
Comments are a way to tell me about corrections or suggestions, what you thought about the resource, or providing additional information. Help feed the discussion!
Comments
I would like to recommend that you take a different route than using regex to find functions and ban them. You banned base64_decode, but there are a myriad ways to do something in a programming language. For example #1: $f = str_rot13('svyr_trg_pbagragf'); print $f('php-notepad-regex.php'); Take #2: $f = str_replace('ph', 'f', 'phile_get_contents'); print $f('php-notepad-regex.php'); Sure, you could go ahead and ban str_replace and str_rot13, but what would you about this: $f = 'xile_fet_montents'; for($i = 0; $i < 14; $i++){ switch($f[$i]){ case 'x': $f[$i] = 'f'; break; case 'f': $f[$i] = 'g'; break; case 'm': $f[$i] = 'c'; break; } } print $f('php-notepad-regex.php'); Ban foreach and switch? What I recommend you use instead is some kind of sandboxing that is a bit more advanced than regular expressions. 1) Either try to assign a custom php.ini to the php-notepad folder and disable "file_get_contents" in there. That way you can re-enable chr(), base64_decode() etc harmless functions, since even if I put "file_get_contents" into $f and call it, PHP will quit with a security error. 2) You can look into the "runkit" extension for PHP, which is essentially a PHP VM and does exactly sandboxing. You can even replace built-in functions with your own, etc. http://www.php.net/manual/en/book.runkit.php 3) Do what other online universal code runners do, and create a folder outside of the wwwroot, cd into it, run the whole php binary with the code sample as a parameter and chroot the php process to the temporary dir you created. Kill it after 2 seconds or if it goes over x% CPU usage, then delete the temporary folder. 4) If you are unable to install PHP extensions (eg. host won't let you) then look into PHP-based solutions for sandboxing code: https://github.com/fieryprophet/php-sandbox (However, this is still PHP-based PHP sandboxing, so it is exploitable. It is vulnerable to this: http://www.thespanner.co.uk/2011/09/22/non-alphanumeric-code-in-php/ ) Feel free to remove my comment or edit out the codes, as they demonstrate a vulnerability on your production server.Hey, the script is great. I don't want to be "that guy", but it's really easy to bypass your *file* restriction. // to list files (you can do ../ and so on) print_r(scandir('.')); // to bypass your security and open file $f = base64_decode('ZmlsZV9nZXRfY29udGVudHM='); echo '<pre>'.htmlspecialchars($f('php-notepad-regex.php')).'</pre>';