Moderator: Moderators


//
// Update the topic view counter
//
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_views = topic_views + 1
WHERE topic_id = $topic_id";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
}
if($cached1 || $cached2)
{
$update_list = array();
for($i=0; $i<count($topic_rowset); $i++)
{
$update_list[] = $topic_rowset[$i]['topic_id'];
}
if(count($update_list))
{
$sql = "SELECT topic_id, topic_views FROM " . TOPICS_TABLE . " WHERE topic_id IN (" . implode(', ', $update_list) . ")";
$list = array();
$result = $db->sql_query($sql);
while( $row = $db->sql_fetchrow($result) )
{
$list[$row['topic_id']] = $row['topic_views'];
}
$db->sql_freeresult($result);
for($i=0; $i<count($topic_rowset); $i++)
{
if(isset($list[$topic_rowset[$i]['topic_id']]))
{
$topic_rowset[$i]['topic_views'] = $list[$topic_rowset[$i]['topic_id']];
}
}
unset($list);
}
}
#
#-----[ OPEN ]------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------
#
WHERE forum_id = $forum_id";
if ( !($result = $db->sql_query($sql)) )
#
#-----[ REPLACE WITH ]------------------------------------------
#
WHERE forum_id = $forum_id";
if ( !($result = $db->sql_query($sql, false, true)) )
#
#-----[ FIND ]------------------------------------------
#
WHERE forum_id = $forum_id";
if ( !($result = $db->sql_query($sql)) )
#
#-----[ REPLACE WITH ]------------------------------------------
#
WHERE forum_id = $forum_id";
if ( !($result = $db->sql_query($sql, false, 'posts_')) )
#
#-----[ FIND ]------------------------------------------
#
GROUP BY u.user_id, u.username
ORDER BY u.user_id";
if ( !($result = $db->sql_query($sql)) )
#
#-----[ REPLACE WITH ]------------------------------------------
#
GROUP BY u.user_id, u.username
ORDER BY u.user_id";
if ( !($result = $db->sql_query($sql, false, true)) )
#
#-----[ FIND ]------------------------------------------
#
GROUP BY g.group_id, g.group_name
ORDER BY g.group_id";
if ( !($result = $db->sql_query($sql)) )
#
#-----[ REPLACE WITH ]------------------------------------------
#
GROUP BY g.group_id, g.group_name
ORDER BY g.group_id";
if ( !($result = $db->sql_query($sql, false, true)) )
#
#-----[ FIND ]------------------------------------------
#
AND p.post_time >= $min_topic_time";
if ( !($result = $db->sql_query($sql)) )
#
#-----[ REPLACE WITH ]------------------------------------------
#
AND p.post_time >= $min_topic_time";
if ( !($result = $db->sql_query($sql, false, 'posts_')) )
#
#-----[ FIND ]------------------------------------------
#
ORDER BY t.topic_last_post_id DESC ";
if ( !($result = $db->sql_query($sql)) )
#
#-----[ REPLACE WITH ]------------------------------------------
#
ORDER BY t.topic_last_post_id DESC ";
if ( !($result = $db->sql_query($sql, false, 'posts_')) )
#
#-----[ FIND ]------------------------------------------
#
$topic_rowset = array();
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$cached1 = $db->cached;
#
#-----[ FIND ]------------------------------------------
#
LIMIT $start, ".$board_config['topics_per_page'];
if ( !($result = $db->sql_query($sql)) )
#
#-----[ REPLACE WITH ]------------------------------------------
#
LIMIT $start, ".$board_config['topics_per_page'];
if ( !($result = $db->sql_query($sql, false, 'posts_')) )
#
#-----[ FIND ]------------------------------------------
#
$total_topics = 0;
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$cached2 = $db->cached;
#
#-----[ FIND ]------------------------------------------
#
//
// Total topics ...
//
#
#-----[ BEFORE, ADD ]------------------------------------------
#
if($cached1 || $cached2)
{
$update_list = array();
for($i=0; $i<count($topic_rowset); $i++)
{
$update_list[] = $topic_rowset[$i]['topic_id'];
}
if(count($update_list))
{
$sql = "SELECT topic_id, topic_views FROM " . TOPICS_TABLE . " WHERE topic_id IN (" . implode(', ', $update_list) . ")";
$list = array();
$result = $db->sql_query($sql);
while( $row = $db->sql_fetchrow($result) )
{
$list[$row['topic_id']] = $row['topic_views'];
}
$db->sql_freeresult($result);
for($i=0; $i<count($topic_rowset); $i++)
{
if(isset($list[$topic_rowset[$i]['topic_id']]))
{
$topic_rowset[$i]['topic_views'] = $list[$topic_rowset[$i]['topic_id']];
}
}
unset($list);
}
}


#
#-----[ FIND ]------------------------------------------
#
$total_topics = 0;
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$cached2 = $db->cached; #
#-----[ FIND ]------------------------------------------
#
$topic_rowset = array();
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$cached1 = $db->cached; 

Users browsing this forum: No registered users and 0 guests