forked from twslade/Magento-PHP-Console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
282 lines (249 loc) · 9.87 KB
/
index.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?php
ini_set('display_errors', 1);
$options = array(
// which string should represent a tab for indentation
'tabsize' => 4,
);
require_once 'lib/TFSN/Projects.php';
require_once 'lib/TFSN/Get.php';
require_once 'lib/TFSN/CommandLine.php';
$get = new Get();
$params = $get->getParams();
$commandLine = new CommandLine();
$projects = new Projects();
$projectsList = $title = $errors = '';
$projectsList .= $projects->renderProjects();
$siteDirectory = '';
if(array_key_exists('a', $params) && $params['a'] == 'debug' && array_key_exists('site', $params)){
$site = $params['site'];
$siteDirectory = $projects->getDirectoryFromSiteName($site);
$mageFile = $siteDirectory . 'app/Mage.php';
if(file_exists($mageFile)){
require_once $mageFile;
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
umask(0);
Mage::app();
$title = '<img src="' . Mage::getDesign()->getSkinUrl() . Mage::getStoreConfig('design/header/logo_src') . '" /><br />';
$title .= (array_key_exists('site', $params) ? $params['site'] . ' (<a target="_blank" href="' . Mage::app()->getStore()->getBaseUrl() . '">' . Mage::app()->getStore()->getBaseUrl() . '</a>)': '');
}
}
/**
* PHP Console
*
* A web-based php debug console
*
* Copyright (C) 2010, Jordi Boggiano
* http://seld.be/ - [email protected]
*
* Licensed under the new BSD License
* See the LICENSE file for details
*
* Source on Github http://github.com/Seldaek/php-console
*/
if (!in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'), true)) {
header('HTTP/1.1 401 Access unauthorized');
die('ERR/401 Go Away');
}
define('PHP_CONSOLE_VERSION', '1.3.0-dev');
require 'krumo/class.krumo.php';
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
$debugOutput = '';
if (isset($_POST['code'])) {
$code = $_POST['code'];
if (get_magic_quotes_gpc()) {
$code = stripslashes($code);
}
// if there's only one line wrap it into a krumo() call
if (preg_match('#^(?!var_dump|echo|print|< )([^\r\n]+?);?\s*$#is', $code, $m) && trim($m[1])) {
$code = 'krumo('.$m[1].');';
}
// replace '< foo' by krumo(foo)
$code = preg_replace('#^<\s+(.+?);?[\r\n]?$#m', 'krumo($1);', $code);
// replace newlines in the entire code block by the new specified one
// i.e. put #\r\n on the first line to emulate a file with windows line
// endings if you're on a unix box
if (preg_match('{#((?:\\\\[rn]){1,2})}', $code, $m)) {
$newLineBreak = str_replace(array('\\n', '\\r'), array("\n", "\r"), $m[1]);
$code = preg_replace('#(\r?\n|\r\n?)#', $newLineBreak, $code);
}
ob_start();
eval($code);
$debugOutput = ob_get_clean();
if (isset($_GET['js'])) {
header('Content-Type: text/plain');
echo $debugOutput;
die('#end-php-console-output#');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Magento/Zend/PHP Debug Console</title>
<link rel="stylesheet" type="text/css" href="./assets/styles/styles.css" />
<link rel="stylesheet" type="text/css" href="./assets/styles/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="./assets/styles/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" href="./assets/styles/docs.css" />
<script src="./assets/js/jquery-1.7.1.min.js"></script>
<script src="./assets/js/jquery-tmpl-min.js"></script>
<script src="./assets/js/ace/ace.js"></script>
<script src="./assets/js/ace/mode-php.js"></script>
<script src="./assets/js/php-console.js"></script>
<script src="./assets/js/google-code-prettify/prettify.js"></script>
<script src="./assets/js/storage.js"></script>
<script src="./assets/js/bootstrap-dropdown.js"></script>
<link rel="stylesheet" type="text/css" href="./assets/js/google-code-prettify/prettify.css" />
<script>
$.console({
tabsize: <?php echo json_encode($options['tabsize']) ?>
});
</script>
</head>
<body onload="prettyPrint()">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./index.php">TFSN</a>
</div>
</div>
</div>
<div class="container">
<div class="row">
<span class="span12">
<h1><?php echo ($title != '') ? $title . '<a class="" href="./index.php"><i class="icon icon-remove-sign"></i></a>' : ''; ?></h1>
</span>
</div>
<div class="row">
<div class="span4">
<div class="btn-group">
<a class="btn dropdown-toggle btn-large btn-info" data-toggle="dropdown" href="#">
Projects
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<?php echo $projectsList ?>
</ul>
</div>
</div>
<div id="snippets-wrapper" class="span8">
<h3 id="slideToggleSnippets">
<i id="expand-snippets-icon" class="icon-plus-sign"></i>Snippets: </h3>
<div id="expandable-snippets" style="display: none">
<ul id="snippet-container" class="nav nav-pills nav-stacked">
</ul>
<script id="snippetsTemplate" type="text/x-jQuery-tmpl">
<li class="active row">
<a
class="load-snippet span4"
data-project="${snippetProject}"
data-label="${snippetLabel}"
onClick="TFSN.LocalStorageHelper.checkSnippet(this)"
>
${snippetProject}: ${snippetLabel}
</a>
<i class="preview-snippet icon-plus-sign"></i>
<i class="remove-snippet icon icon-remove-sign"></i>
<pre class="prettyprint linenums span6 lang-php" style="display: none;">${snippetCode}</pre>
</li>
</script>
<div>
<button id="clearSnippets" class="btn btn-danger">Remove All Snippets <i class="icon-white icon-minus-sign"></i></button>
</div>
</div>
</div>
</div>
<div class="row">
<div class="span12" id="messages">
</div>
</div>
<div class="row">
<div class="span12">
<div class="output"><pre><?php echo $debugOutput ?></pre></div>
</div>
</div>
<div class="row">
<div class="span12">
<form id="code-form" method="POST" action="">
<div class="input">
<label for="editor"></label>
<textarea class="editor" id="editor" name="code"></textarea>
<div class="statusbar">
<span class="position">Line: 1, Column: 1</span>
<span class="copy">
Copy selection: <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="110" height="14" id="clippy">
<param name="movie" value="clippy/clippy.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param NAME="FlashVars" value="text=">
<param name="bgcolor" value="#E8E8E8">
<embed src="clippy/clippy.swf"
width="110"
height="14"
name="clippy"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"
FlashVars="text="
bgcolor="#E8E8E8"
/>
</object>
</span>
</div>
</div>
<input id="try-this" type="submit" name="subm" value="Try this!" class="btn btn-large btn-success" />
<input id="save-snippet" type="button" name="save-snippet" value="Save Snippet!" class="btn btn-primary" />
</form>
</div>
</div>
<div class="row">
<div class="span4">
<div class="help">
debug:
< foo()
krumo(foo());
</div>
</div>
<div class="span4">
<div class="help">
commands:
krumo::backtrace();
krumo::includes();
krumo::functions();
krumo::classes();
krumo::defines();
</div>
</div>
<div class="span4">
<div class="help">
misc:
press ctrl-enter to submit
put '#\n' on the first line to enforce
\n line breaks (\r\n etc work too)
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
var localStorageKey = 'PhpSnippets';
TFSN.LocalStorageHelper = new TFSN.LocalStorageHelper();
TFSN.LocalStorageHelper.initialize(localStorageKey);
$('#slideToggle').click(function() {
$('#expandable').slideToggle();
$('#expand-icon').toggleClass('icon-minus-sign');
});
$('#slideToggleSnippets').click(function() {
$('#expandable-snippets').slideToggle();
$('#expand-snippets-icon').toggleClass('icon-minus-sign');
});
$('.dropdown-toggle').dropdown()
});
</script>
</body>
</html>