Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing PHP to filter out injections and only return domain.tld
    primarykey
    data
    text
    <p>So i'm having a hell of a time trying to figure out a way to sanitize input from a site to prevent URL injections, and only return domain.tld (google.com, etc)</p> <p>Basically i've got a site i've created people can use to get a website's IP address (getwebsiteip.com) and i want to make sure i prevent any malicious injection and at the same time return only google.com no matter if they input <a href="http://google.com" rel="nofollow">http://google.com</a>, <a href="https://google.com" rel="nofollow">https://google.com</a> udp://google.com and so on. I do want to keep subdomains in tact, and technically www is a subdomain, and www.google.com could have a different A record than google.com does.</p> <p>I'm just taking the URL from user input, checking the DNS record, and displaying it. </p> <p>So i've tried a couple different methods and read around online but want to make sure i'm doing this the right way.</p> <p>Read this site: <a href="http://www.phpro.org/tutorials/Filtering-Data-with-PHP.html" rel="nofollow">http://www.phpro.org/tutorials/Filtering-Data-with-PHP.html</a></p> <p>And the filtering does work, but you have to put in the http for it to validate, otherwise it does not.</p> <p>I found this: <a href="http://snipplr.com/view.php?codeview&amp;id=12616" rel="nofollow">http://snipplr.com/view.php?codeview&amp;id=12616</a></p> <p>Which does a good job of striping out the domain itself, but from everything i found it seems like it would take a lot of code to accomplish something that seems like it should be fairly simple.</p> <p>In a perfect world, i would want users to only input subdomain.domain.com or domain.com, but if they use http:// or https:// i still want to strip that out and output the IP. </p> <p>I also want to prevent anybody from trying to inject malicious code.</p> <p>Can anybody point me in the right direction or help out? I think i've got a bald spot now from scratching my head too much :P</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload