Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A tiny PHP sandbox powered by Docker

License

NotificationsYou must be signed in to change notification settings

markjivko/php-sandbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is a tiny PHP sandbox powered by Docker andAce editor.

Use it for quick tests, pair programming or even online interviews.

How to install

  1. First install theLAMP stack (Apache, MySQL, PHP)
sudo apt-get install lamp-server
  1. Clone the repo and link/var/www/html/ tosrc/
git clone https://github.com/markjivko/php-sandboxsudo rm -rf /var/www/htmlln -s $(pwd)/php-sandbox/src /var/www/html

By default Apache runs aswww-data:www-data, which means our php scripts have read-only access to the file system.

This is by design:

  • The only way to create new pages is to manually add text files in/var/www/html/code/
  • In order to make pages editable, manually change their permission to666 (via cli or UI)

There is only 1 page available when you install this script,index.txt.

  • In order to view it, open a browser athttp://localhost/
  • Make it editable withchmod 666 /var/www/html/code/index.txt or directly from your favorite file explorer

Page names contain only lower-case alpha-numeric characters and dashes (regex[\w\-]{1,128}).Page URLs correspond to text files without the ".txt" extension.

  1. Last but not least,installDocker

Update

Updating is as simple as running the following commands:

git add -Agit reset --hardgit pull

Your work in/var/www/html/code is not affected.

Security

The project is read-only for Apache with the exception of the text files you selected.

Your text files are executed with PHP only inside of a Docker container.

  • the Docker container has read-only access to/var/ww/html/code only
  • the script is killed automatically after 3 seconds
  • output is limited to 512KB in length; OOM issues are prevented by forwardingpassthru output to a custom output buffer handler
  • total code size is limited to 512KB

Search functionality is missing by design.However, you could view all pages by running this PHP script:

echo `ls -l /var/www/html/code`;

Improvements

The current version uses a basic state machine to check for changes and regularly fetch updates. This model does not prevent race conditions.diff-match-patch is used to optimally update code changes for observers.

Websockets could be used to make the typing experience more fluid for all parties involved, however this approach is sensitive to network issues (lag, connection losses etc.)

The app is intentionally bare-bones; there are no users/roles/databases to worry about; you just manually add text files in/var/www/html/code/ and set their permissions accordingly.

Simplicity is the ultimate sophistication.

-- Leonardo Da Vinci


[8]ページ先頭

©2009-2025 Movatter.jp