Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default Re: Adding HTTP_SERVER to who's online

    Yes, I see this is going to be tricky, I'll dig around a bit more and see what I can come up with.

    Thanks again

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by simon1066 View Post
    Yes, I see this is going to be tricky, I'll dig around a bit more and see what I can come up with.

    Thanks again
    Instead of using ZenCarts' HTTP_SERVER CONSTANT, try using one of the Global variables.


    $_SERVER['HTTP_HOST']
    or
    $_SERVER['SERVER_NAME']

    Cheers
    RodG

  3. #3
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by RodG View Post
    Instead of using ZenCarts' HTTP_SERVER CONSTANT, try using one of the Global variables.


    $_SERVER['HTTP_HOST']
    or
    $_SERVER['SERVER_NAME']

    Cheers
    RodG
    That won't work, because that will give you the admin $_SERVER['HTTP_HOST'].

    I have the solution down below, but it involves some code changes.
    First add a field to the Who's online table:
    Code:
    ALTER TABLE `whos_online`  ADD `store_address2` TEXT NOT NULL ;
    then open the file includes\functions\whos_online.php

    find:
    PHP Code:
      if ($stored_customer->fields['count'] > 0) {
        
    $sql "update " TABLE_WHOS_ONLINE "
                  set customer_id = '" 
    . (int)$wo_customer_id "',
                      full_name = '" 
    zen_db_input($wo_full_name) . "',
                      ip_address = '" 
    zen_db_input($wo_ip_address) . "',
                      time_last_click = '" 
    zen_db_input($current_time) . "',
                      last_page_url = '" 
    zen_db_input($wo_last_page_url) . "',
                      host_address = '" 
    zen_db_input($_SESSION['customers_host_address']) . "',
                      user_agent = '" 
    zen_db_input($wo_user_agent) . "'
                  where session_id = '" 
    zen_db_input($wo_session_id) . "' and ip_address='" zen_db_input($wo_ip_address) . "'";

        
    $db->Execute($sql);

      } else {
        
    $sql "insert into " TABLE_WHOS_ONLINE "
                    (customer_id, full_name, session_id, ip_address, time_entry,
                     time_last_click, last_page_url, host_address, user_agent )
                  values ('" 
    . (int)$wo_customer_id "', '" zen_db_input($wo_full_name) . "', '"
                             
    zen_db_input($wo_session_id) . "', '" zen_db_input($wo_ip_address)
                             . 
    "', '" zen_db_input($current_time) . "', '" zen_db_input($current_time)
                             . 
    "', '" zen_db_input($wo_last_page_url)
                             . 
    "', '" zen_db_input($_SESSION['customers_host_address'])
                             . 
    "', '" zen_db_input($wo_user_agent)
                             . 
    "')";

        
    $db->Execute($sql); 
    and change to:
    PHP Code:
      if ($stored_customer->fields['count'] > 0) {
        
    $sql "update " TABLE_WHOS_ONLINE "
                  set customer_id = '" 
    . (int)$wo_customer_id "',
                      full_name = '" 
    zen_db_input($wo_full_name) . "',
                      ip_address = '" 
    zen_db_input($wo_ip_address) . "',
                      time_last_click = '" 
    zen_db_input($current_time) . "',
                      last_page_url = '" 
    zen_db_input($wo_last_page_url) . "',
                      host_address = '" 
    zen_db_input($_SESSION['customers_host_address']) . "',
                      user_agent = '" 
    zen_db_input($wo_user_agent) . "',
                      store_address = '" 
    zen_db_input($_SERVER['HTTP_HOST']) . "'
                  where session_id = '" 
    zen_db_input($wo_session_id) . "' and ip_address='" zen_db_input($wo_ip_address) . "'";

        
    $db->Execute($sql);

      } else {
        
    $sql "insert into " TABLE_WHOS_ONLINE "
                    (customer_id, full_name, session_id, ip_address, time_entry,
                     time_last_click, last_page_url, host_address, user_agent, store_address )
                  values ('" 
    . (int)$wo_customer_id "', '" zen_db_input($wo_full_name) . "', '"
                             
    zen_db_input($wo_session_id) . "', '" zen_db_input($wo_ip_address)
                             . 
    "', '" zen_db_input($current_time) . "', '" zen_db_input($current_time)
                             . 
    "', '" zen_db_input($wo_last_page_url)
                             . 
    "', '" zen_db_input($_SESSION['customers_host_address'])
                             . 
    "', '" zen_db_input($wo_user_agent)
                             . 
    "', '" zen_db_input($_SERVER['HTTP_HOST'])
                             . 
    "')";

        
    $db->Execute($sql); 
    Next open YOUR_ADMIN\whos_online.php
    around line 158 find:
    PHP Code:
      $sql "select customer_id, full_name, ip_address, time_entry, time_last_click, last_page_url, session_id, host_address, user_agent 
    change to:
    PHP Code:
      $sql "select customer_id, full_name, ip_address, time_entry,  time_last_click, last_page_url, session_id, host_address, user_agent, store_address 
    find:
    PHP Code:
                        $lastURLlink '<a href="' zen_output_string_protected($whos_online->fields['last_page_url']) . '" target="_blank">' '<u>'zen_output_string_protected($whos_online->fields['last_page_url']) . '</u>' '</a>'
    change to:
    PHP Code:
                        $lastURLlink '<a href="' .  zen_output_string_protected($whos_online->fields['last_page_url']) .  '" target="_blank">' '<u>' .  zen_output_string_protected($whos_online->fields['store_address']) .  zen_output_string_protected($whos_online->fields['last_page_url']) .  '</u>' '</a>'
    Last edited by Design75; 4 Jan 2014 at 04:47 PM.

  4. #4
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by Design75 View Post
    That won't work, because that will give you the admin $_SERVER['HTTP_HOST'].

    I have the solution down below, but it involves some code changes.
    First add a field to the Who's online table:
    Code:
    ALTER TABLE `whos_online`  ADD `store_address2` TEXT NOT NULL ;
    then open the file includes\functions\whos_online.php

    find:
    PHP Code:
      if ($stored_customer->fields['count'] > 0) {
        
    $sql "update " TABLE_WHOS_ONLINE "
                  set customer_id = '" 
    . (int)$wo_customer_id "',
                      full_name = '" 
    zen_db_input($wo_full_name) . "',
                      ip_address = '" 
    zen_db_input($wo_ip_address) . "',
                      time_last_click = '" 
    zen_db_input($current_time) . "',
                      last_page_url = '" 
    zen_db_input($wo_last_page_url) . "',
                      host_address = '" 
    zen_db_input($_SESSION['customers_host_address']) . "',
                      user_agent = '" 
    zen_db_input($wo_user_agent) . "'
                  where session_id = '" 
    zen_db_input($wo_session_id) . "' and ip_address='" zen_db_input($wo_ip_address) . "'";

        
    $db->Execute($sql);

      } else {
        
    $sql "insert into " TABLE_WHOS_ONLINE "
                    (customer_id, full_name, session_id, ip_address, time_entry,
                     time_last_click, last_page_url, host_address, user_agent )
                  values ('" 
    . (int)$wo_customer_id "', '" zen_db_input($wo_full_name) . "', '"
                             
    zen_db_input($wo_session_id) . "', '" zen_db_input($wo_ip_address)
                             . 
    "', '" zen_db_input($current_time) . "', '" zen_db_input($current_time)
                             . 
    "', '" zen_db_input($wo_last_page_url)
                             . 
    "', '" zen_db_input($_SESSION['customers_host_address'])
                             . 
    "', '" zen_db_input($wo_user_agent)
                             . 
    "')";

        
    $db->Execute($sql); 
    and change to:
    PHP Code:
      if ($stored_customer->fields['count'] > 0) {
        
    $sql "update " TABLE_WHOS_ONLINE "
                  set customer_id = '" 
    . (int)$wo_customer_id "',
                      full_name = '" 
    zen_db_input($wo_full_name) . "',
                      ip_address = '" 
    zen_db_input($wo_ip_address) . "',
                      time_last_click = '" 
    zen_db_input($current_time) . "',
                      last_page_url = '" 
    zen_db_input($wo_last_page_url) . "',
                      host_address = '" 
    zen_db_input($_SESSION['customers_host_address']) . "',
                      user_agent = '" 
    zen_db_input($wo_user_agent) . "',
                      store_address = '" 
    zen_db_input($_SERVER['HTTP_HOST']) . "'
                  where session_id = '" 
    zen_db_input($wo_session_id) . "' and ip_address='" zen_db_input($wo_ip_address) . "'";

        
    $db->Execute($sql);

      } else {
        
    $sql "insert into " TABLE_WHOS_ONLINE "
                    (customer_id, full_name, session_id, ip_address, time_entry,
                     time_last_click, last_page_url, host_address, user_agent, store_address )
                  values ('" 
    . (int)$wo_customer_id "', '" zen_db_input($wo_full_name) . "', '"
                             
    zen_db_input($wo_session_id) . "', '" zen_db_input($wo_ip_address)
                             . 
    "', '" zen_db_input($current_time) . "', '" zen_db_input($current_time)
                             . 
    "', '" zen_db_input($wo_last_page_url)
                             . 
    "', '" zen_db_input($_SESSION['customers_host_address'])
                             . 
    "', '" zen_db_input($wo_user_agent)
                             . 
    "', '" zen_db_input($_SERVER['HTTP_HOST'])
                             . 
    "')";

        
    $db->Execute($sql); 
    Next open YOUR_ADMIN\whos_online.php
    around line 158 find:
    PHP Code:
      $sql "select customer_id, full_name, ip_address, time_entry, time_last_click, last_page_url, session_id, host_address, user_agent 
    change to:
    PHP Code:
      $sql "select customer_id, full_name, ip_address, time_entry,  time_last_click, last_page_url, session_id, host_address, user_agent, store_address 
    find:
    PHP Code:
                        $lastURLlink '<a href="' zen_output_string_protected($whos_online->fields['last_page_url']) . '" target="_blank">' '<u>'zen_output_string_protected($whos_online->fields['last_page_url']) . '</u>' '</a>'
    change to:
    PHP Code:
                        $lastURLlink '<a href="' .  zen_output_string_protected($whos_online->fields['last_page_url']) .  '" target="_blank">' '<u>' .  zen_output_string_protected($whos_online->fields['store_address']) .  zen_output_string_protected($whos_online->fields['last_page_url']) .  '</u>' '</a>'
    Code:
    ALTER TABLE `whos_online`  ADD `store_address2` TEXT NOT NULL ;
    should of course be
    Code:
    ALTER TABLE `whos_online`  ADD `store_address` TEXT NOT NULL ;

  5. #5
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by Design75 View Post
    Code:
    ALTER TABLE `whos_online`  ADD `store_address2` TEXT NOT NULL ;
    should of course be
    Code:
    ALTER TABLE `whos_online`  ADD `store_address` TEXT NOT NULL ;
    Trust me, that sort of mistake happens...

    I'm curious though, why the change to the database table(s)? Why not prepend the last_page_uri with the associated server name? Do you have a unique reason to pull the servername out to it's own field?

    Thought is that url would be fully presented both as text (where needed) and as a functional link to the exact location.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by mc12345678 View Post
    Trust me, that sort of mistake happens...

    I'm curious though, why the change to the database table(s)? Why not prepend the last_page_uri with the associated server name? Do you have a unique reason to pull the servername out to it's own field?

    Thought is that url would be fully presented both as text (where needed) and as a functional link to the exact location.
    I wanted to leave the original last_url in tact, because I was not sure what other processes us this, and was lacking the time to find out.

  7. #7
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by Design75 View Post
    I wanted to leave the original last_url in tact, because I was not sure what other processes us this, and was lacking the time to find out.
    Could understand from that perspective. Think a query on the code through developer's tool kit will help answer that question, first would try with the entire var name, then would try with just the field name to see if it is used elsewhere. While possible to have renamed the base variable name, so likely, and even more unlikely to transfer the variable to another and completely change the field's name.

    So, if someone else were to follow up on this thread, there is a solution that will display the full path name; however, it leaves other pieces of data untouched.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by Design75 View Post
    That won't work, because that will give you the admin $_SERVER['HTTP_HOST'].

    I have the solution down below, but it involves some code changes.
    First add a field to the Who's online table:

    ..................
    Just revisiting this topic, and hadn't realised how busty the thread had got.

    Thank you so much for this Design75, does exactly what I needed.

    Quote Originally Posted by mc12345678 View Post
    Could understand from that perspective. Think a query on the code through developer's tool kit will help answer that question, first would try with the entire var name, then would try with just the field name to see if it is used elsewhere. While possible to have renamed the base variable name, so likely, and even more unlikely to transfer the variable to another and completely change the field's name.

    So, if someone else were to follow up on this thread, there is a solution that will display the full path name; however, it leaves other pieces of data untouched.
    I think, although I'll look into it, that this is beyond my capabilities so I'll stick with the posted code for the moment. Thanks for your thoughts though.

    Quote Originally Posted by Design75 View Post
    PHP Code:
                        $lastURLlink '<a href="' .  zen_output_string_protected($whos_online->fields['last_page_url']) .  '" target="_blank">' '<u>' .  zen_output_string_protected($whos_online->fields['store_address']) .  zen_output_string_protected($whos_online->fields['last_page_url']) .  '</u>' '</a>'
    It seems strange that the original of this posted code, in fact all in that post, does not have a horizontal scroll on my screen, I had to expand the window to max to see all of it, luckily I'm on a big screen.

  9. #9
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by simon1066 View Post
    Just revisiting this topic, and hadn't realised how busty the thread had got.

    ...
    should of course be 'busy' - apologies

  10. #10
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by simon1066 View Post
    should of course be 'busy' - apologies
    I liked it better when it was busty :)

    Cheers
    RodG

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Who's Online
    By SaMortensen in forum General Questions
    Replies: 8
    Last Post: 19 May 2008, 04:04 PM
  2. Who's Online
    By qisahn in forum General Questions
    Replies: 5
    Last Post: 25 Sep 2007, 03:47 PM
  3. Who's Online - User gone, but Admin says online
    By johnd in forum General Questions
    Replies: 2
    Last Post: 23 Sep 2007, 01:57 AM
  4. Who is online...side admin vs online group pricing mod
    By csfound in forum General Questions
    Replies: 8
    Last Post: 18 Jul 2007, 04:27 AM
  5. Who's Online
    By TecBrat in forum General Questions
    Replies: 1
    Last Post: 2 Jun 2006, 08:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg