October 6, 200817 yr Well, I've been learning PHP for about 1-2 years and I've learnt a fair bit. I'd still class myself as a beginner, but I have made a couple of interesting scripts before now such as a Register/Login script, and an Image Uploader or two. While I've gotten the hang of using PHP with Databases, I've never really got the grasp of sanitizing the input ($_GET, $_POST, $_COOKIE, etc.) and I'm starting to realise that they are very important to clean up. Although in my Register/Login script that I created I did sanitize the input, it was pretty simple and probably wasn't cleaned up enough. Recently, I've been trying to get the hang of OOP, too. It's proved pretty hard for me to really get "good" with it, but I think I'm starting to make progress. Anyway, getting back to the point, my grandfather downloaded Invision Power Board 1.3.1 Final when it was still available and I got a copy on my computer for PHP modification purposes. I saw that instead of using code like $_GET['act'] in the code, Matt Mecham had used $ibforums->input['act']. This intrigued me, and I thought it was pretty smart as it takes $_GET, $_POST, and a few others into account, and so I wanted something similar, but even though I was looking at the parse_incoming() function in the code, I couldn't figure out how to do it. SO, what I'm saying is, can anybody think of a way to do something similar without me plagiarizing the code?
October 6, 200817 yr This is how I do it: function vald ($stuff) { if (get_magic_quotes_gpc()) $stuff = stripslashes($stuff); $stuff = htmlspecialchars($stuff, ENT_QUOTES, 'UTF-8'); return $stuff; } There are probably better ways, but it works good enough for me. You might have to change the UTF-8 at the end to fit your needs.
October 7, 200817 yr Author This is how I do it: function vald ($stuff) { if (get_magic_quotes_gpc()) $stuff = stripslashes($stuff); $stuff = htmlspecialchars($stuff, ENT_QUOTES, 'UTF-8'); return $stuff; } There are probably better ways, but it works good enough for me. You might have to change the UTF-8 at the end to fit your needs. Thanks for the reply, but that's not really what I'm looking for.
October 7, 200817 yr Invision power board is using some kind of class to get their data without directly using $_POST, and they probably sanitize it in a way quite similar way to Henaro's post above.
Create an account or sign in to comment