Welcome Guest. Please Login or Register  


You are here: Index > Advanced Electron Forums > Bugs > Not a Bug > Topic : The views bug


News:

Group Message
Hello Guest,

Welcome to the AEF Board. AEF is getting better and better and is also becoming more popular.
Take a few seconds to Register, its free, and it inspires us to work harder and improve on whatever we can improve on.
Give us some feedback, and tell your buddies about AEF!

Thanks,
The AEF Team

1


Threaded Mode | Print  

 The views bug (23 Replies, Read 40273 times)
nfsalon
Group: Member
Post Group: Working Newbie
Posts: 81
Status:
Every refresh the view counter counts up and this is bug that easy to fix.
Here the fix:





File: "setup/mysql.php"

Find:
PHP Code

 t_description mediumtext NOT NULL



Add after:
PHP Code

 viewed mediumtext NOT NULL







File: "main/posts.php"

Find:
PHP Code

 'n_posts' => $tmp['n_posts'], 



Add after:
PHP Code

 'viewed' => $tmp['viewed'], 



Find:
PHP Code

 $qresult makequery("UPDATE ".$dbtables['topics']."
   SET n_views = n_views + 1 &nbs p; 
   WHERE tid = "
.$topic['tid'], false); 



Replace:
PHP Code

 if ($_SERVER['HTTP_X_FORWARD_FOR']) {
  
$viewed_ip $_SERVER['HTTP_X_FORWARD_FOR'];
 } else {
  
$viewed_ip $_SERVER['REMOTE_ADDR'];
 }
 
 
//UPDATE the Views of the Topic
 
if(preg_match('|'.$viewed_ip.'|'$topic['viewed'])){
 }else{
 
  
$viewed_ip $topic['viewed'].' |'.$viewed_ip.'|';
  
$globals['add'] = 1;
  
$qresult makequery("UPDATE ".$dbtables['topics']."
    SET n_views = n_views + 1,     viewed = '"
.$viewed_ip."'
    WHERE tid = "
.$topic['tid'], false);
 } 







Done ^^

-----------------------
Board Image
IP: --   

The views bug
VasiliyRS
Group: Support
Post Group: Working Member
Posts: 212
Status:
Doesnt work - i get blank page when trying to browe any topic ...

i guess error is there
Code
if ($_SERVER['HTTP_X_FORWARD_FOR']) {
  $viewed_ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
  $viewed_ip = $_SERVER['REMOTE_ADDR'];
}

//UPDATE the Views of the Topic
if(preg_match('|'.$viewed_ip.'|', $topic['viewed'])){
}else{

  $viewed_ip = $topic['viewed'].' |'.$viewed_ip.'|';
  $globals['add'] = 1;
  $qresult = makequery("UPDATE ".$dbtables['topics']."
    SET n_views = n_views + 1,
    viewed = '".$viewed_ip."'
    WHERE tid = ".$topic['tid'], false);
}


Edited by VasiliyRS : January 15, 2010, 9:15 pm

-----------------------
For quick AEF help join our IRC channel :
http://anelectron.com/board/index.php?tid=6469
Contribute to AEF: https://github.com/AEFGroup/Advanced-Electron-Forum

Board Image
IP: --   

The views bug
Lewtheo
Group: Member
Post Group: Super Member
Posts: 579
Status:
Hello.

My name is Lewis Theobald, developer at OpenInferno

PHP Code

 if ($_SERVER['HTTP_X_FORWARD_FOR']) {
  
$viewed_ip $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
  
$viewed_ip $_SERVER['REMOTE_ADDR'];
}

//UPDATE the Views of the Topic
if(!preg_match('#|'.$viewed_ip.'|#'$topic['viewed'])){
  
$viewed_ip $topic['viewed'].' |'.$viewed_ip.'|';
  
$globals['add'] = 1;
  
$qresult makequery("UPDATE ".$dbtables['topics']."
    SET n_views = n_views + 1,     viewed = '"
.$viewed_ip."'
    WHERE tid = "
.$topic['tid'], false);




I haven't personally got AEF running, but having an empty IF statement is not needed when you can NOT the statement. (!preg_match)

And for a preg search, you need some index definition e.g. # around both parts.

It is a very messy code, I must admit. I would say storing  IP's viewed in a list e.g. 127.0.0.1,127.0.0.2

Then you can use explode to get them into an array, then search through the array :)

But either way, as long as it works

-----------------------
Swoova - the next generation social network experience.
IP: --   

The views bug
nfsalon
Group: Member
Post Group: Working Newbie
Posts: 81
Status:
Im new to PHP, when I created the guide I didnt know how to explode / implode the text...
I dont work anymore with AEF, so nevermined it...

-----------------------
Board Image
IP: --   

The views bug
Lewtheo
Group: Member
Post Group: Super Member
Posts: 579
Status:
Ah fair enough

Same here, I'm trying my best to get something sorted with little cooperation really.. shame it could have had so much more potential, with a more smooth theme and code.. oh well

If you ever need PHP help, ask :)

Helps me learn too :)

-----------------------
Swoova - the next generation social network experience.
IP: --   

The views bug
VasiliyRS
Group: Support
Post Group: Working Member
Posts: 212
Status:
Quote
If you ever need PHP help, ask :)

Can you fix this code to get it working ?

-----------------------
For quick AEF help join our IRC channel :
http://anelectron.com/board/index.php?tid=6469
Contribute to AEF: https://github.com/AEFGroup/Advanced-Electron-Forum

Board Image
IP: --   

The views bug
christianfermin
Group: Member
Post Group: Newbie
Posts: 35
Status:
nfsalon, I was waiting for your version.  :??: .  What happened? I'd like to see what you did so far. ....




Letheo, do you have an award system implemented on AEF?

example: can you award users medals?

uploader of the month award , most thanked award, etc?
Board Image
IP: --   

The views bug
Lewtheo
Group: Member
Post Group: Super Member
Posts: 579
Status:
Hello

I don't develop for AEF any-more sorry, I can complete simple PHP stuff

But all my mods etc are abandoned projects now as I moved over to MyBB which in my eyes was much more stable and easier to use

Sorry about that, no such award system from me.

-----------------------
Swoova - the next generation social network experience.
IP: --   

The views bug
nfsalon
Group: Member
Post Group: Working Newbie
Posts: 81
Status:
http://guy.pointserv.net/forum/avatars/aef/

-----------------------
Board Image
IP: --   

The views bug
christianfermin
Group: Member
Post Group: Newbie
Posts: 35
Status:
hello

Nfsalon, that was a good version , you have. Are you going to make it available for people that wants to use it?

I like what you did with the registration page. When creating an username it tells you right away if its valid or not.  I guess is javascritpt?


Nice version .
IP: --   

The views bug
nfsalon
Group: Member
Post Group: Working Newbie
Posts: 81
Status:
I left developing this version because I dont have enough time, and also because AEF dead.

-----------------------
Board Image
IP: --   

The views bug
christianfermin
Group: Member
Post Group: Newbie
Posts: 35
Status:
:squi: You're not developing that version anymore? It was great.  Can you tell me how you did the Javascript you used in the registration page, that validates the user input instantly? I loved that, I hope your willing to share.
IP: --   

The views bug
nfsalon
Group: Member
Post Group: Working Newbie
Posts: 81
Status:
Sure.
http://livevalidation.com/

-----------------------
Board Image
IP: --   

The views bug
VasiliyRS
Group: Support
Post Group: Working Member
Posts: 212
Status:
Again to new developers . the solution above doesnt work so please fix it in next coming aef release .

-----------------------
For quick AEF help join our IRC channel :
http://anelectron.com/board/index.php?tid=6469
Contribute to AEF: https://github.com/AEFGroup/Advanced-Electron-Forum

Board Image
IP: --   

The views bug
Yagiz
Group: Member
Post Group: Newbie
Posts: 7
Status:
Easy fix. Find in ./main/posts.php:
PHP Code

 //UPDATE the Views of the Topic
        
$qresult makequery("UPDATE ".$dbtables['topics']."
                 SET n_views = n_views + 1             
                 WHERE tid = "
.$topic['tid'], false); 


Replace with:
PHP Code

 //UPDATE the Views of the Topic
    
if (empty($AEF_SESS['lastreadtopic']) || $AEF_SESS['lastreadtopic'] != $topic['tid']){
        
$qresult makequery("UPDATE ".$dbtables['topics']."
                 SET n_views = n_views + 1             
                 WHERE tid = "
.$topic['tid'], false);
        
$AEF_SESS['lastreadtopic'] = $topic['tid'];
    } 




Find in ./main/newtopic.php:
PHP Code

 //Store the last post time
        
$AEF_SESS['last_post'] = time(); 


Add after:
PHP Code

 //Let users to update their own topics'&n bsp;view count
        
$AEF_SESS['lastreadtopic'] = 0




Edited by Yagiz : June 20, 2010, 10:24 pm
IP: --   

« Previous    Next »

Threaded Mode | Print  

1


Jump To :


Members who read this topic
, jlhaslip, Lewtheo, Alex, nfsalon, aryan, Pico4U, Buster, christianfermin, VasiliyRS, tut4ever, Torrentspy, Yukihide, XemiX, SAFAD, Yagiz, Orstio, edybest, ShaunY, midolove, haylau, LaBrie, gvhools, GamingChitChat, CruzBishop, IATIA, keith969, nexgenforum


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is July 19, 2018, 8:18 am.

  Powered By AEF 1.1.0 Preview © 2007-2011 AEF Group. All rights reservedQueries: 13  |  Page Created In:0.138