PDA

View Full Version : Count Listing Visits



Marina Charalampous
May 20, 2014, 10:16 AM
Hello Guys,
Do you know anything about how works the Count Listing Visits?
count per person, ip, view?
Thanks

Dmitry
May 20, 2014, 10:40 AM
Hello Marina,

Count Listing Visits works by IP. Count will be increased after one day if you come back on this listing.

Thanks.

Marina Charalampous
May 20, 2014, 10:44 AM
Ok thanks
Can you change that settings?
make more "sensitive"

Hello Marina,

Count Listing Visits works by IP. Count will be increased after one day if you come back on this listing.

Thanks.

Dmitry
May 22, 2014, 03:45 PM
Hello Marina,

Do you want to add the count each time when user will be updated or go on listing?

Thanks.

Ivan Amador
June 18, 2015, 04:52 AM
Hello,

How can I get the visits to count each time someone go to a listing, instead of limit the visits by IP?

Thanks!

Mahmoud Khedr
August 22, 2018, 03:25 PM
interested

Rudi
August 23, 2018, 06:50 PM
If you need to count listing visits each time the listing is opened
go to ftp > includes > classes > rlListings.class.php > public function countVisit($id)

replace this code:


$id = (int) $id;
$today_period = (date('G') * 3600) + (date('i') * 60) + date('s');

// get and check current IP address
$ip = $this->getClientIpAddress();

$sql = "SELECT `IP` FROM `{db_prefix}listings_shows` ";
$sql .= "WHERE UNIX_TIMESTAMP(DATE_ADD(`Date`, INTERVAL {$today_period} SECOND)) > UNIX_TIMESTAMP() ";
$sql .= "AND `Listing_ID` = {$id} AND `IP` = '{$ip}' ";
$visit_ip = $this->getRow($sql);

if (empty($visit_ip)) {
$save_ip = array(
'Listing_ID' => $id,
'IP' => $ip,
'Date' => 'NOW()',
'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),
);

$this->loadClass('Actions');
$GLOBALS['rlActions']->insertOne($save_ip, 'listings_shows');

// update shows
$sql = "UPDATE `{db_prefix}listings` SET `Last_show` = NOW(), `Shows` = `Shows` + 1 ";
$sql .= "WHERE `ID` = {$id} LIMIT 1";
$this->query($sql);
}


with:


$id = (int) $id;

// get and check current IP address
$ip = $this->getClientIpAddress();

$save_ip = array(
'Listing_ID' => $id,
'IP' => $ip,
'Date' => 'NOW()',
'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),
);

$this->loadClass('Actions');
$GLOBALS['rlActions']->insertOne($save_ip, 'listings_shows');

// update shows
$sql = "UPDATE `" . RL_DBPREFIX . "listings` SET `Last_show` = NOW(), `Shows` = `Shows` + 1 ";
$sql .= "WHERE `ID` = {$id} LIMIT 1";
$this->query($sql);

Mahmoud Khedr
August 24, 2018, 07:30 PM
If you need to count listing visits each time the listing is opened
go to ftp > includes > classes > rlListings.inc.php > public function countVisit($id)

replace all the code inside with:



$id = (int) $id;

// get and check current IP address
$ip = $this->getClientIpAddress();

$save_ip = array(
'Listing_ID' => $id,
'IP' => $ip,
'Date' => 'NOW()',
'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),
);

$this->loadClass('Actions');
$GLOBALS['rlActions']->insertOne($save_ip, 'listings_shows');

// update shows
$sql = "UPDATE `" . RL_DBPREFIX . "listings` SET `Last_show` = NOW(), `Shows` = `Shows` + 1 ";
$sql .= "WHERE `ID` = {$id} LIMIT 1";
$this->query($sql);


hello Rudi

there are no such file rlListings.inc.php in the directory classes also i tried t add it to rlListings.class.php but it doesn't work

Rudi
August 27, 2018, 05:16 AM
sorry, it was a typo, the file is rlListings.class.php

I've checked it again on my end and it works fine,

maybe you did something wrong

Mahmoud Khedr
August 27, 2018, 10:14 AM
sorry, it was a typo, the file is rlListings.class.php

I've checked it again on my end and it works fine,

maybe you did something wrong

ok what code should i remove to add the new code ?

Kenan Mahmutovic
August 27, 2018, 02:47 PM
As fynax support explained, includes/classes/rlListings.class.php Around 2462 line

I comment old function and added new.

Use notepad++ editor for editing file.



/**
* Calc listing visits
*
* @param int $id - listing ID
**/
public function countVisit($id)
{
//default function that counts unique IP hits

/* $id = (int) $id;
$today_period = (date('G') * 3600) + (date('i') * 60) + date('s');

// get and check current IP address
$ip = $this->getClientIpAddress();

$sql = "SELECT `IP` FROM `" . RL_DBPREFIX . "listings_shows` ";
$sql .= "WHERE UNIX_TIMESTAMP(DATE_ADD(`Date`, INTERVAL {$today_period} SECOND)) > UNIX_TIMESTAMP() ";
$sql .= "AND `Listing_ID` = {$id} AND `IP` = '{$ip}' ";
$visit_ip = $this->getRow($sql);

if (empty($visit_ip)) {
$save_ip = array(
'Listing_ID' => $id,
'IP' => $ip,
'Date' => 'NOW()',
'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),
);

$this->loadClass('Actions');
$GLOBALS['rlActions']->insertOne($save_ip, 'listings_shows');

// update shows
$sql = "UPDATE `" . RL_DBPREFIX . "listings` SET `Last_show` = NOW(), `Shows` = `Shows` + 1 ";
$sql .= "WHERE `ID` = {$id} LIMIT 1";
$this->query($sql);
} */

//new function that counts all hits to listing
$id = (int) $id;

// get and check current IP address
$ip = $this->getClientIpAddress();

$save_ip = array(
'Listing_ID' => $id,
'IP' => $ip,
'Date' => 'NOW()',
'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),
);

$this->loadClass('Actions');
$GLOBALS['rlActions']->insertOne($save_ip, 'listings_shows');

// update shows
$sql = "UPDATE `" . RL_DBPREFIX . "listings` SET `Last_show` = NOW(), `Shows` = `Shows` + 1 ";
$sql .= "WHERE `ID` = {$id} LIMIT 1";
$this->query($sql);
}


Thanks to flynax support.

Mahmoud Khedr
September 14, 2018, 12:46 AM
thanks Kenan works perfect
thanks Rudi too


As fynax support explained, includes/classes/rlListings.class.php Around 2462 line

I comment old function and added new.

Use notepad++ editor for editing file.



/**
* Calc listing visits
*
* @param int $id - listing ID
**/
public function countVisit($id)
{
//default function that counts unique IP hits

/* $id = (int) $id;
$today_period = (date('G') * 3600) + (date('i') * 60) + date('s');

// get and check current IP address
$ip = $this->getClientIpAddress();

$sql = "SELECT `IP` FROM `" . RL_DBPREFIX . "listings_shows` ";
$sql .= "WHERE UNIX_TIMESTAMP(DATE_ADD(`Date`, INTERVAL {$today_period} SECOND)) > UNIX_TIMESTAMP() ";
$sql .= "AND `Listing_ID` = {$id} AND `IP` = '{$ip}' ";
$visit_ip = $this->getRow($sql);

if (empty($visit_ip)) {
$save_ip = array(
'Listing_ID' => $id,
'IP' => $ip,
'Date' => 'NOW()',
'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),
);

$this->loadClass('Actions');
$GLOBALS['rlActions']->insertOne($save_ip, 'listings_shows');

// update shows
$sql = "UPDATE `" . RL_DBPREFIX . "listings` SET `Last_show` = NOW(), `Shows` = `Shows` + 1 ";
$sql .= "WHERE `ID` = {$id} LIMIT 1";
$this->query($sql);
} */

//new function that counts all hits to listing
$id = (int) $id;

// get and check current IP address
$ip = $this->getClientIpAddress();

$save_ip = array(
'Listing_ID' => $id,
'IP' => $ip,
'Date' => 'NOW()',
'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),
);

$this->loadClass('Actions');
$GLOBALS['rlActions']->insertOne($save_ip, 'listings_shows');

// update shows
$sql = "UPDATE `" . RL_DBPREFIX . "listings` SET `Last_show` = NOW(), `Shows` = `Shows` + 1 ";
$sql .= "WHERE `ID` = {$id} LIMIT 1";
$this->query($sql);
}


Thanks to flynax support.

Nazzal
March 31, 2020, 10:41 PM
Hello,

What about Banner shows\views count, is it the same setting (per IP)?
If yes, how to change it to be per visit?
That would be very useful for banner boxes that displaying more than one Ad.

Thanks

Rudi
April 1, 2020, 08:58 AM
Hello,

if you mean banners plugin it support clicks count

Nazzal
April 1, 2020, 01:11 PM
Hello Rudi,

No I mean the shows count in banner plugin not clicks count. it comes under shows column in banners list in Admin.
So my question is that shows count worked based on IP or on visit?

if based on IP how can we change it to be per visit same as listing count visits?

Regards,
Munji

Rudi
April 1, 2020, 02:25 PM
the plugin doesn't support it by default

and I think it doesn't make sense if not by IP,

because to visit banner page you need to click it to follow the link and it counts these clicks

Wei Hong
October 6, 2022, 06:49 AM
Hi Rudi, This code is no longer work on 4.9.1. Can we have an update code for it?
I made the same change that you instructed here that worked in 4.8.1. But for 4.9.1 it does not count visit

Rudi
October 6, 2022, 08:28 AM
Hello Wei,

What code do you mean?

Wei Hong
October 6, 2022, 12:01 PM
If you need to count listing visits each time the listing is opened
go to ftp > includes > classes > rlListings.class.php > public function countVisit($id)

replace this code:


$id = (int) $id;
$today_period = (date('G') * 3600) + (date('i') * 60) + date('s');

// get and check current IP address
$ip = $this->getClientIpAddress();

$sql = "SELECT `IP` FROM `{db_prefix}listings_shows` ";
$sql .= "WHERE UNIX_TIMESTAMP(DATE_ADD(`Date`, INTERVAL {$today_period} SECOND)) > UNIX_TIMESTAMP() ";
$sql .= "AND `Listing_ID` = {$id} AND `IP` = '{$ip}' ";
$visit_ip = $this->getRow($sql);

if (empty($visit_ip)) {
$save_ip = array(
'Listing_ID' => $id,
'IP' => $ip,
'Date' => 'NOW()',
'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),
);

$this->loadClass('Actions');
$GLOBALS['rlActions']->insertOne($save_ip, 'listings_shows');

// update shows
$sql = "UPDATE `{db_prefix}listings` SET `Last_show` = NOW(), `Shows` = `Shows` + 1 ";
$sql .= "WHERE `ID` = {$id} LIMIT 1";
$this->query($sql);
}


with:


$id = (int) $id;

// get and check current IP address
$ip = $this->getClientIpAddress();

$save_ip = array(
'Listing_ID' => $id,
'IP' => $ip,
'Date' => 'NOW()',
'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),
);

$this->loadClass('Actions');
$GLOBALS['rlActions']->insertOne($save_ip, 'listings_shows');

// update shows
$sql = "UPDATE `" . RL_DBPREFIX . "listings` SET `Last_show` = NOW(), `Shows` = `Shows` + 1 ";
$sql .= "WHERE `ID` = {$id} LIMIT 1";
$this->query($sql);


Hi Rudi, I meant this code does not work anymore. I want the visit count to add up when user refresh the listing. I used this code in 4.8.1 and it worked. Everytime user refresh the listing, the visit count go up. But I tried this code again in 4.9.1, the visit count stop working.

Rudi
October 7, 2022, 02:41 AM
You need to remove this line:



'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),

Wei Hong
October 7, 2022, 03:56 PM
You need to remove this line:



'Account_ID' => intval(defined('IS_LOGIN') ? $GLOBALS['account_info']['ID'] : 0),


That did the trick, thanks Rudi