Example #1
0
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;
}
        case 'movecat':
            //更改记录分类
            $_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();
Example #3
0
    if (empty($listarr) && empty($itemidarr)) {
        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'];
Example #4
0
$page < 1 ? $page = 1 : '';
$start = ($page - 1) * $perpage;
$listarr = array();
if (submitcheck('listsubmit')) {
    if (!empty($_POST['item'])) {
        $itemidstr = implode('\',\'', $_POST['item']);
    } else {
        showmessage('space_no_item');
    }
    switch ($_POST['operation']) {
        case 'noproblem':
            $_SGLOBAL['db']->query('UPDATE ' . tname('reports') . ' SET status=\'1\' WHERE itemid IN (\'' . $itemidstr . '\')');
            break;
        case 'remove':
            //积分 和 经验
            $uids = getuids($_POST['item'], 'reports', 'reportuid');
            deleteitems('itemid', $_POST['item']);
            $_SGLOBAL['db']->query('DELETE FROM ' . tname('reports') . ' WHERE itemid IN (\'' . $itemidstr . '\')');
            foreach ($uids as $value) {
                getreward('report', 1, $value);
            }
            break;
        case 'rush':
            deleteitems('itemid', $_POST['item'], 1);
            $_SGLOBAL['db']->query('DELETE FROM ' . tname('reports') . ' WHERE itemid IN (\'' . $itemidstr . '\')');
            break;
    }
    showmessage('report_op_ok', $theurl . '&page=' . $page . '&status=' . $status);
}
//GET METHOD
$viewclass_no = $viewclass_yes = '';