Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Is this the correct way to allow any question view, including same IP, to be counted?

+1 vote
34 views
asked Sep 21 in Q2A Core by Ronlaw

Out of the box Q2A doesn't count more than one question view from the same person. I made some changes that allows that. My concern is I might have done something wrong that breaks something else.

The highlighted pieces in yellow were commented out.

1. /qa-include/pages/question.php line 461

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']))

))*/

) {

$qa_content['inc_views_postid'] = $questionid;

}

2. /qa-include/db/hotness.php line 33

function qa_db_increment_views($postid)

{

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

/*$ipHex = bin2hex(@inet_pton(qa_remote_ip_address()));*/


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


return qa_db_affected_rows() > 0;

}

Please log in or register to answer this question.

...