Audit Log

Got something cool to share with AppGini users? Feel free to post it here!
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Audit Log

Post by onoehring » 2021-01-21 12:56

Hi,

I found another little bug (and a place where I wished for a little more precise information):
l25.png
l25.png (13.36 KiB) Viewed 15483 times


Thanks already landinialejandro. GREAT work!

For everyone else:
Once you installed using the plugin-way, you do not need to worry, that running the plugin to install again (i.e. you created new tables in your application), the plugin will not add again to tables that already have the extension.
Also: The extension will be at the beginning of the functions. I have the case, that I am doing some changes to the data in the before/after-update functions. Thus this may not be reflected in the auditor. For these cases you need to move the auditor call to a position n the specific functino after you are done with data manjpulation. I will add this to the docs.

Olaf

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Audit Log

Post by onoehring » 2021-01-21 13:02

Hi

I notice, after adding auditor via the plugin, the admin area is "visually broken" - I suppose it's because the JS is included too early (see images):
l26a.png
l26a.png (17.75 KiB) Viewed 15482 times
l26b.png
l26b.png (7.15 KiB) Viewed 15482 times
Olaf

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Audit Log

Post by onoehring » 2021-01-21 13:44

Hi landinialejandro,

I have one more thing:
When I need the auditor code in the end of a function it currently seems impossible to prevent the plugin, when running a second time to insert the code again.
I thought I comment it out:

Code: Select all

/* Inserted by Audit Log for AppGini on 2021-01-21 01:24:20 */
// table_after_change($_SESSION ['dbase'], $_SESSION['tablenam'],
//     $memberInfo['username'], $memberInfo['IP'], $data['selectedID'],
//     $_SESSION['tableID'], 'INSERTION');
/* End of Audit Log for AppGini code */
This did not work. Running the script again, I got this:

Code: Select all

/* Inserted by Audit Log for AppGini on 2021-01-21 01:28:10 */
table_after_change($_SESSION ['dbase'], $_SESSION['tablenam'],
	$memberInfo['username'], $memberInfo['IP'], $data['selectedID'],
	$_SESSION['tableID'], 'INSERTION');
/* End of Audit Log for AppGini code */
/* Inserted by Audit Log for AppGini on 2021-01-21 01:24:20 */
// table_after_change($_SESSION ['dbase'], $_SESSION['tablenam'],
//     $memberInfo['username'], $memberInfo['IP'], $data['selectedID'],
//     $_SESSION['tableID'], 'INSERTION');
/* End of Audit Log for AppGini code */
It would be great if you could change the file 03_generate.php, where the check for existence is performed (around line 545):

Code: Select all

			/* Checks $code is not already in there */
				if(strpos($old_function_code, $code) !== false) return $this->error('add_to_hook', 'Code already exists');
To check for your insertion comment itself. This way we could run the script again and again when the application has been extended without the need to go through the files and to make sure the additions have not been placed in an unwanted position.
When you check for the insertion comment only, the developer could simply comment the next line(s) out - and your (I am repeating myself) really great plugin script would ignore those functions.

Olaf

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Audit Log

Post by onoehring » 2021-01-21 15:20

Hi,

I updated the documentation to reflect some experiences I made while using the plugin for installation.
The plugin is really good and makes installation a piece of cake. If you have bought any plugin I highly recommend using the plugin for installation!

Download v1.74
https://dl.olaf-noehring.de/?t=a9f118e0 ... 9c9bb466a7

Olaf

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-01-21 17:23

onoehring wrote:
2021-01-21 12:31
Hi,

script seems to work fine.
I was able to use the script and add the auditor to all tables.
I encountered some strange thing and some bug (?not sure!).

Strange: The "false" circled on the right should probably say something like "ok"
Error: Even when I checked the checkbox the files were changed.
Am I correct or just writing crap?

l24.png


Olaf
Hello Olaf, thanks for your answer, the script is correct is added to all the hooks of all the tables, although it could be identified if there are any that we did not want to audit, but it would be for a second version of this installer.
In short I verify what is the problem with the button, it is correct it only indicates that everything is fine.
The option of not writing the hook is not working yet, although it seems to me that enabling would be of great help since a lot depends on what is written in the hook. but I see it without problem.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-01-21 17:32

onoehring wrote:
2021-01-21 09:36
Hi landinialejandro,

inspecting the code of the plugin, it seems, that the plugin does the installation only - but no "uninstall" - is that correct?
As other plugins allow uninstall, I am wondering and think this is worth knowing.

Olaf
right, doesn't have uninstall option. but can i try to do it.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-01-21 21:31

onoehring wrote:
2021-01-21 12:31
Strange: The "false" circled on the right should probably say something like "ok"
Can you check your console, for this error please, this change made with a jquery function and is part of AppGini's code.

I am already correcting the option to not write in the hooks files

thanks
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-01-21 22:04

onoehring wrote:
2021-01-21 13:44
Hi landinialejandro,

I have one more thing:
When I need the auditor code in the end of a function it currently seems impossible to prevent the plugin, when running a second time to insert the code again.
I thought I comment it out:

Code: Select all

/* Inserted by Audit Log for AppGini on 2021-01-21 01:24:20 */
// table_after_change($_SESSION ['dbase'], $_SESSION['tablenam'],
//     $memberInfo['username'], $memberInfo['IP'], $data['selectedID'],
//     $_SESSION['tableID'], 'INSERTION');
/* End of Audit Log for AppGini code */
This did not work. Running the script again, I got this:

Code: Select all

/* Inserted by Audit Log for AppGini on 2021-01-21 01:28:10 */
table_after_change($_SESSION ['dbase'], $_SESSION['tablenam'],
	$memberInfo['username'], $memberInfo['IP'], $data['selectedID'],
	$_SESSION['tableID'], 'INSERTION');
/* End of Audit Log for AppGini code */
/* Inserted by Audit Log for AppGini on 2021-01-21 01:24:20 */
// table_after_change($_SESSION ['dbase'], $_SESSION['tablenam'],
//     $memberInfo['username'], $memberInfo['IP'], $data['selectedID'],
//     $_SESSION['tableID'], 'INSERTION');
/* End of Audit Log for AppGini code */
It would be great if you could change the file 03_generate.php, where the check for existence is performed (around line 545):

Code: Select all

			/* Checks $code is not already in there */
				if(strpos($old_function_code, $code) !== false) return $this->error('add_to_hook', 'Code already exists');
To check for your insertion comment itself. This way we could run the script again and again when the application has been extended without the need to go through the files and to make sure the additions have not been placed in an unwanted position.
When you check for the insertion comment only, the developer could simply comment the next line(s) out - and your (I am repeating myself) really great plugin script would ignore those functions.

Olaf
I have done the code insertion process several times and it is not duplicated.
but ... the slightest change in the inserted code is no longer the same and there it does insert it again, the comparison made by string, one more space anywhere and it is no longer the same.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Audit Log

Post by onoehring » 2021-01-22 08:05

Hi
onoehring wrote: ↑2021-01-21 13:31
Strange: The "false" circled on the right should probably say something like "ok"
Can you check your console, for this error please, this change made with a jquery function and is part of AppGini's code.
Nothing shows up in the console.

but ... the slightest change in the inserted code is no longer the same
Yes, I understand. I agree that this behavior has it's advantages, and maybe it's the easier thing to leave it like this so that anyone with knowledge of php and in the need for a different position (as I am in some cases) has to move the code, comment it out - and, if there are new tables either add the audit by hand or comment it out again.
Instead, maybe there could be some keyword added after your

Code: Select all

/* Inserted by Audit Log for AppGini on 2021-01-21 01:24:20 */
Maybe

Code: Select all

/* Inserted by Audit Log for AppGini on 2021-01-21 01:24:20 */
// ignore
to prevent the script from inserting again. I suppose the script looks for the correct function, then looks if it finds your inserted comment, checks the code. In this case my suggestion could work. A problem would arise, if the audit code that needs to be inserted changes.
For an uninstall procedure maybe check Jan's Inline-DV plugin (if you have that): This has the option for uninstall ( https://appgini.bizzworxx.de/products/i ... ew-plugin/ )

Olaf

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-01-22 22:04

hi!

I put the call function on a single line and it no longer duplicates it, no matter where the hook is located.

example:

Code: Select all

	function contacto_init(&$options, $memberInfo, &$args) {



		$options->ColCaption = ['Name', 'User', 'Rango', 'Prox. Fecha Pago', ];




		/* Inserted by Audit Log for AppGini on 2021-01-22 04:58:38 */
		 
		
		
		$_SESSION ['tablenam'] = $options->TableName; $_SESSION ['tableID'] = $options->PrimaryKey; $tableID = $_SESSION ['tableID'];
		
		
		/* End of Audit Log for AppGini code */


		

		return TRUE;
	}
this code does not generate a duplicate
You can even remove the comments and move it to any position within the hook, you just don't have to add any space in the middle.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-01-22 22:12

As a suggestion, we should ask AppGini for the possibility of adding a call to a hook in the admin area, such as header-extras.php, this would allow flexible customization of this area.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-01-22 22:16

Hi Olaf, to simplify the code on the hook side, I suggest sending the entire array, and then unstructuring it on the function side.
for example the current call to the function is:

Code: Select all

table_after_change ($ _ SESSION ['dbase'], $ _SESSION ['tablenam'],
              $ memberInfo ['username'], $ memberInfo ['IP'], $ data ['selectedID'],
              $ _SESSION ['tableID'], 'UPDATE');
would be:

Code: Select all

table_after_change ($ _ SESSION, $ memberInfo, $ data, 'UPDATE');
on the side of the function would be:

Code: Select all

function table_after_change ($ session, $ memberInfo, $ data, $ type) {

['dbase' => $ db_aname, 'tablenam' => $ TableName, 'tableID' => $ tableID] = $ session;
['username' => $ username, 'IP' => $ userIP] = $ memberInfo;
['selectedID' => $ currentID] = $ data;
...
}
this way your code is not modified, and on the hook side that is best in sight and simpler to maintain.

what do you think?
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-01-22 22:19

onoehring wrote:
2021-01-21 13:02
Hi

I notice, after adding auditor via the plugin, the admin area is "visually broken" - I suppose it's because the JS is included too early (see images):

l26a.png

l26b.png

Olaf
yes, I'm looking at how to solve this, I don't like having to modify code that then renders Appgini again ...

but I think there is no other way ...

Unless appgini in its next update makes a call to a hooks to be able to insert code into the admin area.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Audit Log

Post by onoehring » 2021-01-23 09:03

Hi landinialejandro,

thank you for the adjustment (did not test yet):
I put the call function on a single line and it no longer duplicates it, no matter where the hook is located.
I agree with your suggestion:
to simplify the code on the hook side, I suggest sending the entire array, and then unstructuring it on the function side.
I will update the code and test. I will also take a look if there is old code left that is not actually needed anymore and remove this as well.
I will let you know, when it's done and the plugin can be adjusted (please :-) )

Olaf

User avatar
fbrano
Veteran Member
Posts: 70
Joined: 2018-03-19 10:39
Location: Slovakia
Contact:

Re: Audit Log

Post by fbrano » 2021-02-09 14:20

Hi Olaf,
what does mean this warning after opening plugin?
Attachments
Error in Plugin Audit Log.JPG
Error in Plugin Audit Log.JPG (85.06 KiB) Viewed 15272 times
ver 23.15 1484

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-02-09 15:59

fbrano wrote:
2021-02-09 14:20
Hi Olaf,
what does mean this warning after opening plugin?
hi! need PHP 7 or after.
the dirname function has second parameter added from version 7 of PHP.

regards
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
fbrano
Veteran Member
Posts: 70
Joined: 2018-03-19 10:39
Location: Slovakia
Contact:

Re: Audit Log

Post by fbrano » 2021-02-09 18:38

Server running on php 7.3 or 7.4, but what about syntax, is'nt it wrong?
ver 23.15 1484

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Audit Log

Post by onoehring » 2021-02-10 08:36

Hi,

did you really run phpinfo() and check the php version? landinialejandro's suggestion sounds very reasonable. There is nothing in the line where the error occurs which would make me think it should be something else... and the error tells us dirname is expecting ONE parameter ... which is wrong for PHP 7.0.0 ( https://www.php.net/manual/en/function.dirname.php )

Code: Select all

$folderProject = dirname(__FILE__, 2) . '/hooks'; ?>
Olaf

User avatar
fbrano
Veteran Member
Posts: 70
Joined: 2018-03-19 10:39
Location: Slovakia
Contact:

Re: Audit Log

Post by fbrano » 2021-02-17 06:24

c:\>php -v
PHP 7.4.5 (cli) (built: Apr 14 2020 16:17:19) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
ver 23.15 1484

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Audit Log

Post by landinialejandro » 2021-02-17 12:46

fbrano wrote:
2021-02-17 06:24
c:\>php -v
PHP 7.4.5 (cli) (built: Apr 14 2020 16:17:19) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
hello! I'm not an expert on PHP configuration options, the documentation on the use of the function is clear, as well as the warning message.
If the application can continue without problems, the explanation to the warning may be that there is some configuration that forces to report on the legacy of version 5, but this is only a guess.
the question is: does the installation process follow?
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Update: Audit Log v 1.93/1.94

Post by onoehring » 2021-03-08 08:08

Hi,

it's time! For what? For a new version of the AuditLog.
landinialejandro and I teamed up to make both better: The installation with his marvelous plugin and the AuditLog.

You can download the plugin for easy installation with AuditLog 1.93 here:
https://github.com/myappgini/sbm_audit_log
Currently it also contains the 1.93 version of the AuditLog - so if you download the plugin, you get the latest version of the AuditLog code.

The AuditLog improved in several ways:
-------------------------------------------------
a) Playing with some data I noticed, that data in the AuditLog table might be a danger to your database!
It's strongly recommended that you update to the latest version.

b) The plugin creates now not only a link in the admin area, but a new menu. In this menu you find the original (but improved) Audit Log table. Now you can set the number of records you want to see at once. And the new feature: The link to the timeline.

c) New feature: Timeline. From the new menu you can also choose Timeline. Doing so will present you a wizard that will lead though the process: Select table, select record (using primary), confirm that your selection is correct (you are presented with the current state of the record). In the last step you choose the timeframe you want to see. The wizard automatically grab the first and latest timestamp to help you.
Set some options (if you like) and you will see in a nice table the state of your record at each change.
(Of course only logged changes can be displayed.)
timeline_v1.png
timeline_v1.png (36.59 KiB) Viewed 15057 times
Installation
The plugin will lead you through installation.

If (and only if!) you have installed AuditLog already, you will need to change the files probably by hand (!) this time, as we changed the function calls that are needed and inserted by the plugin. Sorry about that, but we both thought it's a much better way to implement the AuditLog extension.
You will see something like this - just follow the instructions:
Screenshot_20210216_163427.png
Screenshot_20210216_163427.png (47.14 KiB) Viewed 15057 times
Don't worry about the manual labor - you can do it. Search the files for

Code: Select all

/* End of Audit Log for AppGini code */
and just start. I did for 475 places in one application. Sorry again.

Again: Due to security concerns I highly recommend updating!

I have updated the docs with how one can skip certain tables when using the plugin (again) and added a screenshot of the installation notices in 1.94, but there are no code changes.
You can download AuditLog (not plugin) version 1.94 here:
https://dl.olaf-noehring.de/?t=fbd89f6c ... d680af61ad

Olaf

pkumar
Posts: 4
Joined: 2021-05-01 22:52

Re: Audit Log

Post by pkumar » 2021-05-15 15:48

Sir

can you give a step by step procedure to update my AG

i am not able to install the plugin.

Regards

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Audit Log

Post by onoehring » 2021-05-16 06:56

Hi,

if you have bought any plugin at this time you SHOULD USE the plugin installation of AuditLog. I can not say it too often: Manual installation is NOT recommended (anymore).
So, if you have not bought any other plugin, you should consider buying one first and the using the AuditLog Plugin Installation.

Your post is unclear and suggests, you already have installed an older version of the AuditLog.
If so:
You need to remove all calls to the audit log functions that you have installed by hand before and replace those with the new calls.
You will need to do this for all tables.
Please refer to this thread what to do or to an old documentation - I do not have such an old version anymore.
You can of course to the "search & replace" in one step. Use NotePad++ as suggested in the docs and search and replace IN FILES - the old lines to the new lines.


If you have not installed AuditLog yet - just follow the documentation.

If you have not installed AuditLog yet but have bought another plugin: Why can't you install the plugin ... reasons? Problems? Please be more specific about the problem(s).

Olaf

sacgtdev
Veteran Member
Posts: 75
Joined: 2020-06-10 11:14

Re: Audit Log

Post by sacgtdev » 2021-06-14 00:50

Any updates on Audit log in the near future which compatible to the most recent Appgini release 5.96 or 5.97 ?

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Audit Log

Post by onoehring » 2021-06-14 05:59

Hi,

well, is there a problem when using 5.96 or 5.97?
Olaf

Post Reply