×

Error

Please login first

CB Query

13 years 4 months ago #151086 by laptoproadie
CB Query was created by laptoproadie
I'm trying to do login auditing, by just inserting a record into a table whenever anyone logs in.

INSERT INTO jos_login_audit (user_id, ip,timestamp)
VALUES ([cb:userdata field="id" /] , 'fix me',NOW())

If I have the above query, what do I put for the IP so that it uses the actual current value for it?

Is there a table with these or somewhere I can use for future reference? I can find no documentation that lists all the possible substitutions.

Thanks!

Please Log in to join the conversation.

13 years 4 months ago #151179 by krileon
Replied by krileon on topic Re: CB Query
CB does not have an IP address substitution, but it does store their IP address into the database. So you could use the below to achieve what you're wanting (this assumes the user is present in session and the IP is accurate).
INSERT INTO `jos_login_audit` ( `user_id`, `ip`, `timestamp` ) VALUES ( [user_id], ( SELECT `client_ip` FROM `jos_comprofiler_sessions` WHERE `userid` = [user_id] ), NOW() )


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

13 years 4 months ago - 13 years 4 months ago #151191 by laptoproadie
Replied by laptoproadie on topic Re: CB Query
Thanks Krileon.

Now I'm not sure how I activate CB's session functionality. It doesn't seem to be populating the jos_comprofiler_sessions table with any data at all. I'm definitely using the CB login module.

What else should I look for to turn this on? It's definitely populating the regular Joomla session table, but I'd really need that IP address logging so I need to go the route suggested.

Thanks.

Also, If there is a way to troubleshoot a CB query please let me know how. Sometimes the query works and sometimes it doesn't do anything at all. When it dosn't work I assume it's an error with the query, but I never know the specific error it's encountering. I'm just curious if there is a better way to diagnose query issues. Right now I'm trying the query you suggested, Krileon, but it's not doing anything at all right now. Maybe it's because jos_comprofiler_sessions isn't being populated, I don't know.

Please Log in to join the conversation.

13 years 4 months ago #151214 by krileon
Replied by krileon on topic Re: CB Query
It entirely depends on where you are executing the query as to whether CBs sessions table will be populated. Where is this being executed and by what? There's really no other way to get a users IP address aside from what has already been advise. As for debugging you can debug having Debug Mode enabled and Error Reporting maximum within Joomla global configuration.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

13 years 4 months ago #151217 by laptoproadie
Replied by laptoproadie on topic Re: CB Query
Krileon,

The query is set to execute immediately after the onAfterLogin event is fired. This is what led me to believe the sessions would be populated by the time this event happened, because the user would have just logged in. But I'm getting no data at all in my jos_comprofiler_session table, so I think the sessions aren't saving at all.

Please advise in how to get it to work properly. Thanks!

Please Log in to join the conversation.

13 years 4 months ago #151276 by krileon
Replied by krileon on topic Re: CB Query
Interesting, I've no further suggestions at this point. There is no way to get a users IP Address with MYSQL and if CBs sessions are not yet populated then there's no other place to obtain the IP Address as far as I am aware.

You could actually use CB Code incubator project to execute a PHP file that of which does your query, but you'll be able to do this from PHP which PHP does have the functions available to obtain a users IP Address.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.220 seconds