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.

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:
if (empty($_GET['com_id']) && $storypage == 0) {
    
$article->updateCounter();
}

and modify it to this:
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.

Login

Who's Online

375 user(s) are online (223 user(s) are browsing Support Forums)


Members: 0


Guests: 375


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits