Jump to content

Best way to make input safe on input, then readable on output?


Nolongerused3921

Recommended Posts

Well the title says it all, right now I'm using
[code=php:0]
    function strip_array($data, $filter_type) {
        foreach ($data as &$tmp_data) {
            if (get_magic_quotes_gpc()) {
                $tmp_data = stripslashes($tmp_data);
            }
            if ($filter_type == 2) {
                $tmp_data = htmlentities($tmp_data);
            } elseif (!is_numeric($tmp_data)) {
                $tmp_data = htmlspecialchars($tmp_data, ENT_QUOTES);
            }
        }

        return $data;
    }
[/code]

To make the input safe (Actually, anything passed through post goes through this and returns as a nice and neat array), but I'm wondering - should I do more? Should I take out all <'s to remove html? Are there any other vulnerabilities that I should worry about?
Also, how should I make this back into what it originally was on output, without risking anything?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.