Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,303
    Plugin Contributions
    1

    Default Adding HTTP_SERVER to who's online

    So I can more easily identify the subdomain of the last url in Who's Online (using multisite - multiple subdomains on same ZC install) I'm trying to include HTTP_SERVER in Admin/whos_online.php to get the full url, I'm assuming that's the way to go.

    Changing, around line 413

    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>'
    to

    PHP Code:
    $lastURLlink '<a href="' HTTP_SERVER 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>'
    has no effect, any ideas on what I need to do?

  2. #2
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by simon1066 View Post
    So I can more easily identify the subdomain of the last url in Who's Online (using multisite - multiple subdomains on same ZC install) I'm trying to include HTTP_SERVER in Admin/whos_online.php to get the full url, I'm assuming that's the way to go.

    Changing, around line 413

    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>'
    to

    PHP Code:
    $lastURLlink '<a href="' HTTP_SERVER 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>'
    has no effect, any ideas on what I need to do?
    While notsure that returning HTTP_SERVER will identify the correct server for each of your runs, what you have inserted/changed is the link to which clicking on the path will go to. If you want to see the information more easily, you need to add information between the < u > and < /u > (spaces added so that would display on screen p as couldn't get it typed in with no spaces, some sort of autocorrect.)

    If you were to hover mouse over the link, ushould see additional information compared to before.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: Adding HTTP_SERVER to who's online

    Ah yes, I see you're right. What you've described works - thank you.

    Unfortunately, with some testing, I see that the HTTP_SERVER is taken from the mystore.com/admin/includes/configure.php (as I guess one would expect) rather than the mystore.com/includes/configure.php which is where my subdomains are referenced (allbeit indirectly)

    Not entirely sure there's a way around this

  4. #4
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Adding HTTP_SERVER to who's online

    Quote Originally Posted by simon1066 View Post
    Ah yes, I see you're right. What you've described works - thank you.

    Unfortunately, with some testing, I see that the HTTP_SERVER is taken from the mystore.com/admin/includes/configure.php (as I guess one would expect) rather than the mystore.com/includes/configure.php which is where my subdomains are referenced (allbeit indirectly)

    Not entirely sure there's a way around this
    So, as seems usual for me recently, I am not at a computer and review of the whose_online code isn't easy from this device, but... The fact that there is a fields[] variable with the last_url, uld think there is also a similar fields value for the server being accessed (which would be different than the server to which you are currently connected (which I believe is what happened with HTTP_SERVER above.) You need to refernece a variable that is specific to the server(s) in question.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    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

  6. #6
    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

  7. #7
    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.

  8. #8
    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 ;

  9. #9
    Join Date
    Jul 2012
    Posts
    16,816
    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...

  10. #10
    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.

 

 
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