Difference between revisions of "Prolog Mod"

From TNG_Wiki
Jump to navigation Jump to search
(Addedd user detail.)
(157 intermediate revisions by 20 users not shown)
Line 1: Line 1:
 
{{caution |notes= If this mod is installed or configured incorrectly it could make your site appear to crash.  Don't panic. Edit your subroot.php and remove the last line pertaining to Prolog.  Then in mod manager "Clean" the partially installed Prolog to remove the mod.''' [[#Warning|See Below for detail]]
 
{{caution |notes= If this mod is installed or configured incorrectly it could make your site appear to crash.  Don't panic. Edit your subroot.php and remove the last line pertaining to Prolog.  Then in mod manager "Clean" the partially installed Prolog to remove the mod.''' [[#Warning|See Below for detail]]
}}
+
}}{{restricted}}
{{restricted}}
 
 
{{TNGmod
 
{{TNGmod
| mod_name = Prolog Mod
+
| mod_name = {{PAGENAME}}
 
| mod_summary = Adds PHP Rotating Logs to TNG site
 
| mod_summary = Adds PHP Rotating Logs to TNG site
 
| mod_validation =  
 
| mod_validation =  
| mod_last_update = 3 Mar 2020
+
| mod_last_update = 11 Mar 2024
| download_link =  
+
| download_link = <div style="display:inline-block;width:95%;">[https://bisbeefamily.com/ccount/click.php?id=264&user={{#replace:{{CURRENTLOGGEDUSER}}}}&page={{PAGENAMEE}}    version 14.0.0.20.zip]<div style="float:right;">{{Tv140|float=left}}</div></div>
<div   style="display:inline-block;width:95%;">[https://bisbeefamily.com/ccount/click.php?id=172&user={{#replace:{{CURRENTLOGGEDUSER}}}}&page={{PAGENAMEE}}     version 12.2.0.4.zip]<div    style="float:right;">{{Tv120|float=left}}</div></div>
+
<div style="display:inline-block;width:95%;">[https://bisbeefamily.com/ccount/click.php?id=187&user={{#replace:{{CURRENTLOGGEDUSER}}}}&page={{PAGENAMEE}} version 12.0.0.9.zip]<div    style="float:right;">{{Tv120|float=left}}</div></div>
<!-- https://tng.lythgoes.net/wiki/images/f/f5/Prolog_v12.2.0.4.zip -->
+
<!-- https://tng.lythgoes.net/wiki/images/a/a3/Prolog_v12.0.0.9.zip -->
 
+
| download_stats = [https://bisbeefamily.com/ccount/index.php?action=stats&groupid=22 view statistics]
| download_stats = [https://bisbeefamily.com/ccount/index.php?action=stats&groupid=18 view statistics]
 
 
 
 
| mod_author = [[User:Kazooter|Rick Bisbee]]
 
| mod_author = [[User:Kazooter|Rick Bisbee]]
 
| mod_url = [https://bisbeefamily.com/ Bisbee Family Connection]
 
| mod_url = [https://bisbeefamily.com/ Bisbee Family Connection]
 
| mod_support = [https://bisbeefamily.com/support.php?mod={{PAGENAMEE}} Support for {{PAGENAMEE}}]
 
| mod_support = [https://bisbeefamily.com/support.php?mod={{PAGENAMEE}} Support for {{PAGENAMEE}}]
 
| mod_contact = As above
 
| mod_contact = As above
| mod_version = 12.2.0.4
+
| mod_version = 14.0.0.20
 
| use_mod_manager = Yes
 
| use_mod_manager = Yes
 
| manual_install = No
 
| manual_install = No
| min_TNG_ver = 12.2
+
| min_TNG_ver = 13.0
| max_TNG_ver = 12.2+
+
| max_TNG_ver = 14.0+
 
| TNG_file_list =  
 
| TNG_file_list =  
 
| related_mods =
 
| related_mods =
 
| notes =  
 
| notes =  
}}
+
}}{| style="margin-right:0.5 em;" align="right"  
{| style="margin-right:0.5 em;" align="left"  
 
 
| __TOC__
 
| __TOC__
 
|}
 
|}
<br clear=both>
 
 
 
== Prolog (PHP Rotating Log) Introduction ==
 
== Prolog (PHP Rotating Log) Introduction ==
 
[[Image:Prolog6.png|left|150px]]
 
[[Image:Prolog6.png|left|150px]]
Prolog is a utility for TNG testers, mod developers and anyone who wants to monitor their websites for PHP or user issues.  It is an extension of the Show PHP Errors mod created by Roger Mitchell (decd) and provides three selectable levels of error logging: 1) just errors; 2) all errors, warnings and deprecations except for notices (default); or 3) all errors, warnings, notices, and deprecated functions.
+
Prolog is a utility for TNG testers, mod developers and anyone who wants to monitor their websites for PHP or user issues.  It is an extension of the Show PHP Errors mod created by Roger Mitchell (decd) and provides nine selectable levels of error logging from Errors only to all errors, warnings, notices and deprecations.
 +
''An important feature is that fatal errors displayed to the screen are generic and never reveal server information that a hacker may be looking for. The actual error can be found in the error log using the same timestamp shown on the screen.''
  
''An important feature is that fatal errors displayed to the screen are generic and never reveal server information that a hacker may be looking for.''
+
===<span style='color:#990000'>Important Note for TNGv14 Users</span>===
 +
<p style='font-style:italic'>Prolog was updated for TNGv14. In Previous versions, Prolog was initialized in subroot.php. Starting with TNGv14, Prolog v14 is initialized in begin.php. This change makes it very important that you completely uninstall any previous versions you may have tried in TNGv14, before installing Prolog v14.  '''Neglecting to do this may leave unwanted code in TNG files that will result in TNG errors and even site failure.'''</p>
 +
<p>Prolog v14 will fail with errors if any components of previous versions have not been uninstalled.<p>
  
Prolog puts its daily PHP log files in a location provided by the user in the mod's Edit Options page. If the user has a PHP log file defined in php.ini, Prolog will override it.  However, if the user sets the log file path in Prolog the same as in the php.ini, all logs will go to the same folder. Note that the log specified in php.ini will be a single file containing many days worth of errors and can grow very large.
+
===Error Log Location===
 +
Prolog will use the php.ini error_log setting to place its logs in the same location as PHP. If the php.ini is not set, or if it is inaccessible, prolog will use the TNG root-relative path you've set in the Mod Edit Options. If not set there, Prolog will create and default to a logs directory in your TNG root directory. While the last option works fine for offline test sites, for security reasons it is not recommended for a live site.
  
For TNG scripts, Prolog modifies subroot.php to add logging to any page that includes it. Scripts that work independently of TNG will not be logged by this mod; however, those errors will be logged in the file set in php.ini.
+
====php.ini error_log directive====
 +
You must set the '''php.ini error_log directive''' with the full server path to the PHP error log for the site. Error logs can be located above the public_html for greater security (recommended.) In a local WAMP server you can edit it directly into the WAMPS php.ini file.  On a shared hosting server you may be able to add a php.ini file to your root directory with just this directive to override the master php.ini. Some hosts allow a '''user.ini''' to serve the same purpose. See [[PHP error log]] for additional information on setting up error logs. The directive will look something like this ('''note the absolute server path'''):
 +
<pre>
 +
error_log = /home/mysite/mylogs/php_error.log
  
That said, if you do want to Prolog independent scripts, you can include prolog_conf.php at the top of a primary (as opposed to an included) script and as long as the mod remains installed, errors will be logged to the same rotating logs, at the same level as the others.
+
OR FOR A WAMPS where wamps is your server folder name
 +
 
 +
error_log = D:/wamps/logs/php_error.log
 +
</pre>
 +
 
 +
===Log Rotation===
 +
Both Prolog and the PHP system will log errors to the PHP file. At the close of each GMT day Prolog will archive the PHP log to a dated backup and start the PHP log over again. After the first day no single log will contain more that one day's errors. That keeps all of them relatively small and manageable.
 +
 
 +
''Prolog modifies subroot.php to add logging to all TNG pages. Scripts that work independently of TNG will not be logged by this mod; however, those errors will be logged by the system in the same PHP log.''
 +
 
 +
That said, if you do want to Prolog independent scripts, you can include prolog_conf.php at the top of a primary (as opposed to an included) script and as long as the mod remains installed, errors will be logged in the same way as TNG scripts to protect fatal errors from revealing server information.
 
<pre>
 
<pre>
 
if(file_exists('prolog_conf.php'))
 
if(file_exists('prolog_conf.php'))
Line 47: Line 58:
 
</pre>
 
</pre>
  
 
+
===How Prolog Works===
 
 
 
Prolog has two main files:
 
Prolog has two main files:
 
<ol>
 
<ol>
Line 55: Line 65:
 
</ol>
 
</ol>
  
== Features ==
 
 
Prolog adds a log access page link in the TNG Admin management area and features the following:
 
Prolog adds a log access page link in the TNG Admin management area and features the following:
* Rotating error logs created daily to prevent them becoming too large to manage;
+
 
* Daily logs and error entries are timestamped in GMT;
+
* Rotating error logs are created daily to prevent them becoming too large to manage;
* A GMT clock is provided for admin perspective on timestamps;
+
* The php.ini error log collects all of today's errors;
 +
* Errors from previous days may be found in the dated archive logs;
 +
* Archived logs and error entries are timestamped using the timezone set in php.ini;
 +
* A clock is provided for admin perspective on timestamps;
 
* Mod Edit Option to select error level for logging;  
 
* Mod Edit Option to select error level for logging;  
 
* Mod Edit Option to set number of daily logs to keep before auto-deleting the oldest;
 
* Mod Edit Option to set number of daily logs to keep before auto-deleting the oldest;
* Daily logs selectable from drop down list for viewing and/or deletion (see visualization);
+
* Logs selectable from drop down list (see screen shot);
* Other .log files can be viewed and manipulated;
 
 
* Logged items are listed from most recent to oldest for admin convenience;
 
* Logged items are listed from most recent to oldest for admin convenience;
* Filter that limits viewing of logged errors to only items of interest;
+
* A Filter is provided to limit viewing of logged errors to only items of interest;
 
* Language support included in mod folder for easier maintenance;
 
* Language support included in mod folder for easier maintenance;
 
* A fatal shutdown handler.
 
* A fatal shutdown handler.
Line 77: Line 88:
 
</pre>
 
</pre>
 
The exact time can be used to compare with the logs, should a legitimate user choose to report it.
 
The exact time can be used to compare with the logs, should a legitimate user choose to report it.
Compare the actual log entry for displayed message above:
+
Compare the actual log entry with the displayed message above:
<pre>[24-Feb-2020 18:34:02 GMT] Fatal error: File access violation in fgw/fgw_setup.php on line 26  
+
<pre>[24-Feb-2020 18:34:02 America/Phoenix] PRO Fatal error: File access violation in fgw/fgw_setup.php on line 26  
 
</pre>
 
</pre>
  
This was probably a hack attempt. In this case the error was generated by the author of fgw_setup.php, not PHP itself.
+
This was probably a hack attempt. Both the displayed and logged errors were triggered by fgw_setup.php using the following code:
 
<pre>
 
<pre>
 
// ONLY ADMINISTRATOR GETS ACCESS TO THE SETUP PAGE
 
// ONLY ADMINISTRATOR GETS ACCESS TO THE SETUP PAGE
Line 91: Line 102:
  
 
== Language Support ==
 
== Language Support ==
The mod support folder includes support for Czech, English, French, German, Spanish and Swedish. You can modify the files right in the support folder to change the translations.  You can add new folders with other languages if you like.  '''If you make changes or additions I will be happy to add them to the distribution package for others to use as well'''.  Just email them to me or use the mod support link on the Prolog_Mod TNGWiki page.
+
The mod support folder contains support for Czech, English, French, German, Spanish and Swedish. You can modify the files right in the support folder to change the translations.  You can add new folders with other languages if you like.  '''If you make changes or additions I will be happy to add them to the distribution package for others to use as well'''.  Just email them to me or use the mod support link on the Prolog_Mod TNGWiki page.
  
== Version 4 (v12.2.0.4) Enhancements ==
+
== Using the PHP and System Logs ==
 +
In your php.ini set the logfile, for example: <pre>error_log = D:/wampsdir/mylogs/php_error.php</pre>
  
Prolog version 4 will open any .log file in the Prolog directory set in the mod's Edit Options page. Therefore it will handle php.ini and WAMPS server logs if you set it up to do so. Here's how to do it in a directory above the public_html (www) on a Windows WAMP Server at <pre>D:/wampsdir/mylogs/</pre>
+
Prolog will detect the file and use it to log errors.
  
In your php.ini set the logfile: <pre>error_log = D:/wampsdir/mylogs/php_error.php</pre>
+
If you want to view Apache system logs in your WAMPS, in your WAMPS httpd.conf file set up a VirtualHost something like this.  
 
 
In Prolog's Mod Edit options page set the path to <pre>D:/wampsdir/mylogs/</pre>
 
 
 
In your WAMPS httpd.conf file set up a VirtualHost something like this.  
 
 
<pre>
 
<pre>
 
<VirtualHost *:80>
 
<VirtualHost *:80>
 
ErrorDocument 404 /errdocs/_err404.php
 
ErrorDocument 404 /errdocs/_err404.php
 
ErrorDocument 403 /errdocs/_err403.php
 
ErrorDocument 403 /errdocs/_err403.php
ErrorLog D:/wampsdir/logs/server_error.log
+
ErrorLog D:/wampsdir/mylogs/server_error.log
 
</VirtualHost>
 
</VirtualHost>
 
</pre>
 
</pre>
  
Now all log files will go to the mylogs directory, will be listed in Prolog's dropdown menu and can be vieweds and managed by Prolog.
+
using the same directory as the php.ini error log.
 +
 
 +
Prolog will list and display that one too.  It must be managed to prevent it from becoming too large and crashing the system with out-of-memory errors.
 +
 
 +
See [[PHP error log]] for more complete information on setting up error logs in different environments
 +
 
 +
== More About Error Files and Log Dates ==
 +
Archived error files and error items use the date set in the date.timezone directive in the php.ini file. If not set, GMT will be used.
 +
 
 +
On a ''live site with shared hosting'', you may be able to set the timezone by creating a php.ini file in your document root and entering directives, for example:
 +
<pre>
 +
date.timezone = America/Phoenix
 +
error_log = /home/bisbeefa/mylogs/php_error.log
 +
</pre>
 +
It may take 20-30 minutes or more for the changes to take effect on shared hosting, so be patient.
 +
 
 +
You may also be able to add the following '''to your site's main .htaccess file''' for both error_log and date.timezone:
 +
<pre>
 +
<IfModule php7_module>
 +
  php_value date.timezone "America/Phoenix"
 +
  php_value error_log "/home/bisbeefa/mylogs/php_error.log"
 +
</IfModule>
 +
</pre>
 +
If you are still using PHP 5, change the first line above to reflect that.
 +
 
 +
My web host (Bluehost) also uses the following:
 +
<pre>
 +
<IfModule lsapi_module>
 +
  php_value date.timezone "America/Phoenix"
 +
  php_value error_log "/home/bisbeefa/mylogs/php_error.log"
 +
</IfModule>
 +
</pre>
 +
lsapi is a drop-in module to speed up serving PHP pages.
  
 
== TNG Version Compatibility ==
 
== TNG Version Compatibility ==
Prolog is compatible with TNG version 12.1 and up. It may be compatible with TNGv12.0 (not tested)
+
Prolog is compatible with TNG version 12.0 and up.
  
 
== Mod Revision History ==
 
== Mod Revision History ==
Line 122: Line 162:
 
! Date
 
! Date
 
! Updates
 
! Updates
 +
 +
 +
|- valign="top"
 +
| v14.0.0.20
 +
| 12&nbsp;Mar&nbsp;2024
 +
|
 +
* Fixes clash between session filters in Mod Manager and Prolog.
 +
 +
|- valign="top"
 +
| v14.0.0.19
 +
| 11&nbsp;Mar&nbsp;2024
 +
|
 +
* User-selected log files and filters are now persistent during the same session.  If you navigate away from the page and later return, the same log file and filter selections will apply.  You must manually re-select another log file and clear the filter to change them.
 +
 +
|- valign="top"
 +
| v14.0.0.18
 +
| 31&nbsp;Jan&nbsp;2023
 +
|
 +
* Expands choices for error reporting level
 +
 +
|- valign="top"
 +
| v14.0.0.17
 +
| 28&nbsp;Jan&nbsp;2023
 +
|
 +
* Fixes warnings after log file is cleared
 +
 +
|- valign="top"
 +
| v14.0.0.16
 +
| 1&nbsp;Jan&nbsp;2023
 +
|
 +
* Fixes warnings
 +
* Minor syntactic updates
 +
 +
|- valign="top"
 +
| v14.0.0.15
 +
| 17&nbsp;Dec&nbsp;2022
 +
|
 +
* Fixes filemtime problem in Windows
 +
 +
|- valign="top"
 +
| v14.0.0.14
 +
| 14&nbsp;Dec&nbsp;2022
 +
|
 +
* Not released
 +
 +
|- valign="top"
 +
| v14.0.0.13
 +
| 10&nbsp;Sep&nbsp;2022
 +
|
 +
* Updated to work with TNGv14
 +
* Inserts Prolog.conf.php into begin.php vice subroot.php to prevent conflict with the GEDCOM upload progress bar
 +
* Checks for correct version of TNG before allowing installation
 +
* Checks for uninstalled components of previous version of Prolog
 +
* New mod editor option to set the timezone for the log entries
 +
* Updated mod option to display errors to the screen: set to 0, only the public message displays; set to 1, only the raw PHP error is displayed (for developers)
 +
* Moves prolog_conf.php file to the extensions directory
 +
 +
|- valign="top"
 +
| v13.0.0.9
 +
| 21&nbsp;Sep&nbsp;2020
 +
|
 +
* Updated to work with TNGv13 admin which no longer uses iframes.
 +
* Removes external file version number
 +
* Adds tooltip to Admin link showing version number
 +
 +
|- valign="top"
 +
| v12.0.0.9
 +
| 21&nbsp;Sep&nbsp;2020
 +
|
 +
* Removes external file version number
 +
* Adds tooltip to Admin link showing version number
 +
 +
|- valign="top"
 +
| v12.0.0.8
 +
| 10&nbsp;Aug&nbsp;2020
 +
|
 +
* If no error log is defined in php.ini or elsewhere, Prolog creates a logs directory specified in the Prolog Edit Options.
 +
 +
|- valign="top"
 +
| v12.0.0.7a
 +
| 13&nbsp;Mar&nbsp;2020
 +
|
 +
* Fixed bug that prevented parameter updates
 +
 +
|- valign="top"
 +
| v12.0.0.7
 +
| 12&nbsp;Mar&nbsp;2020
 +
|
 +
* Now usese php.ini date.timezone vice GMT for timestamping
 +
* Adds version number to copied files to avoid confusion when upgrading
 +
 +
|- valign="top"
 +
| v12.0.0.6
 +
| 9&nbsp;Mar&nbsp;2020
 +
|
 +
* More reliable trigger to archive PHP file to daily and start again
 +
* Fixes bug that sends fatal error to yesterday's daily
 +
* Fixes bug that kept out-of-date files from being deleted
 +
 +
|- valign="top"
 +
| v12.0.0.5
 +
| 5&nbsp;Mar&nbsp;2020
 +
|
 +
* Tested successfully with TNGv12.0 and up (version number adjustment.)
 +
* Option to specify a log directory is removed.
 +
* Works with error log defined in php.ini
 +
* Both Prolog and PHP errors go to the php.ini error log
 +
* At the end of each GMT day the PHP error log is sent to a dated backup log and the PHP error log is started anew. Keeps all of the day's errors in one place.
  
 
|- valign="top"
 
|- valign="top"
Line 157: Line 305:
 
== Installation ==
 
== Installation ==
 
Prolog installs as a normal TNG mod. Download and unzip the contents -- one file and one folder. Place the prolog.cfg file and the support folder into your TNG site's mods directory. Do not remove folders and files from the support folder -- just leave them there.  Navigate to your Mod Manager, find and open the mod listing and click on ''Install''.
 
Prolog installs as a normal TNG mod. Download and unzip the contents -- one file and one folder. Place the prolog.cfg file and the support folder into your TNG site's mods directory. Do not remove folders and files from the support folder -- just leave them there.  Navigate to your Mod Manager, find and open the mod listing and click on ''Install''.
 +
 +
== Upgrade ==
 +
When installing an updated version of Prolog, it is important that you first use Mod Manager to completely remove any earlier version and preferably delete it.
  
 
== Configuration ==
 
== Configuration ==
 +
You must have a site-wide PHP error log set in your php.ini file, either by directly editing the file in a local WAMPS, or in shared hosting, indirectly by adding a php.ini (or user.ini) file to your TNG root directory with the error_log directive, for example:
 +
<pre>error_log = /home/mysite/mylogs/php_error.log</pre>
 +
The error log file should use the extensions '''.log'''.
  
=== Location for Daily Error Logs ===
+
=== Setting the Error Level for Logging ===
<b style='color:red'>This is very important</b>. As soon as you've installed the mod, open it in the mod manager and click on Edit Options. There you must enter the server path '''to an existing directory''' for your daily logs. For best results, always use an absolute server path.  
+
Error Level settings are designated by adding the index numbers for the items you want reported.
<pre>
+
 
D:/wamps/mylogs/
+
0 == ERRORS<br />
OR
+
1 == WARNINGS<br />
/home2/mysite/mylogs/
+
2 == NOTICES<br />
</pre>
+
4 == DEPRECATED<br />
 +
9 == ALL
 +
 
 +
E_ERROR is always reported. Errors alone are index 0.
  
Be sure to terminate the path with a forward slash and do not surround it with quotes of any kind. Your server path can lead to a location above the public_html directory for extra security if you like (recommended.) If you fail to specify a log file path, or if the path does not exist, Prolog will show a message explaining the problem when the PHP Prolog link is clicked at the top of the TNG Admin page.
+
To specify E_ERROR and an additional type, enter the additional type index number into the parameter box. To specify a combination of error reporting, just add the index numbers and enter the total for the parameter.  
  
=== Setting the Error Level ===
+
A complete map:<br />
* Error level 1 will only log actual, usually fatal errors.
+
0 == errors<br />
 +
1 == errors and warnings (1)<br />
 +
2 == errors and notices (2)<br />
 +
3 == errors and warnings and notices (1+2)<br />
 +
4 == errors and deprecated (4)<br />
 +
5 == errors and warnings and deprecated (1+4)<br />
 +
6 == errors and notices and deprecate (2+4)<br />
 +
7 == errors and warnings and notices and deprecated (1+2+4)<br />
 +
9 == E_ALL
  
* Error level 2, the default, should be about right for a live site. It will log errors, warnings and PHP function deprecations. That latter means the scripts will stop working with new PHP upgrades, so we should know about them.
+
* Error level 5 should be about right for a live site. It will log errors, warnings and PHP function deprecations. That latter means the scripts will stop working with new PHP upgrades, so we should know about them.  Error level 1 would just be errors and warnings.
  
* Error level 3 logs everything -- errors, notices, warnings and deprecations. Because TNG emotes large numbers of notices right now, error level 3 should only be used while actually testing a script and reduced back to 1 or 2 when not testing.  Even a daily log can get very large at error level 3.
+
* Error level 9 logs everything -- errors, notices, warnings, deprecations and everything else. Because TNG emotes large numbers of notices right now, error level 3 should only be used while actually testing a script and reduced back to 1 or 5 when not testing.  Even a daily log can get very large at error level 9.
  
 
== Warning ==
 
== Warning ==
If installed incorrectly this mod can cause the site to appear to crash. Don't panic.  Edit subroot.php and remove the last line pertaining to Prolog.  The site will come good again.  Then go to mod manager and Clean up the partially installed Prolog mod. Prolog modifies subroot.php by including ''prolog_conf.php'' with parameters that are set in the mod's Edit Options. If incorrectly set or if the mod is partially installed for some reason, subroot.php may fail and so will all pages that include it.
+
If installed incorrectly this mod can cause the site to appear to crash. Don't panic.  Edit subroot.php and remove the last line pertaining to Prolog.  The site will come good again.  Then go to mod manager and Clean up the partially installed Prolog mod. Prolog modifies subroot.php by including ''prolog_conf.php'' with parameters that are set in the mod's Edit Options. If the mod's Edit Options are incorrectly set or if the mod is partially installed for some reason, subroot.php may fail and so will all pages that include it.
  
There was a bug in Mod Manager up to TNGv12.3 beta which was corrected during testing.  If a parameter expects a numeric value and you update it with and empty field, it renders a parameter variable such as $mycount as <pre> $mycount = ;</pre> and will cause the script containing the parameter to fail. After the fix to mod manager it will render it as <pre>$mycound = 0;</pre> which fixes the problem.
+
=== Mod Manager Bug ===
 +
''There was a bug in Mod Manager up to TNGv12.3 beta which was corrected during testing.  If a parameter expects a numeric value and you update it with and empty field, it renders a parameter variable such as $mycount <pre> $mycount = ;</pre> That will cause a fatal error and the script containing the parameter will fail. After the fix to mod manager it will render it as'' <pre>$mycound = 0;</pre>.
  
 
== Sites using this mod ==
 
== Sites using this mod ==
If you download this mod, please add your TNG site to the table below:
+
If you download and install this mod, please add your TNG site to the table below:
{| border="0" cellspacing="1" cellpadding="2" class="wikitable"
+
 
 +
{| border="0" cellspacing="1" cellpadding="2" class="wikitable" width="100%"
 
|-
 
|-
 
! URL
 
! URL
Line 192: Line 359:
 
! TNG-Version
 
! TNG-Version
 
! User-language
 
! User-language
|-
+
 
 +
|- style="vertical-align:top;"
 
| [http://www.bisbeefamily.com A Bisbee Family History]
 
| [http://www.bisbeefamily.com A Bisbee Family History]
| [[User:kazooter|Rick Bisbee]]
+
| style="white-space: nowrap;"|[[User:kazooter|Rick Bisbee]]
 
| Mod Developer. A must-have for mod developers
 
| Mod Developer. A must-have for mod developers
| 12.2.0.4
+
| 12.0.0.7
 
| 12.1
 
| 12.1
| English
+
| style="white-space: nowrap;"|EN
|-
+
 
 +
|- style="vertical-align:top;"
 +
|[https://tng.stegemueller.dk Stegemüller Family History]
 +
| style="white-space: nowrap;"|[[User:Stegemüller|Hanne B. Stegemüller]]
 +
|Public site
 +
|14.0.0.16
 +
|14.0
 +
| style="white-space: nowrap;"|EN,DE,DA
 +
 
 +
|- style="vertical-align:top;"
 
| [https://www.royandboucher.com/ Our Roy and Boucher Family]
 
| [https://www.royandboucher.com/ Our Roy and Boucher Family]
| [[User:KenRoy|Ken Roy]]
+
| style="white-space: nowrap;"|[[User:KenRoy|Ken Roy]]
 
| Using with [[Show PHP Error Log]] on test site
 
| Using with [[Show PHP Error Log]] on test site
| 12.2.0.3
+
| 14.0.0.18
| 12.2.0/12.3.0 beta
+
| {{Tv1404|float=left}}
| EN, FR
+
| style="white-space: nowrap;"|EN,FR
|-
+
 
 +
|- style="vertical-align:top;"
 
| [https://www.kmtrees.com/index.php Roots & Relatives Remembered]
 
| [https://www.kmtrees.com/index.php Roots & Relatives Remembered]
| [[User:tngrlkrz| Ron Krzmarzick]]
+
| style="white-space: nowrap;"|[[User:tngrlkrz|Ron Krzmarzick]]
 
| Public & Private
 
| Public & Private
| [https://www.kmtrees.com/rrmodcompare_report.php?power=basic&cachemethod=3&sb=filename&aformat=full&statushilite=1&b1=0 See Here]
+
| [https://www.kmtrees.com/mods-installed See Here]
| [https://www.kmtrees.com/rrmodcompare_report.php?power=basic&cachemethod=3&sb=filename&aformat=full&statushilite=1&b1=0 See Here]
+
| [https://www.kmtrees.com/mods-installed See Here]
| EN,DE,CS,ES
+
| EN,DE,CS
 +
 
 +
|- style="vertical-align:top;"
 +
| [https://www.gilbert-family-history.net Gilbert Family History]
 +
| style="white-space: nowrap;"|[[User:WarrenGilbert|Warren Gilbert]]
 +
| Public
 +
| 14.0.0.15
 +
| 14.0
 +
| style="white-space: nowrap;"|EN
 +
 
 +
|- style="vertical-align:top;"
 +
| style="white-space: nowrap;"|[http://genealogie.mkirsch.be Racines luxo-hennuyeres]
 +
| [[User:MichelKirsch|Michel Kirsch]]
 +
| Registration
 +
| 14.0.0.20
 +
| 14.0.4
 +
| style="white-space: nowrap;"|FR,EN,NL,DE,SP
 +
 
 +
|- style="vertical-align:top;"
 +
| [http://genealogy.oceanwharf.com Hooley Family Links]
 +
| style="white-space: nowrap;"|[[User:lastejas|Rick Hooley]]
 +
| Public/Private, only used on test server
 +
| [[User: lastejas|See Here]]
 +
| [[User: lastejas|See Here]]
 +
| style="white-space: nowrap;"|EN
 +
 
 +
|- style="vertical-align:top;"
 +
| [https://www.rgstrong-genes.com R G Strong Family Genealogy]
 +
| style="white-space: nowrap;"|[[User:Rgstrong|Russell Strong]]
 +
| Public/Private
 +
| 14.0.0.18
 +
| 14.0.4
 +
| style="white-space: nowrap;"|EN,DE,FR,NL
 +
 
 +
|- style="vertical-align:top;"
 +
| [https://www.josephoranholtz.com/ Joseph Oran Holtz Genealogy Pages]
 +
| style="white-space: nowrap;"|[[User:Stores|Jim Holt]]
 +
| Private
 +
| [[User:Stores|See Here]]
 +
| [[User:Stores|See Here]]
 +
| style="white-space: nowrap;"|EN
 +
 
 +
|- style="vertical-align:top;"
 +
|[https://www.pittsburghoneils.com Pittsburgh O'Neils]
 +
| style="white-space: nowrap;"|[[User:Spo9496|Sean O'Neil]]
 +
|
 +
|
 +
| 13.1.2
 +
| style="white-space: nowrap;"|EN
 +
 
 +
|- style="vertical-align:top;"
 +
|[https://cnl-gla.ca/nos-ancetres/lapierreamerique/ Les Lapierre d'Amérique]
 +
| style="white-space: nowrap;"|[[User:NLapierre|Normand Lapierre]]
 +
| Public/Private site
 +
| 14.0.0.16
 +
| 14.0
 +
| style="white-space: nowrap;"|FR,EN
 +
 
 +
|- style="vertical-align:top;"
 +
| [https://www.severijns.family/Severijns The Severijns / Timmer Familytree]
 +
| style="white-space: nowrap;"|[[User:Severijns|Rob Severijns]]
 +
| Public / Private
 +
| 14.0.0.18
 +
| 14.0.4
 +
| style="white-space: nowrap;"|NL,EN
 +
 
 +
|- style="vertical-align:top;"
 +
| [https://zausmerforest.com Zausmer Forest]
 +
| style="white-space: nowrap;"|[[User:Joyaa|Joyaa Antares]]
 +
| Private
 +
| 14​.0​.0​.18
 +
| 14.0.2
 +
| style="white-space: nowrap;"|EN,FR
 +
 
 +
|- style="vertical-align:top;"
 +
| [https://clan.chauvigne.info/ GénéaKat]
 +
| style="white-space: nowrap;"|[[User:Katryne|Katryne]]
 +
| Public & private
 +
| 14.0.0.18
 +
| 14.0.3
 +
| style="white-space: nowrap;"|FR,EN
 +
 
 +
|- style="vertical-align:top;"
 +
| [https://datschetzky.genealogenstammtisch.net Stammbaum der Familie Datschetzky]
 +
| style="white-space: nowrap;"|[[User:ChristianD|Christian Datschetzky]]
 +
| Public
 +
| 14.0.0.18
 +
| 14.0.3
 +
| style="white-space: nowrap;"|DE,EN
 +
 
 +
|- style="vertical-align:top;"
 +
| Development server
 +
| style="white-space: nowrap;"|[[User:Brett|Brett]]
 +
| Local host
 +
| 12.0.9, 14.0.0.20
 +
| 12 - 14
 +
| style="white-space: nowrap;"|EN
 
|}
 
|}
  
 +
[[Category:Mods for TNG v14]]
 +
[[Category:Mods for TNG v13]]
 
[[Category:Mods for TNG v12]]
 
[[Category:Mods for TNG v12]]
 +
 
[[Category:Administrator]]
 
[[Category:Administrator]]
 
[[Category:Maintenance]]
 
[[Category:Maintenance]]
 
[[Category:Troubleshooting]]
 
[[Category:Troubleshooting]]

Revision as of 23:38, 27 March 2024

Caution If this mod is installed or configured incorrectly it could make your site appear to crash. Don't panic. Edit your subroot.php and remove the last line pertaining to Prolog. Then in mod manager "Clean" the partially installed Prolog to remove the mod. See Below for detail Caution


Restricted Downloads of Prolog Mod are restricted to logged in users. If you do not have a user account on the TNG Wiki use the Request Account link to request a user account Restricted
Caution If you have trouble downloading with Google Chrome, Vivaldi, Brave or other Chromium based browser, try using a right-click and select Open in new Window, then F5, or use another browser such as Firefox


Caution


Prolog Mod
Summary Adds PHP Rotating Logs to TNG site
Validation
Mod Updated 11 Mar 2024
Download link
Download stats view statistics
Author(s) Rick Bisbee
Homepage Bisbee Family Connection
Mod Support Support for Prolog_Mod
Contact Developer As above
Latest Mod 14.0.0.20
Min TNG V 13.0
Max TNG V 14.0+
Files modified
Related Mods
Notes

Prolog (PHP Rotating Log) Introduction

Prolog6.png

Prolog is a utility for TNG testers, mod developers and anyone who wants to monitor their websites for PHP or user issues. It is an extension of the Show PHP Errors mod created by Roger Mitchell (decd) and provides nine selectable levels of error logging from Errors only to all errors, warnings, notices and deprecations. An important feature is that fatal errors displayed to the screen are generic and never reveal server information that a hacker may be looking for. The actual error can be found in the error log using the same timestamp shown on the screen.

Important Note for TNGv14 Users

Prolog was updated for TNGv14. In Previous versions, Prolog was initialized in subroot.php. Starting with TNGv14, Prolog v14 is initialized in begin.php. This change makes it very important that you completely uninstall any previous versions you may have tried in TNGv14, before installing Prolog v14. Neglecting to do this may leave unwanted code in TNG files that will result in TNG errors and even site failure.

Prolog v14 will fail with errors if any components of previous versions have not been uninstalled.

Error Log Location

Prolog will use the php.ini error_log setting to place its logs in the same location as PHP. If the php.ini is not set, or if it is inaccessible, prolog will use the TNG root-relative path you've set in the Mod Edit Options. If not set there, Prolog will create and default to a logs directory in your TNG root directory. While the last option works fine for offline test sites, for security reasons it is not recommended for a live site.

php.ini error_log directive

You must set the php.ini error_log directive with the full server path to the PHP error log for the site. Error logs can be located above the public_html for greater security (recommended.) In a local WAMP server you can edit it directly into the WAMPS php.ini file. On a shared hosting server you may be able to add a php.ini file to your root directory with just this directive to override the master php.ini. Some hosts allow a user.ini to serve the same purpose. See PHP error log for additional information on setting up error logs. The directive will look something like this (note the absolute server path):

error_log = /home/mysite/mylogs/php_error.log

OR FOR A WAMPS where wamps is your server folder name

error_log = D:/wamps/logs/php_error.log

Log Rotation

Both Prolog and the PHP system will log errors to the PHP file. At the close of each GMT day Prolog will archive the PHP log to a dated backup and start the PHP log over again. After the first day no single log will contain more that one day's errors. That keeps all of them relatively small and manageable.

Prolog modifies subroot.php to add logging to all TNG pages. Scripts that work independently of TNG will not be logged by this mod; however, those errors will be logged by the system in the same PHP log.

That said, if you do want to Prolog independent scripts, you can include prolog_conf.php at the top of a primary (as opposed to an included) script and as long as the mod remains installed, errors will be logged in the same way as TNG scripts to protect fatal errors from revealing server information.

if(file_exists('prolog_conf.php'))
   require_once 'prolog_conf.php';

How Prolog Works

Prolog has two main files:

  1. prolog_conf.php creates the log files and directs the logging
  2. prolog.php displays and manages rotating logs from the Admin screen.

Prolog adds a log access page link in the TNG Admin management area and features the following:

  • Rotating error logs are created daily to prevent them becoming too large to manage;
  • The php.ini error log collects all of today's errors;
  • Errors from previous days may be found in the dated archive logs;
  • Archived logs and error entries are timestamped using the timezone set in php.ini;
  • A clock is provided for admin perspective on timestamps;
  • Mod Edit Option to select error level for logging;
  • Mod Edit Option to set number of daily logs to keep before auto-deleting the oldest;
  • Logs selectable from drop down list (see screen shot);
  • Logged items are listed from most recent to oldest for admin convenience;
  • A Filter is provided to limit viewing of logged errors to only items of interest;
  • Language support included in mod folder for easier maintenance;
  • A fatal shutdown handler.

Shutdown Handler

The shutdown handler is for errors that might not otherwise be logged because the system shuts down before processing them. Some, but not all servers are able to log fatal errors before shutting down, so there may be double entries in the logs -- but there will always be at least one if it occurs.

Fatal errors are very useful for revealing deliberate attacks that often result in displaying server information that attackers hope to exploit. While Prolog records them for the administrator, all the attacker sees is this, for example, after attempting to access a forbidden script:

[20-02-24 18:34:02] Something went wrong. Please report the error or come back later.

The exact time can be used to compare with the logs, should a legitimate user choose to report it. Compare the actual log entry with the displayed message above:

[24-Feb-2020 18:34:02 America/Phoenix] PRO Fatal error: File access violation in fgw/fgw_setup.php on line 26 

This was probably a hack attempt. Both the displayed and logged errors were triggered by fgw_setup.php using the following code:

// ONLY ADMINISTRATOR GETS ACCESS TO THE SETUP PAGE
if( empty( $superuser ) ) {
	trigger_error( $admtext['wse_access'], E_USER_ERROR );
   die();
}

Language Support

The mod support folder contains support for Czech, English, French, German, Spanish and Swedish. You can modify the files right in the support folder to change the translations. You can add new folders with other languages if you like. If you make changes or additions I will be happy to add them to the distribution package for others to use as well. Just email them to me or use the mod support link on the Prolog_Mod TNGWiki page.

Using the PHP and System Logs

In your php.ini set the logfile, for example:

error_log = D:/wampsdir/mylogs/php_error.php

Prolog will detect the file and use it to log errors.

If you want to view Apache system logs in your WAMPS, in your WAMPS httpd.conf file set up a VirtualHost something like this.

<VirtualHost *:80>
	ErrorDocument 404 /errdocs/_err404.php
	ErrorDocument 403 /errdocs/_err403.php
	ErrorLog D:/wampsdir/mylogs/server_error.log
</VirtualHost>

using the same directory as the php.ini error log.

Prolog will list and display that one too. It must be managed to prevent it from becoming too large and crashing the system with out-of-memory errors.

See PHP error log for more complete information on setting up error logs in different environments

More About Error Files and Log Dates

Archived error files and error items use the date set in the date.timezone directive in the php.ini file. If not set, GMT will be used.

On a live site with shared hosting, you may be able to set the timezone by creating a php.ini file in your document root and entering directives, for example:

date.timezone = America/Phoenix
error_log = /home/bisbeefa/mylogs/php_error.log

It may take 20-30 minutes or more for the changes to take effect on shared hosting, so be patient.

You may also be able to add the following to your site's main .htaccess file for both error_log and date.timezone:

<IfModule php7_module>
   php_value date.timezone "America/Phoenix"
   php_value error_log "/home/bisbeefa/mylogs/php_error.log"
</IfModule>

If you are still using PHP 5, change the first line above to reflect that.

My web host (Bluehost) also uses the following:

<IfModule lsapi_module>
   php_value date.timezone "America/Phoenix"
   php_value error_log "/home/bisbeefa/mylogs/php_error.log"
</IfModule>

lsapi is a drop-in module to speed up serving PHP pages.

TNG Version Compatibility

Prolog is compatible with TNG version 12.0 and up.

Mod Revision History

Version Date Updates


v14.0.0.20 12 Mar 2024
  • Fixes clash between session filters in Mod Manager and Prolog.
v14.0.0.19 11 Mar 2024
  • User-selected log files and filters are now persistent during the same session. If you navigate away from the page and later return, the same log file and filter selections will apply. You must manually re-select another log file and clear the filter to change them.
v14.0.0.18 31 Jan 2023
  • Expands choices for error reporting level
v14.0.0.17 28 Jan 2023
  • Fixes warnings after log file is cleared
v14.0.0.16 1 Jan 2023
  • Fixes warnings
  • Minor syntactic updates
v14.0.0.15 17 Dec 2022
  • Fixes filemtime problem in Windows
v14.0.0.14 14 Dec 2022
  • Not released
v14.0.0.13 10 Sep 2022
  • Updated to work with TNGv14
  • Inserts Prolog.conf.php into begin.php vice subroot.php to prevent conflict with the GEDCOM upload progress bar
  • Checks for correct version of TNG before allowing installation
  • Checks for uninstalled components of previous version of Prolog
  • New mod editor option to set the timezone for the log entries
  • Updated mod option to display errors to the screen: set to 0, only the public message displays; set to 1, only the raw PHP error is displayed (for developers)
  • Moves prolog_conf.php file to the extensions directory
v13.0.0.9 21 Sep 2020
  • Updated to work with TNGv13 admin which no longer uses iframes.
  • Removes external file version number
  • Adds tooltip to Admin link showing version number
v12.0.0.9 21 Sep 2020
  • Removes external file version number
  • Adds tooltip to Admin link showing version number
v12.0.0.8 10 Aug 2020
  • If no error log is defined in php.ini or elsewhere, Prolog creates a logs directory specified in the Prolog Edit Options.
v12.0.0.7a 13 Mar 2020
  • Fixed bug that prevented parameter updates
v12.0.0.7 12 Mar 2020
  • Now usese php.ini date.timezone vice GMT for timestamping
  • Adds version number to copied files to avoid confusion when upgrading
v12.0.0.6 9 Mar 2020
  • More reliable trigger to archive PHP file to daily and start again
  • Fixes bug that sends fatal error to yesterday's daily
  • Fixes bug that kept out-of-date files from being deleted
v12.0.0.5 5 Mar 2020
  • Tested successfully with TNGv12.0 and up (version number adjustment.)
  • Option to specify a log directory is removed.
  • Works with error log defined in php.ini
  • Both Prolog and PHP errors go to the php.ini error log
  • At the end of each GMT day the PHP error log is sent to a dated backup log and the PHP error log is started anew. Keeps all of the day's errors in one place.
v12.2.0.4 3 Mar 2020
  • Fixes wrong support package bug
  • Adds viewing and manipulation of all logs (PHP and system) in Prolog directory
v12.2.0.3 1 Mar 2020
  • Adds link to TNGWiki article
  • Minor Update to language files
v12.2.0.2 24 Feb 2020
  • Initial release

Screen Shots

PC Based WAMPS Test Site

Prolog3.jpg

PHP Prolog link in the Admin page header menu. Note the daily log selected from the drop down list, and that the site's PHP version and current error reporting level are displayed in the prolog header bar. In the above example, All errors, notices, warnings and deprecations are being logged. A developer would want to show all errors and correct those thrown by their own mods or scripts, which can be isolated from any others by using the filter.

The filter searches each logged entry for a matching sub-string and displays the whole line if found. You could filter on a file name to display errors coming from just that script, or on 'Warning' to only see warnings, or 'Undefined: index' to only display those kinds of notices. After entering the filter string you can hit enter or click on the circular arrows to activate it.

Prolog Edit Options Screen

Prolog4.jpg

Installation

Prolog installs as a normal TNG mod. Download and unzip the contents -- one file and one folder. Place the prolog.cfg file and the support folder into your TNG site's mods directory. Do not remove folders and files from the support folder -- just leave them there. Navigate to your Mod Manager, find and open the mod listing and click on Install.

Upgrade

When installing an updated version of Prolog, it is important that you first use Mod Manager to completely remove any earlier version and preferably delete it.

Configuration

You must have a site-wide PHP error log set in your php.ini file, either by directly editing the file in a local WAMPS, or in shared hosting, indirectly by adding a php.ini (or user.ini) file to your TNG root directory with the error_log directive, for example:

error_log = /home/mysite/mylogs/php_error.log

The error log file should use the extensions .log.

Setting the Error Level for Logging

Error Level settings are designated by adding the index numbers for the items you want reported.

0 == ERRORS
1 == WARNINGS
2 == NOTICES
4 == DEPRECATED
9 == ALL

E_ERROR is always reported. Errors alone are index 0.

To specify E_ERROR and an additional type, enter the additional type index number into the parameter box. To specify a combination of error reporting, just add the index numbers and enter the total for the parameter.

A complete map:
0 == errors
1 == errors and warnings (1)
2 == errors and notices (2)
3 == errors and warnings and notices (1+2)
4 == errors and deprecated (4)
5 == errors and warnings and deprecated (1+4)
6 == errors and notices and deprecate (2+4)
7 == errors and warnings and notices and deprecated (1+2+4)
9 == E_ALL

  • Error level 5 should be about right for a live site. It will log errors, warnings and PHP function deprecations. That latter means the scripts will stop working with new PHP upgrades, so we should know about them. Error level 1 would just be errors and warnings.
  • Error level 9 logs everything -- errors, notices, warnings, deprecations and everything else. Because TNG emotes large numbers of notices right now, error level 3 should only be used while actually testing a script and reduced back to 1 or 5 when not testing. Even a daily log can get very large at error level 9.

Warning

If installed incorrectly this mod can cause the site to appear to crash. Don't panic. Edit subroot.php and remove the last line pertaining to Prolog. The site will come good again. Then go to mod manager and Clean up the partially installed Prolog mod. Prolog modifies subroot.php by including prolog_conf.php with parameters that are set in the mod's Edit Options. If the mod's Edit Options are incorrectly set or if the mod is partially installed for some reason, subroot.php may fail and so will all pages that include it.

Mod Manager Bug

There was a bug in Mod Manager up to TNGv12.3 beta which was corrected during testing. If a parameter expects a numeric value and you update it with and empty field, it renders a parameter variable such as $mycount

 $mycount = ;

That will cause a fatal error and the script containing the parameter will fail. After the fix to mod manager it will render it as

$mycound = 0;

.

Sites using this mod

If you download and install this mod, please add your TNG site to the table below:

URL User Note Mod-Version TNG-Version User-language
A Bisbee Family History Rick Bisbee Mod Developer. A must-have for mod developers 12.0.0.7 12.1 EN
Stegemüller Family History Hanne B. Stegemüller Public site 14.0.0.16 14.0 EN,DE,DA
Our Roy and Boucher Family Ken Roy Using with Show PHP Error Log on test site 14.0.0.18
TNG 14.0.4
EN,FR
Roots & Relatives Remembered Ron Krzmarzick Public & Private See Here See Here EN,DE,CS
Gilbert Family History Warren Gilbert Public 14.0.0.15 14.0 EN
Racines luxo-hennuyeres Michel Kirsch Registration 14.0.0.20 14.0.4 FR,EN,NL,DE,SP
Hooley Family Links Rick Hooley Public/Private, only used on test server See Here See Here EN
R G Strong Family Genealogy Russell Strong Public/Private 14.0.0.18 14.0.4 EN,DE,FR,NL
Joseph Oran Holtz Genealogy Pages Jim Holt Private See Here See Here EN
Pittsburgh O'Neils Sean O'Neil 13.1.2 EN
Les Lapierre d'Amérique Normand Lapierre Public/Private site 14.0.0.16 14.0 FR,EN
The Severijns / Timmer Familytree Rob Severijns Public / Private 14.0.0.18 14.0.4 NL,EN
Zausmer Forest Joyaa Antares Private 14​.0​.0​.18 14.0.2 EN,FR
GénéaKat Katryne Public & private 14.0.0.18 14.0.3 FR,EN
Stammbaum der Familie Datschetzky Christian Datschetzky Public 14.0.0.18 14.0.3 DE,EN
Development server Brett Local host 12.0.9, 14.0.0.20 12 - 14 EN