note 85794 deleted from function.exec by cmb

From: Date: Sun, 24 Nov 2019 08:54:12 +0000
Subject: note 85794 deleted from function.exec by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213214@lists.php.net to get a copy of this message
Note Submitter: frantik ---- <?php function _exec($cmd) { $WshShell = new COM("WScript.Shell"); $cwd = getcwd(); if (strpos($cwd,' ')) { if ($pos = strpos($cmd, ' ')) { $cmd = substr($cmd, 0, $pos) . '" ' . substr($cmd, $pos); } else { $cmd .= '"'; } $cwd = '"' . $cwd; } $oExec = $WshShell->Run("cmd /C \" $cwd\\$cmd\"", 0,true); return $oExec == 0 ? true : false; } ?> capture output using ob_start() if you like. Extra code looks for spaces and adds quote marks as they are needed

« previous php.notes (#213214) next »