Changes to C++ code to use SQL functions + checks for validity of the URL