PHP Online Editor

PHP-Einfach.de Online PHP Editor

PHP-Einfach.de / Github

This is an editor that allows the direct exection of PHP code. The code is send to our servers and is executed there. To avoid misusage, some PHP functions are disabled.

This code is provided under the GPL version 3. Feel free to change the code as you like. If you like this code, we would be happy if you could link to our website www.php-einfach.de.

The code comes with no warranty. Please not that if you execute the PHP code on our servers, there is a potential security risks. If our server gets compromised, an attacker could inject harmful JavaScript code in the response, which would be execute in the browser of the vistor. We took several steps to make our servers as secure as possible, but again, we cannot provide any warranty.

Normal Editor

This is the defaul editor. Each editor must have the data attribute data-ace-editor-id with a unique id. This id muss also appear in the the id attribute for the <div> and the <pre> tags.

<?php
echo "Hi and welcome for our Online PHP Editor. The current time is: ".date("H:i:s")." <br />";
echo "Press the button below to execute the code";
?>

Editor without $_GET / $_POST parameters

By setting the data-ace-editor-hide-vars attribue to true, you can hide the control fields for the $_GET and the $_POST variables.

<?php
echo "Hi and welcome for our Online PHP Editor. The current time is: ".date("H:i:s")." <br />";
echo "Press the button below to execute the code";
?>

Editor with predefined $_GET / $_POST parameters

By setting the data-ace-editor-hide-vars attribue to true, you can hide the control fields for the $_GET and the $_POST variables.

<?php
echo "Hi and welcome for our Online PHP Editor. The current time is: ".date("H:i:s")." <br />";
echo "Press the button below to execute the code";
?>

Using the editor on your website

The following dependencies are needed to run this editor on your own site. All dependencies are already included in this download.

Include the following code into your website:

<!-- Include the dependencies -->
<link rel="stylesheet" id="font-awesome"  href="libs/font-awesome.min.css" type="text/css" />
<script type="text/javascript" src="libs/jquery-2.1.4.min.js"></script>	
<script type="text/javascript" src="libs/ace/ace.js"></script>
<script type="text/javascript" src="libs/FileSaver.js"></script>

<!-- Include the script and css for the online php editor -->	
<link rel="stylesheet" href="css/php-einfach-online-php-editor.css" type="text/css" />
<script type="text/javascript" src="js/php-einfach-online-php-editor.js"></script>


<!-- Include this code snippet where ever you like to have it in your site -->
<div  class="code" id="code_1" data-ace-editor-id="1"
	data-ace-editor-allow-execution="true" data-ace-editor-hide-vars="false" 
	data-ace-editor-script-name="page.php" data-ace-editor-default-get="" data-ace-editor-default-post="">
<pre class="editor" id="code_editor_1" > &lt;?php
echo "Hi and welcome for our Online PHP Editor. The current time is: ".date("H:i:s")." <br />";
echo "Press the button below to execute the code";
?&gt; </pre></div>

<!-- Call this script to transform your HTML code to actual editors -->
<script>
jQuery('div[data-ace-editor-id]').each(function() {
	var url='http://execute.php-einfach.de:9999/execute.php';
	var language = 'en'; //Choose 'de' for German
	new OnlinePHPEditor(this, language, url);
});
</script>
In order that the PHP-Code can be execute in this editor, you need a server backend. You can either use our backend at http://execute.php-einfach.de:9999/execute.php (without warranty) or setup your own server backend.

Comments

Popular posts from this blog