Jump to content
Jack_mcs

SiteMonitor

Recommended Posts

Jack already posted the link (https://apps.oscommerce.com/2W7tC&sitemonitor-v3-4) and it's working fine, the docs are there, so not sure what's the issue, Steve:

 

CopyQ.k18200.png

Edited by dr_lucas

Share this post


Link to post
Share on other sites

Yes, that's extremely interesting. I downloaded that link yesterday just before my post above  and UpdateDocs was NOT in the package.  I also see that Jack updated it yesterday.. apparently some time after the above posts since I immediately downloaded it again after Jack said to read UpdateDocs.. NOW it's there.  So, I get to read it.  Hopefully, it will answer any other questions I might come up with.  There must have been some 'grey time' between when Jack uploaded the change and when the server made it available at the public link.

Steve

Share this post


Link to post
Share on other sites

Along about p54 of this thread, there was a discussion about "some" characters that could be used in FILENAMES .. that would 'confuse' sitemonitor and therefore report invalid 'new' and 'deleted' responses from sitemonitor executions.  I note that COMMA and AMPERSAND are at least 2 of them.  'Dot' and 'parenthesis' seems to be OK from my tests, but I wonder about other chars that cause issues.  Jack.. do you have a list that should NOT be used in filenames .. but are 'legal' by other standards . either windows or unix?  Reason.. although I am webmaster, I do NOT manage the day to day updates to the products and images that are uploaded.  I have tried my best to promote 'good practice' to the people that DO that job, but they are somewhat 'computer illiterate' and things don't get updated every day .. so stuff gets 'in there' when transcribed from a sheet of paper into the store ... mostly for image names since they rarely (if ever) actually upload other types of files.  It is somewhat weird to me, based on Jack's posts back then... sitemonitor reads the filenames CORRECTLY when it creates the reference file (i.e. includes the commas and ampersands) - the files are LISTED correctly, but is apparently TRUNCATING the filenames (in different ways) when doing the comparisons... a COMMA in a filename gets a 'New file' flag generated and and AMPERSAND in a filename says it was DELETED.  Both show correctly in the reference file.  Somehow the 2 sections of code - 1 looking for new files . and the other looking for DELETED files, seem to be going through different comparison routines. Could be related to file SIZES I suppose, but those are not listed in the reports and the reports show NO SIZE or TIME differences found.

I also seem to have a problem of some sort in the sitemonitor_configure_setup.php vs sitemonitor_configure_0.txt file.  The .txt file shows the $admin_username = '' (nothing), but whenever I bring up 'Configure' via admin panel, that item is filled in with my admin directory name .. and if I UPDATE without clearing that value, it THEN gets written into the .txt file.  That should NOT happen.. should it?  Why is configure pulling that directory 'out of the sky' and placing it on the config page when it's not needed unless curl is in use from what I've read?

I can live with both of these issues, but thought I'd throw them out there. On the other side .. I do seem to have sitemonitor working on my (practice) site except for the 5 or 6 bogus reports that result from 'bad characters' used in filenames.  It's WONDERFUL to have that peace of mind email every day!  Thanks, Jack for this add-on.  And, BTW, I'm using PHP7, so it does work with that too.

Steve

Share this post


Link to post
Share on other sites

This page and this one lists some characters that should not be used. I never bothered to code for this because it is not recommended that any php shop, oscommerce or any package,  be ran on a Windows server. And using "bad characters" in file names on a Linux server may cause other problems so if someone uses such names, they are asking for problems.

In general, all file names should follow these rules:

  • All lowercase.
  • Words separated by an underscore or a period.
  • No spaces in the name.

Regarding the admin name,  the reason that is filled in is just because I never added a clear for it. On some servers the script would not run as written so I added code to have it load through curl and that requires the admin's login. I haven't seen the need for this for many years so it is probably no longer needed.  But the boxes for it are not needed unless that option is needed so it can be ignored.

Share this post


Link to post
Share on other sites

OK.. Sitemonitor seems to be working mostly, however I keep getting a 'date mismatch' on .htaccess in my admin directory.  I can see no changes in the file, but the date/time *IS* changing.  Maybe about every time Sitemonitor is supposed to delete and reconstruct the reference file.  I have made NO CHANGES at all to the .htaccess file, yet the timestamp keeps changing.

?

Steve

Share this post


Link to post
Share on other sites

Download a copy of that file and then create a new reference file. The next time a change is reported, download the file again and compare it to the first one using a program like WinMerge to see if anything changed.

Share this post


Link to post
Share on other sites
1 hour ago, Jack_mcs said:

Download a copy of that file and then create a new reference file. The next time a change is reported, download the file again and compare it to the first one using a program like WinMerge to see if anything changed.

Have already done that .. there are no changes and the size is identical.  Just that the timestamp is changing.  I've just deleted and recreated the ref file and noted the specific timestamp on the htaccess file according to FileZilla has not changed. I received 2 emails from Sitemonitor. The first one was when I clicked the FIRST ADMIN box to delete/recreate the ref file.  It reported the usual NEW FILES/DELETED FILES referenced in my post on May 26 .. 4 or 5 above this one (as well as a change in the log file as expected) and found NO SIZE MISMATCH and NO PERMISSIONS MISMATCH, but it DID report a TIME MISMATCH on the htaccess file .. it reported "Last Changed on  Tuesday, 12 Jun 2018 19:27:05 GMT".  Interestingly that timestamp happens to be exactly x hours off of the currently showing timestamp via FileZilla of 3:27:05 PM both before and after I clicked the 1st Sitemonitor box.

3 minutes later I clicked the 2nd admin box and received another email - this time showing the usual NEW/DELETED files and ZERO MISMATCH reports.

This SEEMS like a comparison problem of some sort .. but it is also true that the timestamp on htaccess HAS changed in the last few days.. with NO change in what's in it.  I can't even write to it (although I can read it) or modify it in any way.  It was created by my 1and1.com control panel and shows '0 0' as the owner with 644 permissions and I can't change them. I don't have any direct access.  Perhaps this is an issue I need to bring up with 1and1?  Could they possibly be 'pinging it' occasionally thusly changing the timestamp?  I haven't been keeping my daily reports  - I guess I need to retain a few of them to see exactly (if it is 'exact') how often the timestamp is changing....

Maybe I should take a few aspirin and  maybe a tall cocktail and forget this is happening :-).

Oh.. I just looked back in my emails and I have another report from yesterdays' chron run with a TIME MISMATCH  on htaccess showing "Last Changed on  Tuesday, 12 Jun 2018 00:14:45 GMT" .. I guess it was a few minutes into 'today' (the 12th) by GMT when it was still 'yesterday' here in GA.

Steve

Edited by Steve80

Share this post


Link to post
Share on other sites

SiteMonitor is only reporting what it sees and, as you said, the time on the file is changing so it is something else causing that. It is possible a hacker is attempting to change the file and that is causing the timestamp to change, though it seems unlikely to be that frequent. I recall a problem like this years ago. I don't think it was to do with this addon but maybe. It turned out the server was causing the change. I don't remember of other details of it though. There are many posts here about people having problems with 1 and 1 so it wouldn't surprise me if it is was due to how their server is set up. But, as you mentioned, you would need to ask them about it.

Share this post


Link to post
Share on other sites

On both my PHP 7 test shop on my PC and my live PHP 5.6 shop I get these errors. On the live site I cannot access the Configure section, only Site Monitor Admin. Configure throws a 404 error but the file is definitely there.

PHP Warning:  opendir(/home/username/public_html): failed to open dir: No such file or directory in /home/*****/public_html/*********/includes/functions/sitemonitor_functions.php on line 364

image.png.523a13a9d8ec3484a88e788706a325db.png


OsC 2.3.4.1 CE Frozen   PHP 7.2   MySQL 10.1.36-MariaDB-cll-lve. Phoenix in development

Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix 1.0.2.0) here.

Share this post


Link to post
Share on other sites

The /home/username/public_html is invalid, thus the failure. You shouldn't be able to access the Admin section until you've updated the Configure section so that's strange. Did you use the sitemonitor_configure_0.txt from the addon or one from another installation? Does it work if you edit that file manually and enter in the correct path?

Share this post


Link to post
Share on other sites

I have manually edited the sitemonitor_configure_0.txt and it is working now. It detects file changes that I introduced and sends the email.

However I still cannot access the SM configure from within the website admin, it still throws a 404

The URL in the browser displays https://www.my website.co.uk/myadmin/sitemonitor_configure_setup.php but with a 404 error page.

Got it working and can live with the issue as it is doing it's job, but I am confused.

Edited by mhsuffolk
typo

OsC 2.3.4.1 CE Frozen   PHP 7.2   MySQL 10.1.36-MariaDB-cll-lve. Phoenix in development

Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix 1.0.2.0) here.

Share this post


Link to post
Share on other sites

To see if the problem is in the sitemonitor_configure_setup.php file, you can remove it and copy and rename a working file in its place, like the admin file, customers.php, or any other. If the page loads, then it would appear something is wrong in the sitemonitor_configure_setup.php file, though I don't know what it might be.

The settings are rarely changed once setup so this may not be worth messing with if everything else is OK. If you do need to change then, you can always do it manually again, though it would be nice to not have to bother with that.

Share this post


Link to post
Share on other sites

Thanks, as always for your superb support. Will report back shortly

Edited by mhsuffolk
typo

OsC 2.3.4.1 CE Frozen   PHP 7.2   MySQL 10.1.36-MariaDB-cll-lve. Phoenix in development

Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix 1.0.2.0) here.

Share this post


Link to post
Share on other sites

I have tried your idea using Customers.php and that works. So there may be something going on with sitemonitor_configure_setup.php


OsC 2.3.4.1 CE Frozen   PHP 7.2   MySQL 10.1.36-MariaDB-cll-lve. Phoenix in development

Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix 1.0.2.0) here.

Share this post


Link to post
Share on other sites

In anticipation of you possible next suggestion I have re-downloaded the addon and replaced the sitemonitor_configure_setup.php with a fresh copy. Sadly it is still the same.


OsC 2.3.4.1 CE Frozen   PHP 7.2   MySQL 10.1.36-MariaDB-cll-lve. Phoenix in development

Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix 1.0.2.0) here.

Share this post


Link to post
Share on other sites

That was a good idea - too bad it didn't work. :) I don't what might be causing this. The failure you mentioned is in a part of the code that only gets called when the Admin script is ran so I don't see how it is failing in the Configure section. You might want to make sure you can delete the reference file and create it again. Some servers won't allow the files to be changed with altering the user settings. That can cause problems in the Configure section, though usually only when trying to save the settings, from what I've seen.

Share this post


Link to post
Share on other sites

Deleted the reference file via ftp and site monitor has recreated it OK

I am working slightly blind here. Should there be a path instead of the word "array" in these lines?

$excludeList = array('cgi-bin'); //don't check these directories - change to your liking - must be set prior to first run
$hackIgnoreList = array('jpg', 'jpeg','gif','png','txt','zip'); //don't check these types of files - change to your liking

 


OsC 2.3.4.1 CE Frozen   PHP 7.2   MySQL 10.1.36-MariaDB-cll-lve. Phoenix in development

Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix 1.0.2.0) here.

Share this post


Link to post
Share on other sites

Those are correct. The $excludeList includes directories you don't want to search. So if you wanted to skip the pub directory, you would change it to

$excludeList = array('cgi-bin','pub');
Edited by Jack_mcs

Share this post


Link to post
Share on other sites

My problem with PHP Warning:  opendir(/home/username/public_html): failed to open dir: No such file or directory in /home/*****/public_html/*********/includes/functions/sitemonitor_functions.php on line 364 which we discussed in September is still there but Site Monitor works correctly including the daily cron job that is run.

Today, for the first time, this has appeared in the admin error log as a result of the cron job.

[02-Nov-2018 06:00:02 UTC] PHP Notice:  Undefined variable: verbose in /home/****/public_html/*****/includes/functions/sitemonitor_functions.php on line 301

Line 301 is

DisplayMessage($verbose, 'Deleted log file due to age - ' . $file);

Frozen  PHP 7.2


OsC 2.3.4.1 CE Frozen   PHP 7.2   MySQL 10.1.36-MariaDB-cll-lve. Phoenix in development

Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix 1.0.2.0) here.

Share this post


Link to post
Share on other sites
5 hours ago, mhsuffolk said:

Notice:  Undefined variable: verbose

That is saying the variable is used without being declared first. But the verbose variable should be seen by all parts of the code since it is read in from the configure file. I don't have a shop setup on 7.2 using this addon so I can't check it to see why it is doing it. But the following change may work. At line 217 in the functions file, change this

global $logfile, $logfile_delete, $logfile_location;

to this

global $logfile, $logfile_delete, $logfile_location, $verbose;

 

Share this post


Link to post
Share on other sites

Thanks for that. It is interesting that the server can access sitemonitor_functions.php  when running the cron job but I still cannot access it through admin. On my test xampp set up I can access sitemonitor_functions.php so it must be a server issue and not PHP 7.2.

As I cannot emulate it on my xampp I will have to test this using the cron job. I have amended sitemonitor_configure.txt to renew the log after 1 day and will wait until tomorrow or Sunday morning and see if the error is repeated. Then I will apply your change to see if it disappears.

PS. If you want something tested under 7.2 please PM me.

Martin


OsC 2.3.4.1 CE Frozen   PHP 7.2   MySQL 10.1.36-MariaDB-cll-lve. Phoenix in development

Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix 1.0.2.0) here.

Share this post


Link to post
Share on other sites

I've suddenly started getting a time mismatch "error" on the file .ea-php-cli.cache.  It's an Easy Apache file, a link to ea-php71 with a very recent timestamp.  The line in the sitemonitor log shows ".ea-php-cli.cache,0,0,0" so of course SiteMonitor thinks the file was created on January 1, 1970.

Share this post


Link to post
Share on other sites

You can add that file to the exclude list so it is not checked. To do that, find this at line 380 in the admin/includes/functions/sitemonitor_functions.php file 

(strcmp($file, 'sitemonitor_admin.php') == 0) ||

and add this beneath it

(strcmp($file, '.ea-php-cli.cache') == 0) ||

 

Share this post


Link to post
Share on other sites

Great idea, thanks.  I've added your change.

I'm thinking about making a small function that reads a text file that has a list of exclude files in it, and then iterate through the list in the section of code you pointed out, in the CreateReferenceFile() function, after the else statement at line 377.  I could put the SiteMonitor files in the exclude_file_list as well as that Easy Apache cache link or any other trusted files.  Sort of like the exclude directories function you already have.

What do you think?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×