getContext()->getRequest();
// 接收信息
$id = intval($request->getParameter("id")); // 活动id
$uploadImg = addslashes(trim($request->getParameter('uploadImg'))); // 图片上传位置
// 根据插件id,查询插件信息
$sql = 'select * from lkt_set_notice where id='.$id;
$res = $db -> select($sql);
if($res){
$id = $res[0]->id;
$image = $res[0]->img_url;
$name = $res[0]->name;
$detail = $res[0]->detail;
}
$dd = $_SERVER['PHP_SELF'];
$ddd =explode('/', $dd);//打散成数组
$dddd =array_pop($ddd);//去除数组最后一个元素
if($ddd){
$pic = implode('/', $ddd);
}else{
$pic = "/LKT";
}
$pic =str_replace('..', '', $pic);
$request->setAttribute('pic', $pic.'/images');
$request->setAttribute("uploadImg",$uploadImg);
$request->setAttribute("id",$id);
$request->setAttribute("name",$name);
$request->setAttribute("image",$image);
$request->setAttribute("detail",$detail);
return View :: INPUT;
}
public function execute(){
$db = DBAction::getInstance();
$request = $this->getContext()->getRequest();
$id = addslashes(trim($request->getParameter('id'))); //
$url = addslashes(trim($request->getParameter('uploadImg'))); // 图片上传位置
$name = addslashes(trim($request->getParameter('notice'))); // name
$detail = addslashes(trim($request->getParameter('detail'))); //
$oldpic = addslashes(trim($request->getParameter('oldpic')));
$image = addslashes(trim($request->getParameter('image')));
if($image){
$image = preg_replace('/.*\//','',$image);
if($image != $oldpic){
@unlink ($uploadImg.$oldpic);
}
}else{
$image = $oldpic;
}
$admin_id = $this->getContext()->getStorage()->read('admin_id');
//更新数据表
$sql = "update lkt_set_notice " .
"set name='$name',img_url = '$image',user = '$admin_id',detail = '$detail',time = CURRENT_TIMESTAMP " . "where id = '$id'";
$r = $db->update($sql);
if($r == -1) {
echo "";
return $this->getDefaultView();
} else {
header("Content-type:text/html;charset=utf-8");
echo "";
}
}
public function getRequestMethods(){
return Request :: POST;
}
}
?>