Commit 29dc0b5e authored by Franco Fichtner's avatar Franco Fichtner

rc: improve the php config write

o Don't clobber manually installed extensions
o Remove the XDebug enable in favour of an autoload if available
o No longer install XDebug by default

Adds long overdue copyrights, been handling this file since 2014.
parent 68074f42
...@@ -73,7 +73,6 @@ CORE_DEPENDS?= apinger \ ...@@ -73,7 +73,6 @@ CORE_DEPENDS?= apinger \
phalcon \ phalcon \
php-pfSense \ php-pfSense \
php-suhosin \ php-suhosin \
php-xdebug \
php56 \ php56 \
php56-bcmath \ php56-bcmath \
php56-ctype \ php56-ctype \
......
#!/bin/sh #!/bin/sh
# Copyright (C) 2014-2016 Franco Fichtner <franco@opnsense.org>
# Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com> # Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
# All rights reserved. # All rights reserved.
# #
...@@ -72,8 +73,13 @@ PHPMODULES="$PHPMODULES filter" ...@@ -72,8 +73,13 @@ PHPMODULES="$PHPMODULES filter"
# OPNsense # OPNsense
PHPMODULES="$PHPMODULES phalcon" PHPMODULES="$PHPMODULES phalcon"
_EXTENSIONS_INI=$(mktemp -q /tmp/extensions_ini.XXXXXX)
EXTENSIONS_INI=/usr/local/etc/php/extensions.ini
touch ${EXTENSIONS_INI}
cp ${EXTENSIONS_INI} ${_EXTENSIONS_INI}
# Clear the .ini file to make sure we are clean # Clear the .ini file to make sure we are clean
rm -f /usr/local/etc/php/extensions.ini
rm -f /usr/local/etc/php.ini rm -f /usr/local/etc/php.ini
rm -f /usr/local/lib/php.ini rm -f /usr/local/lib/php.ini
...@@ -117,16 +123,15 @@ EOF ...@@ -117,16 +123,15 @@ EOF
# Loop through and generate modules to load. # Loop through and generate modules to load.
for EXT in ${PHPMODULES}; do for EXT in ${PHPMODULES}; do
if [ -f "${EXTENSIONSDIR}${EXT}.so" ]; then sed -i '' -e "/${EXT}.so/d" ${_EXTENSIONS_INI}
echo "extension=${EXT}.so" >> /usr/local/etc/php/extensions.ini echo "extension=${EXT}.so" >> ${_EXTENSIONS_INI}
fi
done done
# Enable XDebug if enabled in config # Enable XDebug if installed
if [ ! -z `grep "<enable_xdebug>1</enable_xdebug>" /conf/config.xml` ]; then if [ -f "${EXTENSIONSDIR}xdebug.so" ]; then
cat >> /usr/local/etc/php/extensions.ini << EOF sed -i '' -e "/xdebug.so/d" ${_EXTENSIONS_INI}
zend_extension=xdebug.so echo "zend_extension=${EXTENSIONSDIR}xdebug.so" >> ${_EXTENSIONS_INI}
EOF
cat >> /usr/local/lib/php.ini << EOF cat >> /usr/local/lib/php.ini << EOF
[xdebug] [xdebug]
...@@ -156,3 +161,4 @@ EOF ...@@ -156,3 +161,4 @@ EOF
# Copy php.ini file to etc/ too (cli) # Copy php.ini file to etc/ too (cli)
cp /usr/local/lib/php.ini /usr/local/etc/php.ini cp /usr/local/lib/php.ini /usr/local/etc/php.ini
mv ${_EXTENSIONS_INI} ${EXTENSIONS_INI}
...@@ -46,7 +46,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -46,7 +46,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']); $pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
$pconfig['nodnsrebindcheck'] = isset($config['system']['webgui']['nodnsrebindcheck']); $pconfig['nodnsrebindcheck'] = isset($config['system']['webgui']['nodnsrebindcheck']);
$pconfig['nohttpreferercheck'] = isset($config['system']['webgui']['nohttpreferercheck']); $pconfig['nohttpreferercheck'] = isset($config['system']['webgui']['nohttpreferercheck']);
$pconfig['enable_xdebug'] = isset($config['system']['webgui']['enable_xdebug']) ;
$pconfig['loginautocomplete'] = isset($config['system']['webgui']['loginautocomplete']); $pconfig['loginautocomplete'] = isset($config['system']['webgui']['loginautocomplete']);
$pconfig['althostnames'] = $config['system']['webgui']['althostnames']; $pconfig['althostnames'] = $config['system']['webgui']['althostnames'];
$pconfig['enableserial'] = $config['system']['enableserial']; $pconfig['enableserial'] = $config['system']['enableserial'];
...@@ -152,12 +151,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -152,12 +151,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
unset($config['system']['webgui']['nohttpreferercheck']); unset($config['system']['webgui']['nohttpreferercheck']);
} }
if ($pconfig['enable_xdebug'] == "yes") {
$config['system']['webgui']['enable_xdebug'] = true;
} elseif (isset($config['system']['webgui']['enable_xdebug'])) {
unset($config['system']['webgui']['enable_xdebug']);
}
if ($pconfig['loginautocomplete'] == "yes") { if ($pconfig['loginautocomplete'] == "yes") {
$config['system']['webgui']['loginautocomplete'] = true; $config['system']['webgui']['loginautocomplete'] = true;
} elseif (isset($config['system']['webgui']['loginautocomplete'])) { } elseif (isset($config['system']['webgui']['loginautocomplete'])) {
...@@ -467,18 +460,6 @@ include("head.inc"); ...@@ -467,18 +460,6 @@ include("head.inc");
</div> </div>
</td> </td>
</tr> </tr>
<tr>
<td><a id="help_for_xdebug" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Enable XDebug"); ?></td>
<td width="78%">
<input name="enable_xdebug" type="checkbox" value="yes" <?=!empty($pconfig['enable_xdebug']) ? "checked=\"checked\"" : "";?> />
<strong><?=gettext("Enable debugger / profiler (developer mode, do not enable in production environment)"); ?></strong>
<div class="hidden" for="help_for_xdebug">
<?php echo gettext("When this is checked, php XDebug will be enabled and profiling output can be analysed using webgrind which will be available at [this-url]/webgrind/"); ?>
<br />
<?php echo gettext("For more information about XDebug profiling and how to enable it for your requests, please visit http://www.xdebug.org/docs/all_settings#profiler_enable_trigger"); ?>
</div>
</td>
</tr>
<tr> <tr>
<th colspan="2"><?=gettext("Secure Shell"); ?></th> <th colspan="2"><?=gettext("Secure Shell"); ?></th>
</tr> </tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment