Author Topic: Count of unique site visits (sessions)?  (Read 22470 times)

0 Members and 2 Guests are viewing this topic.

Offline Jetstream

  • Newbie
  • *
  • Posts: 20
    • View Profile
    • Fotogalerie Chris Gubelmann
visitor counter based on visitor's ip)?
« Reply #15 on: August 20, 2007, 02:44:39 PM »
 :D Thk you very much, I nearly had the solution, made just a syntax fault. Now, if you change sh.session_ip instad of s.session_ip, it gives you out exactly the result I ever wanted: 1404 ip-uniqe visitors since loggin into session_hist_table, which corresponds exactly with the statistics results.

Thunderstrike, thank you for your faboulous work and the invested time!

 :!: We have here a mod for a working IP-based visitor counter for 4images   :!:

If I have the time to, I will post the whole mod instructions in one here.
« Last Edit: August 20, 2007, 03:12:58 PM by Jetstream »

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Count of unique site visits (sessions)?
« Reply #16 on: August 20, 2007, 02:51:17 PM »
Thank for post. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Jetstream

  • Newbie
  • *
  • Posts: 20
    • View Profile
    • Fotogalerie Chris Gubelmann
Re: Count of unique site visits (sessions)?
« Reply #17 on: August 20, 2007, 03:11:14 PM »
thunderstrike, you are the expert of sql AND php, so i have a further question: I have a little problem understanding/converting the 4images date format INT(11). So, my hopefully last question to you is how to supplement the WHERE clause to show the result in an gap of any given date (y, m, d; h, m, s)

greets from rainy switzerland
chris
« Last Edit: August 20, 2007, 05:19:13 PM by Jetstream »

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Jetstream

  • Newbie
  • *
  • Posts: 20
    • View Profile
    • Fotogalerie Chris Gubelmann
Re: Count of unique site visits (sessions)?
« Reply #19 on: August 20, 2007, 05:18:30 PM »
Okay, I think I understand now the syntax of the DATE_FORMAT SQL order.

But I have to ask the question the other way: Can you please make this php code with the SQL clause "WHERE sh.session_lastaction =" to run, I dont know how to get the variables 'today' and 'month', so my idea of the php code with sql query is:

Code: [Select]
//-----------------------------------------------------
//--- total user sessions today------------------------
//-----------------------------------------------------
$sql = "SELECT COUNT(*) as sessions
        FROM (".SESSIONS_HIST_TABLE." sh, " . SESSIONS_TABLE . " s)
        LEFT JOIN "  . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = sh.session_user_id)
        WHERE sh.session_lastaction = today and " . get_user_table_field("u.", "user_level") . " >= '" . GUEST . "' AND " . get_user_table_field("u.", "user_level") . " <= '" . USER . "'
        GROUP BY s.session_ip";

$counter_result_day = $site_db->query_firstrow($sql);

and

Code: [Select]
//-----------------------------------------------------
//--- total user sessions this month ------------------
//-----------------------------------------------------
$sql = "SELECT COUNT(*) as sessions
        FROM (".SESSIONS_HIST_TABLE." sh, " . SESSIONS_TABLE . " s)
        LEFT JOIN "  . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = sh.session_user_id)
        WHERE sh.session_lastaction = month and " . get_user_table_field("u.", "user_level") . " >= '" . GUEST . "' AND " . get_user_table_field("u.", "user_level") . " <= '" . USER . "'
        GROUP BY s.session_ip";

$counter_result_month = $site_db->query_firstrow($sql);

thkyou
chris

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Count of unique site visits (sessions)?
« Reply #20 on: August 20, 2007, 05:30:17 PM »
And how question is after post mine to benefit my time ? :?
You have all need (two links) for DATE_FORMAT from mySQL page ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Jetstream

  • Newbie
  • *
  • Posts: 20
    • View Profile
    • Fotogalerie Chris Gubelmann
Re: Count of unique site visits (sessions)?
« Reply #21 on: August 20, 2007, 06:10:36 PM »
Yes I know I am using your time... I mentioned it above. So thank you for your work and time again. But: I don't know how to handel the DATE_FORMAT in the SQL Query! is it perhaps
Code: [Select]
WHERE sh.session_lastaction = DATE_FORMAT(date,'%d,%m,%y')?

Put how to put the actual date into 'date' in php????

You see once more I am a nerth in php!

thx
Chris

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Count of unique site visits (sessions)?
« Reply #22 on: August 20, 2007, 06:17:49 PM »
Quote
Yes I know I am using your time... I mentioned it above.

Then, a good luck to you !
Want use time ? Use in request for paid in forum.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Jetstream

  • Newbie
  • *
  • Posts: 20
    • View Profile
    • Fotogalerie Chris Gubelmann
Re: Count of unique site visits (sessions)?
« Reply #23 on: August 20, 2007, 07:14:42 PM »
soiifz...   :cry: I dont wanted to waste your time I ment. I dont understand why you helped me so far and now stop it that immediately? Have I used the wrong words perhaps? You must know english isn't my mother tongue!

By the way: the two links to mysqlpage aren't helpful for my question how to convert the 4images date format (int(11)) into a format understood by sql!!!

Sorry for that and thanks again for your grait work and time
Chris

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Count of unique site visits (sessions)?
« Reply #24 on: August 20, 2007, 08:14:42 PM »
Quote
I dont wanted to waste your time I ment. I dont understand why you helped me so far and now stop it that immediately?

Immediately ??  8O
You post on this topic - August 10 start subject and keep add on ... :?

Quote
By the way: the two links to mysqlpage aren't helpful for my question how to convert the 4images date format (int(11)) into a format understood by sql!!!

Match perfect your need. DATE_FORMAT is way to go for request. Is where source manual for mySQL. No better help. Good luck !

By the way - my english poor too.
« Last Edit: August 20, 2007, 08:44:13 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?