Permalink
Browse files

Initial import

  • Loading branch information...
0 parents commit 743e4ecee64ff880a1bf027a242ddff074c40b6e @Seldaek committed Aug 27, 2010
24 LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2010, Jordi Boggiano <j.boggiano@seld.be>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Slippy nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,41 @@
+PHP Console
+===========
+
+A web console to try your PHP code into
+
+Creating a test file or using php's interactive mode can be a bit cumbersome to try random php snippets. This allows you to run small bits of code easily right from your browser.
+
+It is secure since accessible only from the local host, and very easy to setup and use.
+
+Setup
+-----
+
+Clone the git repo or download it as a zip/tarball, drop it somewhere in your local web document root and access it with http://localhost/path/to/php-console
+
+Contribute
+----------
+
+If you like this piece of software, please consider contributing back with Flattr or Pledgie:
+
+<a href="http://flattr.com/thing/55112/PHP-Web-Debug-Console" target="_blank"><img src="http://api.flattr.com/button/button-static-50x60.png" title="Flattr this" border="0" /></a> <a href="http://pledgie.com/campaigns/12919"><img alt="Click here to lend your support to slippy and make a donation via pledgie.com !" src="http://www.pledgie.com/campaigns/12919.png?skin_name=chrome" border="0" /></a>
+
+Code contributions or ideas are obviously also much welcome.
+
+Author
+------
+
+Jordi Boggiano - <j.boggiano@seld.be><br />
+<http://seld.be/> - <http://twitter.com/seldaek>
+
+Changelog
+---------
+
+- 1.0.0
+ - Initial Public Release
+
+License
+-------
+
+PHP Console is licensed under the New BSD License, which means you can do pretty much anything you want with it.
+
+New BSD License - see the LICENSE file for details
@@ -0,0 +1,94 @@
+<?php
+
+/**
+ * PHP Console
+ *
+ * A web-based php debug console
+ *
+ * Copyright (C) 2010, Jordi Boggiano
+ * http://seld.be/ - j.boggiano@seld.be
+ *
+ * Licensed under the new BSD License
+ * See the LICENSE file for details
+ *
+ * Source on Github http://github.com/Seldaek/php-console
+ */
+if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
+ header('HTTP/1.1 401 Access unauthorized');
+ die('ERR/401 Go Away');
+}
+
+define('PHP_CONSOLE_VERSION', '1.0');
+require 'krumo/class.krumo.php';
+
+ini_set('log_errors', 0);
+ini_set('display_errors', 1);
+error_reporting(E_ALL | E_STRICT);
+
+$debugOutput = '';
+
+if (isset($_POST['code'])) {
+ $code = $_POST['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 = '<div class="output">'.ob_get_clean().'</div>';
+}
+
+?>
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <title>Debug Console</title>
+ <link rel="stylesheet" type="text/css" href="styles.css" />
+ <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
+ <script type="text/javascript" src="jquery.selections.js"></script>
+ <script type="text/javascript" src="php-console.js"></script>
+ </script>
+ </head>
+ <body><?php echo $debugOutput ?>
+ <form method="POST" action="">
+ <textarea cols="100" rows="20" name="code"><?php echo (isset($_POST['code']) ? htmlentities($_POST['code'], ENT_QUOTES, 'UTF-8') : null) ?></textarea>
+ <input type="submit" name="subm" value="Try this!" />
+ </form>
+ <div class="help">
+ debug:
+ &lt; foo()
+ krumo(foo());
+ </div>
+ <div class="help">
+ commands:
+ krumo::backtrace();
+ krumo::includes();
+ krumo::functions();
+ krumo::classes();
+ krumo::defines();
+ </div>
+ <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 class="footer">
+ php-console v<?php echo PHP_CONSOLE_VERSION ?> - by <a href="http://seld.be/">Jordi Boggiano</a> - <a href="http://github.com/Seldaek/php-console">sources on github</a>
+ </div>
+ </body>
+</html>
Oops, something went wrong.

0 comments on commit 743e4ec

Please sign in to comment.