<?php

defined ( 'IN_TS' ) or die ( 'Access Denied.' );
$userid = aac('user')->isLogin();

$shopid = intval ( $_POST ['shopid'] );

$stredit = $new ['shop']->find ( 'shop', array ('shopid' => $shopid ) );
$stredit['content'] = tsDecode($stredit['content']);
if($stredit=='')
{
	
	tsNotice('NO!');
}
if($userid!=$stredit['userid'])
{
	tsNotice('NO');
	
}


$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($_FILES['photo']!='')
{
		// 上传图片开始
		$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']);


		}
		// 上传图片结束
}
$new['shop'] -> update('shop', array('shopid' => $shopid), array(
            'type' => $type,
			'note' => $comkey,
			'pay' => $pay,
			'pay_type' => $pay_type,
			'stock' => $stock,
            'title' => $title,
            'content' => $content,
            'addtime' => date('Y-m-d H:i:s')
            ));
header("Location: " . tsUrl('shop', 'show', array('id' => $shopid)));
?>