k2f

PHP strange DOCUMENT_ROOT

妖精的绣舞 提交于 2020-01-01 12:32:51
问题 So basically, I'm writing a framework, and as part of it features, it's supposed to provide a set of well-established URIs/paths to the end-developer. Some two of these paths make use of $_SERVER['DOCUMENT_ROOT'] : /** * Absolute filesystem path to web root install (aka docroot). * @example "C:/wamp/www" OR "/home/visitgoz/public_html/" */ CFG::set('ABS_WWW', str_replace( $tmpseps, DIRECTORY_SEPARATOR, truepath($_SERVER['DOCUMENT_ROOT']).'/' ) ); /** * K2F path relative to web root. *

Proper shell execution in PHP

柔情痞子 提交于 2019-12-09 09:44:57
问题 The problem I was using a function that made use of proc_open() to invoke shell commands. It seems the way I was doing STDIO was wrong and sometimes caused PHP or the target command to lock up. This is the original code: function execute($cmd, $stdin=null){ $proc=proc_open($cmd,array(0=>array('pipe','r'),1=>array('pipe','w'),2=>array('pipe','w')),$pipes); fwrite($pipes[0],$stdin); fclose($pipes[0]); $stdout=stream_get_contents($pipes[1]); fclose($pipes[1]); $stderr=stream_get_contents($pipes