<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
*/
(!defined('IN_ADMIN') || !defined('IN_MUDDER')) && exit('Access Denied');
if(!$dosubmit) {

    $disposal = $disposal != 1 ? 2 : 1;
    $row = $db->get_one("SELECT COUNT(*) count FROM {$dbpre}upshops WHERE disposal='$disposal'");
    $total = $row['count'];
    if($total > 0) {
        $offset = 20;
        $limit = get_limit($page, $offset);
        $query = $db->query("SELECT a.*,b.shopname,subname FROM {$dbpre}upshops a LEFT JOIN {$dbpre}shops b ON(a.shopid=b.sid) WHERE disposal='$disposal' ORDER BY posttime DESC LIMIT $limit");
        while($upinfo = $db->fetch_array($query)) {
            if(preg_match('/^MarkPoint:([A-Za-z0-9\.\-]+),([A-Za-z0-9\.\-]+)\r\n/', $upinfo['upcontent'], $mappoint)) {
                $upinfo['mappoint'] = $mappoint[0];
                $upinfo['upcontent'] = preg_replace('/^MarkPoint:([A-Za-z0-9\.\-]+),([A-Za-z0-9\.\-]+)\r\n/', '', $upinfo['upcontent']);
            }
            $upinfo['shopname'] .= $upinfo['subname'] ? "({$upinfo['subname']})" : '';
            $upinfo['upcontent'] = trimmed_title(html_special_chars(str_replace("\r\n", ".", $upinfo['upcontent'])), 25);
            $upinfo['posttime'] = date('Y-m-d H:i:s', $upinfo['posttime']);
            $upinfos[] = $upinfo;
        }
        $multipage = multi($total, $offset, $page, "admincp.php?action=$action&file=$file");
    }
    include cptpl('itemupdate', MOD_ROOT.'./admin/templates/');

} else {

    if($upids && is_array($upids)) {
        foreach($upids as $val) {
            if(!is_numeric($val) || $val <=0) continue ;
            $db->query("DELETE FROM {$dbpre}upshops WHERE upid='$val'");
        }
        cpmsg('删除完毕！',"admincp.php?action=$action&file=$file");
    } else {
        cpmsg('没有可删除的信息。',"admincp.php?action=$action&file=$file");
    }

}
?>