AWStats malfunction (/stats/ not working as expected)

Discussion in 'Developers' Forum' started by Athar, Aug 11, 2024.

  1. Athar

    Athar New Member

    Hi,

    One new little report on my daily usage and discovery of ISPConfig.
    When AWStats is selected, you can't get the stats displayed.

    This is due to a stupid line in the "index.php" file found in the "stats" folder of the website :

    upload_2024-8-11_21-18-36.png

    Due to this specific line of code, the iframe will never work if "awstats" is selected.
    But, if we remove this line, it will not work either as it need to be properly setup for the iframe to work.

    You would think "hey, but if we remove this line, the "foreach" which is run before (to retrieve past stats months) should be enough no ?"
    Which will be a "yes", if the rest of the code was working, which doesn't seems to at that moment :

    I did change the "foreach" statement to get an echo on which output of the if statement we get :
    upload_2024-8-11_21-23-55.png

    And... C did won this (even if awsindex.html did exist) :
    upload_2024-8-11_21-24-30.png

    upload_2024-8-11_21-25-50.png

    Of course, putting right before all the "$html .=" stuff this line :
    $goaccessindex = 'awsindex.html';
    Will fix the issue.

    I did not dig further for now, but I wanter to report this :)


    Edit : Not 100% sure, but this block of code :
    PHP:
        if(file_exists($value.'/awsindex.html') && file_exists($value.'/goaindex.html')) {
            
    $goaccessindex 'goaindex.html';
        } elseif(
    file_exists($value.'/awsindex.html') && !file_exists($value.'/goaindex.html')) {
                    
    $goaccessindex 'awsindex.html';
        } else {
            
    $goaccessindex 'goaindex.html';
        }
    I think this shouldn't involve the $value to check for the file presence, as the code right below set it for the "options" selector with the value variable.

    In fact, this whole block should be run only once outside of the foreach statement.
    Tested working from what I checked so far :
    upload_2024-8-11_21-33-27.png
     
    Last edited: Aug 11, 2024
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The statistics used to work fine and the code has not been changed since then. Did you wait 24 hours? The first stats are displayed after 24 hours, and when switching to a different stats program, it will also take 24 hours before statistics can be accessed. Also, the site must get traffic to generate statistics.

    But I will see if I can reproduce the issue here.

    In general, please use the issue tracker at git.ispconfig.org to report issues. Issues posted here are not tracked, and fixes will not be integrated into ISPConfig.
     
  3. Athar

    Athar New Member

    I found the git a few hours later after this post to be honest, but yes, there was stats (as the FTP capture shows).

    Create a website with AWStats, and the issue should arise (as the index.php file will always tries to get the "goaindex.html" endpoint).
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    To me, it looks like you switched between goaccess and Awstats and did not wait until the new statistics were generated. Because the code you posted exists only if you have chosen goaccess and not awststs for the website. See index page templates for goaccess and Awstats, the one you posted exists only on goaccess sites, but the HTML files in the output you posted are from awstats, so you must have used awstats in the past and then switched to goaccess and no goaccess statistics were created yet.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    I've added a feature request to add a placeholder page when you switch stats software that informs the user that no statistics are there yet to avoid such confusion as you had because a 404 page showed up after you switched to a different stats software. https://git.ispconfig.org/ispconfig/ispconfig3/-/issues/6762
     
  6. Athar

    Athar New Member

    Yes, I should have added this :
    Website was first enabled with the default AWStats.
    I did changed it to GoAccess, but when accessing it, it fail to display the AWStats which were still present in the "stats" folder.

    The code posted should select which one of the index (awsindex.html or goaindex.html) to use, based on which files are present.
    If both are present in the "stats" folder, GoAccess get the priority.
    If only the "awsindex.html" file is found and not "goaindex.html", then should select AWStats.
    And lastly, if none are found, it should revert by default with GoAccess.

    The issue I report here, is that this code search those files under $value/INDEX, where $value is a date range (month of the expected stats ?) but this if/else condition is badly place and can't work (if no "old stats" are present).

    In my case, the site was 2 days old, so 2 days were present in the AWStats file, but this part of the code get into the third condition doesn't finding AWStat.

    For me, that's still an error on this specific page in this specific case (if this index.php file is generated this way when we select another Stats system).

    I'll check with a site where I didn't touch anything to see how index.php looks by default, but anyways, that's still a code error in this change scenario.

    Regards
     

Share This Page