public function deleteTopic($tid) { global $_FANWE; $topic = TopicService::getTopicById($tid); if (empty($topic)) { return; } FanweService::instance()->cache->loadCache('forums'); $forum_id = $topic['fid']; $forum = $_FANWE['cache']['forums']['all'][$forum_id]; $share_id = $topic['share_id']; $share = FS('Share')->getShareById($share_id); FS('Share')->deleteShare($share_id); $res = FDB::query('SELECT * FROM ' . FDB::table('forum_post') . ' WHERE tid = ' . $tid); while ($data = FDB::fetch($res)) { TopicService::deletePost($data['share_id'], false); } FDB::query('DELETE FROM ' . FDB::table('forum_post') . ' WHERE tid = ' . $tid); FDB::query('DELETE FROM ' . FDB::table('user_attention') . ' WHERE type=\'bar\' AND rec_id = ' . $tid); FDB::query('DELETE FROM ' . FDB::table('forum_thread') . ' WHERE tid = ' . $tid); FDB::query('UPDATE ' . FDB::table('forum') . ' SET thread_count = thread_count - 1 WHERE fid = ' . $forum_id); if ($forum['parent_id'] > 0) { FDB::query('UPDATE ' . FDB::table('forum') . ' SET thread_count = thread_count - 1 WHERE fid = ' . $forum['parent_id']); } FS('Medal')->runAuto($share['uid'], 'forums'); clearCacheDir('topic/thread/' . getDirsById($tid) . '/'); }
public function deleteUser($ids) { vendor("common"); @set_time_limit(0); if (function_exists('ini_set')) { ini_set('max_execution_time', 0); } $id_arr = explode(',', $ids); $ids = implode(',', $id_arr); if (empty($ids)) { return false; } //==================添加第三方整合会员添加 chenfq 2011-10-14================ foreach ($id_arr as $uid) { $user = $this->getById($uid); $user_field = fanweC('INTEGRATE_FIELD_ID'); $integrate_id = intval($user[$user_field]); if ($integrate_id > 0) { FS("Integrate")->adminInit(fanweC('INTEGRATE_CODE'), fanweC('INTEGRATE_CONFIG')); FS("Integrate")->delUser($integrate_id); //exit; } } //==================添加第三方整合会员添加chenfq 2011-10-14================ $condition = array('uid' => array('in', $id_arr)); if (false !== $this->where($condition)->delete()) { D('AskPost')->where($condition)->delete(); D('AskThread')->where($condition)->delete(); D('ForumPost')->where($condition)->delete(); D('ForumThread')->where($condition)->delete(); D('ManageLog')->where($condition)->delete(); D('SecondGoods')->where($condition)->delete(); D('ShareComment')->where($condition)->delete(); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_category WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share WHERE uid IN (' . $ids . '))'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_match WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share WHERE uid IN (' . $ids . '))'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_tags WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share WHERE uid IN (' . $ids . '))'); $res = FDB::query('SELECT share_id FROM ' . FDB::table('share') . ' WHERE uid IN (' . $ids . ')'); while ($data = FDB::fetch($res)) { $key = getDirsById($data['share_id']); clearCacheDir('share/' . $key); clearDir(PUBLIC_ROOT . './upload/share/' . $key, true); } D('Share')->where($condition)->delete(); D('ShareGoods')->where($condition)->delete(); D('SharePhoto')->where($condition)->delete(); D('UserAttention')->where($condition)->delete(); D('UserAuthority')->where($condition)->delete(); D('UserCount')->where($condition)->delete(); //删除喜欢收藏 $list = M()->query('SELECT uid,COUNT(uid) AS ccount FROM ' . C("DB_PREFIX") . 'user_collect WHERE c_uid IN (' . $ids . ') GROUP BY uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET collects = collects - ' . $data['ccount'] . ' WHERE uid = ' . $data['uid']); } M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_collect WHERE c_uid IN (' . $ids . ')'); //删除粉丝关注 $list = M()->query('SELECT uid FROM ' . C("DB_PREFIX") . 'user_follow WHERE f_uid IN (' . $ids . ') GROUP BY uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET fans = fans - 1 WHERE uid = ' . $data['uid']); } $list = M()->query('SELECT f_uid FROM ' . C("DB_PREFIX") . 'user_follow WHERE uid IN (' . $ids . ') GROUP BY f_uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET fans = follows - 1 WHERE uid = ' . $data['f_uid']); } M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow WHERE f_uid IN (' . $ids . ')'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow WHERE uid IN (' . $ids . ')'); D('UserDaren')->where($condition)->delete(); D('UserMedal')->where($condition)->delete(); D('UserMeTags')->where($condition)->delete(); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_msg WHERE author_id IN (' . $ids . ')'); D('UserMsgRel')->where($condition)->delete(); D('UserNotice')->where($condition)->delete(); D('UserProfile')->where($condition)->delete(); D('UserStatistics')->where($condition)->delete(); D('UserStatus')->where($condition)->delete(); foreach ($id_arr as $uid) { $this->deleteUserAvatar($uid); } return true; } else { return false; } }
public function insertDaren() { clearCacheDir('daren'); }
public function remove() { //删除指定记录 $result = array('isErr' => 0, 'content' => ''); $id = $_REQUEST['id']; if (!empty($id)) { $model = D("UserDaren"); $condition = array('id' => array('in', explode(',', $id))); $list = $model->where($condition)->findAll(); if (false !== $model->where($condition)->delete()) { foreach ($list as $item) { if (!empty($item['img'])) { @unlink(FANWE_ROOT . $item['img']); } if (!empty($item['index_img'])) { @unlink(FANWE_ROOT . $daren['index_img']); } D("User")->where('uid = ' . $item['uid'])->setField('is_daren', 0); } Vendor("common"); clearCacheDir('daren'); $this->saveLog(1, $id); } else { $result['isErr'] = 1; $result['content'] = L('REMOVE_ERROR'); } } else { $result['isErr'] = 1; $result['content'] = L('ACCESS_DENIED'); } die(json_encode($result)); }
public function removeComment() { //删除指定记录 $result = array('isErr' => 0, 'content' => ''); $id = $_REQUEST['id']; if (!empty($id)) { $model = D('ShareComment'); $pk = 'comment_id'; $condition = array($pk => array('in', explode(',', $id))); $count = $model->where($condition)->count(); $comments = $model->where($condition)->findAll(); if (false !== $model->where($condition)->delete()) { Vendor("common"); $share_id = $_REQUEST['share_id']; $key = getDirsById($share_id); clearCacheDir('share/' . $key . '/commentlist'); D('Share')->where("share_id = '{$share_id}'")->setDec('comment_count', $count); FS('Share')->updateShareCache($share_id, 'comments'); $this->saveLog(1, $id); } else { $this->saveLog(0, $id); $result['isErr'] = 1; $result['content'] = L('REMOVE_ERROR'); } } else { $result['isErr'] = 1; $result['content'] = L('ACCESS_DENIED'); } die(json_encode($result)); }
public function deleteShare($share_id, $is_score = true) { $share = ShareService::getShareById($share_id); if (!empty($share)) { $goods_count = FDB::resultFirst('SELECT COUNT(goods_id) FROM ' . FDB::table('share_goods') . ' WHERE share_id = ' . $share_id); $photo_count = FDB::resultFirst('SELECT COUNT(photo_id) FROM ' . FDB::table('share_photo') . ' WHERE share_id = ' . $share_id); $collect_count = FDB::resultFirst('SELECT COUNT(c_uid) FROM ' . FDB::table('user_collect') . ' WHERE share_id = ' . $share_id); FDB::delete('share', 'share_id = ' . $share_id); FDB::delete('share_goods', 'share_id = ' . $share_id); FDB::delete('share_photo', 'share_id = ' . $share_id); FDB::delete('share_category', 'share_id = ' . $share_id); FDB::delete('share_comment', 'share_id = ' . $share_id); FDB::delete('share_match', 'share_id = ' . $share_id); FDB::delete('share_tags', 'share_id = ' . $share_id); FDB::delete('user_collect', 'share_id = ' . $share_id); $pattern = "/#([^\f\n\r\t\v]{1,80}?)#/"; if (preg_match($pattern, $share['content'])) { FS("Event")->deleteEvent($share_id); } $pattern = "/@([^\f\n\r\t\v@ ]{2,20}?)(?:\\:| )/"; if (preg_match($pattern, $share['content'])) { FDB::delete('atme', 'share_id = ' . $share_id); } if (defined('MANAGE_HANDLER') && MANAGE_HANDLER && $is_score) { if (!in_array($share['type'], array('fav', 'album_best', 'album_rec'))) { if ($share['rec_uid'] == 0 && in_array($share['share_data'], array('goods', 'photo', 'goods_photo'))) { FS("User")->updateUserScore($share['uid'], 'delete_share', 'image', $share['content'], $share_id); } else { FS("User")->updateUserScore($share['uid'], 'delete_share', 'default', $share['content'], $share_id); } } } FDB::query('UPDATE ' . FDB::table('user_count') . ' SET shares = shares - 1, photos = photos - ' . $photo_count . ', goods = goods - ' . $goods_count . ', collects = collects - ' . $collect_count . ' WHERE uid = ' . $share['uid']); $key = getDirsById($share_id); clearCacheDir('share/' . $key); $count = (int) FDB::resultFirst('SELECT COUNT(share_id) FROM ' . FDB::table('share_rec') . ' WHERE share_id = ' . $share_id); if ($count == 0) { ShareService::deleteShareImages($share_id, $share['server_code']); } } }