datadir = "{$globals->spoolroot}/$alias"; $this->caller =& $caller; $this->alias = $alias; } /** Execute a shell command and store information about it. * * @param $cmd the command to execute */ function cmdExec($cmd) { $this->cmd_call = $cmd; unset($this->cmd_output); unset($this->cmd_return); exec($cmd, $this->cmd_output, $this->cmd_return); return $this->cmd_return; } /** Return information about the last command that was executed. */ function cmdStatus() { $out = "-- [ command information ] -- \n". "command : {$this->cmd_call}\n". "return value : {$this->cmd_return}\n". "-- [ command output ] --\n". implode("\n", $this->cmd_output)."\n". "--"; return $out; } /** Report an information. * * @param msg */ function info($msg) { $this->caller->info($msg); } /** Die with a given error message. * * @param msg */ function kill($msg) { $this->caller->kill($msg); } /** Record an action to the log. * * @param action * @param data */ function log($action,$data) { $this->caller->log($action, $data); } /** Check that a path is valid. * * @param parent parent directory * @param entry the item * @param fatal should we consider a failure to be fatal? */ function checkPath($parent,$entry,$fatal = true) { $ret = preg_match("/^([a-zA-Z0-9\-_]+[\.,\/]?)*$/",$parent) && preg_match("/^([a-zA-Z0-9\-_]+[\., ]?)*$/",$entry); if (!$ret && $fatal) $this->kill("malformed path ('$parent','$entry')"); return $ret; } /** Add missing tags to a Diogenes page to make it a proper HTML file * * @param html * @see importHtmlString */ function exportHtmlString($html) { // if we have the body open & close tags, return raw file if (preg_match("/
]*|)>(.*)<\/body>/si",$html)) return $html; return "\n