Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Whos Online - Not showing Name or IP


Guest

Recommended Posts

I recently did a new install of RH8.0 with Apache 2.0.40 PHP 4.2.2 & MySQL 3.23.55

 

Loaded osC MS1 and have a problem with the Whos Online.

 

When I sign into the website whos_online reports all visitors as guest regardless of whether they have logged in or not. I am not sure if this is a MS1 problem or if it has something to do with my configuration.

 

Also there are no IP addresses or info in the Last URL. This I am sure is a configuration problem as I have loaded MS1 on a Win2K/Apache 1.37 and these functions worked fine.

 

I am at a loss as to what to do next...

 

I have searched the forums and found no answers.

 

:cry:

Link to comment
Share on other sites

i just tried to go to sourceforge to look for the commit that fixes this but unfortunately they are down for maintenance right now..... will check again later

Link to comment
Share on other sites

here is the latest file in the CVS

 

make a copy of your original file, then replace the contents of the file with the following:

 

 

<?php

/*

$Id: whos_online.php,v 1.30 2002/11/22 14:45:49 dgw_ Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

$xx_mins_ago = (time() - 900);

 

require('includes/application_top.php');

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

// remove entries that have expired

tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr class="dataTableHeadingRow">

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_ONLINE; ?></td>

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMER_ID; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_FULL_NAME; ?></td>

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_IP_ADDRESS; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_ENTRY_TIME; ?></td>

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_LAST_CLICK; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LAST_PAGE_URL; ?> </td>

</tr>

<?php

$whos_online_query = tep_db_query("select customer_id, full_name, ip_address, time_entry, time_last_click, last_page_url, session_id from " . TABLE_WHOS_ONLINE);

while ($whos_online = tep_db_fetch_array($whos_online_query)) {

$time_online = (time() - $whos_online['time_entry']);

if ( ((!$HTTP_GET_VARS['info']) || (@$HTTP_GET_VARS['info'] == $whos_online['session_id'])) && (!$info) ) {

$info = $whos_online['session_id'];

}

if ($whos_online['session_id'] == $info) {

echo ' <tr class="dataTableRowSelected">' . "n";

} else {

echo ' <tr class="dataTableRow" onmouseover="this.className='dataTableRowOver';this.style.cursor='hand'" onmouseout="this.className='dataTableRow'" onclick="document.location.href='' . tep_href_link(FILENAME_WHOS_ONLINE, tep_get_all_get_params(array('info', 'action')) . 'info=' . $whos_online['session_id'], 'NONSSL') . ''">' . "n";

}

?>

<td class="dataTableContent"><?php echo gmdate('H:i:s', $time_online); ?></td>

<td class="dataTableContent" align="center"><?php echo $whos_online['customer_id']; ?></td>

<td class="dataTableContent"><?php echo $whos_online['full_name']; ?></td>

<td class="dataTableContent" align="center"><?php echo $whos_online['ip_address']; ?></td>

<td class="dataTableContent"><?php echo date('H:i:s', $whos_online['time_entry']); ?></td>

<td class="dataTableContent" align="center"><?php echo date('H:i:s', $whos_online['time_last_click']); ?></td>

<td class="dataTableContent"><?php if (eregi('^(.*)' . tep_session_name() . '=[a-f,0-9]+[&]*(.*)', $whos_online['last_page_url'], $array)) { echo $array[1] . $array[2]; } else { echo $whos_online['last_page_url']; } ?> </td>

</tr>

<?php

}

?>

<tr>

<td class="smallText" colspan="7"><?php echo sprintf(TEXT_NUMBER_OF_CUSTOMERS, tep_db_num_rows($whos_online_query)); ?></td>

</tr>

</table></td>

<?php

$heading = array();

$contents = array();

if ($info) {

$heading[] = array('text' => '<b>' . TABLE_HEADING_SHOPPING_CART . '</b>');

 

if (STORE_SESSIONS == 'mysql') {

$session_data = tep_db_query("select value from " . TABLE_SESSIONS . " WHERE sesskey = '" . $info . "'");

$session_data = tep_db_fetch_array($session_data);

$session_data = trim($session_data['value']);

} else {

if ( (file_exists(tep_session_save_path() . '/sess_' . $info)) && (filesize(tep_session_save_path() . '/sess_' . $info) > 0) ) {

$session_data = file(tep_session_save_path() . '/sess_' . $info);

$session_data = trim(implode('', $session_data));

}

}

 

if ($length = strlen($session_data)) {

if (PHP_VERSION < 4) {

$start_id = strpos($session_data, 'customer_id[==]s');

$start_cart = strpos($session_data, 'cart[==]o');

$start_currency = strpos($session_data, 'currency[==]s');

$start_country = strpos($session_data, 'customer_country_id[==]s');

$start_zone = strpos($session_data, 'customer_zone_id[==]s');

} else {

$start_id = strpos($session_data, 'customer_id|s');

$start_cart = strpos($session_data, 'cart|O');

$start_currency = strpos($session_data, 'currency|s');

$start_country = strpos($session_data, 'customer_country_id|s');

$start_zone = strpos($session_data, 'customer_zone_id|s');

}

 

for ($i=$start_cart; $i<$length; $i++) {

if ($session_data[$i] == '{') {

if (isset($tag)) {

$tag++;

} else {

$tag = 1;

}

} elseif ($session_data[$i] == '}') {

$tag--;

} elseif ( (isset($tag)) && ($tag < 1) ) {

break;

}

}

 

$session_data_id = substr($session_data, $start_id, (strpos($session_data, ';', $start_id) - $start_id + 1));

$session_data_cart = substr($session_data, $start_cart, $i);

$session_data_currency = substr($session_data, $start_currency, (strpos($session_data, ';', $start_currency) - $start_currency + 1));

$session_data_country = substr($session_data, $start_country, (strpos($session_data, ';', $start_country) - $start_country + 1));

$session_data_zone = substr($session_data, $start_zone, (strpos($session_data, ';', $start_zone) - $start_zone + 1));

 

session_decode($session_data_id);

session_decode($session_data_currency);

session_decode($session_data_country);

session_decode($session_data_zone);

session_decode($session_data_cart);

 

if (PHP_VERSION < 4) {

$broken_cart = $cart;

$cart = new shoppingCart;

$cart->unserialize($broken_cart);

}

 

if (is_object($cart)) {

$products = $cart->get_products();

for ($i = 0, $n = sizeof($products); $i < $n; $i++) {

$contents[] = array('text' => $products[$i]['quantity'] . ' x ' . $products[$i]['name']);

}

 

if (sizeof($products) > 0) {

$contents[] = array('text' => tep_draw_separator('pixel_black.gif', '100%', '1'));

$contents[] = array('align' => 'right', 'text' => TEXT_SHOPPING_CART_SUBTOTAL . ' ' . $currencies->format($cart->show_total(), true, $currency));

} else {

$contents[] = array('text' => ' ');

}

}

}

}

 

if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {

echo ' <td width="25%" valign="top">' . "n";

 

$box = new box;

echo $box->infoBox($heading, $contents);

 

echo ' </td>' . "n";

}

?>

</tr>

</table></td>

</tr>

</table></td>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

I dont get how the whos online sql supposed to call logged in users if it keeps defining them as guests with IDs of 0.

 

Why not fetch info from the customers table instead?

Link to comment
Share on other sites

ok, heres a copy of my file and its working:

 

<?php

/*

$Id: whos_online.php,v 1.30 2002/11/22 14:45:49 dgw_ Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2002 osCommerce

 

Released under the GNU General Public License

*/

 

$xx_mins_ago = (time() - 900);

 

require('includes/application_top.php');

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

// remove entries that have expired

tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'");

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr class="dataTableHeadingRow">

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_ONLINE; ?></td>

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMER_ID; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_FULL_NAME; ?></td>

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_IP_ADDRESS; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_ENTRY_TIME; ?></td>

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_LAST_CLICK; ?></td>

<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LAST_PAGE_URL; ?> </td>

</tr>

<?php

$whos_online_query = tep_db_query("select customer_id, full_name, ip_address, time_entry, time_last_click, last_page_url, session_id from " . TABLE_WHOS_ONLINE);

while ($whos_online = tep_db_fetch_array($whos_online_query)) {

$time_online = (time() - $whos_online['time_entry']);

if ( ((!$HTTP_GET_VARS['info']) || (@$HTTP_GET_VARS['info'] == $whos_online['session_id'])) && (!$info) ) {

$info = $whos_online['session_id'];

}

if ($whos_online['session_id'] == $info) {

echo ' <tr class="dataTableRowSelected">' . "n";

} else {

echo ' <tr class="dataTableRow" onmouseover="this.className='dataTableRowOver';this.style.cursor='hand'" onmouseout="this.className='dataTableRow'" onclick="document.location.href='' . tep_href_link(FILENAME_WHOS_ONLINE, tep_get_all_get_params(array('info', 'action')) . 'info=' . $whos_online['session_id'], 'NONSSL') . ''">' . "n";

}

?>

<td class="dataTableContent"><?php echo gmdate('H:i:s', $time_online); ?></td>

<td class="dataTableContent" align="center"><?php echo $whos_online['customer_id']; ?></td>

<td class="dataTableContent"><?php echo $whos_online['full_name']; ?></td>

<td class="dataTableContent" align="center"><?php echo $whos_online['ip_address']; ?></td>

 

 

<td class="dataTableContent"><?php echo date('H:i:s', $whos_online['time_entry']); ?></td>

<td class="dataTableContent" align="center"><?php echo date('H:i:s', $whos_online['time_last_click']); ?></td>

<td class="dataTableContent"><?php if (eregi('^(.*)' . tep_session_name() . '=[a-f,0-9]+[&]*(.*)', $whos_online['last_page_url'], $array)) { echo $array[1] . $array[2]; } else { echo $whos_online['last_page_url']; } ?> </td>

</tr>

<?php

}

?>

<tr>

<td class="smallText" colspan="7"><?php echo sprintf(TEXT_NUMBER_OF_CUSTOMERS, tep_db_num_rows($whos_online_query)); ?></td>

</tr>

</table></td>

<?php

$heading = array();

$contents = array();

if ($info) {

$heading[] = array('text' => '<b>' . TABLE_HEADING_SHOPPING_CART . '</b>');

 

if (STORE_SESSIONS == 'mysql') {

$session_data = tep_db_query("select value from " . TABLE_SESSIONS . " WHERE sesskey = '" . $info . "'");

$session_data = tep_db_fetch_array($session_data);

$session_data = trim($session_data['value']);

} else {

if ( (file_exists(tep_session_save_path() . '/sess_' . $info)) && (filesize(tep_session_save_path() . '/sess_' . $info) > 0) ) {

$session_data = file(tep_session_save_path() . '/sess_' . $info);

$session_data = trim(implode('', $session_data));

}

}

 

if ($length = strlen($session_data)) {

if (PHP_VERSION < 4) {

$start_id = strpos($session_data, 'customer_id[==]s');

$start_cart = strpos($session_data, 'cart[==]o');

$start_currency = strpos($session_data, 'currency[==]s');

$start_country = strpos($session_data, 'customer_country_id[==]s');

$start_zone = strpos($session_data, 'customer_zone_id[==]s');

} else {

$start_id = strpos($session_data, 'customer_id|s');

$start_cart = strpos($session_data, 'cart|O');

$start_currency = strpos($session_data, 'currency|s');

$start_country = strpos($session_data, 'customer_country_id|s');

$start_zone = strpos($session_data, 'customer_zone_id|s');

}

 

for ($i=$start_cart; $i<$length; $i++) {

if ($session_data[$i] == '{') {

if (isset($tag)) {

$tag++;

} else {

$tag = 1;

}

} elseif ($session_data[$i] == '}') {

$tag--;

} elseif ( (isset($tag)) && ($tag < 1) ) {

break;

}

}

 

$session_data_id = substr($session_data, $start_id, (strpos($session_data, ';', $start_id) - $start_id + 1));

$session_data_cart = substr($session_data, $start_cart, $i);

$session_data_currency = substr($session_data, $start_currency, (strpos($session_data, ';', $start_currency) - $start_currency + 1));

$session_data_country = substr($session_data, $start_country, (strpos($session_data, ';', $start_country) - $start_country + 1));

$session_data_zone = substr($session_data, $start_zone, (strpos($session_data, ';', $start_zone) - $start_zone + 1));

 

session_decode($session_data_id);

session_decode($session_data_currency);

session_decode($session_data_country);

session_decode($session_data_zone);

session_decode($session_data_cart);

 

if (PHP_VERSION < 4) {

$broken_cart = $cart;

$cart = new shoppingCart;

$cart->unserialize($broken_cart);

}

 

if (is_object($cart)) {

$products = $cart->get_products();

for ($i = 0, $n = sizeof($products); $i < $n; $i++) {

$contents[] = array('text' => $products[$i]['quantity'] . ' x ' . $products[$i]['name']);

}

 

if (sizeof($products) > 0) {

$contents[] = array('text' => tep_draw_separator('pixel_black.gif', '100%', '1'));

$contents[] = array('align' => 'right', 'text' => TEXT_SHOPPING_CART_SUBTOTAL . ' ' . $currencies->format($cart->show_total(), true, $currency));

} else {

$contents[] = array('text' => ' ');

}

}

}

}

 

if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {

echo ' <td width="25%" valign="top">' . "n";

 

$box = new box;

echo $box->infoBox($heading, $contents);

 

echo ' </td>' . "n";

}

?>

</tr>

</table></td>

</tr>

</table></td>

<!-- body_text_eof //-->

</tr>

</table>

<!-- body_eof //-->

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<!-- footer_eof //-->

<br>

</body>

</html>

<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

Hi,

I'm having the same problem in MS1

It worked fine in 2.2.

I even went back and put 2.2 whos online in MS1 and it won't work with MS1.

 

 

Dee

I got grey hair with osCommerce.

Link to comment
Share on other sites

Hi,

I'm having the same problem in MS1

It worked fine in 2.2.

I even went back and put 2.2 whos online in MS1 and it won't work with MS1.

 

 

Dee

I got grey hair with osCommerce.

Link to comment
Share on other sites

in the bug report/commits list it shows the following:

 

Description

The admin's who's online function always shows "guest" with customer-id zero.

 

This is caused by an error in:

catalog/includes/functions/whos_online.php

 

Line 16 reads:

if (tep_session_is_registered($customer_id)) {

where it should read:

if (tep_session_is_registered(customer_id)) {

 

Mark the $-sign!

 

 

:oops: :oops:

 

been looking at the wrong file - sorry everyone....

 

this should fix it for everyone

Link to comment
Share on other sites

i have been working on so many different pieces of code for the past 3 days i am going blind (and semi stupid)

 

glad we found the solution for everyone

 

now back to the other mods.......

Link to comment
Share on other sites

Not an sql expert but i would check on this too:

 

Here is my M1 whosonline table:

 

CREATE TABLE whos_online(

customer_id int( 11 ) default NULL ,

full_name varchar( 64 ) NOT NULL default '',

session_id varchar( 128 ) NOT NULL default '',

ip_address varchar( 15 ) NOT NULL default '',

time_entry varchar( 14 ) NOT NULL default '',

time_last_click varchar( 14 ) NOT NULL default '',

last_page_url varchar( 64 ) NOT NULL default ''

) TYPE = MyISAM;

 

Dont know if the customer_id can increase thus remaining "0" zero and why theres always guests.

 

Look at the customers table:

 

DROP TABLE IF EXISTS customers;

CREATE TABLE customers (

  customers_id int NOT NULL auto_increment,

  customers_gender char(1) NOT NULL,

  customers_firstname varchar(32) NOT NULL,

  customers_lastname varchar(32) NOT NULL,

  customers_dob datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,

  customers_email_address varchar(96) NOT NULL,

  customers_default_address_id int(5) DEFAULT '1' NOT NULL,

  customers_telephone varchar(32) NOT NULL,

  customers_fax varchar(32),

  customers_password varchar(40) NOT NULL,

  customers_newsletter char(1),

  PRIMARY KEY (customers_id)

);

 

 

Just this:

customers_id int NOT NULL auto_increment,

Looks like it updates the user's ID if they logged but this doesnt seem to happen on the whosonline table.

 

Tried to conbine or invent a sql whosonline customer_id thing but im not that good with sql. :cry: [/code]

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...