public function onResponseSent() { if (!$this->settings->hasSetting("debug_log") or !$this->environment->request()) { return; } $path = $this->environment->request()->path(); if (count($path) > 0 and strcasecmp($path[0], "debug") == 0) { return; } $log = $this->settings->setting("debug_log"); $handle = @fopen($log, "a"); if (!$handle) { Logging::logError("Could not write to log file: " . $log); return; } $trace = Logging::getTrace(); try { foreach ($trace as $d) { fwrite($handle, Util::toString($d)); } fclose($handle); } catch (Exception $e) { Logging::logError("Could not write to log file: " . $log); Logging::logException($e); } }
function globalExceptionHandler($e) { global $responseHandler; Logging::logException($e); Logging::logDebug(Util::array2str(debug_backtrace())); if ($responseHandler == NULL) { $responseHandler = new ResponseHandler(new OutputHandler()); } $responseHandler->unknownServerError($e->getMessage()); die; }
public function onError($e) { Logging::logException($e); }
public function put($data) { if ($data == NULL) { Logging::logDebug("Ignoring empty update"); return; } checkUploadSize(); $oldSize = $this->file->exists() ? $this->file->size() : NULL; $size = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : NULL; Logging::logDebug("Update " . $size); if ($size == 0) { Logging::logDebug("Ignoring empty update"); return; } try { $this->env->filesystem()->updateFileContents($this->file, $data, $size); } catch (Exception $e) { Logging::logException($e); if ($oldSize != 0 and $this->env->request()->isWindowsClient()) { // windows tries to clean up interrupted overwrite // for existing files this is not acceptable, ignore later delete request Logging::logDebug("File update failed, marking delete ignore"); $this->env->session()->setValue("ignore_delete_" . $this->file->id(), "" . time()); } throw new Sabre_DAV_Exception_Forbidden(); } }
$env->authentication()->setAuth($user); } $command = $opts["commands"][0]; if (!$env->commands()->exists($command)) { echo "Invalid command: " . $command . "\n"; return; } echo "Command [" . $command . "]\n"; //TODO allow command registrations from plugins etc try { $env->commands()->execute($command, $options); } catch (ServiceException $e) { Logging::logException($e); echo "ERROR: " . $e->type() . " " . $e->details() . " (" . Util::array2str($e->data()) . ")\n"; } catch (Exception $e) { Logging::logException($e); echo "ERROR: " . $e->getMessage() . "\n"; } // TOOLS function getOpts($args) { array_shift($args); $endofoptions = false; $ret = array('commands' => array(), 'options' => array(), 'flags' => array(), 'arguments' => array()); while ($arg = array_shift($args)) { // if we have reached end of options, //we cast all remaining argvs as arguments if ($endofoptions) { $ret['arguments'][] = $arg; continue; }