getContext()->getRequest(); // 接收信息 $id = intval($request->getParameter("id")); // 推广图id // 根据推广图id,查询推广图信息 $sql = "select * from lkt_extension where id = '$id'"; $r = $db->select($sql); $res = []; if ($r) { $data = json_decode($r[0]->data); // 推广图 $res = $r[0]; } // 查询配置表信息 $sql = "select * from lkt_config where id = 1"; $r_1 = $db->select($sql); $uploadImg_domain = $r_1[0]->uploadImg_domain; // 图片上传域名 $uploadImg = $r_1[0]->uploadImg; // 图片上传位置 if (strpos($uploadImg, '../') === false) { // 判断字符串是否存在 ../ $img = $uploadImg_domain . $uploadImg; // 图片路径 } else { // 不存在 $img = $uploadImg_domain . substr($uploadImg, 2); // 图片路径 } $request->setAttribute("uploadImg", $uploadImg); $request->setAttribute("img", $img); $request->setAttribute("res", $res); $request->setAttribute('id', $id); $request->setAttribute('data', $data); return View :: INPUT; } public function execute() { $db = DBAction::getInstance(); $request = $this->getContext()->getRequest(); // 接收数据 $title = trim($request->getParameter('title')); // 名称 $type = trim($request->getParameter('type')); // 海报类型 $keyword = trim($request->getParameter('keyword')); // 关键词 $isdefault = trim($request->getParameter('isdefault')); // 是否默认 $bg = trim($request->getParameter('bg')); // 背景图片 $waittext = trim($request->getParameter('waittext')); // 等待语 $data = trim($request->getParameter('data')); // 排序的数据 $color = trim($request->getParameter('color')); // 颜色 $img = $request->getParameter('img'); // 添加数据 if ($isdefault) { $sql = "update lkt_extension set isdefault = 0 where type = '$type'"; $db->update($sql); } $id = intval($request->getParameter("id")); // 推广图id $sql = "update lkt_extension set image='$img',name='$title',type='$type',keyword='$keyword',isdefault='$isdefault',bg='$bg',waittext='$waittext',data='$data',color='$color',add_date =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 ""; } return; } public function getRequestMethods() { return Request :: POST; } } ?>