1
mouacy
news read count hack
  • 2005/1/19 21:58

  • mouacy

  • Not too shy to talk

  • Posts: 138

  • Since: 2002/11/2


I need to modify the news module to prevent a user from increasing count read on his/her own articles by clicking multiple times. Has anyone made some similar change? Where and which file can I go to add a condition to "not count click" from the author, the same previous user?

2
mouacy
Re: news read count hack
  • 2005/1/20 8:31

  • mouacy

  • Not too shy to talk

  • Posts: 138

  • Since: 2002/11/2


ok. No reply so i thought I try something... and here is what i got... I edit the

class.sfiles.php file in the modules/news/class directory to add the following codes to after the line 161 in the updateCounter fuction. here is how it looks... but it doesn't seem to work.

le="color: #000000"><?php function updateCounter() { //hacked to prevent same author or user read count $active_ip = getenv("REMOTE_ADDR"); $sql="SELECT hostname FROM".$this->table." WHERE hostname=".$this->getFileid(); $host_ip=$this->db->queryF($sql); //echo $active_ip; $host_ip=$hostname; if ($active_ip==$host_ip || $active_ip==$last_ip) { return false; }else{ $last_ip=$active_ip; //hack ends here $sql = "UPDATE ".$this->table." SET counter=counter+1 WHERE fileid=".$this->getFileid(); if(!$result = $this->db->queryF($sql)) { return false; } return true; } }


I hope someone can help me with this.

3
Mithrandir
Re: news read count hack

sFiles is short for "storyFiles" i.e. it has nothing to do with the story counter.

Also, you have a $xoopsUser object to work with to identify users, hacking to compare IP's etc. is not needed.

Instead work with article.php and fin this:
le="color: #000000"><?php if (empty($_GET['com_id']) && $storypage == 0) { $article->updateCounter(); }

and modify it to this:
le="color: #000000"><?php if (empty($_GET['com_id']) && $storypage == 0) { if (!$xoopsUser || $xoopsUser->getVar('uid') != $article->uid() ) { $article->updateCounter(); } }

4
mouacy
Re: news read count hack
  • 2005/1/20 8:52

  • mouacy

  • Not too shy to talk

  • Posts: 138

  • Since: 2002/11/2


Thanks for the quick reply. That is not so difficult

I will make good use of it.