Allow configuring options, closes #30
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
vendor
|
vendor
|
||||||
|
config.php
|
||||||
|
|||||||
+15
-3
@@ -3,9 +3,12 @@ PHP Console
|
|||||||
|
|
||||||
A web console to try your PHP code into
|
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.
|
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.
|
It is secure since accessible only from the local host, and very easy to
|
||||||
|
setup and use.
|
||||||
|
|
||||||
Screenshot
|
Screenshot
|
||||||
----------
|
----------
|
||||||
@@ -15,12 +18,21 @@ Screenshot
|
|||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
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
|
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
|
||||||
|
|
||||||
You can also install it with Composer using this command:
|
You can also install it with Composer using this command:
|
||||||
|
|
||||||
composer create-project --stability=dev --keep-vcs seld/php-console
|
composer create-project --stability=dev --keep-vcs seld/php-console
|
||||||
|
|
||||||
|
To update it just run `git pull` in the directory to pull the latest changes in.
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Default settings are available in `config.php.dist`, if you would like to modify
|
||||||
|
them, you can copy the file to `config.php` and edit settings.
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return array(
|
||||||
|
// how many spaces to use for indention, 0 will make it use real tabs
|
||||||
|
'tabsize' => 4,
|
||||||
|
|
||||||
|
// whitelist of IPs which don't need to be authenticated
|
||||||
|
// use '*' to allow any IP
|
||||||
|
'ip_whitelist' => array('127.0.0.1', '::1'),
|
||||||
|
);
|
||||||
@@ -1,12 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$options = array(
|
$defaults = array(
|
||||||
// which string should represent a tab for indentation
|
// how many spaces to use for indention, 0 will make it use real tabs
|
||||||
'tabsize' => 4,
|
'tabsize' => 4,
|
||||||
|
|
||||||
// whitelist of IPs which don't need to be authenticated
|
// whitelist of IPs which don't need to be authenticated
|
||||||
|
// use '*' to allow any IP
|
||||||
'ip_whitelist' => array('127.0.0.1', '::1'),
|
'ip_whitelist' => array('127.0.0.1', '::1'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (file_exists(__DIR__.'/config.php')) {
|
||||||
|
$options = include __DIR__.'/config.php';
|
||||||
|
$options = array_merge($defaults, $options);
|
||||||
|
} else {
|
||||||
|
$options = $defaults;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Console
|
* PHP Console
|
||||||
*
|
*
|
||||||
@@ -20,7 +29,9 @@ $options = array(
|
|||||||
*
|
*
|
||||||
* Source on Github http://github.com/Seldaek/php-console
|
* Source on Github http://github.com/Seldaek/php-console
|
||||||
*/
|
*/
|
||||||
if (!in_array($_SERVER['REMOTE_ADDR'], $options['ip_whitelist'], true)) {
|
if (!in_array('*', $options['ip_whitelist'], true) &&
|
||||||
|
!in_array($_SERVER['REMOTE_ADDR'], $options['ip_whitelist'], true)
|
||||||
|
) {
|
||||||
header('HTTP/1.1 401 Access unauthorized');
|
header('HTTP/1.1 401 Access unauthorized');
|
||||||
die('ERR/401 Go Away');
|
die('ERR/401 Go Away');
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -149,8 +149,12 @@
|
|||||||
editor.getSession().setMode(new PhpMode());
|
editor.getSession().setMode(new PhpMode());
|
||||||
|
|
||||||
// tab size
|
// tab size
|
||||||
editor.getSession().setTabSize(options.tabsize);
|
if (options.tabsize) {
|
||||||
editor.getSession().setUseSoftTabs(true);
|
editor.getSession().setTabSize(options.tabsize);
|
||||||
|
editor.getSession().setUseSoftTabs(true);
|
||||||
|
} else {
|
||||||
|
editor.getSession().setUseSoftTabs(false);
|
||||||
|
}
|
||||||
|
|
||||||
// events
|
// events
|
||||||
editor.getSession().selection.on('changeCursor', updateStatusBar);
|
editor.getSession().selection.on('changeCursor', updateStatusBar);
|
||||||
|
|||||||
Reference in New Issue
Block a user