Best place for own script? (Userlog)

Marcin5 years ago

Because there seems to be no buit in function, i try to log the logged in users with an own script.
In Debug Version i get this to work (not very nice and slow)
Is there a place i can add an include line?
Or maybe only a sql statement insert which gets called after login?

At all fathers: Have a nice day. Going for beer now..

Marcin5 years ago

Forget to wrote:
What i tried is putting:
<entry key='database.loginUser'> INSERT INTO tc_loguser (ben, count) VALUES ('joe', '1') </entry>
into default.xml
But that only fires a windows which tells me
Can not issue data manipulation statements with executeQuery(). - SQLException (... < QueryBuilder:424 < *:308 < DataManager:319 < PermissionsManager:439 < ...)

But this seems to be the best way to get additional data in bb.
But how?

Anton Tananaev5 years ago

Have you changed the code as well?

Marcin5 years ago

No. Nothing
Hoped just the sql would work...

Anton Tananaev5 years ago

What version of Traccar are you using?

Marcin5 years ago

Hi Anton
I use 4.8

Anton Tananaev5 years ago

You have to modify the code if you want to do an insert statement. Alternative is to use a trigger in your database.

Marcin5 years ago

Trigger in Database can only be used if something gets inserted. And there happens nothing.

Even i could make a cronjob ala
if grep -q 'user' /opt/traccar/log/tracker-server.log; then php /var/www/phpjob/insert.php; sed -i s/user/inserted/gp /opt/traccar/log/tracker-server.log;

But thats not nice enough.
When modifying code i have to use debug version for all, thats not what i like.

So i have to test a little on my own in spare time

Marcin5 years ago

It took until now as i learned: "there is no php working in /opt/traccar/"

Before i tried different things.
-Using php code within index.PHP >> nothing
-calling a insert.php within /simple >> just sourcetext
-calling a insert.php within /var/www/phpjob/ >> works if i call insert.php directly, but not from /opt/traccar/web/simple/ index.PHP
(The PHP in Capitals is just for telling that it was renamed from html to php)

How can i get php work in /opt/traccar/web/simple/
have added

<Directory /opt/traccar/web/simple/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

to apache2.conf and restarted apache2 but still the same

Dan Dyse5 years ago

It does on my server ... maybe this helps:
https://www.tecmint.com/run-php-codes-from-linux-commandline/

Marcin5 years ago

Hm? I cant see the difference between running it in var/www or in commandline.