function post_create($arr, $fid) { global $conf, $time; $pid = post__create($arr); if (!$pid) { return $pid; } $tid = $arr['tid']; $uid = $arr['uid']; // 回帖 if ($tid > 0) { thread__update($tid, array('posts+' => 1, 'lastpid' => $pid, 'lastuid' => $uid, 'last_date' => $time)); $uid and user__update($uid, array('posts+' => 1)); runtime_set('posts+', 1); runtime_set('todayposts+', 1); forum__update($fid, array('todayposts+' => 1)); // 最新回复 thread_lastpid_create($tid, $pid); thread_tids_cache_delete_by_order($fid, 'lastpid'); } post_list_cache_delete($tid); // 更新板块信息。 thread_lastpid_cache_delete(); forum_list_cache_delete(); // 更新附件 $attachlist = attach_find_just_upload($uid); if ($attachlist) { foreach ($attachlist as $attach) { attach__update($attach['aid'], array('tid' => $tid, 'pid' => $pid)); } list($images, $files) = attach_images_files($attachlist); post__update($pid, array('images' => $images, 'files' => $files)); } return $pid; }
function agree_update($touid, $pid, $tid, $fid, $isfirst) { global $conf, $time, $group, $longip, $sid, $uid, $gid, $user; //user_login_check($user); if (!forum_access_user($fid, $gid, 'allowagree')) { return xn_error(10, '您(' . $user['groupname'] . ')无权限在此版块点喜欢'); } if ($uid > 0) { // 每日最大喜欢数限制 if ($time - $user['last_agree_date'] > 86400) { user__update($uid, array('last_agree_date' => $time)); $user['today_agrees'] = 0; } $user['last_agree_date'] = $time; $user['today_agrees']++; if ($user['today_agrees'] > $group['maxagrees']) { return xn_error(-1, '请您休息会,您所在的用户组每日最大喜欢数为:' . $group['maxagrees']); } $agree = myagree_read($pid, $uid); if ($agree) { // 取消喜欢 $r = myagree_delete($uid, $pid, $isfirst); if ($r === FALSE) { return xn_error(2, '取消喜欢失败'); } thread_tids_cache_delete_by_order($fid, 'agree'); return xn_error(1, '取消喜欢成功'); // 1 表示取喜欢喜欢,前台会根据此项判断减1 } else { // 点击喜欢 $r = myagree_create($uid, $touid, $pid, $tid, $isfirst); if ($r === FALSE) { return xn_error(2, '点喜欢失败'); } thread_tids_cache_delete_by_order($fid, 'agree'); return xn_error(0, '点喜欢成功'); } } else { // ip 限制 $n = guest_agree_count_by_ip($longip); if ($n > $group['maxagrees']) { return xn_error(-1, '请您休息会,您所在的用户组每日最大喜欢数为:' . $group['maxagrees']); } // sid 限制 $agree = guest_agree_read($sid, $pid); if ($agree) { // 取消喜欢 $r = guest_agree_delete($sid, $pid, $touid, $isfirst ? $tid : 0); if ($r === FALSE) { return xn_error(2, '取消喜欢失败'); } thread_tids_cache_delete_by_order($fid, 'agree'); return xn_error(1, '取消喜欢成功'); // 1 表示取消喜欢,前台会根据此项判断减1 } else { // 点击喜欢 $r = guest_agree_create($sid, $longip, $pid, $touid, $isfirst ? $tid : 0); if ($r === FALSE) { return xn_error(2, '点喜欢失败'); } thread_tids_cache_delete_by_order($fid, 'agree'); return xn_error(0, '点喜欢成功'); } } }
function thread_tids_cache_delete($fid, $force = FALSE) { global $conf; static $deleted = FALSE; if ($deleted && !$force) { return; } $limit = $conf['cache_thread_list_pages'] * $conf['pagesize']; foreach (array('tid', 'lastpid', 'agrees') as $v) { thread_tids_cache_delete_by_order($fid, $v); } $deleted = TRUE; }