moved sql files to sql directory
replaced clumsy concat with qq quoting
updated templates to use long2ip on ipaddresses