How does PHP prevent users from uploading adult photos or nude photos ?? How does PHP prevent users from uploading adult photos or nude photos? In this tutorial, we will learn how to organize users to upload adult photos or nude photos through PHP. example: www. rrpowered. download comdemoNudityFilter: www. rrpowered. how does comcodeRRPowered-Nudi PHP prevent users from uploading adult photos or nude photos?
?
?
PHP prevents users from uploading adult photos or nude photos
?
In this tutorial, we will learn how to organize users to upload adult photos or nude photos through PHP.
Example: http://www.rrpowered.com/demo/NudityFilter/
Download: http://www.rrpowered.com/code/RRPowered-NudityFilter.zip
On phpclasses.org, I accidentally found a very useful file. developed by Bakr Alsharif, it can help developers detect bare image files based on skin pixels.
It analyzes the colors used in different parts of an image and determines whether it matches the human skin color.
As a result of the analysis, the system returns a score that reflects the possibility of image exposure.
In addition, he can output the analyzed image and mark the pixels with the color given.
Currently, it can analyze PNG, GIF, and JPEG images.
PHP
The following shows how to use this PHP class.
Let's start with the inclusion of the native filter, nf. php file.
include ('nf.php');
Next, create a new class named ImageFilter and put it in a variable named $ filter.
$filter = new ImageFilter;
Get the image score and put it in a $ score variable.
$score = $filter -> GetScore($_FILES['img']['tmp_name']);
If the image score is greater than or equal to 60%, an alarm message is displayed.
if($score >= 60){/*Message*/}
Below are all the PHP code:
GetScore($_FILES['img']['tmp_name']);/*If the $score variable is set*/if (isset($score)) {/*If the image contains nudity, display image score and message. Score value if more than 60%, it is considered an adult image.*/if ($score >= 60) { echo "Image scored " . $score . "%, It seems that you have uploaded a nude picture.";/*If the image doesn't contain nudity*/ } else if ($score < 0) { echo "Congratulations, you have uploaded an non-nude image.";}}?>
Markup language
We can use a basic HTML form to upload images.
Upload image:
Via:
Http://www.oschina.net/translate/prevent-uploads-of-adult-or-nude-pictures-using-php
Http://www.rrpowered.com/2014/04/prevent-uploads-of-adult-or-nude-pictures-using-php/