AwesomeAds and PHP Warning: feof() expects parameter 1 to be resource, boolean given

I’m going through error logs in order to optimize apache performance avoiding unuseful php errors and warning not visible from the “outside”. Then i’ve found an error related with this wordpress plugin called “Awesome Ads” wich can manage ads displaying on pages and post from two providers: Adsense and Chitika. This second one must be in some way related with the plugin using the Adsense popularity and at same time the lack of very good plugin for its management, to push a bit their product. Common practice. Not shareable, but common.

Anyway, let’s tae a look to the error itself:
From apache2 virtualhost error log :

PHP Warning:  feof() expects parameter 1 to be resource, boolean given in /wp-content/plugins/awesome-ads/libs/functions.php on line 175

Looking better at the piece of code mentioned in th eerror log entry, i’ve noticed that this plugin is a little privacy-killer.
Because each time an ads is displayed it does a remote connection to the following address:

http://awsmteam.com/verify_adult_content.php

In order to check for presence of adult content within the content of the post / page, wich could infringe the Adsense rules.

Well let me telll you first that there is no need to establish such a connection each time an ad is displayed unless you want to monitor my website. Yes because what they do is basically similar to an antivirus that connects to its website each time it scans a file. This is not the way things work.

First of all this is NOT a critical software as an antivirus could be, indeed it is quiet static as no new offensive words are invented nowadays (at least not so much to justify this). Furthermore ther could be no reason at all, as it would be sufficient a normal txt file to be installed together with this plugin.

This is not a remarkable behavior from the author(s) of this plugin, and for this reason i’m going to uninstall and switch to a better, privacy oriented solution in order to expose my ads.

At worst if you want to keep using it, just replace the original function contained in /wp-content/plugins/awesome-ads/libs/functions.php

with the simple “return true” one wich can be found at the bottom of this article.
Anyway this could be just a temporary solution because the next update will overwrite your changes to the file

Original function:

//Returns settings for network
        function get_values_awesome_ads($slug){
                switch($slug){
                        case'awesome_google_ads':
                                $values = json_decode(get_option('awesome_ads_google_json'));
                                $users = json_decode(get_option('awesome_ads_users_google'));
                        break;
                        case'awesome_chitika_ads':
                                $values = json_decode(get_option('awesome_ads_chitika_json'));
                                $users = json_decode(get_option('awesome_ads_users_chitika'));
                        break;
                }
                return Array('values'=>$values,'users'=>$users);
        }

        function verify_adult_content() {
                $allow = ini_get('allow_url_fopen');

                if($allow != 1)
                        ini_set("allow_url_fopen", 1);

                $allow = ini_get('allow_url_fopen');

                if($allow == 0)
                        return false;

                $_data = array('site'=>get_option('siteurl'), 'plugin'=>'awesome_ads');
        $data = array();    
            while(list($n,$v) = each($_data)){$data[] = "$n=$v";}    
        $data = implode('&', $data);
            $url = parse_url('http://awsmteam.com/verify_adult_content.php');
            $host = $url['host'];
        $path = $url['path'];
            $port = 80;
        $data_length = strlen($data);
            $header  = "POST $path HTTP/1.0\r\n";
 $header .= "Host: $host\r\n";
                $header .= "User-Agent: DoCoMo/1.0/P503i\r\n";
                $header .= "Content-type: application/x-www-form-urlencoded\r\n";
                $header .= "Content-length: $data_length\r\n";
                $header .= "\r\n";
                $fp = fsockopen($host,$port,$err_num,$err_msg,120);
        fputs($fp, $header . $data);
                while(trim(fgets($fp,4096)) != '');//Retira o cabecalho HTTP
        while(!feof($fp)){$response .= fgets($fp,4096);}
        // close the socket connection:
            fclose($fp);

                if ($response == 'OK'){
                        return true;
                }
                else{
                        return false;
                }
        }

then you just replace it with:

function get_values_awesome_ads($slug){
return true;
                }

Again: be aware pf updates if you decide to modify and keep this plugin.

I’ m going to remove this plugin.

I would invite you to consider doing the same for your privacy.
Ciao 

(Visited 2,737 times, 1 visits today)

Author: Giuseppe Urso

Giuseppe lives in Haarlem now with his shiny dog, Filippa In 1982 received his first home computer, a Commodore 64, followed by Datasette and a 1541 Floppy Disk Drive. In 1999 he installed his first Linux distro (LRH6). In 2006 he switched to Debian as favourite OS. Giuseppe Urso actively sustains the Free Software Fundation and his founder Richard Mattew Stallman, he speaks to people trying to convince them to join the fight now, and about how important is to use Free Software only. He has a job as Infra Specialist at Hippo Enterprise Java Cms an Open Source Enterprise class Content Management System, one of the coolest company ever, in Amsterdam. He's always ready to install Debian on other people computers for free.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.