Documentation and some restructure in RedBasicAuth

Add some documentation for include/auth.php and include/reddav.php.
Removed some duplicate code in RedBasicAuth and restructured it a bit.
Please check if my understanding of the variables was right or if I am on the wrong way.