2017年12月

第一步:下载Ueditor1.4.3

下载之后重命名为ueditor ,并放到项目的public目录下

第二步:引入

在视图文件里引入一下js文件

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>//也可以引用本地的
<js file="__ROOT__/Public/Ueditor/ueditor.config.js"/>  
<js file="__ROOT__/Public/Ueditor/ueditor.all.min.js"/>  
<js file="__ROOT__/Public/Ueditor/lang/zh-cn/zh-cn.js"/>  
<script type="text/javascript" charset="utf-8">  
   window.UEDITOR_HOME_URL = "__PUBLIC__/Ueditor/";  
    $(document).ready(function () {  
      UE.getEditor('info', {  
      initialFrameHeight: 500,  
      initialFrameWidth: 1100,  
      serverUrl: "{:U(MODULE_NAME.'/Index/save_info')}"  
    });  
  });    
</script>

在需要编辑器的地方写入以下代码

<textarea name="info" id="info" style="width:1024px;height:500px;"></textarea>  

第三步:控制器

在控制器中放入以下代码

public function save_info(){  
   $ueditor_config = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "",     file_get_contents("./Public/Ueditor/php/config.json")), true);  
        $action = $_GET['action'];  
        switch ($action) {  
            case 'config':  
                $result = json_encode($ueditor_config);  
                break;  
                /* 上传图片 */  
            case 'uploadimage':  
                /* 上传涂鸦 */  
            case 'uploadscrawl':  
                /* 上传视频 */  
            case 'uploadvideo':  
                /* 上传文件 */  
            case 'uploadfile':  
                $upload = new \Think\Upload();  
                $upload->maxSize = 3145728;  
                $upload->rootPath = './Public/Uploads/';  
                $upload->exts = array('jpg', 'gif', 'png', 'jpeg');  
                $info = $upload->upload();  
                if (!$info) {  
                    $result = json_encode(array(  
                            'state' => $upload->getError(),  
                    ));  
                } else {  
                    $url = __ROOT__ . "/Public/Uploads/" . $info["upfile"]["savepath"] . $info["upfile"]['savename'];  
                    $result = json_encode(array(  
                            'url' => $url,  
                            'title' => htmlspecialchars($_POST['pictitle'], ENT_QUOTES),  
                            'original' => $info["upfile"]['name'],  
                            'state' => 'SUCCESS'  
                    ));  
                }  
                break;  
            default:  
                $result = json_encode(array(  
                'state' => '请求地址出错'  
                        ));  
                        break;  
        }  
        /* 输出结果 */  
        if (isset($_GET["callback"])) {  
            if (preg_match("/^[\w_]+$/", $_GET["callback"])) {  
                echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';  
            } else {  
                echo json_encode(array(  
                        'state' => 'callback参数不合法'  
                ));  
            }  
        } else {  
            echo $result;  
        }  
    }  

注意:文件默认目录为"Public/Uploads",如果没有就自己创建,也可以自己修改。

关闭apache的开机启动

  • 安装sysv-rc-conf

    sudo apt-get install sysv-rc-conf

  • 运行sysv-rc-conf

    sudo sysv-rc-conf

将apache2服务对应的开机启动全部去掉(即运行级别2345的都去掉)
如下图
2017-12-14 07-54-38屏幕截图.png

  • 按q保存退出

关闭apache的开机启动

  • 执行如下命令即可:

    sudo update-rc.d mysql disable

第一步:下载Page.class.php

把下载后的Page.class.php放入ThinkPHP/Extend/Library/ORG/Util/(如果该目录不存在就手动去创建)。

第二步:控制器

 

  $User = M('Goods');//实例化Goods数据对象  Goods是你的表名
  //p是前台传值过来的参数,也就是页码
    if($_GET['p']==NULL){
        $p=1;
    }else{
        $p=$_GET['p'];
    }
    $list = $User->order('id')->page($p.',10')->select();// 查询满足要求的总记录数
    $this->assign('list',$list);// 赋值数据集
    $count = $User->count();
    $Page = new \Think\Page($count,10);
    $show = $Page->show();
    $this->assign('page',$show);
    $this->display();

第三步:视图

<div class="result page">{$page}</div>

第四步:css

引入的样式小编感觉不是很好看,所以进行了一下美化,想要的童鞋可以拿走哦

.page{
    padding-top: 20px;
    padding-bottom: 15px;
    text-align: center;
    clear: both;
}
.num,.current,.prev,.next{
background-color: rgb(255, 255, 255);
border-bottom-color: rgb(226, 226, 226);
border-bottom-style: solid;
border-bottom-width: 0.666667px;
border-image-outset: 0;
border-image-repeat: stretch stretch;
border-image-slice: 100%;
border-image-source: none;
border-image-width: 1;
border-left-color: rgb(226, 226, 226);
border-left-style: solid;
border-left-width: 0.666667px;
border-right-color: rgb(226, 226, 226);
border-right-style: solid;
border-right-width: 0.666667px;
border-top-color: rgb(226, 226, 226);
border-top-style: solid;
border-top-width: 0.666667px;
box-sizing: content-box;
color: rgb(51, 51, 51);
display: inline-block;
font-family: Helvetica Neue, Helvetica, PingFang SC, 微软雅黑, Tahoma, Arial, sans-serif;
font-feature-settings: normal;
font-kerning: auto;
font-language-override: normal;
font-size: 12px;
font-size-adjust: none;
font-stretch: normal;
font-style: normal;
font-variant: normal;
font-variant-alternates: normal;
font-variant-caps: normal;
font-variant-east-asian: normal;
font-variant-ligatures: normal;
font-variant-numeric: normal;
font-variant-position: normal;
font-weight: 400;
height: 28px;
line-height: 28px;
margin-bottom: 5px;
margin-left: 0px;
margin-right: -1px;
margin-top: 0px;
padding-bottom: 0px;
padding-left: 15px;
padding-right: 15px;
padding-top: 0px;
position: relative;
text-align: left;
vertical-align: middle;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
}
.current{
    background:orange;
}