Hello guys
For my project i am tring to compare elements of an array with string.This could help at a certain extent to prevent pornographics uploads based on the filenames
Here is my snippet
$banned_file_names = array('bestiality','lolita','porn','xxx','incest','cock','teenporn');
$filen = preg_replace("/\\.[^.\\s]{3,4}$/", "", $file_name);
if (in_array($filen,$banned_file_names) === true) {
echo 'Adult image upload is not allowed';
exit;
This works fine for a filename like porn.png but i wanted to make it more efficient.
I added$filen = preg_replace("/\\.[^.\\s]{3,4}$/", "", $file_name);
so that if user upload an image with name like porn-img.png , filen becomes like pornimg and get blocked
However this fails.......
Bottom line is how can i compare 2 string so that pornimg.png get block as porn
is an element of array banned_file_names.
This is not a very efficient code to prevent porn uploads but its my first level check....
Kindly help me with this and feel free to suggest other checks that could be perform to prevent porn uploads of any kind
Regards