Support Forums - Classified Ads Script Osclass

General osclass questions => Report bug => Topic started by: katalin2k on January 05, 2025, 05:04:56 PM

Title: Admin listings views not working
Post 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.
Title: Re: Admin listings views not working
Post by: MB Themes on January 08, 2025, 11:06:02 AM
Views are not counted for users logged-in as admin.
Title: Re: Admin listings views not working
Post by: katalin2k on January 08, 2025, 09:08:42 PM
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.
Title: Re: Admin listings views not working
Post by: MB Themes on January 11, 2025, 08:47:33 PM
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

Code: [Select]
        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;

            }
          }
        }
Title: Re: Admin listings views not working
Post by: katalin2k on January 13, 2025, 10:18:00 PM
Mine looks like this:
Code: [Select]
        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.
Title: Re: Admin listings views not working
Post by: MB Themes on January 21, 2025, 07:54:41 AM
I have not told to replace, just pointed you where to look and debug.
Title: Re: Admin listings views not working
Post by: katalin2k on January 23, 2025, 08:30:17 PM
Ok but I am not very experienced so I can’t make it work…
Title: Re: Admin listings views not working
Post by: MB Themes on January 27, 2025, 07:24:25 AM
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.
Title: Re: Admin listings views not working
Post by: katalin2k on January 27, 2025, 08:52:35 PM
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?
Title: Re: Admin listings views not working
Post by: MB Themes on January 28, 2025, 09:48:52 PM
No, as it looks like issue on your side (never seen anyone having such problem). You must debug by yourself.
Title: Re: Admin listings views not working
Post by: katalin2k on February 09, 2025, 05:31:38 PM
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

Code: [Select]
        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.
Title: Re: Admin listings views not working
Post by: MB Themes on February 10, 2025, 09:36:39 AM
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:
Code: [Select]
$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:
Code: [Select]
  $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'
  );
Title: Re: Admin listings views not working
Post by: katalin2k on February 10, 2025, 06:27:44 PM
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:
Code: [Select]
$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:
Code: [Select]
  $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
Title: Re: Admin listings views not working
Post by: MB Themes on February 12, 2025, 03:09:29 PM
>>> database debug.
Title: Re: Admin listings views not working
Post by: katalin2k on February 12, 2025, 09:22:05 PM
>>> database debug.
A little more specific please?
Title: Re: Admin listings views not working
Post by: MB Themes on February 13, 2025, 08:45:09 AM
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.
Title: Re: Admin listings views not working
Post by: katalin2k on February 15, 2025, 09:41:04 PM
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...
Title: Re: Admin listings views not working
Post by: MB Themes on February 16, 2025, 10:59:18 AM
Ok, how your item views update statement looks like? Have you run it on DB? What you got as result?