How PHP prevents users from uploading adult photos or nude photos
?
?
How 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 via PHP.
Example: http://www.rrpowered.com/demo/NudityFilter/
Download: Http://www.rrpowered.com/code/RRPowered-NudityFilter.zip
I stumbled upon a very useful phpclasses.org that was developed by Bakr Alsharif to help developers detect nude photos of pictures based on their skin pixels.
It analyzes the colors used in different parts of a picture and determines whether they match the color tones of the human skin.
As a result of the analysis, he returns a score that reflects the likelihood that the image will contain nudity.
In addition, he can output images that have been analyzed, which mark the pixels of the skin color using a given color.
Currently it can analyze png,gif and JPEG images.
Php
The following shows how to use this PHP class.
Let's start with a nf.php file containing a nude filter.
include ('nf.php');
Next, create a new class called ImageFilter, and then put it in a variable called $filter.
$filternew ImageFilter;
Gets the image's score and puts it into a $score variable.
$score$filter -> GetScore($_FILES['img']['tmp_name']);
If the image score is greater than or equal to 60%, then a message is displayed.
if($score60){/*Message*/}
Here is all the PHP code:
/*include the nudity Filter file*/include(' nf.php ');/*create a new class called $filter * /$filter=NewImageFilter;/*get The score of the image*/$score=$filter-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's considered an adult image.*/if($score>= -) {Echo "Image scored".$score."%, It seems so you had uploaded a nude picture.";/*if The image doesn ' t contain nudity*/}Else if($score<0) {Echo "Congratulations, you had uploaded an non-nude image.";}}?>
Markup language
We can upload images using a basic HTML form.
<form Method="POST" enctype="Multipart/form-data" Action="
">Upload Image:<input type="file" name="img " id="img" /> <input type="Submit" value="Sumit Image" />
Form
>
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/