function changemodelfolder($modelname, $ids, $undel = 0) { global $_SGLOBAL, $_SCONFIG, $systemfieldarr; include_once S_ROOT . './include/model_field.inc.php'; $_GET['mid'] = empty($_GET['mid']) ? 0 : intval($_GET['mid']); if (is_array($ids)) { $ids = simplode($ids); } if ($undel == 1) { //还原 $columnsarr = $feedimg = $defaultarr = $setmessagesqlarr = $setmessagesqlnoitemidarr = array(); $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('modelcolumns') . ' WHERE mid = \'' . $_GET['mid'] . '\''); while ($result = $_SGLOBAL['db']->fetch_array($query)) { $columnsarr[$result['fieldname']] = $result['isfixed']; if (empty($result['isfixed'])) { $defaultarr[$result['fieldname']] = $result['fielddefault']; } if ($result['formtype'] == 'img') { $feedimg[] = $result['fieldname']; } } foreach ($systemfieldarr as $tmpvalue) { $columnsarr[$tmpvalue['fieldname']] = $tmpvalue['isfixed']; if (empty($tmpvalue['isfixed'])) { $defaultarr[$tmpvalue['fieldname']] = $tmpvalue['fielddefault']; } } $idarr = explode(',', str_replace('\'', '', $ids)); $uids = getuids($idarr, 'modelfolders'); updatecredit('delnews', $uids); $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('modelfolders') . ' i WHERE i.mid=\'' . $_GET['mid'] . '\' AND i.itemid IN (' . $ids . ')'); $i = $j = 0; $addfeed = array(); while ($result = $_SGLOBAL['db']->fetch_array($query)) { $data = $setitemssqlarr = array(); $data = unserialize($result['message']); $tmpdefaultarr = $defaultarr; if (empty($data['itemid'])) { $addfeed[$i] = $data; } unset($data['addfeed']); foreach ($data as $tmpkey => $tmpvalue) { if ($columnsarr[$tmpkey] == 1 || preg_match("/^click_/i", $tmpkey) || preg_match("/^attaches/i", $tmpkey)) { $setitemssqlarr[$tmpkey] = $tmpvalue; } else { $tmpdefaultarr[$tmpkey] = $tmpvalue; } } if (empty($data['itemid'])) { $setmessagesqlnoitemidarr[$j] = $tmpdefaultarr; } else { $setmessagesqlarr[$i] = $tmpdefaultarr; } if (empty($data['itemid'])) { $setmessagesqlnoitemidarr[$j]['itemid'] = $addfeed[$i]['itemid'] = inserttable($modelname . 'items', $setitemssqlarr, 1); $oldhash = getmodelhash($_GET['mid'], $result['itemid'], 'f'); $hash = getmodelhash($_GET['mid'], $setmessagesqlnoitemidarr[$j]['itemid']); $_SGLOBAL['db']->query('UPDATE ' . tname('attachments') . ' SET hash=\'' . $hash . '\' WHERE hash = \'' . $oldhash . '\''); $j++; } else { $setmessagesqlarr[$i]['itemid'] = $data['itemid']; inserttable($modelname . 'items', $setitemssqlarr); $i++; } } if (allowfeed()) { $cacheinfo = getmodelinfoall('modelname', $modelname); foreach ($addfeed as $feedvalue) { if (!empty($feedvalue['addfeed']) && !empty($feedvalue['uid'])) { $feed['uid'] = $feedvalue['uid']; $feed['username'] = $feedvalue['username']; $feed['icon'] = 'comment'; $feed['title_template'] = 'feed_model_title'; $feed['title_data'] = array('modelname' => '<a href="' . S_URL_ALL . '/m.php?name=' . $modelname . '">' . $cacheinfo['models']['modelalias'] . '</a>'); $feed['body_template'] = 'feed_model_message'; $feed['body_data'] = array('subject' => '<a href="' . geturl('action/model/name/' . $modelname . '/itemid/' . $feedvalue['itemid'], 1) . '">' . $feedvalue['subject'] . '</a>', 'message' => cutstr(strip_tags(preg_replace("/\\[.+?\\]/is", '', $feedvalue['message'])), 150)); if (!empty($feedvalue['subjectimage'])) { $feed['images'][] = array('url' => A_URL . '/' . $feedvalue['subjectimage'], 'link' => geturl('action/model/name/' . $modelname . '/itemid/' . $feedvalue['itemid'], 1)); } else { $feedbool = false; foreach ($feedimg as $feedimgvalue) { if (!empty($feedvalue[$feedimgvalue])) { $feed['images'][] = array('url' => A_URL . '/' . $feedvalue[$feedimgvalue], 'link' => geturl('action/model/name/' . $modelname . '/itemid/' . $feedvalue['itemid'], 1)); break; } } if (empty($feed['images'])) { $picurl = getmessagepic(stripslashes($feedvalue['message'])); if (!empty($picurl)) { $feed['images'][] = array('url' => $picurl, 'link' => geturl('action/model/name/' . $modelname . '/itemid/' . $feedvalue['itemid'], 1)); } } } postfeed($feed); } } } $insertvalue = $insertkey = $comma = $pre = ''; if (!empty($setmessagesqlarr)) { foreach ($setmessagesqlarr[0] as $tmpkey => $tmpvalue) { $insertkey .= $pre . $tmpkey; $pre = ','; } foreach ($setmessagesqlarr as $tmpvalue) { $insertvalue .= $comma . '(' . simplode($tmpvalue) . ')'; $comma = ','; } $_SGLOBAL['db']->query('INSERT INTO ' . tname($modelname . 'message') . ' (' . $insertkey . ') VALUES ' . $insertvalue); } $insertvalue = $insertkey = $comma = $pre = ''; if (!empty($setmessagesqlnoitemidarr)) { foreach ($setmessagesqlnoitemidarr[0] as $tmpkey => $tmpvalue) { $insertkey .= $pre . $tmpkey; $pre = ','; } foreach ($setmessagesqlnoitemidarr as $tmpvalue) { $insertvalue .= $comma . '(' . simplode($tmpvalue) . ')'; $comma = ','; } $_SGLOBAL['db']->query('INSERT INTO ' . tname($modelname . 'message') . ' (' . $insertkey . ') VALUES ' . $insertvalue); } $_SGLOBAL['db']->query("DELETE FROM " . tname('modelfolders') . " WHERE itemid IN ({$ids})"); } elseif ($undel == 2) { $_SGLOBAL['db']->query('UPDATE ' . tname('modelfolders') . ' SET folder=2 WHERE mid=\'' . $_GET['mid'] . '\' AND itemid IN (' . $ids . ')'); } elseif ($undel == 3) { $idarr = $itemid = array(); $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('modelfolders') . ' i WHERE i.mid=\'' . $_GET['mid'] . '\' AND i.itemid IN (' . $ids . ')'); while ($result = $_SGLOBAL['db']->fetch_array($query)) { $data = array(); $data = saddslashes(unserialize($result['message'])); if (empty($data['itemid'])) { //待审箱的 $idarr[] = getmodelhash($_GET['mid'], $result['itemid'], 'f'); } else { //废件箱的 $idarr[] = getmodelhash($_GET['mid'], $data['itemid']); $itemid[] = $data['itemid']; } } if (!empty($data['itemid'])) { $itemid = simplode($itemid); $_SGLOBAL['db']->query("DELETE FROM " . tname($modelname . 'comments') . " WHERE itemid IN ({$itemid})"); $_SGLOBAL['db']->query("DELETE FROM " . tname($modelname . 'rates ') . " WHERE itemid IN ({$itemid})"); } $idarr = simplode($idarr); delattachments($idarr, 'IN'); $_SGLOBAL['db']->query("DELETE FROM " . tname('modelfolders') . " WHERE itemid IN ({$ids})"); } return true; }
function moveitemfolder($itemarr, $from = 0, $to = 1, $colname = 'itemid') { global $_SGLOBAL; include_once S_ROOT . './function/tag.func.php'; $itemstr = is_array($itemarr) ? simplode($itemarr) : trim($itemarr); if (empty($from)) { $item = array(); $itemmsg = $uidarr = array(); $query = $_SGLOBAL['db']->query('SELECT i.*, ii.* FROM ' . tname('spaceitems') . ' ii LEFT JOIN ' . tname('spacenews') . ' i ON i.itemid=ii.itemid WHERE ii.' . $colname . ' IN(' . $itemstr . ')'); $oldid = ''; while ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($value['itemid'] != $oldid) { $item['oitemid'] = intval($value['itemid']); $item['catid'] = intval($value['catid']); $item['uid'] = intval($value['uid']); $item['username'] = $value['username']; $item['subject'] = $value['subject']; $item['type'] = $value['type']; $item['dateline'] = $value['dateline']; $item['lastpost'] = $value['lastpost']; $item['hash'] = $value['hash']; $item['haveattach'] = $value['haveattach']; $item['picid'] = $value['picid']; $item['fromtype'] = $value['fromtype']; $item['fromid'] = $value['fromid']; $item['folder'] = $to; $itemmsg['itemid'] = inserttable('postitems', saddslashes($item), 1); $uidarr[$item['uid']] = $item['uid']; } $itemmsg['onid'] = intval($value['onid']); $itemmsg['message'] = $value['message']; $itemmsg['relativetags'] = $value['relativetags']; $itemmsg['postip'] = $value['postip']; $itemmsg['relativeitemids'] = $value['relativeitemids']; $itemmsg['customfieldid'] = $value['customfieldid']; $itemmsg['customfieldtext'] = $value['customfieldtext']; $itemmsg['includetags'] = $value['includetags']; $itemmsg['newsauthor'] = $value['newsauthor']; $itemmsg['newsfrom'] = $value['newsfrom']; $itemmsg['newsfromurl'] = $value['newsfromurl']; $itemmsg['newsurl'] = $value['newsurl']; $itemmsg['pageorder'] = intval($value['pageorder']); updatespacetagspass($item['oitemid'], '0'); inserttable('postmessages', saddslashes($itemmsg)); deletetable('spaceitems', array('itemid' => $value['itemid'])); deletetable('spacenews', array('itemid' => $value['itemid'])); } updatecredit('delinfo', $uidarr); } elseif ($to == 0) { $item = array(); $itemmsg = array(); $query = $_SGLOBAL['db']->query('SELECT ii.*, i.* FROM ' . tname('postitems') . ' ii LEFT JOIN ' . tname('postmessages') . ' i ON i.itemid=ii.itemid WHERE ii.' . $colname . ' IN(' . $itemstr . ')'); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $item['itemid'] = empty($value['oitemid']) ? '' : intval($value['oitemid']); $item['subject'] = $value['subject']; $item['username'] = $value['username']; $item['uid'] = $value['uid']; $item['catid'] = $value['catid']; $item['dateline'] = $value['dateline']; $item['lastpost'] = $value['dateline']; $item['type'] = $value['type']; $item['picid'] = $value['picid']; $item['haveattach'] = $value['haveattach']; $item['allowreply'] = $value['allowreply']; $item['hash'] = $value['hash']; $item['fromtype'] = $value['fromtype']; $item['fromid'] = $value['fromid']; $item_query = $_SGLOBAL['db']->query('SELECT itemid FROM ' . tname('spaceitems') . ' WHERE itemid = \'' . $item['itemid'] . '\''); $item_space = $_SGLOBAL['db']->fetch_array($item_query); $itemmsg['itemid'] = $item_space ? $item['itemid'] : inserttable('spaceitems', saddslashes($item), 1); if (!empty($value['onid'])) { $itemmsg['nid'] = intval($value['onid']); } $itemmsg['message'] = $value['message']; $itemmsg['relativetags'] = $value['relativetags']; $itemmsg['postip'] = $value['postip']; $itemmsg['relativeitemids'] = $value['relativeitemids']; $itemmsg['customfieldid'] = $value['customfieldid']; $itemmsg['customfieldtext'] = $value['customfieldtext']; $itemmsg['includetags'] = $value['includetags']; $itemmsg['newsauthor'] = $value['newsauthor']; $itemmsg['newsfrom'] = $value['newsfrom']; $itemmsg['newsfromurl'] = $value['newsfromurl']; $itemmsg['newsurl'] = $value['newsurl']; $itemmsg['pageorder'] = $value['pageorder']; inserttable('spacenews', saddslashes($itemmsg)); //Òƶ¯¶Ôtag½øÐиüРempty($value['oitemid']) ? updatespacetagspass($value['itemid'], '1', '1', $itemmsg['itemid']) : updatespacetagspass($value['oitemid'], '1'); deletetable('postitems', array('itemid' => $value['itemid'])); deletetable('postmessages', array('itemid' => $value['itemid'])); getreward('postinfo', 1, $value['uid']); } } else { $query = $_SGLOBAL['db']->query('UPDATE ' . tname('postitems') . ' SET folder=\'' . $to . '\' WHERE ' . $colname . ' IN(' . $itemstr . ')'); } }
showmessage('not_find_qualified_information', $theurl); } } elseif (submitcheck('dosubmit')) { if (empty($_POST['itemids'])) { if (empty($_POST['item'])) { showmessage('you_have_no_choice_information'); } $itemids = implode("','", $_POST['item']); } else { $itemids = $_POST['itemids']; } $itemids = str_replace('\\\'', '\'', $itemids); $idarr = explode(',', str_replace('\'', '', $itemids)); // 评论删除的积分 $uids = getuids($idarr, 'spacecomments', 'authorid'); updatecredit('delcomment', $uids); if (empty($_POST['theop'])) { showmessage('please_choose_type_operation'); } if (empty($itemids)) { showmessage('you_have_no_choice_information'); } if ($_POST['theop'] == 'delete') { deleteitems('itemid', "'{$itemids}'", $_POST['undelete']); } elseif ($_POST['theop'] == 'deleteattach') { $filearr = 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']; }
//更改记录分类 $_SGLOBAL['db']->query('UPDATE ' . tname($resultmodels['modelname'] . 'items') . ' SET catid=\'' . $_POST['opcatid'] . '\' WHERE itemid IN (' . $itemidstr . ')'); break; case 'check': //审核等级 $_SGLOBAL['db']->query('UPDATE ' . tname($resultmodels['modelname'] . 'items') . ' SET grade=\'' . intval($_POST['opcheck']) . '\' WHERE itemid IN (' . $itemidstr . ')'); break; case 'allowreply': //是否允许评论 $_SGLOBAL['db']->query('UPDATE ' . tname($resultmodels['modelname'] . 'items') . ' SET allowreply=\'' . $_POST['opallowreply'] . '\' WHERE itemid IN (' . $itemidstr . ')'); break; case 'delete': //删除操作 //积分 $uids = getuids($newidarr, $resultmodels['modelname'] . 'items'); updatecredit('delinfo', $uids); deletemodelitems($resultmodels['modelname'], $itemidstr, $_GET['mid'], $_POST['opdelete']); break; } } elseif (submitcheck('valuesubmit')) { if (!(checkperm('managemodpost') || checkperm('manageeditpost'))) { showmessage('no_authority_management_operation'); } modelpost($cacheinfo); } if (!empty($_GET['op']) && ($_GET['op'] == 'add' || $_GET['op'] == 'edit')) { if (!(checkperm('managemodpost') || checkperm('manageeditpost'))) { showmessage('no_authority_management_operation'); } $resultmodelcolumns = array(); if ($_GET['mid'] > 0) {