I want to sanitize data against mysql injection. So I need to write a pattern to recognize and remove 4 main mysql SELECT, Replace, DELETE , UPDATE.  I want to use this general rule for array_map  $_POST = array_map('stz',$_POST);   However I stuck in to write that pattern to against happens like this "  ' AND 1=1; SELECT * FROM test_table "
If user input is inserted without modification into an SQL query, then the application becomes vulnerable to , like in the following example:  $unsafe_variable = $_POST['user_input'];   mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')");   That's because the user can input something like value'); DROP TABLE table;--, and the query becomes:  INSERT INTO `table` (`column`) VALUES('value'); DROP TABLE table;--')   What can be done to prevent this from happening?
Function to determine if two numbers are nearly equal when rounded to n significant decimal digits I have been asked to test a library provided by a 3rd party. The library is known to be accurate to n significant figures. Any less-significant errors can safely be ignored. I want to write a function to help me compare the results:  def nearlyequal( a, b, sigfig=5 ):   The purpose of this function is to determine if two floating-point numbers (a and b) are approximately equal. The function will return True if a==b (exact match) or if a and b have the same value when rounded to sigfig significant-figures when written in decimal.   Can anybody suggest a good implementation? I've written a mini unit-test. Unless you can see a bug in my tests then a good implementation should pass the following:  assert nearlyequal(1, 1, 5)  assert nearlyequal(1.0, 1.0, 5)  assert nearlyequal(1.0, 1.0, 5)  assert nearlyequal(-1e-9, 1e-9, 5)  assert nearlyequal(1e9, 1e9 + 1 , 5)  assert not nearlyequal( 1e4, 1e4 + 1, 5)  assert nearlyequal( 0.0, 1e-15, 5 )  assert not nearlyequal( 0.0, 1e-4, 6 )    Additional notes:   Values a and b might be of type int, float or numpy.float64. Values a and b will always be of the same type. It's vital that conversion does not introduce additional error into the function. Lets keep this numerical, so functions that convert to strings or use non-mathematical tricks are not ideal. This program will be audited by somebody who is a mathematician who will want to be able to prove that the function does what it is supposed to do. Speed... I've got to compare a lot of numbers so the faster the better. I've got numpy, scipy and the standard-library. Anything else will be hard for me to get, especially for such a small part of the project. I'm using Ubuntu 16.04 and there's no fglrx! I'm using Ubuntu 16.04 and there's no fglrx! What happened? When are stopovers permitted on Japan Railways (JR) trains? Regarding : in general, what are the rules governing stopovers for JR trains if one does not use a rail pass? A stopover means you have a ticket from stations A to B (say, Tokyo to Hiroshima) and you disembark and exit the ticket gates at an intermediate station (say, Kyoto).  (Spoiler alert: it's complicated.) What is the agreed upon definition of a "positive definite matrix"? In Windows there’re perhaps only a couple of important folders (by important I mean important in my logical picture of the Windows file system) in the installation drive (in my case C:\). Namely Program Files and Windows. I simply stay away from Windows folder and the “add remove program files” is good enough to handle the program files folder of Windows. Of course there’s a folder named Users where the users (who are not admins) can access only their folders.  Thus there’s a clear picture at some level in my mind of the Windows file system. In Ubuntu, when I reach the location /, there’s a huge list of folders, most of which I have no clue as to what they contain. The /bin folder seems to be the equivalent of the Windows folder in windows. The /usr folder seems like it’s the equivalent of the Users folder in Windows. But even the /home folder looks like it can fit the bill.  Please understand that I do understand, that Ubuntu (Linux) has a different character than that of Windows, i.e., there need not be exact equivalent of Windows functions, in Ubuntu. All I am looking for is a bit more clearer picture of the Ubuntu file system.   This question is a part of a bigger question which I am splitting up to make it more answerable. The original question can be found here: Are all oscillatory motions periodic motions? For example, if a pendulum system in the real world oscillates its amplitude and period will eventually decrease. Does that still count as a periodic motion? Since the motion doesn't have the same amplitude at equal time periods. java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config Is there a way in blender or an addon that allows me to select a bunch of faces (or verts) and evenly distributes (or relaxes) them into quads clean quads.  Without screwing up the vert ID/order.  Edit: I would like to have the shapes of my quads to turn into perfect squares while maintaining the volume of the object and the vertex order. Prove that if $|G| = p^n$ then $G$ has a subgroup of order $p^m$ for all $0\le m &lt;n.$   Since $G$ is of prime-power order I know $|Z(G)| \ne e$ so there is an $a\in Z(G)$ with order $p$ such that $p \mid |Z(G)|$. Now, the subgroup generated by is normal since it's a subgroup of the center. How can I get this normal subgroup to be less than $n$? One-dimensional vector space and it's subspaces CBC-MAC Padding weaknesses I'm trying to wrap my head around how different padding methods affect the strength of CBC-MAC's. Suppose a message is split into different blocks, m1, m2, m3 etc. and the last block is padded with 0's to fill it if needed.  If the message is intercepted, why can an attacker easily create another message with the same MAC tag for the same key as the message that was intercepted?  If another message is intercepted that does not contain any padding (so it completely fills the last block), how does this make it more difficult for the attacker to create a tag that matches? Does the message need to meet any conditions for the attack to work?  If this padding method is not secure, what is a better method to secure against these attacks? Would it be more secure if the padding was just random? Not sure how that would work. I process all my photos to black and white. Although I use a polariser where possible, I often find myself wanting to drop the luminance of the sky further which I do using a Black and White adjustment layer (in Photoshop). This usually results in a lighter halo following the line of the horizon, where the blues of the sky meet whatever the colour of the land is.  My current solution to this problem is to run a brush along this margin with a colour set to the same as the sky and the blend-mode set to Darken. This effectively paints in the lighter band with the sky colour while not laying down the colour on top of the darker horizon. Whilst this is effective, it is very time consuming.  Is there a better approach to dealing with these halos?  Here is a video that illustrated the Darken solution that I mention: Can you block installers from making desktop shortcuts? I've been keeping my desktop totally free from shortcuts. I'd rather not have to take action to do so. Is it safe to delete from C:\Windows\Installer? I would like to parse a string such as p1=6&amp;p2=7&amp;p3=8 into a NameValueCollection.  What is the most elegant way of doing this when you don't have access to the Page.Request object? New top bar quick reference guide / Where has the link to  gone? What are the pros and cons of adding a vapor barrier behind shower backer board? After much research, I have a lot of conflicting advise about the need to add a vapor barrier before installing the backer (hardy / cement) board for my bathroom shower. The &quot;expert&quot; at Home Depot, and  seem to think this is a very good idea, and even suggest sealing it with roofing tape.  (The guy on Youtube tapes it directly to the sill of tub.) However, when I asked about the tape and how far down I should go at Lowes, they told me they'd never hear of anyone doing that, and that it didn't seem like a good idea.   Likewise,  putting down caulking on the sill before applying the backer board, and then again after before adding tile, and then caulking a 3rd time under the tiles before grouting. Should I add a vapor barrier between the frame and the cement board?  Why or why not? Can I purge configuration files after I've removed the package? I was doing a package removal with apt-get remove but then realized I should have done a --purge along with it to remove the configuration files.  Can I remove the packages configuration files easily or do I need to reinstall the package and then remove with a --purge? Directory-tree listing in Python As we all know, going near a black hole (Gargantua in this case) slows down time, according to the theory of relativity.  So when Cooper comes out of the black hole, after spending a fair bit of time there, shouldn't he be much older than Brand who hasn't gone inside Gargantua?