Support Forums - Classified Ads Script Osclass
General osclass questions => Report bug => Topic started by: katalin2k on January 05, 2025, 05:04:56 PM
-
In admin backend when I go to see all listings view count is not working: https://prnt.sc/wr_HZoi81FEj
I use latest OSC.
-
Views are not counted for users logged-in as admin.
-
I understand that but I also browse incognito to make tests and it seems that it doesn't count any of that also. As you can see in the attached image it shows 0 for all and some show 0x0x, which is very strange.
-
There could be some issue, try to debug osclass and see errors. Also database logs.
Check this section in oc-includes/osclass/controller/item.php
if(!osc_is_admin_user_logged_in() && !($item['fk_i_user_id']!='' && $item['fk_i_user_id']==osc_logged_user_id())) {
require_once(osc_lib_path() . 'osclass/user-agents.php');
foreach($user_agents as $ua) {
if(preg_match('|'.$ua.'|', Params::getServerParam('HTTP_USER_AGENT'))) {
$mStats = new ItemStats();
$mStats->increase('i_num_views', $item['pk_i_id']);
break;
}
}
}
-
Mine looks like this:
if(!osc_is_admin_user_logged_in() && !(osc_is_web_user_logged_in() && $item['fk_i_user_id'] == osc_logged_user_id())) {
require_once(osc_lib_path() . 'osclass/user-agents.php');
foreach($user_agents as $ua) {
if(preg_match('|'.$ua.'|', Params::getServerParam('HTTP_USER_AGENT'))) {
$mStats = new ItemStats();
$mStats->increase('i_num_views', $item['pk_i_id']);
break;
}
}
}
I tried to replace with yours but I still get 0 views in backend for each listing. Frontend views work fine, the issue is in admin backend.
-
I have not told to replace, just pointed you where to look and debug.
-
Ok but I am not very experienced so I can’t make it work…
-
You should have tech person that can help you with such issues or look for developer.
Unfortunately, for open-source there is never dedicated support that would solve your specific issues.
-
You should have tech person that can help you with such issues or look for developer.
Unfortunately, for open-source there is never dedicated support that would solve your specific issues.
But this is a bug from osclass, don't you think some developer that helped build it should try and help me fix the issue?
-
No, as it looks like issue on your side (never seen anyone having such problem). You must debug by yourself.
-
There could be some issue, try to debug osclass and see errors. Also database logs.
Check this section in oc-includes/osclass/controller/item.php
if(!osc_is_admin_user_logged_in() && !($item['fk_i_user_id']!='' && $item['fk_i_user_id']==osc_logged_user_id())) {
require_once(osc_lib_path() . 'osclass/user-agents.php');
foreach($user_agents as $ua) {
if(preg_match('|'.$ua.'|', Params::getServerParam('HTTP_USER_AGENT'))) {
$mStats = new ItemStats();
$mStats->increase('i_num_views', $item['pk_i_id']);
break;
}
}
}
Isn't this code for adding new views to listings? I said I see 0x views in admin backend under Listings section.
-
Correct, it is, so you should debug it and identify which part it does not like.
My guess is that it might be related to user agents.
Try this.
Go to oc-includes/osclass/user-agents.php
Replace old list:
$user_agents = array(
'MSIE ([0-9].*)$',
'^Mozilla/[0-9].([^c][^o][^m].)$',
'^Mozilla/5.*Gecko',
'^Mozilla/5.(PLAYSTATION.)',
'Safari',
'Omni',
'iCab',
'Opera',
'Konqueror',
'AOL',
'MSN',
'WebTV',
'BlackBerry.*'
);
With new list:
$user_agents = array(
'MSIE ([0-9].*)$',
'^Mozilla/[0-9].([^c][^o][^m].)$',
'^Mozilla/5.*Gecko',
'^Mozilla/5.(PLAYSTATION.)',
'Safari',
'Omni',
'iCab',
'Opera',
'Konqueror',
'AOL',
'MSN',
'WebTV',
'BlackBerry.*',
'Trident/.*rv:11\.0',
'Chrome',
'CriOS',
'FxiOS',
'Edge',
'Edg/',
'OPR',
'Firefox',
'SamsungBrowser',
'UCBrowser'
);
-
Correct, it is, so you should debug it and identify which part it does not like.
My guess is that it might be related to user agents.
Try this.
Go to oc-includes/osclass/user-agents.php
Replace old list:
$user_agents = array(
'MSIE ([0-9].*)$',
'^Mozilla/[0-9].([^c][^o][^m].)$',
'^Mozilla/5.*Gecko',
'^Mozilla/5.(PLAYSTATION.)',
'Safari',
'Omni',
'iCab',
'Opera',
'Konqueror',
'AOL',
'MSN',
'WebTV',
'BlackBerry.*'
);
With new list:
$user_agents = array(
'MSIE ([0-9].*)$',
'^Mozilla/[0-9].([^c][^o][^m].)$',
'^Mozilla/5.*Gecko',
'^Mozilla/5.(PLAYSTATION.)',
'Safari',
'Omni',
'iCab',
'Opera',
'Konqueror',
'AOL',
'MSN',
'WebTV',
'BlackBerry.*',
'Trident/.*rv:11\.0',
'Chrome',
'CriOS',
'FxiOS',
'Edge',
'Edg/',
'OPR',
'Firefox',
'SamsungBrowser',
'UCBrowser'
);
Replaced code but I still see 0x views for all listings in admin Manage listings: https://prnt.sc/wzzSMAc6S-Dm
-
>>> database debug.
-
>>> database debug.
A little more specific please?
-
https://docs.osclass-classifieds.com/debug-mode-php-errors-and-database-logs-i72
Enable database queries debug, store it to file (as it can be seen as admin only and for admins views are not collected) and review if there are any red related to views statistics.
-
https://docs.osclass-classifieds.com/debug-mode-php-errors-and-database-logs-i72
Enable database queries debug, store it to file (as it can be seen as admin only and for admins views are not collected) and review if there are any red related to views statistics.
I did and did not get any error related...
-
Ok, how your item views update statement looks like? Have you run it on DB? What you got as result?