12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace Admin\Controller;
- use Think\Controller;
- class IndexController extends BaseController {
- public function index(){
- $this->display();
- }
- public function parsedown($text){//以thinkphp为列
- import('Vendor.Parsedown.Parsedown');//将parsedown放到第三方库目录.class.php命名(用import引入必须用此命名)
- $parsedown = new \Parsedown();
- return $parsedown->text($text);
- }
-
- public function demo(){
- echo $this->parsedown('# 你说这是什么');
- }
- public function showall(){
- $data=I('post.');
- if ($_FILES['a-img']) {
- # code...
- $upload=new \Think\Upload();//实例化上传类
- $upload->maxSize= 553145728 ;//设置上传大小
- $upload->exts=array('pdf','doc','txt','docx','png','jpg','jpeg');//设置文件上传类型
- $upload->savePath = './Uploads/'; // 设置附件上传(子)目录
- $upload->rootPath='./';//上传根目录
- $upload->saveName=array('uniqid','');//上传文件的保存规则,支持数组和字符串方式定义
- $info=$upload->uploadOne($_FILES['a-img']);
- if (!$info){
- $this->error($upload->getError());//上传错误提示信息
- }else{
- $data['a-img']='/'.$info['savepath'].$info['savename'];
- $data['a-time']=date('Y-m-d H:i:s',time());
- $data['a-main']=$this->parsedown($data['a-main']);
- $data['a-jianjie']=$this->parsedown($data['a-jianjie']);
- $data['a-type']=implode(',', $data['a-type']);
- // var_dump($data);
- $re=M('article')->add($data);
- if ($re) {
- $this->success('添加成功',U('form'));
- }else{
- $this->error('添加失败',U('form'));
- }
- }
- }
- }
- public function guanli(){
- $ar=M('article')->select();
- $this->assign('showg',$ar);
- $this->display();
- }
- public function showw(){
- $data['id']=I('get.id');
- $ar=M('article')->where($data)->find();
- $this->assign('showw',$ar);
- $this->display();
- }
- public function updatew(){
- $da['id']=I('get.id');
- $arr=M('article')->where($da)->find();
- // $arr['a-main']=$this->parsedown($arr['a-main']);
- // $arr['a-title']=$this->parsedown($arr['a-title']);
- $this->assign('showa',$arr);
- $this->display();
- }
- public function del(){
- $dat['id']=I('post.id');
- $ar=M('article')->where($dat)->delete();
- if ($ar) {
- $this->ajaxReturn(['status'=>'0']);
- }else{
- $this->ajaxReturn(['status'=>'1']);
- }
- }
- }
|