Updating scannning.js to use M.cfg.wwwroot
Update some SQL to be more postgres / layout friendly
Use $CFG->tempdir instead of $CFG->dataroot