<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
* @version $Id 3 2008-08-25 18:35 $
*/
!defined('IN_MUDDER') && exit('Access Denied');

if(!check_submit('mysubmit')) {

    $from = "{$dbpre}pictures a LEFT JOIN {$dbpre}shops b ON(a.shopid=b.sid)";
    $where = "a.uid='{$user->uid}'";
    $row = $db->get_one("SELECT COUNT(*) as count FROM $from WHERE $where");
    $total = &$row['count'];
    if($total > 0) {
        $query = $db->query("SELECT a.pid as pictureid,a.shopid,a.title,a.filename,a.folder,a.width,a.height,a.size,a.browse,a.status,FROM_UNIXTIME(a.addtime,'%Y-%m-%d %H:%i:%s')as addtime,b.shopname,b.subname FROM $from WHERE $where ORDER BY addtime DESC");
        while($picture = $db->fetch_array($query)) {
            $picture['shopname'] .= ($picture['subname'] ? "({$picture['subname']})" : "");
            $picture['statusname'] = $picture['status'] == 1 ? '正常' : ($picture['status'] == 2 ? '未审核' : '隐藏');
            $picture['size'] = round($picture['size'] / 1024).'KB';
            $pictures[] = $picture;
        }
        $multipage = multi($total, $offset, $page, "index.php?ac=$ac");
    }

} else {

    if($pictureids && is_array($pictureids)) {
        require_once MUDDER_ROOT.'./include/addnew.func.php';
        foreach($pictureids as $id) {
            delete_picture($id, true, true);
        }
        redirect('删除完毕！',"index.php?ac=$ac");
    } else {
        redirect('未选择，请返回修改，至少选择一项。');
    }

}
?>