Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
in Q2A Core by
edited by

I already tried this solutions:

Look at the bottom of pages/question.php. There's a big if statement with various checks. You can remove the two IP checks (the ones with "different IP" comments).

Also I remove the below line of codes from that function.

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, then it must be different IP & user & cookieid from the creator
        (@inet_ntop($question['createip']) != qa_remote_ip_address() || !isset($question['createip'])) &&
        ($question['userid'] != $userid || !isset($question['userid'])) &&
        ($question['cookieid'] != $cookieid || !isset($question['cookieid']))
And just put the below code instead 

$qa_content['inc_views_postid'] = $questionid;

But it didn't work properly for me or I actually didn't understand what should will do.

Q2A version: 1.8.5

1 Answer

+1 vote
selected by
Best answer

1. Edit this line:


2. Turn it into:

$query = 'UPDATE ^posts SET views=views+1, lastviewip=UNHEX($) WHERE postid=#';

3. Edit this line:


4. Turn it into:

qa_db_query_sub($query, $ipHex, $postid);

5. Edit this whole IF statement:


6. Turn it into:

if (qa_opt('do_count_q_views') && !$formrequested && !qa_is_http_post() && qa_is_human_probably()) {

$qa_content['inc_views_postid'] = $questionid;


I tried this but unfortunately this is not working. Is there any other way ? Can you tell me please what actually the problem ? Thanks in advance.
You're correct. I hadn't tested this. Take a look at the updated answer
Oh! you are really great . Now your solution is perfectly working.
Worked great!  Thanx!
Wondering if there is a site wide view stats...