So i'm currently working on a website on which the user can upload a file (e.g. myfile.html). Now i want the upload script to search for multiple strings (from an array) in this file, before moving it to the upload-directory.
As soon as it found string from the array in the file for the first time, it should not keep searching but tell the user about this and save the file (inaccessible of course), so i can look into it and may set it free by hand, if it was a "false positive".
This is what i've got so far:
$forbidden = array('thisisnotallowed', 'thisisntaswell', 'alsonotallowed');
$uploaded_file = file($_FILES['fileupload']['name']);
$deleted = str_ireplace($forbidden, "", $uploaded_file);
foreach($deleted as $line) {
echo($line.'<br>');
}
So obviously this would just replace all the forbidden strings in the file and output the new file with them replaced by nothing.
But i'd like it to do something like this:
if(find_string($uploaded_file, $forbidden)) {
echo('found a forbidden string in your file');
$new_filename = $filename.'.lookinto';
}
I hope you understand what i mean and can help me?
NOTE: The uploaded files would obviously not just contain exactly one of the strings in a line. They may look like this: <p>thisisnotallowed</p>
or something.