f (!empty($uidarr)) { $uids = array(); $update = array(); foreach ($uidarr as $_uid => $n) { $uids[] = $_uid; $update[$_uid] = array('articles-' => $n); 'mysql' != $conf['cache']['type'] and cache_delete('user-' . $_uid); } user_big_update(array('uid' => $uids), $update); } !empty($operate_create) && function_exists('operate_big_insert') and operate_big_insert($operate_create); return TRUE; } // 大数据量容易超时 删除用户时使用,删除主题 回复 栏目统计 附件 全站统计 function well_thread_delete_all_by_uid($uid) { // 用户主题数 $user = user_read_cache($uid); set_time_limit(0); // 删除所有回复 if ($user['comments']) { $postist = comment_pid_find_by_uid($uid, 1, $user['comments'], FALSE); $pidarr = array(); foreach ($postist as $val) { $pidarr[] = $val['pid']; } unset($postist); !empty($pidarr) and comment_delete_by_pids($pidarr); } if ($user['articles']) { // 如果主题、附件和回复数量太大会超时 $tidlist = thread_tid_find_by_uid($uid, 1, $user['articles'], FALSE, 'tid', array('tid')); $tidarr = array(); foreach ($tidlist as $val) { $tidarr[] = $val['tid']; } unset($tidlist); !empty($tidarr) and well_thread_delete_all($tidarr); } return TRUE; } // 搜索标题 function well_thread_find_by_keyword($keyword, $d = NULL) { if (empty($keyword)) return NULL; $db = $_SERVER['db']; $d = $d ? $d : $db; if (!$d) return FALSE; $threadlist = db_sql_find("SELECT * FROM `{$d->tablepre}website_thread` WHERE subject LIKE '%$keyword%' LIMIT 60;", 'tid', $d); if ($threadlist) { $threadlist = arrlist_multisort($threadlist, 'tid', FALSE); foreach ($threadlist as &$thread) { well_thread_format($thread); // 关键词标色 //$thread['subject'] = comment_highlight_keyword($thread['subject'], $keyword); } } return $threadlist; } // 查找 最后评论 lastpid function well_thread_find_lastpid($tid) { $arr = comment_pid_read(array('tid' => $tid), array('pid' => -1), array('pid')); $lastpid = empty($arr) ? 0 : $arr['pid']; return $lastpid; } // 更新最后的 uid function well_thread_update_last($tid) { if (empty($tid)) return FALSE; $lastpid = well_thread_find_lastpid($tid); if (empty($lastpid)) return FALSE; $lastpost = comment_read($lastpid); if (empty($lastpost)) return FALSE; $r = well_thread_update($tid, array('lastuid' => $lastpost['uid'])); return $r; } function well_thread_maxid() { $n = db_maxid('website_thread', 'tid'); return $n; } // 主题状态 0:通过 1~9 审核:1待审核 10~19:10退稿 11逻辑删除 function well_thread_format(&$thread) { global $gid, $uid, $forumlist; $conf = _SERVER('conf'); if (empty($thread)) return; $thread['create_date_fmt'] = humandate($thread['create_date']); $thread['last_date_fmt'] = humandate($thread['last_date']); $thread['create_date_fmt_ymd'] = date('Y-m-d', $thread['create_date']); $thread['last_date_fmt_ymd'] = date('Y-m-d', $thread['last_date']); $user = user_read_cache($thread['uid']); $onlinelist = online_user_list_cache(); $user['online_status'] = isset($onlinelist[$user['uid']]) ? 1 : 0; $thread['username'] = $user['username']; $thread['user_avatar_url'] = array_value($user, 'avatar_url'); $thread['user'] = user_safe_info($user); unset($user); $forum = array_value($forumlist, $thread['fid']); $thread['forum_name'] = array_value($forum, 'name'); $thread['forum_url'] = array_value($forum, 'url'); if ($thread['last_date'] == $thread['create_date']) { $thread['last_date_fmt'] = ''; $thread['lastuid'] = 0; $thread['lastusername'] = ''; } else { $lastuser = $thread['lastuid'] ? user_read_cache($thread['lastuid']) : array(); $thread['lastusername'] = $thread['lastuid'] ? $lastuser['username'] : lang('guest'); $thread['lastuser'] = $thread['lastuid'] ? user_safe_info($lastuser) : array(); unset($lastuser); } $thread['url'] = url('read-' . $thread['tid'], '', FALSE); if ($conf['url_rewrite_on'] > 1) { !empty($forum['well_alias']) and $thread['url'] = url(urlencode($forum['well_alias'])."-$thread[create_date]a$thread[tid]", '', FALSE); } else { $thread['url'] = url("read-$thread[create_date]a$thread[tid]", '', FALSE); } $thread['user_url'] = url('user-' . $thread['uid']); $thread['sticky_class'] = ''; if ($thread['sticky'] > 0) { if (1 == $thread['sticky']) { $thread['sticky_class'] = 'success'; } elseif (2 == $thread['sticky']) { $thread['sticky_class'] = 'warning'; } elseif (3 == $thread['sticky']) { $thread['sticky_class'] = 'danger'; } } $nopic = view_path() . 'img/nopic.png'; if ($thread['icon']) { $attach_dir_save_rule = array_value($conf, 'attach_dir_save_rule', 'Ym'); $day = date($attach_dir_save_rule, $thread['icon']); $thread_format_icon_default = 1; if (1 == $thread_format_icon_default) { // 本地文件绝对路径 $destfile = $conf['upload_path'] . 'thumbnail/' . $day . '/' . $thread['uid'] . '_' . $thread['tid'] . '_' . $thread['icon'] . '.jpeg'; // 本地 $thread['icon_fmt'] = is_file($destfile) ? file_path($thread['attach_on']) . 'thumbnail/' . $day . '/' . $thread['uid'] . '_' . $thread['tid'] . '_' . $thread['icon'] . '.jpeg' : $nopic; if (1 == $conf['attach_on'] && 1 == $thread['attach_on']) { // 云储存 $thread['icon_fmt'] = file_path($thread['attach_on']) . 'thumbnail/' . $day . '/' . $thread['uid'] . '_' . $thread['tid'] . '_' . $thread['icon'] . '.jpeg'; } elseif (2 == $conf['attach_on'] && 2 == $thread['attach_on']) { // 图床 未上传成功 本地图片在的话使用本地,不在则默认 $thread['icon_fmt'] = $thread['image_url'] ? $thread['image_url'] : $thread['icon_fmt']; } } } else { $thread['icon_fmt'] = $nopic; } // 回复页面 $thread['pages'] = ceil($thr ?>组保留的标签 余下为需要删除的标签 unset($oldtag[$key]); } } } if (!empty($oldtag)) { $tagids = array(); foreach ($oldtag as $tagid => $tagname) { $tagids[] = $tagid; } well_oldtag_delete($tagids, $tid); } $r = well_tag_process($tid, $fid, $create_tag, $tagarr); return $r; } // 删除标签和绑定的主题 function well_oldtag_delete($tagids, $tid) { $pagesize = count($tagids); $arrlist = well_tag_find_by_tagids($tagids, 1, $pagesize); $delete_tagids = array(); // 删除 $tagids = array(); $n = 0; foreach ($arrlist as $val) { ++$n; if (1 == $val['count']) { // 只有一个主题 $delete_tagids[] = $val['tagid']; } else { $tagids[] = $val['tagid']; } } !empty($delete_tagids) and well_tag_delete($delete_tagids); $arlist = well_tag_thread_find_by_tid($tid, 1, $n); if ($arlist) { $ids = array(); foreach ($arlist as $val) $ids[] = $val['id']; well_tag_thread_delete($ids); } !empty($tagids) and well_tag_update($tagids, array('count-' => 1)); } // 标签数据处理 $arr=新提交的数组 $tagarr=保留的旧标签 function well_tag_process($tid, $fid, $new_tags = array(), $tagarr = array()) { if (empty($tid)) return ''; // 新标签处理入库 if ($new_tags) { $threadarr = array(); $tagids = array(); $i = 0; $size = 5; $n = count($tagarr); $n = $n > $size ? $size : $size - $n; foreach ($new_tags as $name) { ++$i; $name = trim($name); $name = stripslashes($name); $name = strip_tags($name); $name = str_replace(array(' ', '#', "@", "$", "%", "^", '&', '·', '<', '>', ';', '`', '~', '!', '¥', '……', ';', '?', '?', '-', '—', '_', '=', '+', '.', '{', '}', '|', ':', ':', '、', '/', '。', '[', ']', '【', '】', '‘', ' ', ' ', ' ', ' ', ' '), '', $name); $name = htmlspecialchars($name, ENT_QUOTES); if ($name && $i <= $n) { // 查询标签 $read = well_tag_read_name($name); if ($read) { // 存在 count+1 $tagids[] = $read['tagid']; } else { // 入库 $arr = array('name' => $name, 'count' => 1); $tagid = well_tag_create($arr); FALSE === $tagid and message(-1, lang('create_failed')); $read = array('tagid' => $tagid, 'name' => $name); } $tag_thread = array('tagid' => $read['tagid'], 'tid' => $tid); $threadarr[] = $tag_thread; $tagarr[$read['tagid']] = $read['name']; } } !empty($threadarr) and tag_thread_big_insert($threadarr); !empty($tagids) and well_tag_update($tagids, array('count+' => 1)); } $json = empty($tagarr) ? '' : xn_json_encode($tagarr); return $json; } ?>return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>