classic ui: fix empty REMOTE_ADDR env var causes sigsegv in cmd.cgi (use_logging=1)

strdup on empty getenv is generally a bad idea.

fixes #4445
classic ui: avoid logging to ourselves on error

during log calls, we cannot just errors again, as it may create log
loops.

refs #4389