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; }
$_SGLOBAL['db']->query($sql); } deletetable('models', array('mid' => $resultmodels['mid'])); //ɾ³ýÄ£ÐͱíÏà¹ØÊý¾Ý deletetable('modelcolumns', array('mid' => $resultmodels['mid'])); //ɾ³ýÄ£ÐÍ×ֶαíÏà¹ØÊý¾Ý deletetable('categories', array('type' => $resultmodels['modelname'])); //ɾ³ý·ÖÀà±íÏà¹ØÊý¾Ý deletetable('modelfolders', array('mid' => $resultmodels['mid'])); //ɾ³ýÄ£ÐÍͶ¸å±íÏà¹ØÊý¾Ý deletetable('spacecomments', array('type' => $resultmodels['modelname'])); //ɾ³ýÆÀÂÛ±íÏà¹ØÊý¾Ý deletetable('channels', array('nameid' => $resultmodels['modelname'])); //ɾ³ýchannels±íÏà¹ØÊý¾Ý $hash = 'm' . str_pad($_POST['mid'], 6, 0, STR_PAD_LEFT); delattachments($hash); //ɾ³ý¸½¼þ //ɾ³ýÄ£ÐÍĿ¼¼°Îļþ $todir = S_ROOT . './model/data/' . $resultmodels['modelname'] . '/'; deltree($todir); //ɾ³ý»º´æÎļþ $cachefile = S_ROOT . './cache/model/model_' . $_POST['mid'] . '.cache.php'; if (file_exists($cachefile)) { @unlink($cachefile); } $cachefile = S_ROOT . './cache/model/model_' . $resultmodels['modelname'] . '.cache.php'; if (file_exists($cachefile)) { @unlink($cachefile); } //¸üлº´æ updatesettingcache();