WordPress.org

Ready to get started?Download WordPress

Forums

Top 10 - Popular posts plugin for WordPress
[resolved] Stats aren't updating (19 posts)

  1. particlerealities
    Member
    Posted 1 year ago #

    My stats don't seem to be updating. To confirm this, yesterday I took a screen capture of my Top 10 Overall Posts and the numbers are the same today as they were yesterday. The Daily Popular Posts page is blank (no stats shown). My website is live and otherwise working properly. Google Analytics is showing I had 144 unique visitors yesterday, so I know people are hitting my site. Any suggestions how to fix this?

    http://wordpress.org/extend/plugins/top-10/

  2. particlerealities
    Member
    Posted 1 year ago #

    Actually, my site is now getting a Malware warning according to http://www.securi.net. It says "Malware found on javascript file: http://www.adamsleatherworks.com/wp-content/plugins/top-10/top-10-addcount.js.php?top_ten_id=8".

    My site:
    http://www.adamsleatherworks.com

    The security site I checked it with:
    http://www.securi.net

  3. esmi
    Forum Moderator
    Posted 1 year ago #

    The malware warning may be a false positive. FTP into your site (or use whatever file management application your host provides) & rename the wp-content/plugins/top-10 folder.

  4. particlerealities
    Member
    Posted 1 year ago #

    Deactivating the plugin cleared the Malware warning on Sucuri. I could try deleting the plugin, then reinstalling it, but I don't want to reset my page view counts and I'm not sure what/how to backup the table to save my page counts. Looking forward to your feedback/suggestions.

  5. particlerealities
    Member
    Posted 1 year ago #

    I renamed the top-10 folder and re-ran the securi scanner - there are no threats listed now. I assume the plugin is inoperable with the folder renamed, so what should I try now?

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    Try deleting the plugin's folder inside wp-content/plugins by FTP AND then uploading a fresh copy. Bear in mind that I'm not the plugin's author, so this is more of a general troubleshooting tip given that you seem to have been missing a few files.

  7. particlerealities
    Member
    Posted 1 year ago #

    I did as you suggested - deleted the plugin folder via my cPanel, then uploaded a fresh zip from here: http://wordpress.org/extend/plugins/top-10/

    Still getting the threat warning. :(

    I appreciate your help, by the way!

  8. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    I checked out what the error displayed is:

    Site error detected.
    Details: http://sucuri.net/malware/php-error-fatal-error
    <b>Warning</b>: require(/home/EXAMPLE/public_html/wp-config.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in <b>/home/EXAMPLE/public_html/wp-content/plugins/top-10/top-10-addcount.js.php</b> on line <b>18</b><br />

    The malware is a false positive like emsi mentioned. Securi is detecting this because it believes that the script addcount is forcibly trying to include the wp-config.php file.

    The actual issue is that the plugin can't find the wp-config.php file to include it.

    Could you please check the exact location of wp-config.php
    Is it in /public_html/ or is it in a subfolder?

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    The error message suggests that you're still missing files. Have you moved your wp-config.php file?

  10. particlerealities
    Member
    Posted 1 year ago #

    I moved it up one folder, which I believe is allowed in the plugin's coding - I don't know much about coding, but I did open the file in question and it looks like the descriptive text allows for the user to move it up one folder. It's in the root directory of my site. It worked fine for a while - it's logged almost 10,000 views on my home page already, but just recently stopped working. I have not moved my wp-config.php file since I built the site and the plugin has been working fine till just recently.

  11. particlerealities
    Member
    Posted 1 year ago #

    FYI - the following is copied from the plugin's "Overall Popular Posts" page in the dashboard showing the page visits.

    Home (9,683)
    Sig Sauer P938 Holster: New Gun Model (3,165)
    How to Make Leather Holsters (2,002)
    Gallery (1,374)
    DIY: Pancake Holster (1,360)
    Pancake: Standard (1,156)
    Gun Models List (1,072)
    Avenger: Standard (816)
    Tippmann Boss Leather Hand Stitcher (807)
    Avenger: Ultimate (675)

    The "Daily Popular Posts" page is blank since it's not currently tracking anything.

    As you can see, it was working fine. I posted to my blog on 2012/12/07 - that page receive 79 total views (that were actually tracked), then I posted another blog post on 2013/01/02 - that page hasn't logged any views, but I know that's not accurate. So, I believe a plugin update of some kind between mid-December and early January must have broken something... :(

  12. esmi
    Forum Moderator
    Posted 1 year ago #

    I moved it up one folder, which I believe is allowed in the plugin's coding

    I suspect that this particular plugin can't handle that move. Could be that the plugin author has made an assumption as to the location of wp-config.php. :-(

  13. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    particlerealities,

    I've changed the way the plugin has detected the wp-config to what was a more recommended method.

    My question remains.

    I assume that your wp-config is not located in:

    /public_html/wp-config.php

    But, actually one folder higher?

  14. particlerealities
    Member
    Posted 1 year ago #

    Ajay - yes, as I stated previously, I moved it up one folder to the root of my website. It is not in the /public_html/ folder - it is one folder higher.

  15. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Please backup your site first

    Could you please edit this line:

    $wp_config_path = dirname( dirname( dirname( __FILE__ ) ) );

    and replace with:

    $wp_config_path = dirname ( dirname( dirname( dirname( __FILE__ ) ) ) );

    And test again?

    Alternatively, please try this code:
    Replace

    // Build the wp-config.php path from a plugin/theme
    $wp_config_path = dirname( dirname( dirname( __FILE__ ) ) );
    $wp_config_filename = '/wp-config.php';
    
    // Check if the file exists in the root or one level up
    if( !file_exists( $wp_config_path . $wp_config_filename ) ) {
        // Just in case the user may have placed wp-config.php one more level up from the root
        $wp_config_filename = dirname( $wp_config_path ) . $wp_config_filename;
    }
    // Require the wp-config.php file
    require( $wp_config_filename );

    with:

    while(!is_file('wp-config.php')){
    
      if(is_dir('../')) chdir('../');
    
      else die('Could not find WordPress.');
    
    }
    
    include( 'wp-config.php' );

    You can load http://www.adamsleatherworks.com/wp-content/plugins/top-10/top-10-addcount.js.php?top_ten_id=8 to see if it still throws the error.

  16. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    And, yet another solution for this. Note the added lines for the ABSPATH definition

    Edit the lines 12-16.

    // Check if the file exists in the root or one level up
    if( !file_exists( $wp_config_path . $wp_config_filename ) ) {
        // Define ABSPATH since the wp-config.php file is one level up
        define( 'ABSPATH', $wp_config_path . "/" );
        // Just in case the user may have placed wp-config.php one more level up from the root
        $wp_config_filename = dirname( $wp_config_path ) . $wp_config_filename;
    }

    Source: http://kynatro.com/blog/2012/12/11/finally-a-practical-use-for-wordpress-secret-shortinit-constant/

  17. particlerealities
    Member
    Posted 1 year ago #

    Note that I copied the original text to a clean text file. I tried each of your suggestions, and none seemed to work (tested by loading the http://www.adamsleatherworks.com/wp-content/plugins/top-10/top-10-addcount.js.php?top_ten_id=8 page). Before I tried one of your other suggestions, I first reverted back to the original code I copied to the text file.

  18. particlerealities
    Member
    Posted 1 year ago #

    I went back and edited lines 12-16 like you said, and also went back and added the initial code snippet (not realizing it was necessary to replace it in addition to the 12-16 edit)$wp_config_path = dirname ( dirname( dirname( dirname( __FILE__ ) ) ) );

    That seems to work. Here is the entire file's code:

    <?php
    //"top-10-addcount.js.php" Add count to database
    Header("content-type: application/x-javascript");
    
    // Force a short-init since we just need core WP, not the entire framework stack
    define( 'SHORTINIT', true );
    
    // Build the wp-config.php path from a plugin/theme
    $wp_config_path = dirname ( dirname( dirname( dirname( __FILE__ ) ) ) );
    $wp_config_filename = '/wp-config.php';
    
    // Check if the file exists in the root or one level up
    if( !file_exists( $wp_config_path . $wp_config_filename ) ) {
        // Define ABSPATH since the wp-config.php file is one level up
        define( 'ABSPATH', $wp_config_path . "/" );
        // Just in case the user may have placed wp-config.php one more level up from the root
        $wp_config_filename = dirname( $wp_config_path ) . $wp_config_filename;
    }
    // Require the wp-config.php file
    require( $wp_config_filename );
    
    // Include the now instantiated global $wpdb Class for use
    global $wpdb;
    
    // Ajax Increment Counter
    tptn_inc_count();
    function tptn_inc_count() {
    	global $wpdb;
    	$table_name = $wpdb->prefix . "top_ten";
    	$top_ten_daily = $wpdb->prefix . "top_ten_daily";
    
    	$id = intval($_GET['top_ten_id']);
    	if($id > 0) {
    		$wpdb->query("INSERT INTO $table_name (postnumber, cntaccess) VALUES('$id', '1') ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ");
    		$current_date = gmdate( 'Y-m-d', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) );
    		$wpdb->query("INSERT INTO $top_ten_daily (postnumber, cntaccess, dp_date) VALUES('$id', '1', '$current_date' ) ON DUPLICATE KEY UPDATE cntaccess= cntaccess+1 ");
    	}
    }
    
    ?>

    It seems to be working fine now, and I'm not getting the sucuri warning anymore. Thanks for all your help!! :)

  19. Ajay
    Member
    Plugin Author

    Posted 1 year ago #

    Good news indeed!

    Glad to know this work. I'll test the code above on my installations as well and will put through a fix for Top 10.

    The visits should be counting properly now. Let me know if this isn't the case.

    Thanks for testing it out.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.