public function newImg()
{
if ($_GET['post_id'] != '') {
$imgs = M('weiba_post')->where('post_id=' . $_GET['post_id'])->find();
//dump(M()->getLastSql());
$this->assign('img', $imgs);
//dump($imgs);exit;
}
if (IS_POST) {
$img = M('weiba_post')->where('post_id=' . (int) $_POST['post_id'])->find();
if ($_POST['img_1'] == '') {
$this->error('请上传图片!');
} else {
$data['index_img'] = (int) $_POST['img_1'];
$data['is_index'] = 1;
$data['is_index_time'] = time();
if ($img && $img['is_del'] != 1) {
$res = M('weiba_post')->where('post_id=' . $img['post_id'])->save($data);
//dump(M()->getLastSql());
//dump($res);exit;
} else {
$this->error('该帖子已经删除!');
}
if ($res) {
$this->assign('jumpUrl', U('weiba/Admin/indexPost'));
$this->success('设置成功!');
} else {
$this->error('设置失败!');
}
}
} else {
$this->display();
}
}