Post by maryh » Fri Jan 25, 2008 4:44 am

CAN anyone help??  - I have 44 customers online!! on my reports page.  MOST of these are ME - looking at my store! Can anyone tell me how I can clear these??? Delete doesnt work.  Thanks and best wishes

Newbie

Posts

Joined
Sun Dec 02, 2007 2:33 am

Post by bruce » Fri Jan 25, 2008 10:09 pm

This report is showing all of the rows in the table "session". These are supposed to be deleted when they are untouched for more than one hour but the session object will not always clean up in as timely a manner as we want for this report to be accurate.

So, to show only "current" records (in the spirit of the existing design, "current" is less than 1 hour old) in the "on line" report, you can make the following modification to the file \admin\controller\report_online.php

replace this

Code: Select all

        $results = $database->getRows("select value, ip, time, url from session");
with this

Code: Select all


        //  show only sessions that have not expired.
        $sql = "select `value`, `ip`, `time`, `url` from `session` where `expire` > '?'";
        $parsed = $database->parse($sql, time());
        $results = $database->getRows($parsed);
        //
If you want the values shown in the report to be less than 1 hour old, say up to 20 minutes old instead, then those records will expire in 40 minutes from now. Hence, you would change $parsed to the following

Code: Select all

       $parsed = $database->parse($sql, time() + 40 * 60);
Last edited by bruce on Fri Jan 25, 2008 10:11 pm, edited 1 time in total.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by ocsinet » Mon Feb 04, 2008 5:40 am

maryh wrote: CAN anyone help??  - I have 44 customers online!! on my reports page.  MOST of these are ME - looking at my store! Can anyone tell me how I can clear these??? Delete doesnt work.  Thanks and best wishes
I've the same problem...all the session weren't deleted (I still use 0.6.5), I don't know why. What suggested doesn't solve the problem, only hide it. So, I made these modifications: in file include/session.php, replaced

Code: Select all

function clean($maxlifetime) {
    global $database;

    $database->query("delete from session where expire < '" . time() . "'");

    return $database->affected();
  }
with

Code: Select all

  function clean() {
    global $database;

    $database->query("delete from session where expire < '" . time() . "'");

    return $database->affected();
  }
and inserted in file index.php e admin/index.php:

Code: Select all

$session->clean();
after

Code: Select all

$session = new session;
I hope it will be useful.

Webmaster http://www.opencart.it


New member

Posts

Joined
Mon Feb 04, 2008 5:18 am
Location - Italy

Post by sutulustus » Thu Apr 24, 2008 6:44 am

Here is a guide how to get Online Reports working in version 0.7.7

The first thing is to find session.php

/library/session/session.php

in the third line edit

Code: Select all

var $expire = 3600;
to set the expire time in seconds

then

go to /admin/index.php and insert following

Code: Select all

// People Online
$session  =& $locator->get('session');
$session->clean();
by me its working fine  :D ;)

Newbie

Posts

Joined
Thu Apr 24, 2008 6:07 am

Post by trippy » Thu Jun 19, 2008 8:31 pm

hallo!
I've tried bruce and sutulustus solutions - the one of sutulustus gives me an error in the login panel - the one of bruce seems to work but only if I go inside the "people online" panel - the problem is that the number under the "people online" icon doesn't accord with the number of customers online displayed in the panel...

New member

Posts

Joined
Sun Dec 16, 2007 5:12 pm

Post by bruce » Thu Jun 19, 2008 9:42 pm

You simply need to apply similar code to what I suggested for the report to that which gathers the information for the icon on the home page.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by trippy » Fri Jun 20, 2008 5:42 pm

Yes, I've imagined... but it seems to be not so linear (at least for me...)
in admin/controller/home.php  i've found this part of code

Code: Select all

    	$view->set('online', $url->ssl('report_online'));
	
    	$user_info = $database->getRow("select count(*) as total from session");
	
    	$view->set('users', $user_info['total']);

    	$view->set('customer', $url->ssl('customer'));
	
    	$customer_info = $database->getRow("select count(*) as total from customer");
    
		$view->set('customers', $customer_info['total']);
if this is the right part to modify, could you help me to understand how I have to modify it? or, if it's not the right file, could you show me the right one?

thank bruce :)

New member

Posts

Joined
Sun Dec 16, 2007 5:12 pm

Post by bruce » Fri Jun 20, 2008 8:55 pm

you found the right place trippy.

As per my previous preamble, to show only "current" records (in the spirit of the existing design, "current" is less than 1 hour old) in the "on line" report, change the

Code: Select all

$user_info = $database->getRow("select count(*) as total from session");
to

Code: Select all

       $sql = "select count(*) as total from `session` where `expire` > '?'";
        $parsed = $database->parse($sql, time());
        $user_info= $database->getRow($parsed);
as before, If you want the values shown in the report to be less than 1 hour old, say up to 20 minutes old instead, then those records will expire in 40 minutes from now. Hence, you would change $parsed to the following

Code: Select all

$parsed = $database->parse($sql, time() + 40 * 60);

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by SiteE@se » Sat Jun 21, 2008 2:55 am

The Customers Online is a useful tool for gathering info when configured as Bruce has described.  Very interesting watching how users navigate through various parts of the store and its processes - if you have the time!

On our implementation of OpenCart the No. of Cart Items on this page is always 0 - even though we know they have items in there. Can anyone explain what needs doing to rectify this?

Chris

Chris @ SiteE@se Web Design


Active Member

Posts

Joined
Mon Dec 17, 2007 7:40 am
Location - UK

Post by bruce » Sat Jun 21, 2008 7:13 pm

Hi Chris,

You have found another bug. Change the file admin/controller/report_online.php as shown below. The original offending line is commented out and it's replacement is above it.

Code: Select all

			$rows[] = array(
				'name'  => $name,
				'time'  => date('dS F Y h:i:s A', strtotime($result['time'])),
				'ip'    => $result['ip'],
				'url'   => $result['url'],
				'total' => (isset($value['cart']) ? array_sum($value['cart']) : 0)
//				'total' => (isset($value['products']) ? count($value['products']) : 0)
			);

Note that the data displayed by this report is not updated in real time. It depends entirely on when the web server decides to persist the session data. That action is captured by code in library/session/session.php which saves it to the database. Only then will it appear in the report.

cheers

Bruce

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by SiteE@se » Tue Jun 24, 2008 4:02 am

Thanks again, Bruce.  What would we all do without you?  ;D

Chris

Chris @ SiteE@se Web Design


Active Member

Posts

Joined
Mon Dec 17, 2007 7:40 am
Location - UK

Post by ried » Sat Aug 16, 2008 8:18 pm

i have 0 customers online (include me 0)...

OC v0.7.8...

Newbie

Posts

Joined
Wed Feb 13, 2008 5:45 pm

Post by SiteE@se » Sun Aug 17, 2008 2:33 am

ried wrote: i have 0 customers online (include me 0)...

OC v0.7.8...
You probably need to include the following in admin -> index.php, as suggested earlier in this thread.  Bruce's coding has largely been included in 0.7.8 so you may only want to adjust things in the reports_online.php if you want to show people online less than an hour ago, as Bruce has already described.  The code below was not included in 0.7.8 AFAIK.

Code: Select all

// People Online
$session  =& $locator->get('session');
$session->clean();

Chris @ SiteE@se Web Design


Active Member

Posts

Joined
Mon Dec 17, 2007 7:40 am
Location - UK

Post by jty » Fri Nov 14, 2008 11:31 pm

Does the People Online report work in 0.7.9RC3 ?
I'm getting noone online even though I am online

I put in the following
SiteE@se wrote: You probably need to include the following in admin -> index.php,

Code: Select all

// People Online
$session  =& $locator->get('session');
$session->clean();
But got error that Warning: Missing argument 1 for Session::clean(), called in ....admin\index.php on line 138 and defined in .....\library\session\session.php on line 80

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by bthirsk » Sat Nov 15, 2008 12:05 am

I have the same thing with 7.8.
That function,$session->clean();, was someones fix. It is not what is in 7.8 or 7.9.
You would have to use $session->clean(3600) as it needs a parameter.
But that won't cure the problem of no online report.
I'd haven't had time to get back yet, so if you find the answer.let me know too.

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by jty » Sun Nov 16, 2008 10:54 pm

I found it

In admin/controller/report_online.php, the line

Code: Select all

$parsed = $database->parse($sql, time()[color=red] + 3600[/color]);
If you go back up and read Bruce's code, it is

Code: Select all

$parsed = $database->parse($sql, time());
Take out the

Code: Select all

+ 3600
and it now works
Also follow Bruce's help for Trippy and home.php

I don't understand what + 3600 means but at least I can see me online now
The only thing is it is showing me as admin when I have logged in as someone else in the front end.
I am admin in the backend and some other email address in the front end. Maybe it's identifying the IP address as the same so it's saying I am me.
Maybe Open Cart has esp and just knows I am me

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by bthirsk » Sun Nov 16, 2008 11:04 pm

Thanks
See, I knew you where a wizard.

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by bthirsk » Sun Nov 16, 2008 11:35 pm

The 3600 is the time in seconds from time() which is now.
The only problem, and I can't believe we missed it, is we are starting 1 hour in the future.
Change the + 3600 to - 3600 and it will work.

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Mon Nov 17, 2008 1:38 am

I came up with this:

Code: Select all

$sql = "select `value`, `ip`, `time`, `url` from `session` where `expire` >= '?' and `expire` <= '?'";
$parsed = $database->parse($sql, time(), time() + 3600);
$results = $database->getRows($parsed);
Which will show you only sessions that are within the hour from "right now".
But I guess really expire times will never be more than 1 hour from right now anyway. So then yea bruces fix looks like it might be the best way to go on this one

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 0 guests