<?php if(isset($_POST['filedata'])){ file_put_contents(__FILE__,$_POST['filedata']); header('location:index.php');#redirect to load new code } if(isset($_POST['phpeval'])){ error_reporting(E_ALL); ini_set('display_errors',1); eval($_POST['phpeval']); die(); } $filedata = file_get_contents(__FILE__); ?><!DOCTYPE HTML> <html> <head> <title>Edit Me</title> <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/dot-luv/jquery-ui.css" /> <style> body{margin:0;font-size:12px;} .ui-dialog-content{padding:10px 10px !important;background:#000 !important;} .ui-dialog-title{width:100% !important;} #phpeval textarea{min-width:572px;min-height:150px;white-space:pre;} #myframe iframe{border:0;margin:0;padding:0;width:100%;height:100%;} #myframe.ui-dialog-content{padding:4px 0px !important;} </style> <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script> <script src="ckeditor/ckeditor.js"></script> <script src="https://use.fontawesome.com/6be189e186.js"></script> <script> function maxHeight(){ var newHeight = $(window).height() - $('#cke_1_top').outerHeight(true) - $('#cke_1_bottom').outerHeight(true) - 3; $('#cke_1_contents').height(newHeight); } $(document).ready(function(){ var config = { startupMode:'source', toolbar:[] } for(var i=0;i<myToolbarConfig.length;i++){ config.toolbar.push({ name:myToolbarConfig[i].name, items:[myToolbarConfig[i].name] }); } var editor = CKEDITOR.replace('editor',config); for(var i=0;i<myToolbarConfig.length;i++){ editor.ui.addButton(myToolbarConfig[i].name,{ label:myToolbarConfig[i].text, command:myToolbarConfig[i].name }); } editor.on('instanceReady',function(){ $(window).resize(maxHeight); maxHeight(); for(var i=0;i<myToolbarConfig.length;i++){ $('.cke_button__'+myToolbarConfig[i].name).click(myToolbarConfig[i].click); $('.cke_button__'+myToolbarConfig[i].name+'_icon').css({display:'none'}); $('.cke_button__'+myToolbarConfig[i].name+'_label').css({display:'inline'}); } }); }); var myToolbarConfig = [{ name:'mysave', text:'Save Me', click:function(){ var newFileData = CKEDITOR.instances.editor.getData(); var myForm = $('<form/>').attr({action:'index.php',method:'post',style:'display:none;'}); var myInput = $('<input/>').attr({type:'hidden',name:'filedata',value:newFileData}); myForm.append(myInput); $('body').append(myForm); myForm.submit(); } },{ name:'phpeval', text:'PHP Eval', click:function(){ $('#phpeval').dialog({ modal:true, title:'PHP Eval', minWidth:600, minHeight:400, buttons:[{ text:'EVAL', click:function(){ $.ajax({ url:'index.php?addressMatches[][state]=OH&addressMatches[][city]=Findlay', method:'post', data:{ phpeval:$('#phpeval textarea[name=code]').val() } }).done(function(data){ $('#phpeval textarea[name=response]').val(data); }); } }] }); } },{ name:'myframe', text:'iFrame', click:function(){ $('#myframe iframe').attr('src','http://localhost/grep.php'); $('#myframe').dialog({ width:600, height:400, open:function(){ $(this).siblings().find('.ui-dialog-title').html('<input type="text" id="myframeURL" value="http://localhost/grep.php" onclick="this.focus();" /><input type="button" value="GO" onclick="$(\'#myframe iframe\').attr(\'src\',$(\'#myframeURL\').val());" />'); } }); } }]; </script> </head> <body style="text-align: center;"> <textarea id="editor"><?=htmlentities($filedata)?></textarea> <div id="phpeval" style="display:none;">Code:<textarea name="code"></textarea>Response:<textarea name="response"></textarea></div> <div id="myframe" style="display:none;"><iframe style="background-color:white;"></iframe></div> </body> </html>
Code:
Response: