function deletealbums($albumids) { global $_SGLOBAL, $_SC; $dels = $newids = $sizes = $spaces = array(); $allowmanage = checkperm('managealbum'); $managebatch = checkperm('managebatch'); $delnum = 0; $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('album') . " WHERE albumid IN (" . simplode($albumids) . ")"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($allowmanage || $value['uid'] == $_SGLOBAL['supe_uid']) { $dels[] = $value; $newids[] = $value['albumid']; if (!$managebatch && $value['uid'] != $_SGLOBAL['supe_uid']) { $delnum++; } } } if (empty($dels) || !$managebatch && $delnum > 1) { return array(); } //获取积分 $reward = getreward('delimage', 0); $pics = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('pic') . " WHERE albumid IN (" . simplode($newids) . ")"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size']; $pics[] = $value; $setsql = ''; if ($allowmanage && $value['uid'] != $_SGLOBAL['supe_uid']) { //扣除积分 $setsql = $reward['credit'] ? ",credit=credit-{$reward['credit']}" : ""; $setsql .= $reward['experience'] ? ",experience=experience-{$reward['experience']}" : ""; } $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET attachsize=attachsize-{$value['size']} {$setsql} WHERE uid='{$value['uid']}'"); } if ($sizes) { $_SGLOBAL['db']->query("DELETE FROM " . tname('pic') . " WHERE albumid IN (" . simplode($newids) . ")"); } $_SGLOBAL['db']->query("DELETE FROM " . tname('album') . " WHERE albumid IN (" . simplode($newids) . ")"); $_SGLOBAL['db']->query("DELETE FROM " . tname('feed') . " WHERE id IN (" . simplode($newids) . ") AND idtype='albumid'"); //删除举报 $_SGLOBAL['db']->query("DELETE FROM " . tname('report') . " WHERE id IN (" . simplode($newids) . ") AND idtype='albumid'"); //删除图片 if ($pics) { deletepicfiles($pics); //删除图片 } return $dels; }
} if (!empty($blogids)) { C::t('common_moderate')->delete($blogids, 'blogid'); } C::t('home_blog')->delete_by_uid($member['uid']); C::t('home_blogfield')->delete_by_uid($member['uid']); C::t('home_feed')->delete_by_uid_idtype($member['uid'], 'blogid'); $membercount['blogs'] = 0; } if (in_array('album', $_GET['clear'])) { C::t('home_album')->delete_by_uid($member['uid']); $picids = array(); $query = C::t('home_pic')->fetch_all_by_uid($member['uid']); foreach ($query as $value) { $picids[] = $value['picid']; deletepicfiles($value); } if (!empty($picids)) { C::t('common_moderate')->delete($picids, 'picid'); } C::t('home_pic')->delete_by_uid($member['uid']); C::t('home_feed')->delete_by_uid_idtype($member['uid'], 'albumid'); $membercount['albums'] = 0; } if (in_array('share', $_GET['clear'])) { $shareids = array(); foreach (C::t('home_share')->fetch_all_by_uid($member['uid']) as $value) { $shareids[] = $value['sid']; } if (!empty($shareids)) { C::t('common_moderate')->delete($shareids, 'sid');
function deletepics($picids) { global $_G; $albumids = $sizes = $pics = $newids = array(); $allowmanage = checkperm('managealbum'); $haveforumpic = false; $query = C::t('home_pic')->fetch_all($picids); foreach ($query as $value) { if ($allowmanage || $value['uid'] == $_G['uid']) { $pics[] = $value; $newids[] = $value['picid']; $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size']; $albumids[$value['albumid']] = $value['albumid']; if (!$haveforumpic && $value['remote'] > 1) { $haveforumpic = true; } } } if (empty($pics)) { return array(); } C::t('home_pic')->delete($newids); if ($haveforumpic) { for ($i = 0; $i < 10; $i++) { C::t('forum_attachment_n')->reset_picid($i, $newids); } } C::t('home_comment')->delete('', $newids, 'picid'); C::t('home_feed')->delete_by_id_idtype($newids, 'picid'); C::t('home_clickuser')->delete_by_id_idtype($newids, 'picid'); C::t('common_moderate')->delete($newids, 'picid'); C::t('common_moderate')->delete($newids, 'picid_cid'); if ($sizes) { foreach ($sizes as $uid => $setarr) { $attachsize = intval($sizes[$uid]); updatemembercount($uid, array('attachsize' => -$attachsize), false); } } require_once libfile('function/spacecp'); foreach ($albumids as $albumid) { if ($albumid) { album_update_pic($albumid); } } deletepicfiles($pics); return $pics; }
function deletealbums($albumids) { global $_G; $sizes = $dels = $newids = $counts = array(); $allowmanage = checkperm('managealbum'); $query = DB::query("SELECT * FROM " . DB::table('home_album') . " WHERE albumid IN (" . dimplode($albumids) . ")"); while ($value = DB::fetch($query)) { if ($allowmanage || $value['uid'] == $_G['uid']) { $dels[] = $value; $newids[] = $value['albumid']; if (!empty($value['pic'])) { include_once libfile('function/home'); pic_delete($value['pic'], 'album', 0, $value['picflag'] == 2 ? 1 : 0); } } $counts[$value['uid']]['albums'] -= 1; } if (empty($dels)) { return array(); } $pics = $picids = array(); $query = DB::query("SELECT * FROM " . DB::table('home_pic') . " WHERE albumid IN (" . dimplode($newids) . ")"); while ($value = DB::fetch($query)) { $pics[] = $value; $picids[] = $value['picid']; $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size']; } DB::query("DELETE FROM " . DB::table('home_pic') . " WHERE albumid IN (" . dimplode($newids) . ")"); DB::query("DELETE FROM " . DB::table('home_album') . " WHERE albumid IN (" . dimplode($newids) . ")"); DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE id IN (" . dimplode($newids) . ") AND idtype='albumid'"); if ($picids) { DB::query("DELETE FROM " . DB::table('home_clickuser') . " WHERE id IN (" . dimplode($picids) . ") AND idtype='picid'"); } if ($sizes) { foreach ($sizes as $uid => $value) { $attachsize = intval($sizes[$uid]); $albumnum = $counts[$uid]['albums'] ? $counts[$uid]['albums'] : 0; updatemembercount($uid, array('albums' => $albumnum, 'attachsize' => -$attachsize), false); } } if ($pics) { deletepicfiles($pics); } return $dels; }
function deletepics($picids) { global $_G; $albumids = $sizes = $pics = $newids = array(); $allowmanage = checkperm('managealbum'); $haveforumpic = false; $query = DB::query("SELECT * FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($picids) . ")"); while ($value = DB::fetch($query)) { if ($allowmanage || $value['uid'] == $_G['uid']) { $pics[] = $value; $newids[] = $value['picid']; $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size']; $albumids[$value['albumid']] = $value['albumid']; if (!$haveforumpic && $value['remote'] > 1) { $haveforumpic = true; } } } if (empty($pics)) { return array(); } DB::query("DELETE FROM " . DB::table('home_pic') . " WHERE picid IN (" . dimplode($newids) . ")"); if ($haveforumpic) { for ($i = 0; $i < 10; $i++) { DB::query("UPDATE " . DB::table('forum_attachment_' . $i) . " SET picid='0' WHERE picid IN (" . dimplode($newids) . ")"); } } DB::delete('home_comment', "id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::delete('home_feed', "id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::delete('home_clickuser', "id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::delete('common_moderate', "id IN (" . dimplode($newids) . ") AND idtype='picid'"); DB::delete('common_moderate', "id IN (" . dimplode($newids) . ") AND idtype='picid_cid'"); if ($sizes) { foreach ($sizes as $uid => $setarr) { $attachsize = intval($sizes[$uid]); updatemembercount($uid, array('attachsize' => -$attachsize), false); } } require_once libfile('function/spacecp'); foreach ($albumids as $albumid) { if ($albumid) { album_update_pic($albumid); } } deletepicfiles($pics); return $pics; }
function deletealbums($albumids) { global $_G; $sizes = $dels = $newids = $counts = array(); $allowmanage = checkperm('managealbum'); $query = DB::query("SELECT * FROM " . DB::table('home_album') . " WHERE albumid IN (" . dimplode($albumids) . ")"); while ($value = DB::fetch($query)) { if ($allowmanage || $value['uid'] == $_G['uid']) { $dels[] = $value; $newids[] = $value['albumid']; } $counts[$value['uid']]['albums'] -= 1; } if (empty($dels)) { return array(); } $pics = $picids = array(); $query = DB::query("SELECT * FROM " . DB::table('home_pic') . " WHERE albumid IN (" . dimplode($newids) . ")"); while ($value = DB::fetch($query)) { $pics[] = $value; $picids[] = $value['picid']; $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size']; if ($value['uid'] != $_G['uid']) { $counts[$value['uid']]['coef'] -= 1; } } DB::query("DELETE FROM " . DB::table('home_pic') . " WHERE albumid IN (" . dimplode($newids) . ")"); DB::query("DELETE FROM " . DB::table('home_album') . " WHERE albumid IN (" . dimplode($newids) . ")"); DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE id IN (" . dimplode($newids) . ") AND idtype='albumid'"); if ($picids) { DB::query("DELETE FROM " . DB::table('home_clickuser') . " WHERE id IN (" . dimplode($picids) . ") AND idtype='picid'"); } if ($counts) { foreach ($counts as $uid => $setarr) { $attachsize = intval($sizes[$uid]); batchupdatecredit('uploadimage', $uid, array('albums' => $setarr['albums'], 'attachsize' => -$attachsize), $setarr['coef']); } } if ($sizes) { foreach ($sizes as $uid => $value) { $attachsize = intval($sizes[$uid]); updatemembercount($uid, array('attachsize' => -$attachsize), false); } } if ($pics) { deletepicfiles($pics); } return $dels; }
function deletealbums($albumids) { global $_SGLOBAL, $_SC; $dels = $newids = $sizes = $spaces = array(); $allowmanage = checkperm('managealbum'); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('album') . " WHERE albumid IN (" . simplode($albumids) . ")"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($allowmanage || $value['uid'] == $_SGLOBAL['supe_uid']) { $dels[] = $value; $newids[] = $value['albumid']; } } if (empty($dels)) { return array(); } $pics = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('pic') . " WHERE albumid IN (" . simplode($newids) . ")"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $sizes[$value['uid']] = $sizes[$value['uid']] + $value['size']; $pics[] = $value; $spaces[$value['uid']]++; } if ($sizes) { $nums = renum($sizes); foreach ($nums[0] as $num) { $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET attachsize=attachsize-{$num} WHERE uid IN (" . simplode($nums[1][$num]) . ")"); } $_SGLOBAL['db']->query("DELETE FROM " . tname('pic') . " WHERE albumid IN (" . simplode($newids) . ")"); } //积分 $pic_credit = creditrule('pay', 'pic'); if ($pic_credit && $spaces) { $nums = renum($spaces); foreach ($nums[0] as $num) { $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET credit=credit-" . $pic_credit * $num . " WHERE uid IN (" . simplode($nums[1][$num]) . ")"); } } $_SGLOBAL['db']->query("DELETE FROM " . tname('album') . " WHERE albumid IN (" . simplode($newids) . ")"); //删除举报 $_SGLOBAL['db']->query("DELETE FROM " . tname('report') . " WHERE id IN (" . simplode($newids) . ") AND idtype='album'"); //删除图片 if ($pics) { deletepicfiles($pics); //删除图片 } return $dels; }