-
Notifications
You must be signed in to change notification settings - Fork 0
/
Salvor.php
107 lines (93 loc) · 2.33 KB
/
Salvor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/*
Plugin Name: Salvor
Plugin URI: http://clarknikdelpowell.com
Description: Test PHP code from wordpress control panel tools.
Author: Samuel Mello
Author URI: http://clarknikdelpowell.com/agency/people/sam/
Version: 1.2
Copyright 2013+ Clark/Nikdel/Powell (email : sam@clarknikdelpowell.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2 (or later),
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// set global variable
$code = '';
function salvor_print_page() {
global $code;
?>
<style>
#content {
margin-top:50px;
}
#code {
width:90%;
height:300px;
}
#submit {
display:block;
}
#results {
margin-top:20px;
}
</style>
<h2>Salvor</h2>
<em>Inline PHP Testing</em>
<div id="content">
<?php
if (is_super_admin()) {
?>
<form id="salvorform" action="tools.php?page=salvor" method="post">
<textarea name="code" id="code">
<?php
if (isset($code) && $code) echo $code;
else {
?>/*
* Enter your PHP code in here.
*
* You can use this to test wordpress functions like "get_post", "wp_uploads_dir", etc.
*/<?php
}
?>
</textarea>
<input id="submit" class="button button-primary" type="submit" value="Execute Code" />
</form>
</div>
<div id="results">
<?php if(isset($code) && $code) echo '<h2><em>Results:</em></h2>' ?>
<?php
if(isset($code) && $code) {
try {
eval($code);
}
catch (Exception $e) {
echo $e;
}
}
}
else {
echo '<span style="color:#f00;">You must be a super-admin to use this tool.</span>';
}
?>
</div>
<?php
}
function salvor_create_page() {
add_management_page('Salvor','Salvor','manage_options','salvor','salvor_print_page');
}
add_action('admin_menu','salvor_create_page');
function salvor_intercept_post() {
global $code;
if (isset($_POST['code']) && $_POST['code']) {
$code = stripslashes($_POST['code']);
}
}
add_action('wp_loaded','salvor_intercept_post');
?>