Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
694 views
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
by
selected by
 
Best answer

1. Edit this line:

https://github.com/q2a/question2answer/blob/947a970beb76168a3ab1f4cbd0af468a168121c6/qa-include/db/hotness.php#L35

2. Turn it into:

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

3. Edit this line:

https://github.com/q2a/question2answer/blob/947a970beb76168a3ab1f4cbd0af468a168121c6/qa-include/db/hotness.php#L37

4. Turn it into:

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

5. Edit this whole IF statement:

https://github.com/q2a/question2answer/blob/4344721c138e7f6845a8129278c9d3374daee085/qa-include/pages/question.php#L463-L472

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;

}

by
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.
by
You're correct. I hadn't tested this. Take a look at the updated answer
by
Oh! you are really great . Now your solution is perfectly working.
by
Worked great!  Thanx!
Wondering if there is a site wide view stats...
...