/** * Constructor. * @return void */ public function init() { $this->header('Content-Type: text/html'); // default header. $this->proc = new \PHPDaemon\Core\ShellCommand(); $this->proc->readPacketSize = $this->appInstance->readPacketSize; $this->proc->onReadData([$this, 'onReadData']); $this->proc->onWrite([$this, 'onWrite']); $this->proc->binPath = $this->appInstance->binPath; $this->proc->chroot = $this->appInstance->chroot; if (isset($this->attrs->server['BINPATH'])) { if (isset($this->appInstance->binAliases[$this->attrs->server['BINPATH']])) { $this->proc->binPath = $this->appInstance->binAliases[$this->attrs->server['BINPATH']]; } elseif ($this->appInstance->config->allowoverridebinpath->value) { $this->proc->binPath = $this->attrs->server['BINPATH']; } } if (isset($this->attrs->server['CHROOT']) && $this->appInstance->config->allowoverridechroot->value) { $this->proc->chroot = $this->attrs->server['CHROOT']; } if (isset($this->attrs->server['SETUSER']) && $this->appInstance->config->allowoverrideuser->value) { $this->proc->setUser = $this->attrs->server['SETUSER']; } if (isset($this->attrs->server['SETGROUP']) && $this->appInstance->config->allowoverridegroup->value) { $this->proc->setGroup = $this->attrs->server['SETGROUP']; } if (isset($this->attrs->server['CWD']) && $this->appInstance->config->allowoverridecwd->value) { $this->proc->cwd = $this->attrs->server['CWD']; } elseif ($this->appInstance->config->cwd->value !== null) { $this->proc->cwd = $this->appInstance->config->cwd->value; } else { $this->proc->cwd = dirname($this->attrs->server['SCRIPT_FILENAME']); } $this->proc->setArgs([$this->attrs->server['SCRIPT_FILENAME']]); $this->proc->setEnv($this->attrs->server); $this->proc->execute(); }