function getgroupcache($fid, $typearray = array(), $timestamp = 0, $num = 10, $privacy = 0, $force = 0) { $groupcache = array(); $typeadd = $typearray && is_array($typearray) ? "AND type IN(" . dimplode($typearray) . ")" : ''; if (!$force) { $query = DB::query("SELECT fid, dateline, type, data FROM " . DB::table('forum_groupfield') . " WHERE fid='{$fid}' AND privacy='{$privacy}' {$typeadd}"); while ($group = DB::fetch($query)) { $groupcache[$group['type']] = unserialize($group['data']); $groupcache[$group['type']]['dateline'] = $group['dateline']; } } $cachetimearray = array('replies' => 3600, 'views' => 3600, 'dateline' => 0, 'lastpost' => 3600, 'digest' => 86400, 'ranking' => 86400, 'activityuser' => 3600); $userdataarray = array('activityuser' => 'lastupdate', 'newuserlist' => 'joindateline'); foreach ($typearray as $type) { if (empty($groupcache[$type]) || !empty($cachetimearray[$type]) && TIMESTAMP - $groupcache[$type]['dateline'] > $cachetimearray[$type]) { if ($type == 'ranking') { $groupcache[$type]['data'] = getgroupranking($fid, $groupcache[$type]['data']['today']); } elseif (in_array($type, array('activityuser', 'newuserlist'))) { $num = $type == 'activityuser' ? 50 : 8; $groupcache[$type]['data'] = groupuserlist($fid, $userdataarray[$type], $num, '', "AND level>'0'"); } else { $groupcache[$type]['data'] = getgroupthread($fid, $type, $timestamp, $num, $privacy); } if (!$force && $fid) { DB::query("REPLACE INTO " . DB::table('forum_groupfield') . " (fid, dateline, type, data) VALUES ('{$fid}', '" . TIMESTAMP . "', '{$type}', '" . addslashes(serialize($groupcache[$type])) . "')", 'UNBUFFERED'); } } } return $groupcache; }
function getgroupcache($fid, $typearray = array(), $timestamp = 0, $num = 10, $privacy = 0, $force = 0) { $groupcache = array(); if (!$force) { $query = C::t('forum_groupfield')->fetch_all_group_cache($fid, $typearray, $privacy); foreach ($query as $group) { $groupcache[$group['type']] = dunserialize($group['data']); $groupcache[$group['type']]['dateline'] = $group['dateline']; } } $cachetimearray = array('replies' => 3600, 'views' => 3600, 'dateline' => 900, 'lastpost' => 3600, 'digest' => 86400, 'ranking' => 86400, 'activityuser' => 3600); $userdataarray = array('activityuser' => 'lastupdate', 'newuserlist' => 'joindateline'); foreach ($typearray as $type) { if (empty($groupcache[$type]) || !empty($cachetimearray[$type]) && TIMESTAMP - $groupcache[$type]['dateline'] > $cachetimearray[$type]) { if ($type == 'ranking') { $groupcache[$type]['data'] = getgroupranking($fid, $groupcache[$type]['data']['today']); } elseif (in_array($type, array('activityuser', 'newuserlist'))) { $num = $type == 'activityuser' ? 50 : 8; $groupcache[$type]['data'] = C::t('forum_groupuser')->groupuserlist($fid, $userdataarray[$type], $num, '', "AND level>'0'"); } else { $groupcache[$type]['data'] = getgroupthread($fid, $type, $timestamp, $num); } if (!$force && $fid) { C::t('forum_groupfield')->insert(array('fid' => $fid, 'dateline' => TIMESTAMP, 'type' => $type, 'data' => serialize($groupcache[$type])), false, true); } } } return $groupcache; }