direct change view count:
SELECT * FROM cleargov1.qa_posts
where postid = 790
edit views value, apply change
==============================================
每一个点击,增加random(100-200)个virew
两个都改成这样
update views in mysql database:
------------------------------------------------
cleargov1: mysql : run sql:
update cleargov1.qa_posts
set views = views * FLOOR(RAND()*(200-100+1)+100)
--------------------------------------------------------------------------
glassgov1: mysql : run sql:
update glassgov1.carbon_topics
set views = views * FLOOR(RAND()*(200-100+1)+100)
====================================================
sql get random number > 100, but < 200
SELECT FLOOR(RAND()*(200-100+1)+100);
==================================================
every view + random (100-200)
for cleargov1:
/qa-include/db/hotness.php
change here:
......................................................................................
ffunction qa_db_increment_views($postid)
{
/* original + 1, now + random(100-200)
$query = 'UPDATE ^posts SET views=views+1, lastviewip=UNHEX($) WHERE postid=# AND (lastviewip IS NULL OR lastviewip!=UNHEX($))';
*/
/* C:\Apache24\htdocs\cleargov1\qa-include\pages\question.php
* add following line to bypass check user,cookie, cache, id, etc..
* $qa_content['inc_views_postid'] = $questionid;
*
* Below sql AND change to OR will bypass check ip
*/
$query = 'UPDATE ^posts SET views=views+FLOOR(RAND()*(200-100+1)+100), lastviewip=UNHEX($) WHERE postid=# OR (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;
}
............................................................................................................................................
// bypass check user id, user cookie, ip, etc. any click by any one will count to increase page views.
// comment this out, if you want check user
$qa_content['inc_views_postid'] = $questionid;
return $qa_content;
views count above
called here /qa-include/qa-page.php
===================================
glassgov1:
change here:
C:\Apache24\htdocs\glassgov1\controller\topic.php
+ 1 change to + FLOOR(RAND()*(200-100+1)+100)
only change 1 place : other + 1 no need to change
SET Views = Views+1,LastViewedTime
to
SET Views = Views+FLOOR(RAND()*(200-100+1)+100),LastViewedTime
//更新浏览量
if ($MCache) {
$TopicViews = $MCache->get(MemCachePrefix . 'Topic_Views_' . $ID);
//30天内攒满200次点击,Update一次数据库数据
if ($TopicViews && ($TopicViews - $Topic['Views']) >= 200) {
$DB->query("UPDATE " . PREFIX . "topics
FORCE INDEX(PRI)
SET Views = :Views,LastViewedTime = :LastViewedTime Where ID=:ID", array(
'Views' => $TopicViews + 1,
"LastViewedTime" => $TimeStamp,
"ID" => $ID
));
//清理主题缓存
$MCache->delete(MemCachePrefix . 'Topic_' . $ID);
}
$Topic['Views'] = (($TopicViews) ? $TopicViews : $Topic['Views']) + 1;
$MCache->set(MemCachePrefix . 'Topic_Views_' . $ID, $Topic['Views'], 86400 * 30);
} else {
$DB->query("UPDATE " . PREFIX . "topics
FORCE INDEX(PRI)
SET Views = Views+1,LastViewedTime = :LastViewedTime Where ID=:ID", array(
"LastViewedTime" => $TimeStamp,
"ID" => $ID
));
}
==================================================
every view + random (100-200)
for cleargov1:
/qa-include/db/hotness.php
change here:
......................................................................................
ffunction qa_db_increment_views($postid)
{
/* original + 1, now + random(100-200)
$query = 'UPDATE ^posts SET views=views+1, lastviewip=UNHEX($) WHERE postid=# AND (lastviewip IS NULL OR lastviewip!=UNHEX($))';
*/
/* C:\Apache24\htdocs\cleargov1\qa-include\pages\question.php
* add following line to bypass check user,cookie, cache, id, etc..
* $qa_content['inc_views_postid'] = $questionid;
*
* Below sql AND change to OR will bypass check ip
*/
$query = 'UPDATE ^posts SET views=views+FLOOR(RAND()*(200-100+1)+100), lastviewip=UNHEX($) WHERE postid=# OR (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;
}
............................................................................................................................................
C:\Apache24\htdocs\cleargov1\qa-include\pages\question.php
add one line at bottom:
$qa_content['inc_views_postid'] = $questionid;
// bypass check user id, user cookie, ip, etc. any click by any one will count to increase page views.
// comment this out, if you want check user
$qa_content['inc_views_postid'] = $questionid;
return $qa_content;
views count above
called here /qa-include/qa-page.php
===================================
glassgov1:
change here:
C:\Apache24\htdocs\glassgov1\controller\topic.php
+ 1 change to + FLOOR(RAND()*(200-100+1)+100)
only change 1 place : other + 1 no need to change
SET Views = Views+1,LastViewedTime
to
SET Views = Views+FLOOR(RAND()*(200-100+1)+100),LastViewedTime
//更新浏览量
if ($MCache) {
$TopicViews = $MCache->get(MemCachePrefix . 'Topic_Views_' . $ID);
//30天内攒满200次点击,Update一次数据库数据
if ($TopicViews && ($TopicViews - $Topic['Views']) >= 200) {
$DB->query("UPDATE " . PREFIX . "topics
FORCE INDEX(PRI)
SET Views = :Views,LastViewedTime = :LastViewedTime Where ID=:ID", array(
'Views' => $TopicViews + 1,
"LastViewedTime" => $TimeStamp,
"ID" => $ID
));
//清理主题缓存
$MCache->delete(MemCachePrefix . 'Topic_' . $ID);
}
$Topic['Views'] = (($TopicViews) ? $TopicViews : $Topic['Views']) + 1;
$MCache->set(MemCachePrefix . 'Topic_Views_' . $ID, $Topic['Views'], 86400 * 30);
} else {
$DB->query("UPDATE " . PREFIX . "topics
FORCE INDEX(PRI)
SET Views = Views+1,LastViewedTime = :LastViewedTime Where ID=:ID", array(
"LastViewedTime" => $TimeStamp,
"ID" => $ID
));
}
No comments:
Post a Comment