Block unfair hits

General questions relating to Joomla! 3.x. Please consider the availability of third-party templates and extensions when deciding which Joomla version to use.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Post Reply
promoitalia
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Sep 26, 2018 7:23 am

Block unfair hits

Post by promoitalia » Wed Sep 26, 2018 7:41 am

Dear Sir,

as you well know, visits to joomla articles (hits) increase by reloading the page and this is not fair. It is also true that if a person goes to read the same article several times in a day it is right that the reading increases.
Is it possible to block the wise ones that increase the readings to their article with F5 limiting the increase in visits after 1 hour?
If I do F5 continuously does not increase the reading, if I return to read it after an hour it is right to count a new hit.
I hope to solve with your advice,

best regards

Walter
Last edited by toivo on Wed Sep 26, 2018 8:04 am, edited 1 time in total.
Reason: mod note: moved, not related to 3.x Extensions

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Sep 26, 2018 8:36 am

i guess it will not solve the problem unless you close the articles from unregistered visitors, because hundreds of bots will increase the counter.

promoitalia
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Sep 26, 2018 7:23 am

Re: Block unfair hits

Post by promoitalia » Wed Sep 26, 2018 9:11 am

it would be enough to set the time limiting with ip?
but I do not know how I can do it

KianWilliam
Joomla! Explorer
Joomla! Explorer
Posts: 400
Joined: Thu Jan 12, 2017 10:13 am

Re: Block unfair hits

Post by KianWilliam » Wed Sep 26, 2018 9:53 am

You mean based on $remoteAddr you want to allow visitors of your site read your articles based on a timescale and after that for like 24 hours they are not able to read more?
Kian William

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Sep 26, 2018 10:01 am

i mean what today this counter show unreal hight numbers because of many site scanners/bots so you cant use it as valid visitor counter unless u block content from unregistered users.
and IP isnt enough because of proxy servers.

promoitalia
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Sep 26, 2018 7:23 am

Re: Block unfair hits

Post by promoitalia » Wed Sep 26, 2018 10:11 am

what concerns me to limit are the young guys who go on an acquaintance's article and with F5 the visits increase. I just block these, not even novice hackers

KianWilliam
Joomla! Explorer
Joomla! Explorer
Posts: 400
Joined: Thu Jan 12, 2017 10:13 am

Re: Block unfair hits

Post by KianWilliam » Wed Sep 26, 2018 10:30 am

How could you know those visitors are young or old? how you check it?
Kian William

promoitalia
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Sep 26, 2018 7:23 am

Re: Block unfair hits

Post by promoitalia » Wed Sep 26, 2018 10:44 am

I know because they told me

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Sep 26, 2018 10:48 am

i guess u can try increase "session time" for 2-3 hours. if i understand it right this counter must use session or cookies.
but this is not recommended via increasing security risks.
so the right solution will be making plugin for decreasing hitcounter based on cookies or even IP (in this case your DB size will increased).
example
https://joomla.stackexchange.com/questi ... -the-pages

KianWilliam
Joomla! Explorer
Joomla! Explorer
Posts: 400
Joined: Thu Jan 12, 2017 10:13 am

Re: Block unfair hits

Post by KianWilliam » Wed Sep 26, 2018 10:54 am

I can tell you what to do to limit time access to an article for registered users and prevent them from being logged for a spell of time but your viewers could be of any age unless you develop a form that requires a copy of birth-cirtificate. There might be other ways but I developed this simple logic as I am typing, if it could be of use, I will be happy to help you.
Kian William

promoitalia
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Sep 26, 2018 7:23 am

Re: Block unfair hits

Post by promoitalia » Wed Sep 26, 2018 12:03 pm

it is not a counter but hits the joomla article
it would be enough for me to limit the bill at any hour. if a visitor starts to do F5 does not count, but counts if he returns after one hour

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Sep 26, 2018 12:15 pm

promoitalia wrote:
Wed Sep 26, 2018 12:03 pm
it is not a counter but hits the joomla article
this is EXACTLY the same (hits = visit/view counter).
if you cant understand how to solve problem based on my advise you must hire programmer for this.
or maybe there is free plugin for this but i cant find one.

promoitalia
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Sep 26, 2018 7:23 am

Re: Block unfair hits

Post by promoitalia » Wed Sep 26, 2018 1:44 pm

I think the only way will be the plugin that you have recommended to me, thank you very much.
I think that joomla should adopt this default option
thank you so much

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Sep 26, 2018 1:54 pm

i agree. i will post this suggestion to Joomla 4 thread.

promoitalia
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Sep 26, 2018 7:23 am

Re: Block unfair hits

Post by promoitalia » Wed Sep 26, 2018 1:56 pm

but it would be necessary to find a way for the memory of the database to be deleted every hour, is it possible with a cron? but how do you do it?
the plugin allows you to count a single visit forever, works on groups but you can not set a refresh time?

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Sep 26, 2018 2:12 pm

the logic depend of where you will store visited articles ID's.
if u make it based on Cookies then DB will be not involved. so u only consern will be this Cookie size.

and for DB you can use cron and clean this table every 1 weak, for example.

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 11724
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Block unfair hits

Post by brian » Wed Sep 26, 2018 2:13 pm

You do realise that it is optional to display the hits - personally the first thing I do on a site is to make sure it is not displaying hits on the frontend
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Sep 26, 2018 2:15 pm

@brian, we talk about make it useful not invisible.

promoitalia
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Sep 26, 2018 7:23 am

Re: Block unfair hits

Post by promoitalia » Wed Sep 26, 2018 2:25 pm

could you give me a directive how I can use the cron?

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Sep 26, 2018 2:30 pm

sorry, i am not such developer.
and firstly u must make the plugin.

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Sat Sep 29, 2018 4:03 pm

Look like we have good chance to get rid of mad increment in 3.x version.
and i made simple plugin for writing id of articles in cookies, so bright future is near ).

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Tue Oct 02, 2018 6:25 pm

I made the plugin. It use cookies and prevent multiply hits count, also visits of search bots don't count.
https://yadi.sk/d/lkyrvAibes66Ag

SharkyKZ
Joomla! Ace
Joomla! Ace
Posts: 1332
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: Block unfair hits

Post by SharkyKZ » Wed Oct 03, 2018 6:59 am

effrit wrote:
Tue Oct 02, 2018 6:25 pm
I made the plugin. It use cookies and prevent multiply hits count, also visits of search bots don't count.
https://yadi.sk/d/lkyrvAibes66Ag
Logic should be reversed. Hits should be blocked when needed, not by default. Now they're blocked everywhere.

You can also get category ID from input instead from model. This will avoid unnecessary DB query.

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Oct 03, 2018 7:13 am

The logic is right.
Because for corporate site with blog, for example, u need only one category with counter and other will be without it. Just because of DB caching. This is how i see it.
So if anyone want different logic he must change the code.
Thanks for catID suggestion, will use it.

SharkyKZ
Joomla! Ace
Joomla! Ace
Posts: 1332
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: Block unfair hits

Post by SharkyKZ » Wed Oct 03, 2018 7:29 am

I don't think you understood me. You are now blocking hits on all components. This is because you set hitcount to 0 on all pages. Instead, you should set it after performing the checks in your plugin.

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Oct 03, 2018 7:34 am

Hm, look like i must check "context" then.

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Oct 03, 2018 12:27 pm

@SharkyKZ, seems i cant deactivate hits only for com_content.
i tried other plugin triggers but problem is the hit DB query already done if trigger not onAfterInitialise.
and inside this trigger i cant get context data, so it's dead end...
but good part is - PR we made is merged, so in next Joomla version disabling standard articles hits will be possible via options so i will can remove this part from plugin.

also getting category ID don't look safe because for uncategorised articles it return nothing, so i must assume what current id = 2:
$catid = $jinput->getInt('catid', 2);

SharkyKZ
Joomla! Ace
Joomla! Ace
Posts: 1332
Joined: Fri Jul 05, 2013 10:35 am
Location: Unknown

Re: Block unfair hits

Post by SharkyKZ » Wed Oct 03, 2018 2:28 pm

Use onAfterRoute.
also getting category ID don't look safe because for uncategorised articles it return nothing
In Joomla articles can't be uncategorised. Each article must have a category assigned.

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Oct 03, 2018 2:33 pm

try get ID of article inside uncategorised via input.
it return nothing.
for other categories it return number.

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: Block unfair hits

Post by effrit » Wed Oct 03, 2018 3:20 pm

implemented suggestions of SharkyKZ, new version.
https://yadi.sk/d/IypdyLc5zz8sKg


Post Reply

Return to “General Questions/New to Joomla! 3.x”