} showmessage('do_success', 'cp.php?ac=news&op=list&do=' . $do . '&type=' . $_POST['type']); } elseif (submitcheck('delitemsubmit')) { $itemarr = array(); $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('postitems') . ' WHERE itemid IN(' . simplode($_POST['item'], ',') . ') AND uid=\'' . $_SGLOBAL['supe_uid'] . '\''); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $itemarr[] = $value['itemid']; $type = $value['type']; $tag_itemidarr[] = empty($value['oitemid']) ? $value['itemid'] : $value['oitemid']; } $_SGLOBAL['db']->query('DELETE FROM ' . tname('postitems') . ' WHERE itemid IN(' . simplode($itemarr, ',') . ')'); $_SGLOBAL['db']->query('DELETE FROM ' . tname('postmessages') . ' WHERE itemid IN(' . simplode($itemarr, ',') . ')'); //删除并更表tag总数 $tagarr = array('existsname' => array(), 'nonename' => array(), 'closename' => array(), 'existsid' => array()); foreach ($tag_itemidarr as $id) { postspacetag('update', $type, $id, $tagarr, '0'); } showmessage('do_success', 'cp.php?ac=news&op=list&type=' . $type); } elseif (!empty($_POST['postnews'])) { $_POST['message'] = strip_tags($_POST['message'], '<p><a><img>'); $_POST['message'] = stripslashes($_POST['message']); $url = trim($_POST['url']); $_POST['message'] = preg_replace_callback("/src\\=(.{1})([^\\>\\s]{10,105})\\.(jpg|gif|png)/i", 'addurlhttp', $_POST['message']); $item['message'] = jsstrip($_POST['message']); if (empty($_POST['subject'])) { $item['subject'] = strip_tags(stripslashes(cutstr($_POST['message'], 60))); } else { $item['subject'] = trim($_POST['subject']); } } if ($itemid) {
$op = 'update'; if (!$_SGET['folder']) { updatetable('spaceitems', $setsqlarr, array('itemid' => $itemid)); } else { unset($setsqlarr['styletitle']); unset($setsqlarr['digest']); unset($setsqlarr['top']); unset($setsqlarr['grade']); unset($setsqlarr['tid']); $setsqlarr['folder'] = 1; //待审箱 updatetable('postitems', $setsqlarr, array('itemid' => $itemid)); } //信息与tag关联处理 $itemid = empty($_POST['oitemid']) ? $itemid : $_POST['oitemid']; postspacetag('update', $type, $itemid, $tagarr, $status); } //附件 if ($setsqlarr['haveattach']) { $_SGLOBAL['db']->query('UPDATE ' . tname('attachments') . ' SET isavailable=1, type=\'' . $type . '\', itemid=' . $itemid . ', catid=\'' . $_POST['catid'] . '\' WHERE hash=\'' . $_POST['hash'] . '\''); } //内容 图片路径和附件路径处理 $_POST['message'] = preg_replace_callback("/src\\=(.{2})([^\\>\\s]{10,105})\\.(jpg|gif|png)/i", 'addurlhttp', $_POST['message']); $_POST['message'] = str_replace('href=\\"batch.download.php', 'href=\\"' . S_URL . '/batch.download.php', $_POST['message']); $setsqlarr = array('message' => scensor($_POST['message'], 1), 'postip' => $_SGLOBAL['onlineip'], 'customfieldid' => $_POST['customfieldid'], 'customfieldtext' => $setcustomfieldtext); //相关TAG $tagnamearr = array_merge($tagarr['existsname'], $tagarr['nonename']); $setsqlarr['relativetags'] = addslashes(serialize($tagnamearr)); //包含tag $setsqlarr['includetags'] = postgetincludetags($_POST['message'], $tagnamearr); //相关阅读
function deleteitems($colname, $idsarr, $undel = 0, $from = 0) { global $_SGLOBAL, $_SCONFIG; include_once S_ROOT . './function/tag.func.php'; if (is_array($idsarr)) { $ids = simplode($idsarr); } else { $ids = $idsarr; } if ($undel) { moveitemfolder($idsarr, $from, 2, $colname); //Òƶ¯µ½À¬»øÏä return true; } if (!$from) { $hasharr = $itemarr = array(); $itemidarr = array(); $uidarr = array(); $filearr = array(); //spaceitems//¸Ä±äÓû§Í³¼ÆÊý¾Ý $numarr = array(); $itemtypearr = array(); $itemuidarr = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('spaceitems') . " WHERE {$colname} IN ({$ids})"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $type = $value['type']; $hasharr[] = md5($value['subject']); if (empty($itemarr[$type])) { $itemarr[$type] = array(); } if (empty($numarr[$value['uid']][$type])) { $numarr[$value['uid']][$type] = 0; } if (empty($numarr[$value['uid']]['all'])) { $numarr[$value['uid']]['all'] = 0; } $itemarr[$type][] = $value['itemid']; $uidarr[$value['uid']] = $value['uid']; $itemidarr[] = $value['itemid']; if ($type != 'news') { $numarr[$value['uid']]['all']++; $numarr[$value['uid']][$type]++; } $itemtypearr[$value['itemid']] = $value['type']; $itemuidarr[$value['itemid']] = $value['uid']; $delhtmlarr[$value['catid']][] = $value['itemid']; } if (empty($itemidarr)) { return false; } $itemids = implode('\',\'', $itemidarr); //ɾ³ý²É¼¯·ÀÖؼǼ if (!empty($hasharr)) { $hash = '\'' . implode('\',\'', $hasharr) . '\''; $_SGLOBAL['db']->query("DELETE FROM " . tname('robotlog') . " WHERE hash IN ({$hash})"); } //Ö÷ÌâÌù $_SGLOBAL['db']->query("DELETE FROM " . tname('spaceitems') . " WHERE itemid IN ('{$itemids}')"); //ÄÚÈÝ foreach ($_SGLOBAL['type'] as $type) { if (!in_array($type, $itemtypearr)) { continue; } $tablename = tname('spacenews'); $_SGLOBAL['db']->query("DELETE FROM {$tablename} WHERE itemid IN ('{$itemids}')"); } //attachments//²»¸Ä±äÓû§Í³¼ÆÊý¾Ý $uidattachs = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('attachments') . " WHERE itemid IN ('{$itemids}')"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if (!empty($value['filepath'])) { $filearr[] = A_DIR . '/' . $value['filepath']; } if (!empty($value['thumbpath'])) { $filearr[] = A_DIR . '/' . $value['thumbpath']; } } $_SGLOBAL['db']->query("DELETE FROM " . tname('attachments') . " WHERE itemid IN ('{$itemids}')"); //spacecomments $_SGLOBAL['db']->query("DELETE FROM " . tname('spacecomments') . " WHERE itemid IN ('{$itemids}')"); //ɾ³ý²¢¸ü±ítag×ÜÊý $tagarr = array('existsname' => array(), 'nonename' => array(), 'closename' => array(), 'existsid' => array()); foreach ($itemidarr as $id) { postspacetag('update', $type, $id, $tagarr, '1'); } //¾Ù±¨ÐÅÏ¢ $_SGLOBAL['db']->query("DELETE FROM " . tname('reports') . " WHERE itemid IN ('{$itemids}')"); //ɾ³ý¸½¼þ if (!empty($filearr)) { foreach ($filearr as $value) { if (!@unlink($value)) { errorlog('attachment', 'Unlink ' . $value . ' Error.'); } } } //ɾ³ýhtmlÎļþ if ($_SCONFIG['makehtml'] == 1) { include_once S_ROOT . '/data/system/htmlcat.cache.php'; foreach ($delhtmlarr as $catid => $itemidarr) { foreach ($itemidarr as $itemid) { $htmlpath = S_ROOT . '/' . substr($_SCONFIG['newspath'], 2) . '/' . substr($catarr[$catid]['htmlpath'], 2); $syear = sgmdate($value['dateline'], 'Y'); $smoon = sgmdate($value['dateline'], 'n'); $file = $htmlpath . '/' . $syear . '/' . $smoon . '/' . $catarr[$catid]['pre_html'] . $itemid . '.html'; @unlink($file); } } showmessage('delete_html', 'admincp.php?action=makehtml&op=updatehtml&do=updatelisthtml'); } else { foreach ($itemidarr as $itemid) { if ($itemtypearr[$itemid] == 'news') { $id = $itemid; } else { $id = $itemuidarr[$itemid]; } $idvalue = $id > 9 ? substr($id, -2, 2) : $id; $filedir = H_DIR . '/' . $idvalue; if (is_dir($filedir)) { $filearr = sreaddir($filedir); foreach ($filearr as $file) { if (preg_match("/\\-{$itemid}(\\.|\\-)/i", $file)) { @unlink($filedir . '/' . $file); } } } } } updatecredit('delinfo', $uidarr); } else { $itemidarr = array(); $oitemidarr = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('postitems') . " WHERE {$colname} IN ({$ids})"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $itemidarr[] = $value['itemid']; $oitemidarr[] = $value['oitemid']; $tag_itemid[] = empty($value['oitemid']) ? $value['itemid'] : $value['oitemid']; } $itemids = implode('\',\'', $itemidarr); $oitemids = implode('\',\'', $oitemidarr); $_SGLOBAL['db']->query("DELETE FROM " . tname('postitems') . " WHERE itemid IN ('{$itemids}')"); $_SGLOBAL['db']->query("DELETE FROM " . tname('postmessages') . " WHERE itemid IN ('{$itemids}')"); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('attachments') . " WHERE itemid IN ('{$oitemids}')"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if (!empty($value['filepath'])) { $filearr[] = A_DIR . '/' . $value['filepath']; } if (!empty($value['thumbpath'])) { $filearr[] = A_DIR . '/' . $value['thumbpath']; } } $_SGLOBAL['db']->query("DELETE FROM " . tname('attachments') . " WHERE itemid IN ('{$oitemids}')"); //ɾ³ý¸½¼þ if (!empty($filearr)) { foreach ($filearr as $value) { if (!@unlink($value)) { errorlog('attachment', 'Unlink ' . $value . ' Error.'); } } } //ɾ³ý²¢¸ü±ítag×ÜÊý $tagarr = array('existsname' => array(), 'nonename' => array(), 'closename' => array(), 'existsid' => array()); foreach ($tag_itemid as $id) { postspacetag('update', $type, $id, $tagarr, '0'); } } }
$feed['images'][] = array('url' => $picurl, 'link' => $subjecturl); } postfeed($feed); } //信息与tag关联处理 postspacetag('add', $type, $itemid, $tagarr); } else { //更新 $op = 'update'; if (!checkperm('managecheck')) { $setsqlarr['grade'] = 0; } //编辑后,审核等级归为0 updatetable('spaceitems', $setsqlarr, array('itemid' => $itemid)); //信息与tag关联处理 postspacetag('update', $type, $itemid, $tagarr); } //附件 if ($setsqlarr['haveattach']) { $_SGLOBAL['db']->query('UPDATE ' . tname('attachments') . ' SET isavailable=1, type=\'' . $type . '\', itemid=' . $itemid . ', catid=\'' . $_POST['catid'] . '\' WHERE hash=\'' . $_POST['hash'] . '\''); } //内容 图片路径和附件路径处理 $_POST['message'] = preg_replace_callback("/src\\=(.{2})([^\\>\\s]{10,105})\\.(jpg|gif|png)/i", 'addurlhttp', $_POST['message']); $_POST['message'] = str_replace('href=\\"batch.download.php', 'href=\\"' . S_URL . '/batch.download.php', $_POST['message']); $setsqlarr = array('message' => scensor($_POST['message'], 1), 'postip' => $_SGLOBAL['onlineip'], 'customfieldid' => $_POST['customfieldid'], 'customfieldtext' => $setcustomfieldtext); //相关TAG $tagnamearr = array_merge($tagarr['existsname'], $tagarr['nonename']); $setsqlarr['relativetags'] = addslashes(serialize($tagnamearr)); //包含tag $setsqlarr['includetags'] = postgetincludetags($_POST['message'], $tagnamearr); //相关阅读