• Hi! We recently signed up for the WebPurify ImageFilter. We currently use their Profanity Filter plugin and it works great. The only problem with the Image Filter is that I need to implement it manually. I thought I wouldn’t have any issues, but it looks like I am already banging my head against the wall. They give some basic instructions, sample code, etc.

    For Example:

    $checkurl = "http://api1.webpurify.com/services/rest/?method=webpurify.live.imgcheck&api_key=[API KEY]&imgurl=http://farm1.static.flickr.com/30/59010752_4d16aca1ec_o.jpg
    $response = simplexml_load_file($checkurl,'SimpleXMLElement', LIBXML_NOCDATA);
    var_dump($response);

    Their documentation is here.

    To sum things up, we are running on WordPress 3.0.4 and BuddyPress 1.2.7. I took a look at the WebPurify TextReplace plugin code to see if I could figure anything out from there, but had no luck. I also checked out some bp-core files. bp-core-avatars.php had nothing for me either. I was hoping I could find how it works there. But it looks like it points to /wp-admin/includes/image.php which I am guessing handles all image uploads for wordpress, then places them in the according uploads folder. I couldnt figure out where to put the code to send the request to WebPurify to check the image. I want it to check every image on the site that is uploaded, so I am assuming implementing it in this file would be the best bet. We have the option to upload an avatar as well as a photo gallery. Im not sure how the gallery handles uploads, but if I can figure this part out, I think I should be fine with that. Hopefully its all handled the same though with WP core files. Any help would be great!

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Friendesha

    (@friendesha)

    So after some trial and error I havent had much progress. All I know is that I need to find where WP or BP get the uploaded image. I am looking for this type of flow…

    1. User selects image to upload and clicks upload.
    2. Image is uploaded.
    3. Image Filter request is sent to WebPurify with Image URL.
    4. Image is either approved or denied.
    4a. If approved the user sees the “Crop Avatar” page.
    4b. If denied the user sees an error to upload a different image.

    That is the basics of it. Its my hope that I can get this to work over the next couple days, but I am definitely going to need help figuring out how WordPress uploads images, and how to integrate this into those functions.

    Here is my example plugin code so far (I know its not correct):

    add_action( 'bp_init', 'bp_wpurifyimg_init' );
    
    function WebPurifyImgReplace($file) {
        global $wpdb;
    
       	$imgurl = ('bp_avatar_to_crop_src()');
    
        $params = array(
          'api_key' => 'XXXXXXXXXXXXXXXXX',
          'method' => 'webpurify.live.imgcheck',
    	  'imgurl' => $imgurl(''),
        );
    
        $encoded_params = array();
        foreach ($params as $k => $v){
            $encoded_params[] = urlencode($k).'='.urlencode($v);
        }
    
    #
    # call the API and decode the response
    #
        $url = "http://www.webpurify.com/services/rest/?".implode('&', $encoded_params);
    
        $response = simplexml_load_file($checkurl,'SimpleXMLElement', LIBXML_NOCDATA);
    	var_dump($response);
    	$response = $imgurl;
    
    }
    
    function bp_wpurifyimg_init() {
    	add_action('bp_avatar_upload','WebPurifyImgReplace');}

    Thanks for any help in advance!

    Thread Starter Friendesha

    (@friendesha)

    Response from their team:

    Hello Rob,

    The image filter works through a two step process.

    After you submit the URL of the image to the service, XML is returned with a unique ID for the image.

    that will look like so:

    <?xml version=”1.0″ encoding=”utf-8″ ?>

    <rsp stat=”ok”>
    <method>webpurify.live.imgcheck</method>
    <format>rest</format>
    <imgid>7de93bc200ff21a26da6ddb115506e82</imgid>
    <status>pending</status>

    <api_key>f3412a9614845dc17d97a5d51a647a13</api_key>
    </rsp>

    Once the image is moderated (which can take between 2 and 5 minutes)

    Our service makes a request to a script you will have to host. Our request is a GET that have two arguments “status” and “imgid”

    The imgid will be the ID we return to you after step 1.

    The status, the result will be:

    status = 1 means the image has been approved and is clear of adult content
    status = 2 means the image has been declined and contains adult content.

    So, your code and database will have to store the image id and only allow the image to be displayed on your site once the image has been returned a status of 1.

    I hope this helps,

    Please let us know if you have any questions.

    Sincerely,

    WP Support

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Help with Web Purify Image Filter?’ is closed to new replies.