Support » Plugin: podPress » [Plugin: podPress] Stats patch suggestion

  • I would recommend podpress_functions.php to change the podPress_StatCollector function as follows to prevent counting duplicates. I made the change to my own site because it was attacked by some robot and making our stats numbers unbelievably high..

    function podPress_StatCollector($postID, $media, $method) {
    		global $wpdb;
    		$media = addslashes($media);
    		$method = addslashes($method);
    		$ip = addslashes($_SERVER['REMOTE_ADDR']);
    		//$cntry = addslashes(podPress_determineCountry($ip));
    		$cntry = addslashes('');
    		$lang = addslashes(podPress_determineLanguage());
    		$ref = addslashes($_SERVER['HTTP_REFERER']);
    		$url = parse_url($ref);
    		$domain = addslashes(eregi_replace('^www.','',$url['host']));
    		//$res = $_SERVER['REQUEST_URI'];
    		$ua = addslashes($_SERVER['HTTP_USER_AGENT']);
    		$br = podPress_parseUserAgent($_SERVER['HTTP_USER_AGENT']);
    		$dt = time();
    		// -- mod begin --
    		// check the db for existing stats record (media file, IP address and datestamp) before counting
    		$last_day = $dt - 86400; // so the request within a day will be found
    		$e_query = "select * from ".$wpdb->prefix."podpress_stats where media like '$media' and remote_ip like '$ip' and dt >= $last_day";
    		$existing_rec = $wpdb->get_results($e_query);
    		if ($wpdb->num_rows == 0) // if request for the file from the ip address is not made in the last day, it should be counted.
    		// -- mod end --
    		$query = "INSERT INTO ".$wpdb->prefix."podpress_stats (postID, media, method, remote_ip, country, language, domain, referer, user_agent, platform, browser, version, dt) VALUES ('$postID', '$media', '$method', '".$ip."', '$cntry', '$lang', '$domain', '$ref', '$ua', '".addslashes($br['platform'])."', '".addslashes($br['browser'])."', '".addslashes($br['version'])."', $dt)";
    		$result = $wpdb->query($query);
    		return $wpdb->insert_id;
    		// -- mod begin --
    		else return false;
    		// -- mod ends --

    It is just a quick and dirty fix to stop the attacker. Please feel free to include or modify the code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author ntm


    Thank you! I will look into this in the next days and give you a more detailed response.

    Plugin Author ntm


    podPress does not contain this code. But it is a good idea to make the download counter a little bit more intelligent than it is until today. The big problem is that the current counter counts each request/click while not only robots do multiple requests in a short time period. For instance the iTunes player on the iTunes pages do multiple requests per media files while it plays the file.

    I will probably work on a solution when I implement a new player into podPress.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: podPress] Stats patch suggestion’ is closed to new replies.