check for "shell_exec" before using it

Christof Meerwald via Phpwiki-talk <[email protected]> Tue, 23 Jan 2024 22:07:16 +0100
Newsgroups gmane.comp.web.wiki.phpwiki.talk
Message-ID <[email protected]>
--4yLyb/IG91GIHlXn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

"shell_exec" might have been disabled in the PHP configuration, this
will result in a hard error when trying to use ` (shell_exec), so
check for it.

(btw, there is another use in Units.php, but that can be disabled with
DISABLE_UNITS=1, so didn't bother to patch that one)


Christof

-- 

https://cmeerw.org                             sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org                   xmpp:cmeerw at cmeerw.org

--4yLyb/IG91GIHlXn
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="systeminfo.diff"

Index: lib/plugin/SystemInfo.php
===================================================================
--- lib/plugin/SystemInfo.php	(revision 11072)
+++ lib/plugin/SystemInfo.php	(working copy)
@@ -403,7 +403,11 @@
         if (empty($content)) {
             $dir = defined('PHPWIKI_DIR') ? PHPWIKI_DIR : '.';
             //TODO: windows only (no cygwin)
-            $appsize = `du -s $dir | cut -f1`;
+            if (function_exists('shell_exec')) {
+                $appsize = `du -s $dir | cut -f1`;
+            } else {
+                $appsize = 0;
+            }
 
             if (in_array($DBParams['dbtype'], array('SQL', 'PDO'))) {
                 //TODO: where is the data is actually stored? see phpMyAdmin
@@ -417,8 +421,12 @@
                 }
                 // if issubdirof($dbdir, $dir) $appsize -= $pagesize;
             } else { // flatfile
-                $dbdir = $DBParams['directory'];
-                $pagesize = `du -s $dbdir`;
+                if (function_exists('shell_exec')) {
+                    $dbdir = $DBParams['directory'];
+                    $pagesize = `du -s $dbdir`;
+                } else {
+                    $pagesize = 0;
+                }
                 // if issubdirof($dbdir, $dir) $appsize -= $pagesize;
             }
             $content = array('appsize' => $appsize,

--4yLyb/IG91GIHlXn
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--4yLyb/IG91GIHlXn
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Phpwiki-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/phpwiki-talk

--4yLyb/IG91GIHlXn--