briedis Posted February 28, 2010 Report Share Posted February 28, 2010 @rATRIJS - paldies. izmantošu obligāti! :) vispār man ir vienalga vai tā ir modernāk vai nav. :D man svarīgi ir lai kods būtu drošs un ātrs, tāpēc nolēmu pamēģināt klases. firebug'ā salīdzinot viena koda ātrumu ar otra ātrumu nekādas atšķirības nav. par drošību nezinu. secinājums - izmantošu db klasi, lai būtu gana "moderns", bet tas arī viss no klasēm. laikam. firebugs nav domāts, lai skatītos, cik ātri pildās php kods. Firebugs vairāk parādīs kopējo pieprasījuma laiku (kas ietver izpildi, datu pārsūtīšanas laiku). Quote Link to comment Share on other sites More sharing options...
thesnarkie Posted March 18, 2010 Author Report Share Posted March 18, 2010 Mazs jautājums: mysql_real_escape_string($_POST['haha']) vienmēr pasargās no visām sql injekcijām un pārējām drazām? Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 18, 2010 Report Share Posted March 18, 2010 (edited) klases smird. Lai developeri, kas strādā ar mani, raksta precīzi tāpat kā es! :] EDIT: Jā, snake, pasargās. Edited March 18, 2010 by anonīms Quote Link to comment Share on other sites More sharing options...
thesnarkie Posted March 18, 2010 Author Report Share Posted March 18, 2010 Paldies! Quote Link to comment Share on other sites More sharing options...
briedis Posted March 18, 2010 Report Share Posted March 18, 2010 Mazs jautājums: mysql_real_escape_string($_POST['haha']) vienmēr pasargās no visām sql injekcijām un pārējām drazām? Nē, tas tevi pasargās tikai no sql injekcijām. No citām drazām ne (XSS, piemēram) Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 18, 2010 Report Share Posted March 18, 2010 (edited) nezinu cik laba štelle, bet nu foreach ($_GET as $check_url) { if ((eregi("<[^>]*script*\"?[^>]*>", $check_url)) || (eregi("<[^>]*object*\"?[^>]*>", $check_url)) || (eregi("<[^>]*iframe*\"?[^>]*>", $check_url)) || (eregi("<[^>]*applet*\"?[^>]*>", $check_url)) || (eregi("<[^>]*meta*\"?[^>]*>", $check_url)) || (eregi("<[^>]*style*\"?[^>]*>", $check_url)) || (eregi("<[^>]*form*\"?[^>]*>", $check_url)) || (eregi("\([^>]*\"?[^)]*\)", $check_url)) || (eregi("\"", $check_url))) { die (); } } unset($check_url); Edited March 18, 2010 by anonīms Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted March 18, 2010 Report Share Posted March 18, 2010 (edited) IMO galiigi useless...kapeec die()? Kapeec eregi? Kapeec visu GET paarbaudiit? Kapeec GET nevis POST? Piedevaam tas neko iipashi neaizsargaa... Edited March 18, 2010 by rATRIJS Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 18, 2010 Report Share Posted March 18, 2010 (edited) kapēc gan form(EDIT: POST) vajadzētu, ja pietiek ar to pašu intval escape strings? Kā jau teicu: "Nezinu vai laba štelle". Edited March 18, 2010 by anonīms Quote Link to comment Share on other sites More sharing options...
thesnarkie Posted March 18, 2010 Author Report Share Posted March 18, 2010 (edited) Nē, tas tevi pasargās tikai no sql injekcijām. No citām drazām ne (XSS, piemēram) Nu tas būtu gadījumā, ja es ievadītos datus parādītu lapā, bet šis būs gana labs, ja tālāk visus ievadītos datus izmanto tikai priekš kverijiem? <? $mysqli = new mysqli("localhost", "", "", ""); $mysqli->query("SET NAMES utf8"); $mysqli->query("SET CHARACTER SET utf8"); $formData["username"] = $mysqli->real_escape_string($_POST["username"]); $formData["password"] = $mysqli->real_escape_string($_POST["password"]); $formData["email"] = $mysqli->real_escape_string($_POST["email"]); $formData["gender"] = $mysqli->real_escape_string($_POST["gender"]); //Check if everything is filled. if(empty($formData["username"]) || empty($formData["password"]) || empty($formData["email"]) && empty($formData["gender"])) { echo "<div style=\"-moz-border-radius: 4px 4px 4px 4px; background: none repeat scroll 0% 0% rgb(244, 209, 209); border: 1px solid rgb(217, 34, 34); padding: 4px; margin-top: 3px;\"><b style=\"text-shadow: 0pt 1px 1px rgb(198, 198, 198);\">Error:</b><br>You must fill in all of the fields.</div>"; } else { //Check if username not already taken. $result = $mysqli->query("SELECT COUNT(a.id) AS idCount FROM accounts AS a WHERE a.username='".$formData["username"]."'"); $row = $result->fetch_array(MYSQLI_ASSOC); if($row["idCount"] == 1) { //.. } else { //.. } } $mysqli->close(); ?> Edited March 18, 2010 by thesnarkie Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 18, 2010 Report Share Posted March 18, 2010 ievadei mysql_real_escape_string/intval izvadei htmlspecialchars Quote Link to comment Share on other sites More sharing options...
thesnarkie Posted March 18, 2010 Author Report Share Posted March 18, 2010 Paldies! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.