

<?php

defined ( 'IN_TS' ) or die ( 'Access Denied.' );

//判断用户登录
$userid = aac('user') -> isLogin();

//判断发布者状态
if(aac('user')->isPublisher()==false) tsNotice('你还不能发布内容，检查邮箱是否认证。','->点击认证<-',tsUrl('user','verify'));

//echo print_r($_POST);


$title = trim($_POST['title']);
$type=intval($_POST['type']);
$comkey = trim($_POST['comkey']);
$content = tsClean($_POST['content']);
$pay_type=intval($_POST['pay_type']);
$pay=intval($_POST['pay']);
$stock=intval($_POST['stock']);

		if (intval($TS_USER['isadmin']) == 0) {
			// 过滤内容开始
			aac('system') -> antiWord($title);
			aac('system') -> antiWord($content);
			// 过滤内容结束
		}

		if ($title == '' || $type == '' || $pay_type == '' || $pay == '')
		{
			tsNotice("Have null");
		}
$isaudit = 0;

        $shopid = $new['shop'] -> create('shop', array(
            'userid' => $userid,
            'locationid' => aac('user') -> getLocationId($userid),
            'type' => $type,
			'note' => $comkey,
			'pay' => $pay,
			'pay_type' => $pay_type,
			'stock' => $stock,
            'title' => $title,
            'content' => $content,
            'isaudit' => $isaudit,
            'addtime' => date('Y-m-d H:i:s')
        ));	

		// 上传图片开始
		$arrUpload = tsUpload($_FILES['photo'], $shopid, 'shop', array('jpg', 'gif', 'png', 'jpeg'));
		if ($arrUpload) {
			$new['shop'] -> update('shop', array(
                'shopid' => $shopid
            ), array(
                'path' => $arrUpload['path'],
                'photo' => $arrUpload['url']
            ));


			#生成不同尺寸的图片
            //tsXimg($arrUpload['url'],'shop',320,180,$arrUpload['path'],'1');
            //tsXimg($arrUpload['url'],'shop',640,'',$arrUpload['path']);


		}
		// 上传图片结束
header("Location: " . tsUrl('shop', 'show', array('id' => $shopid)));		
?>