==README for Last Visit add-on for miniBB==
Release date: June 18, 2016.
Latest update: December 10, 2025.
miniBB version: 3.3 and higher
Author: Paul Puzyrev (minibb.com).


"Last Visit" is the free add-on for miniBB, which fixes the DATE of the most recent visit of a registered member. This value is recorded to the database only once a day disregarding how much time a member spent on the forum. Then it's also displayed on the User-Info page and could be used in some other add-ons, like the Search option in the Premoderation add-on.


==INSTALLATION==

Please follow this guide carefully and don't just copy the files included with this package - installation will require some manual operations! Use miniBB Compiler if you're doubt how to paste this or that.


***** Execute the SQL commands code, located in the file `last_visit.sql` of this package. You could use phpMyAdmin or whatever mySQL management tool. This code adds a new field to the users table, and assigns default values to member registration dates - this is for the case if you have some existing members already.


***** Under setup_options.php, you should properly update $dbUserSheme array, adding the aforementioned field at the end of the array and providing the proper 'XX' key (use "Determine Fields" script for that). For example, it should look like this:

$dbUserSheme=array(
'username'=>array(1,'username','login'),
'user_password'=>array(3,'user_password','passwd'),

[...here follows list of other fields defined...]

'user_customlastvisit'=>array(XX, 'user_customlastvisit', ''),
);

where XX stands for the numerical index of the new fields. It could be different for each different case, and is related to the other 'user_custom' fields added. It's very important to add the proper value for this index, be careful at that.

***** Modify `bb_specials.php` file of your forum, locate the closing ?> tag at the bottom of it, and above it, paste the code from `bb_specials.code.txt` file. `$lastVisitPeriods` array defines parts of the day associated with certain definitions. DON'T CHANGE THE DEFAULT DEFINITIONS (keys like 'night', 'morning' etc. should all stay as provided), but depending on your preference, you could change time periods and also add a new definition, but be careful at that: 1) define all periods carefully, so they fully cover the 24-hours period and are defined in HH:MM format; keep in mind the times are inclusive; 2) new definition should be translated with the relative key in the language pack - read below how.

***** 

***** Modify `bb_cookie.php` file of your forum carefully, copying and adding the following parts of the code contained in the `bb_cookie.code.txt` of this package (DO NOT STRAIGHT COPY THE CODES OF THIS FILE!):

- both "db_simpleSelect" function blocks related to the admin data and member data selection, should contain the new field added, resp. '$GLOBALS['dbUserSheme']['user_customlastvisit'][1]'. It should be added to the end of fields chain for each request.

- in both data selections you should add related codes, which will store the values of the last visit field, these codes are located between `/* Last Visit */` and `/* --Last Visit */` comments.


***** Modify your language pack(s); default is located under `/lang/eng.php` -> open it for editing, locate the closing ?> tag at the bottom of it, and above it, or in any other notable place, paste (and optionally translate) the code from `/lang/eng.code.txt` of this package (or related language code, if available). NOTE that instead of 'XX-6' you should supply the proper language index for this custom field. This index is calculated regarding 'user_custom*' fields from $dbUserSheme option; if your forums do not have Archives installed, and the last field before 'user_custom1' is 'num_posts', then start from 12 until the 'user_customlastvisit' is reached; if there is 'num_live_posts' before, start with 14. If you add 'user_customlastvisit' straight after 'user_custom3', the language index will be 15.

Another variable in this package is `$lastVisitPeriods_defs` and it's tied up with the `$lastVisitPeriods` setting from `bb_specials.php` described above. Here, each key from `$lastVisitPeriods` is translated, and on the page it will be concatenated with the last visit date or meaning. For example, if would be 'Today, noon' or 'Yesterday, in the morning' or 'December 7, 2025 at night' - all depends on your dates configuration. In various languages the 'comma' needed as the separated between these meanings, in others not. Add anything else in this translation up to your knowledge.


***** Edit your forums' `bb_plugins.php` file and CAREFULLY paste the codes located in 

- `bb_plugins.code_1.txt` of this package -- it should appear preferraby ad the very top of `bb_plugins.php`, before actually any other code is executed, right after the '<?php' tag.

- `bb_plugins.code_2.txt` of this package - it should be pasted in any other place, preferrably closer to the end of `bb_plugins.php` before the closing '?>' tag.


***** Edit your forums' `bb_plugins2.php` file and paste the code located in `bb_plugins2.code.txt`. It could be pasted at any place of the file, but preferrably somewhere at the beginning, right after the opening '<?php' tag.


==FINALLY==
Enjoy this add-on! Post whateve bugs found and suggestions for new options on our forums:
https://www.minibb.com/forums/plugins-11/
