Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
577 views
in Q2A Core by
Before I go digging through the code, does anyone have an idea why views are not incrementing?

The site is at http://www.noblood.org/answers/

Thank you :)
Q2A version: 1.5.1

3 Answers

0 votes
by

Perhaps the user's IP address is not being provided by the web server in the usual way? The code to debug is at the end of qa-page-question.php.

+1 vote
by
I had to comment out:

//(!qa_is_http_post()) &&

This works now. Don't ask me why.

//    Determine whether this request should be counted for page view statistics

    if (
        qa_opt('do_count_q_views') &&
        (!$formrequested) &&
        //(!qa_is_http_post()) &&
        qa_is_human_probably() &&
        ( (!$question['views']) || ( // if it has more than zero views
            ( ($question['lastviewip']!=qa_remote_ip_address()) || (!isset($question['lastviewip'])) ) && // then it must be different IP from last view
            ( ($question['createip']!=qa_remote_ip_address()) || (!isset($question['createip'])) ) && // and different IP from the creator
            ( ($question['userid']!=$userid) || (!isset($question['userid'])) ) && // and different user from the creator
            ( ($question['cookieid']!=$cookieid) || (!isset($question['cookieid'])) ) // and different cookieid from the creator
        ) )
    )
        $qa_content['inc_views_postid']=$questionid;
+1 vote
by
edited by

 

If you have a reverse proxy or a load balancer at your network and it replaces the client ip address with it own ip address,

you can solve it by telling the server to look at the original ip address that stored in the HTTP header  (called HTTP_X_FORWARDED_FOR)

changing the file - qa-base.php

in the function qa_remote_ip_address()

replcae this line:

return @$_SERVER['REMOTE_ADDR'];

with:

 

//return @$_SERVER['REMOTE_ADDR'];
$arr=explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]);
return $arr[0];
 
Sharon.
My new faq page - 
 
...