function deletespace($uid, $force = 0) { global $_SGLOBAL, $_SC, $_SCONFIG; $delspace = array(); $allowmanage = checkperm('managedelspace'); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('space') . " WHERE uid='{$uid}'"); if ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($force || $allowmanage && $value['uid'] != $_SGLOBAL['supe_uid']) { $delspace = $value; //如果不是强制删除则入删除记录表 if (!$force) { $setarr = array('uid' => $value['uid'], 'username' => saddslashes($value['username']), 'opuid' => $_SGLOBAL['supe_uid'], 'opusername' => $_SGLOBAL['supe_username'], 'flag' => '-1', 'dateline' => $_SGLOBAL['timestamp']); inserttable('spacelog', $setarr, 0, true); } } } if (empty($delspace)) { return array(); } //履盖权限设置 $_SGLOBAL['usergroup'][$_SGLOBAL['member']['groupid']]['managebatch'] = 1; //space $_SGLOBAL['db']->query("DELETE FROM " . tname('space') . " WHERE uid='{$uid}'"); //spacefield $_SGLOBAL['db']->query("DELETE FROM " . tname('spacefield') . " WHERE uid='{$uid}'"); //feed $_SGLOBAL['db']->query("DELETE FROM " . tname('feed') . " WHERE uid='{$uid}' OR (id='{$uid}' AND idtype='uid')"); //记录 $doids = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('doing') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $doids[$value['doid']] = $value['doid']; } $_SGLOBAL['db']->query("DELETE FROM " . tname('doing') . " WHERE uid='{$uid}'"); //删除记录回复 $_SGLOBAL['db']->query("DELETE FROM " . tname('docomment') . " WHERE doid IN (" . simplode($doids) . ") OR uid='{$uid}'"); //分享 $_SGLOBAL['db']->query("DELETE FROM " . tname('share') . " WHERE uid='{$uid}'"); //数据 $_SGLOBAL['db']->query("DELETE FROM " . tname('album') . " WHERE uid='{$uid}'"); //删除积分记录 $_SGLOBAL['db']->query("DELETE FROM " . tname('creditlog') . " WHERE uid='{$uid}'"); //删除通知 $_SGLOBAL['db']->query("DELETE FROM " . tname('notification') . " WHERE (uid='{$uid}' OR authorid='{$uid}')"); //删除打招呼 $_SGLOBAL['db']->query("DELETE FROM " . tname('poke') . " WHERE (uid='{$uid}' OR fromuid='{$uid}')"); //删除他仓建的投票 $pollid = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('poll') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pollid[$value['pid']] = $value['pid']; } deletepolls($pollid); //删除他参与的投票 $pollid = array(); $query = $_SGLOBAL['db']->query("SELECT pid FROM " . tname('polluser') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pollid[$value['pid']] = $value['pid']; } //扣除投票数 if ($pollid) { $_SGLOBAL['db']->query("UPDATE " . tname('poll') . " SET voternum=voternum-1 WHERE pid IN (" . simplode($pollid) . ")"); } $_SGLOBAL['db']->query("DELETE FROM " . tname('polluser') . " WHERE uid='{$uid}'"); //活动 $ids = array(); $query = $_SGLOBAL['db']->query('SELECT eventid FROM ' . tname('event') . " WHERE uid = '{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $ids[] = $value['eventid']; } deleteevents($ids); //删除他参加的活动 $ids = $ids1 = $ids2 = array(); $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('userevent') . " WHERE uid = '{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($value['status'] == 1) { $ids1[] = $value['eventid']; //关注 } elseif ($value['status'] > 1) { $ids2[] = $value['eventid']; //参加 } $ids[] = $value['eventid']; } if ($ids1) { $_SGLOBAL['db']->query('UPDATE ' . tname('event') . ' SET follownum = follownum - 1 WHERE eventid IN (' . simplode($ids1) . ')'); } if ($ids2) { $_SGLOBAL['db']->query('UPDATE ' . tname('event') . ' SET membernum = membernum - 1 WHERE eventid IN (' . simplode($ids2) . ')'); // to to: 最好还要检查并减去他携带的人数 } if ($ids) { $_SGLOBAL['db']->query('DELETE FROM ' . tname('userevent') . ' WHERE eventid IN (' . simplode($ids) . ") AND uid = '{$uid}'"); } //删除相关活动邀请 $_SGLOBAL['db']->query('DELETE FROM ' . tname('eventinvite') . " WHERE uid = '{$uid}' OR touid = '{$uid}'"); //删除上传的活动图片 $_SGLOBAL['db']->query('DELETE FROM ' . tname('eventpic') . " WHERE picid = '{$uid}'"); //to do: 最好同时更新活动图片数和活动话题数 //道具 $_SGLOBAL['db']->query('DELETE FROM ' . tname('usermagic') . " WHERE uid = '{$uid}'"); $_SGLOBAL['db']->query('DELETE FROM ' . tname('magicinlog') . " WHERE uid = '{$uid}'"); $_SGLOBAL['db']->query('DELETE FROM ' . tname('magicuselog') . " WHERE uid = '{$uid}'"); //pic //删除图片附件 $pics = array(); $query = $_SGLOBAL['db']->query("SELECT filepath FROM " . tname('pic') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pics[] = $value; } //数据 $_SGLOBAL['db']->query("DELETE FROM " . tname('pic') . " WHERE uid='{$uid}'"); //blog $blogids = array(); $query = $_SGLOBAL['db']->query("SELECT blogid FROM " . tname('blog') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $blogids[$value['blogid']] = $value['blogid']; //tag $tags = array(); $subquery = $_SGLOBAL['db']->query("SELECT tagid, blogid FROM " . tname('tagblog') . " WHERE blogid='{$value['blogid']}'"); while ($tag = $_SGLOBAL['db']->fetch_array($subquery)) { $tags[$tag['tagid']] = $tag['tagid']; } if ($tags) { $_SGLOBAL['db']->query("UPDATE " . tname('tag') . " SET blognum=blognum-1 WHERE tagid IN (" . simplode($tags) . ")"); $_SGLOBAL['db']->query("DELETE FROM " . tname('tagblog') . " WHERE blogid='{$value['blogid']}'"); } } //数据删除 $_SGLOBAL['db']->query("DELETE FROM " . tname('blog') . " WHERE uid='{$uid}'"); $_SGLOBAL['db']->query("DELETE FROM " . tname('blogfield') . " WHERE uid='{$uid}'"); //bwzt $bwztids = array(); $query = $_SGLOBAL['db']->query("SELECT bwztid FROM " . tname('bwzt') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $bwztids[$value['bwztid']] = $value['bwztid']; //tag $tags = array(); $subquery = $_SGLOBAL['db']->query("SELECT tagid, bwztid FROM " . tname('tagbwzt') . " WHERE bwztid='{$value['bwztid']}'"); while ($tag = $_SGLOBAL['db']->fetch_array($subquery)) { $tags[$tag['tagid']] = $tag['tagid']; } if ($tags) { $_SGLOBAL['db']->query("UPDATE " . tname('tag') . " SET bwztnum=bwztnum-1 WHERE tagid IN (" . simplode($tags) . ")"); $_SGLOBAL['db']->query("DELETE FROM " . tname('tagbwzt') . " WHERE bwztid='{$value['bwztid']}'"); } } //数据删除 $_SGLOBAL['db']->query("DELETE FROM " . tname('bwzt') . " WHERE uid='{$uid}'"); $_SGLOBAL['db']->query("DELETE FROM " . tname('bwztfield') . " WHERE uid='{$uid}'"); //评论 $_SGLOBAL['db']->query("DELETE FROM " . tname('comment') . " WHERE (uid='{$uid}' OR authorid='{$uid}' OR (id='{$uid}' AND idtype='uid'))"); //访客 $_SGLOBAL['db']->query("DELETE FROM " . tname('visitor') . " WHERE (uid='{$uid}' OR vuid='{$uid}')"); //删除任务记录 $_SGLOBAL['db']->query("DELETE FROM " . tname('usertask') . " WHERE uid='{$uid}'"); //class $_SGLOBAL['db']->query("DELETE FROM " . tname('class') . " WHERE uid='{$uid}'"); //friend //好友 $_SGLOBAL['db']->query("DELETE FROM " . tname('friend') . " WHERE (uid='{$uid}' OR fuid='{$uid}')"); //member $_SGLOBAL['db']->query("DELETE FROM " . tname('member') . " WHERE uid='{$uid}'"); //删除脚印 $_SGLOBAL['db']->query("DELETE FROM " . tname('clickuser') . " WHERE uid='{$uid}'"); //删除黑名单 $_SGLOBAL['db']->query("DELETE FROM " . tname('blacklist') . " WHERE (uid='{$uid}' OR buid='{$uid}')"); //删除邀请记录 $_SGLOBAL['db']->query("DELETE FROM " . tname('invite') . " WHERE (uid='{$uid}' OR fuid='{$uid}')"); //删除邮件队列 $_SGLOBAL['db']->query("DELETE FROM " . tname('mailcron') . ", " . tname('mailqueue') . " USING " . tname('mailcron') . ", " . tname('mailqueue') . " WHERE " . tname('mailcron') . ".touid='{$uid}' AND " . tname('mailcron') . ".cid=" . tname('mailqueue') . ".cid"); //漫游邀请 $_SGLOBAL['db']->query("DELETE FROM " . tname('myinvite') . " WHERE (touid='{$uid}' OR fromuid='{$uid}')"); $_SGLOBAL['db']->query("DELETE FROM " . tname('userapp') . " WHERE uid='{$uid}'"); $_SGLOBAL['db']->query("DELETE FROM " . tname('userappfield') . " WHERE uid='{$uid}'"); //mtag //thread $tids = array(); $query = $_SGLOBAL['db']->query("SELECT tid, tagid FROM " . tname('thread') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $tids[$value['tagid']][] = $value['tid']; } foreach ($tids as $tagid => $v_tids) { deletethreads($tagid, $v_tids); } //post $pids = array(); $query = $_SGLOBAL['db']->query("SELECT pid, tagid FROM " . tname('post') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pids[$value['tagid']][] = $value['pid']; } foreach ($pids as $tagid => $v_pids) { deleteposts($tagid, $v_pids); } $_SGLOBAL['db']->query("DELETE FROM " . tname('thread') . " WHERE uid='{$uid}'"); $_SGLOBAL['db']->query("DELETE FROM " . tname('post') . " WHERE uid='{$uid}'"); //session $_SGLOBAL['db']->query("DELETE FROM " . tname('session') . " WHERE uid='{$uid}'"); //排行榜 $_SGLOBAL['db']->query("DELETE FROM " . tname('show') . " WHERE uid='{$uid}'"); //群组 $mtagids = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('tagspace') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $mtagids[$value['tagid']] = $value['tagid']; } if ($mtagids) { $_SGLOBAL['db']->query("UPDATE " . tname('mtag') . " SET membernum=membernum-1 WHERE tagid IN (" . simplode($mtagids) . ")"); $_SGLOBAL['db']->query("DELETE FROM " . tname('tagspace') . " WHERE uid='{$uid}'"); } $_SGLOBAL['db']->query("DELETE FROM " . tname('mtaginvite') . " WHERE (uid='{$uid}' OR fromuid='{$uid}')"); //删除图片 deletepicfiles($pics); //删除图片 //删除举报 $_SGLOBAL['db']->query("DELETE FROM " . tname('report') . " WHERE id='{$uid}' AND idtype='uid'"); //变更记录 if ($_SCONFIG['my_status']) { inserttable('userlog', array('uid' => $uid, 'action' => 'delete', 'dateline' => $_SGLOBAL['timestamp']), 0, true); } return $delspace; }
<?php /* deletetopic.php删除话题 Add by am@ihome.2012-10-19 10:00 */ include_once '../iauth_verify_forward.php'; include_once '../../../common.php'; include_once S_ROOT . './uc_client/client.php'; @(include_once S_ROOT . './data/data_profield.php'); $userid = intval(iauth_verify()); //$userid = 96; //$username = '******'; $tagid = intval($_POST['tagid']); $pids = intval($_POST['pid']); $tids = intval($_POST['topic_id']); $dtreply = deleteposts($tagid, array($pid)); $delthreads = deletethreads($tagid, $tids); if ($dtreply && $delthreads) { $arrs = array('flag' => 'success'); } else { $arrs = array('flag' => 'fail'); } $result = json_encode($arrs); $result = preg_replace("#\\\\u([0-9a-f]+)#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $result); echo $result; exit; function deleteposts($tagid, $pids) { global $_SGLOBAL; //整理 $nums = renum($postnums);
<?php if (!defined('iBUAA') || !defined('IN_ADMINCP')) { exit('Access Denied'); } $tagid = empty($_GET['tagid']) ? 0 : intval($_GET['tagid']); if (submitcheck('deletesubmit')) { include_once S_ROOT . './source/function_delete.php'; if (!empty($_POST['ids']) && deleteposts($tagid, $_POST['ids'])) { cpmessage('do_success', $_POST['mpurl']); } else { cpmessage('choose_to_delete_the_topic', $_POST['mpurl']); } } //权限 $managebatch = checkperm('managebatch'); $allowbatch = true; $allowmanage = 0; if (checkperm('managethread')) { $allowmanage = 1; } else { //群主 if ($tagid) { $grade = getcount('tagspace', array('tagid' => $tagid, 'uid' => $_SGLOBAL['supe_uid']), 'grade'); if ($grade >= 8) { //是否成员 $allowmanage = 1; $managebatch = 1; } } }
if ($thread) { $post['message'] = str_replace('&', '&amp;', $post['message']); $post['message'] = shtmlspecialchars($post['message']); $_GET['op'] = ''; $albums = getalbums($_SGLOBAL['supe_uid']); if ($post['pic']) { $post['message'] .= "<div><img src=\"{$post['pic']}\"></div>"; } } else { $post['message'] = html2bbcode($post['message']); //显示用 } } elseif ($_GET['op'] == 'delete') { include_once S_ROOT . './source/function_delete.php'; if (submitcheck('postdeletesubmit')) { if ($delposts = deleteposts($tagid, array($pid))) { $post = $delposts[0]; if ($post['isthread']) { $url = "space.php?uid={$post['uid']}&do=mtag&tagid={$post['tagid']}&view=list"; } else { $url = $_POST['refer']; } showmessage('do_success', $url, 0); } else { showmessage('no_privilege'); } } } elseif ($_GET['op'] == 'reply') { if ($eventid) { if ($userevent['status'] < 2) { showmessage('event_only_allows_member_thread');
function deleteinfo($ids) { global $_SGLOBAL; include_once S_ROOT . './source/function_delete.php'; $deltype = array(); $reportuser = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('report') . " WHERE rid IN (" . simplode($ids) . ")"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $value['user'] = unserialize($value['uids']); $reportuser[] = array_shift(array_flip($value['user'])); $deltype[$value['idtype']][] = $value['id']; } $gid = getgroupid($_SGLOBAL['member']['experience'], $_SGLOBAL['member']['groupid']); //Perform the corresponding delete operations $i = 0; $_SGLOBAL['usergroup'][$gid]['managebatch'] = 1; foreach ($deltype as $key => $value) { switch ($key) { case 'blogid': $_SGLOBAL['usergroup'][$gid]['manageblog'] = 1; deleteblogs($value); break; case 'picid': $_SGLOBAL['usergroup'][$gid]['managealbum'] = 1; deletepics($value); break; case 'albumid': $_SGLOBAL['usergroup'][$gid]['managealbum'] = 1; deletealbums($value); break; case 'tid': $_SGLOBAL['usergroup'][$gid]['managethread'] = 1; deletethreads(0, $value); break; case 'tagid': $_SGLOBAL['usergroup'][$gid]['managemtag'] = 1; deletemtag($value); break; case 'sid': $_SGLOBAL['usergroup'][$gid]['manageshare'] = 1; deleteshares($value); break; case 'uid': $_SGLOBAL['usergroup'][$gid]['managedelspace'] = 1; foreach ($value as $uid) { deletespace($uid); } break; case 'eventid': $_SGLOBAL['usergroup'][$gid]['manageevent'] = 1; deleteevents($value); break; case 'pid': $_SGLOBAL['usergroup'][$gid]['managepoll'] = 1; deletepolls($value); break; case 'comment': $_SGLOBAL['usergroup'][$gid]['managecomment'] = 1; deletecomments($value); break; case 'post': $_SGLOBAL['usergroup'][$gid]['managethread'] = 1; deleteposts(0, $value); break; } //The first reporter award getreward('report', 1, $reportuser[$i], '', 0); $i++; } }
function deletespace($uid, $force = 0) { global $_SGLOBAL, $_SC, $_SCONFIG; $delspace = array(); $allowmanage = checkperm('managespace'); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('space') . " WHERE uid='{$uid}'"); if ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($force || $allowmanage && $value['uid'] != $_SGLOBAL['supe_uid']) { $delspace = $value; //如果不是强制删除则入删除记录表 if (!$force) { $setarr = array('uid' => $value['uid'], 'username' => saddslashes($value['username']), 'opuid' => $_SGLOBAL['supe_uid'], 'opusername' => $_SGLOBAL['supe_username'], 'flag' => '-1', 'dateline' => $_SGLOBAL['timestamp']); inserttable('spacelog', $setarr, 0, true); } } } if (empty($delspace)) { return array(); } //space $_SGLOBAL['db']->query("DELETE FROM " . tname('space') . " WHERE uid='{$uid}'"); //spacefield $_SGLOBAL['db']->query("DELETE FROM " . tname('spacefield') . " WHERE uid='{$uid}'"); //feed $_SGLOBAL['db']->query("DELETE FROM " . tname('feed') . " WHERE uid='{$uid}'"); //记录 $_SGLOBAL['db']->query("DELETE FROM " . tname('doing') . " WHERE uid='{$uid}'"); //删除记录回复 $_SGLOBAL['db']->query("DELETE FROM " . tname('docomment') . " WHERE uid='{$uid}'"); //分享 $_SGLOBAL['db']->query("DELETE FROM " . tname('share') . " WHERE uid='{$uid}'"); //数据 $_SGLOBAL['db']->query("DELETE FROM " . tname('album') . " WHERE uid='{$uid}'"); //删除通知 $_SGLOBAL['db']->query("DELETE FROM " . tname('notification') . " WHERE (uid='{$uid}' OR authorid='{$uid}')"); //删除打招呼 $_SGLOBAL['db']->query("DELETE FROM " . tname('poke') . " WHERE (uid='{$uid}' OR fromuid='{$uid}')"); //pic //删除图片附件 $pics = array(); $query = $_SGLOBAL['db']->query("SELECT filepath FROM " . tname('pic') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pics[] = $value; } //数据 $_SGLOBAL['db']->query("DELETE FROM " . tname('pic') . " WHERE uid='{$uid}'"); //blog $blogids = array(); $query = $_SGLOBAL['db']->query("SELECT blogid FROM " . tname('blog') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $blogids[$value['blogid']] = $value['blogid']; //tag $tags = array(); $subquery = $_SGLOBAL['db']->query("SELECT tagid, blogid FROM " . tname('tagblog') . " WHERE blogid='{$value['blogid']}'"); while ($tag = $_SGLOBAL['db']->fetch_array($subquery)) { $tags[$tag['tagid']] = $tag['tagid']; } if ($tags) { $_SGLOBAL['db']->query("UPDATE " . tname('tag') . " SET blognum=blognum-1 WHERE tagid IN (" . simplode($tags) . ")"); $_SGLOBAL['db']->query("DELETE FROM " . tname('tagblog') . " WHERE blogid='{$value['blogid']}'"); } } //数据删除 $_SGLOBAL['db']->query("DELETE FROM " . tname('blog') . " WHERE uid='{$uid}'"); $_SGLOBAL['db']->query("DELETE FROM " . tname('blogfield') . " WHERE uid='{$uid}'"); //评论 $_SGLOBAL['db']->query("DELETE FROM " . tname('comment') . " WHERE (uid='{$uid}' OR authorid='{$uid}' OR (id='{$uid}' AND idtype='uid'))"); //访客 $_SGLOBAL['db']->query("DELETE FROM " . tname('visitor') . " WHERE (uid='{$uid}' OR vuid='{$uid}')"); //删除活动记录 $_SGLOBAL['db']->query("DELETE FROM " . tname('usertask') . " WHERE uid='{$uid}'"); //class $_SGLOBAL['db']->query("DELETE FROM " . tname('class') . " WHERE uid='{$uid}'"); //friend //好友 $_SGLOBAL['db']->query("DELETE FROM " . tname('friend') . " WHERE (uid='{$uid}' OR fuid='{$uid}')"); //member $_SGLOBAL['db']->query("DELETE FROM " . tname('member') . " WHERE uid='{$uid}'"); //删除脚印 $_SGLOBAL['db']->query("DELETE FROM " . tname('trace') . " WHERE uid='{$uid}'"); //删除黑名单 $_SGLOBAL['db']->query("DELETE FROM " . tname('blacklist') . " WHERE (uid='{$uid}' OR buid='{$uid}')"); //删除邀请记录 $_SGLOBAL['db']->query("DELETE FROM " . tname('invite') . " WHERE (uid='{$uid}' OR fuid='{$uid}')"); //删除邮件队列 $_SGLOBAL['db']->query("DELETE FROM " . tname('mailcron') . ", " . tname('mailqueue') . " USING " . tname('mailcron') . ", " . tname('mailqueue') . " WHERE " . tname('mailcron') . ".touid='{$uid}' AND " . tname('mailcron') . ".cid=" . tname('mailqueue') . ".cid"); //漫游邀请 $_SGLOBAL['db']->query("DELETE FROM " . tname('myinvite') . " WHERE (touid='{$uid}' OR fromuid='{$uid}')"); $_SGLOBAL['db']->query("DELETE FROM " . tname('userapp') . " WHERE uid='{$uid}'"); //mtag //thread $tids = array(); $query = $_SGLOBAL['db']->query("SELECT tid, tagid FROM " . tname('thread') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $tids[$value['tagid']][] = $value['tid']; } foreach ($tids as $tagid => $v_tids) { deletethreads($tagid, $v_tids); } //post $pids = array(); $query = $_SGLOBAL['db']->query("SELECT pid, tagid FROM " . tname('post') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pids[$value['tagid']][] = $value['pid']; } foreach ($pids as $tagid => $v_pids) { deleteposts($tagid, $v_pids); } $_SGLOBAL['db']->query("DELETE FROM " . tname('thread') . " WHERE uid='{$uid}'"); $_SGLOBAL['db']->query("DELETE FROM " . tname('post') . " WHERE uid='{$uid}'"); //session $_SGLOBAL['db']->query("DELETE FROM " . tname('session') . " WHERE uid='{$uid}'"); //排行榜 $_SGLOBAL['db']->query("DELETE FROM " . tname('show') . " WHERE uid='{$uid}'"); //群组 $mtagids = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('tagspace') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $mtagids[$value['tagid']] = $value['tagid']; } if ($mtagids) { $_SGLOBAL['db']->query("UPDATE " . tname('mtag') . " SET membernum=membernum-1 WHERE tagid IN (" . simplode($mtagids) . ")"); $_SGLOBAL['db']->query("DELETE FROM " . tname('tagspace') . " WHERE uid='{$uid}'"); } $_SGLOBAL['db']->query("DELETE FROM " . tname('mtaginvite') . " WHERE (uid='{$uid}' OR fromuid='{$uid}')"); //删除图片 deletepicfiles($pics); //删除图片 //删除举报 $_SGLOBAL['db']->query("DELETE FROM " . tname('report') . " WHERE id='{$uid}' AND idtype='space'"); //变更记录 if ($_SCONFIG['my_status']) { inserttable('userlog', array('uid' => $uid, 'action' => 'delete', 'dateline' => $_SGLOBAL['timestamp']), 0, true); } return $delspace; }
function deletespace($uid, $force = 0) { global $_SGLOBAL, $_SC, $_SCONFIG; $delspace = array(); $allowmanage = checkperm('managedelspace'); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('space') . " WHERE uid='{$uid}'"); if ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($force || $allowmanage && $value['uid'] != $_SGLOBAL['supe_uid']) { $delspace = $value; //Èç¹û²»ÊÇÇ¿ÖÆɾ³ýÔòÈëɾ³ý¼Ç¼±í if (!$force) { $setarr = array('uid' => $value['uid'], 'username' => saddslashes($value['username']), 'opuid' => $_SGLOBAL['supe_uid'], 'opusername' => $_SGLOBAL['supe_username'], 'flag' => '-1', 'dateline' => $_SGLOBAL['timestamp']); inserttable('spacelog', $setarr, 0, true); } } } if (empty($delspace)) { return array(); } //ÂĸÇȨÏÞÉèÖà $_SGLOBAL['usergroup'][$_SGLOBAL['member']['groupid']]['managebatch'] = 1; //space $_SGLOBAL['db']->query("DELETE FROM " . tname('space') . " WHERE uid='{$uid}'"); //spacefield $_SGLOBAL['db']->query("DELETE FROM " . tname('spacefield') . " WHERE uid='{$uid}'"); //feed $_SGLOBAL['db']->query("DELETE FROM " . tname('feed') . " WHERE uid='{$uid}' OR (id='{$uid}' AND idtype='uid')"); //¼Ç¼ $doids = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('doing') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $doids[$value['doid']] = $value['doid']; } $_SGLOBAL['db']->query("DELETE FROM " . tname('doing') . " WHERE uid='{$uid}'"); //ɾ³ý¼Ç¼»Ø¸´ $_SGLOBAL['db']->query("DELETE FROM " . tname('docomment') . " WHERE doid IN (" . simplode($doids) . ") OR uid='{$uid}'"); //·ÖÏí $_SGLOBAL['db']->query("DELETE FROM " . tname('share') . " WHERE uid='{$uid}'"); //Êý¾Ý $_SGLOBAL['db']->query("DELETE FROM " . tname('album') . " WHERE uid='{$uid}'"); //ɾ³ý»ý·Ö¼Ç¼ $_SGLOBAL['db']->query("DELETE FROM " . tname('creditlog') . " WHERE uid='{$uid}'"); //ɾ³ý֪ͨ $_SGLOBAL['db']->query("DELETE FROM " . tname('notification') . " WHERE (uid='{$uid}' OR authorid='{$uid}')"); //ɾ³ý´òÕкô $_SGLOBAL['db']->query("DELETE FROM " . tname('poke') . " WHERE (uid='{$uid}' OR fromuid='{$uid}')"); //ɾ³ýËû²Ö½¨µÄͶƱ $pollid = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('poll') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pollid[$value['pid']] = $value['pid']; } deletepolls($pollid); //ɾ³ýËû²ÎÓëµÄͶƱ $pollid = array(); $query = $_SGLOBAL['db']->query("SELECT pid FROM " . tname('polluser') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pollid[$value['pid']] = $value['pid']; } //¿Û³ýͶƱÊý if ($pollid) { $_SGLOBAL['db']->query("UPDATE " . tname('poll') . " SET voternum=voternum-1 WHERE pid IN (" . simplode($pollid) . ")"); } $_SGLOBAL['db']->query("DELETE FROM " . tname('polluser') . " WHERE uid='{$uid}'"); //»î¶¯ $ids = array(); $query = $_SGLOBAL['db']->query('SELECT eventid FROM ' . tname('event') . " WHERE uid = '{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $ids[] = $value['eventid']; } deleteevents($ids); //ɾ³ýËû²Î¼ÓµÄ»î¶¯ $ids = $ids1 = $ids2 = array(); $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('userevent') . " WHERE uid = '{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($value['status'] == 1) { $ids1[] = $value['eventid']; //¹Ø×¢ } elseif ($value['status'] > 1) { $ids2[] = $value['eventid']; //²Î¼Ó } $ids[] = $value['eventid']; } if ($ids1) { $_SGLOBAL['db']->query('UPDATE ' . tname('event') . ' SET follownum = follownum - 1 WHERE eventid IN (' . simplode($ids1) . ')'); } if ($ids2) { $_SGLOBAL['db']->query('UPDATE ' . tname('event') . ' SET membernum = membernum - 1 WHERE eventid IN (' . simplode($ids2) . ')'); // to to: ×îºÃ»¹Òª¼ì²é²¢¼õÈ¥ËûЯ´øµÄÈËÊý } if ($ids) { $_SGLOBAL['db']->query('DELETE FROM ' . tname('userevent') . ' WHERE eventid IN (' . simplode($ids) . ") AND uid = '{$uid}'"); } //ɾ³ýÏà¹Ø»î¶¯ÑûÇë $_SGLOBAL['db']->query('DELETE FROM ' . tname('eventinvite') . " WHERE uid = '{$uid}' OR touid = '{$uid}'"); //ɾ³ýÉÏ´«µÄ»î¶¯Í¼Æ¬ $_SGLOBAL['db']->query('DELETE FROM ' . tname('eventpic') . " WHERE picid = '{$uid}'"); //to do: ×îºÃͬʱ¸üлͼƬÊýºÍ»î¶¯»°ÌâÊý //µÀ¾ß $_SGLOBAL['db']->query('DELETE FROM ' . tname('usermagic') . " WHERE uid = '{$uid}'"); $_SGLOBAL['db']->query('DELETE FROM ' . tname('magicinlog') . " WHERE uid = '{$uid}'"); $_SGLOBAL['db']->query('DELETE FROM ' . tname('magicuselog') . " WHERE uid = '{$uid}'"); //pic //ɾ³ýͼƬ¸½¼þ $pics = array(); $query = $_SGLOBAL['db']->query("SELECT filepath FROM " . tname('pic') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pics[] = $value; } //Êý¾Ý $_SGLOBAL['db']->query("DELETE FROM " . tname('pic') . " WHERE uid='{$uid}'"); //blog $blogids = array(); $query = $_SGLOBAL['db']->query("SELECT blogid FROM " . tname('blog') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $blogids[$value['blogid']] = $value['blogid']; //tag $tags = array(); $subquery = $_SGLOBAL['db']->query("SELECT tagid, blogid FROM " . tname('tagblog') . " WHERE blogid='{$value['blogid']}'"); while ($tag = $_SGLOBAL['db']->fetch_array($subquery)) { $tags[$tag['tagid']] = $tag['tagid']; } if ($tags) { $_SGLOBAL['db']->query("UPDATE " . tname('tag') . " SET blognum=blognum-1 WHERE tagid IN (" . simplode($tags) . ")"); $_SGLOBAL['db']->query("DELETE FROM " . tname('tagblog') . " WHERE blogid='{$value['blogid']}'"); } } //Êý¾Ýɾ³ý $_SGLOBAL['db']->query("DELETE FROM " . tname('blog') . " WHERE uid='{$uid}'"); $_SGLOBAL['db']->query("DELETE FROM " . tname('blogfield') . " WHERE uid='{$uid}'"); //ÆÀÂÛ $_SGLOBAL['db']->query("DELETE FROM " . tname('comment') . " WHERE (uid='{$uid}' OR authorid='{$uid}' OR (id='{$uid}' AND idtype='uid'))"); //·Ã¿Í $_SGLOBAL['db']->query("DELETE FROM " . tname('visitor') . " WHERE (uid='{$uid}' OR vuid='{$uid}')"); //ɾ³ýÈÎÎñ¼Ç¼ $_SGLOBAL['db']->query("DELETE FROM " . tname('usertask') . " WHERE uid='{$uid}'"); //class $_SGLOBAL['db']->query("DELETE FROM " . tname('class') . " WHERE uid='{$uid}'"); //friend //ºÃÓÑ $_SGLOBAL['db']->query("DELETE FROM " . tname('friend') . " WHERE (uid='{$uid}' OR fuid='{$uid}')"); //member $_SGLOBAL['db']->query("DELETE FROM " . tname('member') . " WHERE uid='{$uid}'"); //ɾ³ý½ÅÓ¡ $_SGLOBAL['db']->query("DELETE FROM " . tname('clickuser') . " WHERE uid='{$uid}'"); //ɾ³ýºÚÃûµ¥ $_SGLOBAL['db']->query("DELETE FROM " . tname('blacklist') . " WHERE (uid='{$uid}' OR buid='{$uid}')"); //ɾ³ýÑûÇë¼Ç¼ $_SGLOBAL['db']->query("DELETE FROM " . tname('invite') . " WHERE (uid='{$uid}' OR fuid='{$uid}')"); //ɾ³ýÓʼþ¶ÓÁÐ $_SGLOBAL['db']->query("DELETE FROM " . tname('mailcron') . ", " . tname('mailqueue') . " USING " . tname('mailcron') . ", " . tname('mailqueue') . " WHERE " . tname('mailcron') . ".touid='{$uid}' AND " . tname('mailcron') . ".cid=" . tname('mailqueue') . ".cid"); //ÂþÓÎÑûÇë $_SGLOBAL['db']->query("DELETE FROM " . tname('myinvite') . " WHERE (touid='{$uid}' OR fromuid='{$uid}')"); $_SGLOBAL['db']->query("DELETE FROM " . tname('userapp') . " WHERE uid='{$uid}'"); $_SGLOBAL['db']->query("DELETE FROM " . tname('userappfield') . " WHERE uid='{$uid}'"); //mtag //thread $tids = array(); $query = $_SGLOBAL['db']->query("SELECT tid, tagid FROM " . tname('thread') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $tids[$value['tagid']][] = $value['tid']; } foreach ($tids as $tagid => $v_tids) { deletethreads($tagid, $v_tids); } //post $pids = array(); $query = $_SGLOBAL['db']->query("SELECT pid, tagid FROM " . tname('post') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $pids[$value['tagid']][] = $value['pid']; } foreach ($pids as $tagid => $v_pids) { deleteposts($tagid, $v_pids); } $_SGLOBAL['db']->query("DELETE FROM " . tname('thread') . " WHERE uid='{$uid}'"); $_SGLOBAL['db']->query("DELETE FROM " . tname('post') . " WHERE uid='{$uid}'"); //session $_SGLOBAL['db']->query("DELETE FROM " . tname('session') . " WHERE uid='{$uid}'"); //ÅÅÐаñ $_SGLOBAL['db']->query("DELETE FROM " . tname('show') . " WHERE uid='{$uid}'"); //Ⱥ×é $mtagids = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('tagspace') . " WHERE uid='{$uid}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $mtagids[$value['tagid']] = $value['tagid']; } if ($mtagids) { $_SGLOBAL['db']->query("UPDATE " . tname('mtag') . " SET membernum=membernum-1 WHERE tagid IN (" . simplode($mtagids) . ")"); $_SGLOBAL['db']->query("DELETE FROM " . tname('tagspace') . " WHERE uid='{$uid}'"); } $_SGLOBAL['db']->query("DELETE FROM " . tname('mtaginvite') . " WHERE (uid='{$uid}' OR fromuid='{$uid}')"); //ɾ³ýͼƬ deletepicfiles($pics); //ɾ³ýͼƬ //ɾ³ý¾Ù±¨ $_SGLOBAL['db']->query("DELETE FROM " . tname('report') . " WHERE id='{$uid}' AND idtype='uid'"); //±ä¸ü¼Ç¼ if ($_SCONFIG['my_status']) { inserttable('userlog', array('uid' => $uid, 'action' => 'delete', 'dateline' => $_SGLOBAL['timestamp']), 0, true); } return $delspace; }