Your Name 2 mēnešus atpakaļ
vecāks
revīzija
209bad38b1

+ 2
- 0
application/admin/view/cms/cms/classlist.html Parādīt failu

@@ -19,6 +19,7 @@
19 19
 {switch $catid}
20 20
 {case 17}{include file="../application/admin/view/cms/cms/script/catid_17.html" /}{/case}
21 21
 {case 18}{include file="../application/admin/view/cms/cms/script/catid_18.html" /}{/case}
22
+{case 14}{include file="../application/admin/view/cms/cms/script/catid_14.html" /}{/case}
22 23
 {default /}{include file="../application/admin/view/cms/cms/script/default.html" /}
23 24
 {/switch}
24 25
 
@@ -50,6 +51,7 @@
50 51
 {switch $catid}
51 52
 {case 17}{include file="../application/admin/view/cms/cms/list/catid_17.html" /}{/case}
52 53
 {case 18}{include file="../application/admin/view/cms/cms/list/catid_18.html" /}{/case}
54
+{case 14}{include file="../application/admin/view/cms/cms/list/catid_14.html" /}{/case}
53 55
 {default /}{include file="../application/admin/view/cms/cms/list/default.html" /}
54 56
 {/switch}
55 57
 

+ 118
- 0
application/admin/view/cms/cms/list/catid_14.html Parādīt failu

@@ -0,0 +1,118 @@
1
+
2
+<script>
3
+    layui.use(['yzn','table', 'yznTable'], function() {
4
+        var table = layui.table,
5
+            $ = layui.$,
6
+            form = layui.form,
7
+            table = layui.table,
8
+            yzn = layui.yzn,
9
+            yznTable = layui.yznTable;
10
+
11
+        var init = {
12
+            table_elem: '#currentTable',
13
+            table_render_id: 'currentTable',
14
+            add_url: "{:url('add',['catid'=>$catid])}",
15
+            delete_url: "{:url('del',['catid'=>$catid])}",
16
+            modify_url: '{:url("listorder",["catid"=>$catid])}',
17
+        };
18
+
19
+        yznTable.render({
20
+            init: init,
21
+            toolbar: ['refresh',
22
+                [{
23
+                    text: '添加',
24
+                    url: init.add_url,
25
+                    method: 'open',
26
+                    auth: 'add',
27
+                    icon: 'iconfont icon-add',
28
+                    class: 'layui-btn layui-btn-normal layui-btn-sm btn-add',
29
+                    extend: 'data-full="true"',
30
+                }], 'delete',
31
+                [{
32
+                    html: '<button class="layui-btn layui-btn-sm layui-btn-normal move"><i class="iconfont icon-yidong"></i>&nbsp;批量移动</button> ',
33
+                    auth: 'remove',
34
+                }],
35
+                [{
36
+                    html: '<button class="layui-btn layui-btn-warm layui-btn-sm" data-table="currentTable" data-open="{:url("recycle",["catid"=>$catid])}"><i class="iconfont icon-recycle-line"></i>&nbsp;回收站</button>',
37
+                    auth: 'recycle',
38
+                }],
39
+            ],
40
+            url: '{:url("classlist",["catid"=>$catid])}',
41
+            cols: [
42
+                [
43
+                    { type: 'checkbox', fixed: 'left' },
44
+                    { field: 'listorder', width: 70, title: '排序', edit: 'text',search:false },
45
+                    { field: 'id', width: 60, title: 'ID' },
46
+                    { field: 'title', align: "left", title: '标题', templet: '#title', searchOp: 'like' },
47
+                    { field: 'flag', width: 100, title: '属性',hide: true, selectList: { 1: '置顶', 2: '头条', 3: '特荐', 4: '推荐', 5: '热点', 6: '幻灯' }, searchOp: 'FIND_IN_SET' },
48
+                    //{ field: 'thumb', width: 100, title: '图片', search: false, templet: yznTable.formatter.image },
49
+                    { field: 'hits', width: 80, title: '点击量',search: 'between',searchTip:'点击量' },
50
+                    { field: 'update_time', width: 160, title: '更新时间', search: 'range' },
51
+                    { field: 'username', width: 80, title: '发布人', templet: '#username' },
52
+                    { field: 'url', width: 60, align: "center", title: 'URL', templet: yznTable.formatter.url, search: false },
53
+                    { field: 'status', width: 100, align: "center", title: '状态', templet: '#statusTpl', unresize: true, selectList: { 0: '待审核', 1: '通过' } },
54
+                    { field: 'diqu', width: 100, align: "center", title: '区域', templet: '#areaTpl', unresize: true, selectList: {"1":"广东","30":"福建","6872":"陕西","6791":"西藏","6645":"云南","6344":"四川","6303":"重庆","6003":"海南","5879":"广西","5742":"湖南","5625":"湖北","5448":"河南","5179":"江西","5056":"安徽","4833":"江苏","4813":"上海","4667":"黑龙江","4589":"吉林","4474":"辽宁","4228":"山西","4042":"河北","4023":"天津","4003":"浙江","6547":"贵州","4359":"内蒙古","4004":"北京","6990":"甘肃","7092":"青海","7144":"宁夏","7171":"新疆","10000":"主站"} },
55
+                    { field: 'step', width: 100, align: "center", title: '步骤', templet: '#stepTpl', unresize: true, selectList: {"0":"未开始","1":"生成标题","2":"生成文章","3":"AI检测","4":"原创度检测","5":"违禁词过滤","6":"待发布"} },
56
+                    { fixed: 'right', width: 90, title: '操作', toolbar: '#barTool' }
57
+                ]
58
+            ],
59
+            page: {}
60
+        });
61
+        yznTable.bindevent();
62
+
63
+        $('body').on('click', '.btn-add', function() {
64
+            var url = $(this).attr('data-open');
65
+            {if $cmsConfig['doc_edit_mode'] == 0}
66
+            yzn.open('添加', url,'100%','100%');
67
+            {else}
68
+            window.top.layui.admin.addTab('cms_add','添加',url)
69
+            {/if}
70
+                return false;
71
+            });
72
+
73
+
74
+            $('body').on('click', '.move', function() {
75
+                var checkStatus = table.checkStatus('currentTable'),
76
+
77
+                    ids = [],
78
+                    id = tag = '';
79
+                var data = checkStatus.data;
80
+                if (data.length > 0) {
81
+                    for (let i in data) {
82
+                        id += tag + data[i].id;
83
+                        tag = '|';
84
+                        //ids.push(data[i].id);
85
+                    }
86
+                    layer.open({
87
+                        title: '批量移动',
88
+                        type: 1,
89
+                        content: $('#remove'),
90
+                        area: ['300px', '250px'],
91
+                        btn: ['移动'],
92
+                        yes: function(index, layero) {
93
+                            var tocatid = $("select[name='remove']").val();
94
+                            if (tocatid == 0) {
95
+                                layer.msg("请选择移动的栏目",{icon: 2});
96
+                                return;
97
+                            }
98
+                            $.post('{:url("remove",["catid"=>$catid])}', { 'ids': id, 'tocatid': tocatid }, function(data) {
99
+                                if (data.code == 1) {
100
+                                    table.reload('currentTable');
101
+                                    layer.msg(data.msg,{icon: 1});
102
+                                    layer.close(index);
103
+                                } else {
104
+                                    layer.msg(data.msg,{icon: 2});
105
+                                }
106
+                            })
107
+                        },
108
+                        end: function(){
109
+                            $('#remove').hide();
110
+                        }
111
+                    });
112
+                } else {
113
+                    layer.msg("请选择需要移动的数据",{icon: 2});
114
+                }
115
+            });
116
+
117
+        });
118
+</script>

+ 1
- 2
application/admin/view/cms/cms/list/catid_18.html Parādīt failu

@@ -43,6 +43,7 @@
43 43
                     { type: 'checkbox', fixed: 'left' },
44 44
                     { field: 'listorder', width: 50, title: '排序', edit: 'text',search:false },
45 45
                     { field: 'id', width: 80, title: 'ID' },
46
+                    { field: 'ar_type', width: 80, title: '类型', templet: '#ar_type', selectList: { 0: '普通', 1: '范文'} },
46 47
                     { field: 'gzxh', width: 60, title: '规则' },
47 48
                     { field: 'zc', width: 60, title: '主词', templet: '#zc', searchOp: 'like' },
48 49
                     { field: 'title', align: "left", title: '标题', templet: '#title', searchOp: 'like' },
@@ -58,8 +59,6 @@
58 59
                     { field: 'status', width: 100, align: "center", title: '状态', templet: '#statusTpl', unresize: true, selectList: { 0: '待审核', 1: '通过' } },
59 60
                     { field: 'is_cf', width: 100, title: '重复', templet: '#isCf', selectList: { 0: '未检测', 1: '重复', 2: '已同步'} },
60 61
                     //{ field: 'diqu', width: 100, align: "center", title: '区域', templet: '#areaTpl', unresize: true, selectList: {"1":"广东","30":"福建","6872":"陕西","6791":"西藏","6645":"云南","6344":"四川","6303":"重庆","6003":"海南","5879":"广西","5742":"湖南","5625":"湖北","5448":"河南","5179":"江西","5056":"安徽","4833":"江苏","4813":"上海","4667":"黑龙江","4589":"吉林","4474":"辽宁","4228":"山西","4042":"河北","4023":"天津","4003":"浙江","6547":"贵州","4359":"内蒙古","4004":"北京","6990":"甘肃","7092":"青海","7144":"宁夏","7171":"新疆","10000":"主站"} },
61
-
62
-
63 62
                     { fixed: 'right', width: 90, title: '操作', toolbar: '#barTool' }
64 63
                 ]
65 64
             ],

+ 70
- 0
application/admin/view/cms/cms/script/catid_14.html Parādīt failu

@@ -0,0 +1,70 @@
1
+<script type="text/html" id="barTool">
2
+    {if $cmsConfig['doc_edit_mode'] == 1}
3
+    <a class="layui-btn layui-btn-xs btn-addtabs{:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-menu-id="{$catid}-{{ d.id }}" data-url='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
4
+    {else}
5
+    <a class="layui-btn layui-btn-xs {:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
6
+    {/if}
7
+    <a href='{:url("del",["catid"=>$catid])}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('cms.cms/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a>
8
+</script>
9
+<script type="text/html" id="title">
10
+    {{# if(d.flag.indexOf("1")!==-1){ }}
11
+    <span class="text-danger">[置顶]</span>
12
+    {{#  } }}
13
+    {{# if(d.flag.indexOf("2")!==-1){ }}
14
+    <span class="text-danger">[头条]</span>
15
+    {{#  } }}
16
+    {{# if(d.flag.indexOf("3")!==-1){ }}
17
+    <span class="text-danger">[特荐]</span>
18
+    {{#  } }}
19
+    {{# if(d.flag.indexOf("4")!==-1){ }}
20
+    <span class="text-danger">[推荐]</span>
21
+    {{#  } }}
22
+    {{# if(d.flag.indexOf("5")!==-1){ }}
23
+    <span class="text-danger">[热点]</span>
24
+    {{#  } }}
25
+    {{# if(d.flag.indexOf("6")!==-1){ }}
26
+    <span class="text-danger">[幻灯]</span>
27
+    {{#  } }}
28
+    {{# if(d.thumb){ }}
29
+    <span class="text-success">[有图]</span>
30
+    {{#  } }}
31
+    <a  data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true">{{ d.title }}</a>
32
+</script>
33
+<script type="text/html" id="username">
34
+    {{# if(d.sysadd==1){ }}
35
+    {{ d.username }}
36
+    {{#  } else { }}
37
+    <span class="text-danger">{{ d.username }}</span>
38
+    {{#  } }}
39
+</script>
40
+<script type="text/html" id="statusTpl">
41
+    <input type="checkbox" name="status" data-href='{:url("setstate",["catid"=>$catid])}?id={{d.id}}' value="{{d.id}}" lay-skin="switch" lay-text="通过|待审核" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
42
+</script>
43
+
44
+<script type="text/html" id="areaTpl">
45
+    {{ d.diqu }}
46
+</script>
47
+
48
+<script type="text/html" id="stepTpl">
49
+    {{# if(d.step == 0 || d.step == '0'){ }}
50
+    <span class="text-danger">未开始</span>
51
+    {{#  } }}
52
+    {{# if(d.step == 1 || d.step == '1'){ }}
53
+    <span class="text-danger">生成标题</span>
54
+    {{#  } }}
55
+    {{# if(d.step == 2 || d.step == '2'){ }}
56
+    <span class="text-danger">生成文章</span>
57
+    {{#  } }}
58
+    {{# if(d.step == 3 || d.step == '3'){ }}
59
+    <span class="text-danger">AI检测</span>
60
+    {{#  } }}
61
+    {{# if(d.step == 4 || d.step == '4'){ }}
62
+    <span class="text-danger">原创度检测</span>
63
+    {{#  } }}
64
+    {{# if(d.step == 5 || d.step == '5'){ }}
65
+    <span class="text-danger">违禁词过滤</span>
66
+    {{#  } }}
67
+    {{# if(d.step == 6 || d.step == '6'){ }}
68
+    <span class="text-danger">待发布</span>
69
+    {{#  } }}
70
+</script>

+ 9
- 0
application/admin/view/cms/cms/script/catid_18.html Parādīt failu

@@ -28,6 +28,7 @@
28 28
     {{# if(d.thumb){ }}
29 29
     <span class="text-success">[有图]</span>
30 30
     {{#  } }}
31
+
31 32
     <a  data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true">{{ d.title }}</a>
32 33
 </script>
33 34
 
@@ -43,6 +44,14 @@
43 44
     {{#  } }}
44 45
 </script>
45 46
 
47
+<script type="text/html" id="ar_type">
48
+    {{# if(d.is_cf.indexOf("0")!==-1){ }}
49
+    <span class="text-danger">[普通]</span>
50
+    {{#  } }}
51
+    {{# if(d.is_cf.indexOf("1")!==-1){ }}
52
+    <span class="text-danger">[范文]</span>
53
+    {{#  } }}
54
+</script>
46 55
 
47 56
 <script type="text/html" id="zc">
48 57
     <sapn>{{ d.zc }}</sapn>

+ 288
- 8
application/api/controller/Ai.php Parādīt failu

@@ -25,7 +25,7 @@ use think\Db;
25 25
 class Ai extends MemberApi
26 26
 {
27 27
 
28
-    protected $noNeedLogin = ['login', 'register','uploadCsv','uploadCsvFrom','exportCsv','dsTitle','dsTitlelist','dsTitle13','bdPicHandle','titleHandleApi'];
28
+    protected $noNeedLogin = ['login', 'register','uploadCsv','uploadCsvFrom','exportCsv','dsTitle','dsTitlelist','dsTitle13','bdPicHandle','titleHandleApi','dsTitlelist14','getTitleZl','getContentZl','getContent5188Zl'];
29 29
     protected $noNeedRight = [];
30 30
 
31 31
     //初始化
@@ -101,7 +101,7 @@ class Ai extends MemberApi
101 101
             return json($data);
102 102
         }
103 103
         if(!empty($post['url'])){
104
-            $this->csvHandle('./uploads/'.$post['url'],$post['rule'],$post['title']);
104
+            $this->csvHandle('./uploads/'.$post['url'],$post['rule'],$post['title'],$post['ar_type']);
105 105
             $data = ['code' => 0, 'msg' => '提交成功', 'data' =>$post];
106 106
         }else{
107 107
             $data = ['code' => 1, 'msg' => '提交失败', 'data' => []];
@@ -114,7 +114,7 @@ class Ai extends MemberApi
114 114
      * 逻辑控制器
115 115
      * 规则的指令集和创意 如果为空 调用全局的即可 同样优先调用自身规则
116 116
      */
117
-    public function csvHandle($url,$rule,$title){
117
+    public function csvHandle($url,$rule,$title,$ar_type){
118 118
         // 读取CSV文件
119 119
         $filename = $url;
120 120
         if (file_exists($filename)) {
@@ -173,6 +173,7 @@ class Ai extends MemberApi
173 173
                                 'is_use' => $is_use, //是否合法
174 174
                                 'desc' => $desc, //非法原因 或者 合法匹配结果
175 175
                                 'gzxh' => $rule,
176
+                                'ar_type' => $ar_type, //类型
176 177
                                 'sj' => $task_no, //写入时间维度 批次
177 178
                                 'is_use_id' => json_encode($rule_id,JSON_UNESCAPED_UNICODE), //写入具体规则id 可查询到对应规则是什么 判断是否合法
178 179
                             ];
@@ -562,7 +563,8 @@ class Ai extends MemberApi
562 563
         $id_list = Db::name('cms_zl')->where([
563 564
                 'catid'=>18,
564 565
                 'is_use' => 1,
565
-                'status' => 0
566
+                'status' => 0,
567
+                'ar_type' => 0
566 568
             ])->limit(10)->column('id');
567 569
         dump($id_list);
568 570
         Db::name('cms_zl')->where('id','in',$id_list)->update([
@@ -598,6 +600,7 @@ class Ai extends MemberApi
598 600
                 'is_use' => 1, //合法
599 601
                 'status' => 1,
600 602
                 'is_cf' => 0, //是否重复
603
+                'ar_type' => 0
601 604
                 //'id'=>1199
602 605
             ])
603 606
             ->field('id,title,create_time,is_use_id')
@@ -637,10 +640,7 @@ class Ai extends MemberApi
637 640
                         //既然指定 不管管是否为空
638 641
                         $cy = $json['cy'.$json['is_sj']];
639 642
                     }else{
640
-
641 643
                         //随机
642
-
643
-
644 644
                         $sj_num = [];
645 645
                         for($i=1;$i<=6;$i++){
646 646
                             if(!empty($json['cy'.$i])){
@@ -708,7 +708,6 @@ class Ai extends MemberApi
708 708
             'status' => 1
709 709
         ]);
710 710
     }
711
-
712 711
     /*
713 712
      * 处理百度的的ai图片 变成本地的
714 713
      * 定时任务处理
@@ -804,5 +803,286 @@ class Ai extends MemberApi
804 803
     }
805 804
 
806 805
 
806
+    /*
807
+     * 定时同步 范文到自动发文
808
+     *  http://console.zx2049.com/api/ai/dsTitlelist14
809
+     */
810
+    public function dsTitlelist14()
811
+    {
812
+        //得到最后时间
813
+        $row = Db::name('cms_ai')->where([
814
+            'catid' => 14
815
+        ])
816
+            ->order('tb_time desc')
817
+            ->limit(1)
818
+            ->find();
819
+
820
+        //var_dump($row);
821
+
822
+        if(isset($row['tb_time'])){
823
+            $lasttime = $row['tb_time'];
824
+        }else{
825
+            $lasttime = 0;
826
+        }
827
+
828
+        //目前没有规则
829
+        $list = Db::name('cms_zl')->where([
830
+                'catid'=>18,
831
+                //'is_use' => 1, //合法
832
+                //'status' => 1,
833
+                //'is_cf' => 0, //是否重复
834
+                'ar_type' => 1
835
+                //'id'=>1199
836
+            ])
837
+            ->field('id,title,create_time,is_use_id')
838
+            ->where('create_time','>',$lasttime)
839
+            //->limit(10) //不能限制数量 不然时间查询 下次会漏掉某些时间相同的剩余数量 //要么使用状态字段 //要么使用自增id判断
840
+            ->order('create_time asc') //必须asc排序 先入库
841
+            ->select();
842
+
843
+        //dump($list);die;
844
+
845
+        foreach ($list  as $index=>$row) {
846
+            $one = Db::name('cms_ai')->field('id,title')->where(['catid' => 14])->where('title','=',$row['title'])->find();
847
+
848
+            if(empty($one)){
849
+
850
+                //$json = strip_tags(htmlspecialchars_decode($row['is_use_id']));
851
+                //echo $json;
852
+                $json = $row['is_use_id'];
853
+                $json = json_decode($json,true);
854
+                //dump($json);die;
855
+
856
+
857
+                if(!empty($json['zlj'])) {
858
+                    //读取指令集
859
+                    $zlj = $json['zlj'];
860
+                    $zlj_arr = json_decode($zlj, true);
861
+                    $zlj_end = end($zlj_arr);
862
+                    $key = count($zlj_arr) - 1;
863
+                    unset($zlj_arr[$key]);
864
+                    $zlj = json_encode($zlj_arr, JSON_UNESCAPED_UNICODE);
865
+                }else{
866
+                    $zlj_end = '0';
867
+                    $zlj = '';
868
+                }
869
+
870
+                if(empty($json['is_sj'])){
871
+                    $is_sj = "0";
872
+                }else{
873
+                    $is_sj = $json['is_sj'];
874
+                }
875
+
876
+                //获取创意
877
+                if((string)$json['is_sj'] === '-1'){
878
+                    //不需要加创意
879
+                    $cy = '0';
880
+                }else{
881
+                    if((int)$json['is_sj'] > 0){
882
+                        //既然指定 不管管是否为空
883
+                        $cy = $json['cy'.$json['is_sj']];
884
+                    }else{
885
+                        //随机
886
+                        $sj_num = [];
887
+                        for($i=1;$i<=6;$i++){
888
+                            if(!empty($json['cy'.$i])){
889
+                                $sj_num[] = $i;
890
+                            }
891
+                        }
892
+                        if(!empty($sj_num)){
893
+                            $randomKey = array_rand($sj_num);
894
+                            $num = $sj_num[$randomKey];
895
+                            $cy = $json['cy'.$num];
896
+                        }else{
897
+                            $cy = '0';
898
+                        }
899
+                    }
900
+                }
901
+
902
+                //不存在于ai中
903
+                $data = [
904
+                    'catid' => 14,
905
+                    'title' => $row['title'],
906
+                    'content' => '0',
907
+                    'topic_1' => '0',
908
+                    'topic_2' => '0',
909
+                    'topic_3' => '0',
910
+                    'didian' => '0',
911
+                    'dssj' => '0',
912
+                    'fbsj' => '0',
913
+                    'tb_time' => $row['create_time'],
914
+                    'create_time' => time(),
915
+                    'update_time' => time(),
916
+                    'status' => 0, //默认手动开启
917
+                    'cy' => $cy, //创意
918
+                    'zlj' => $zlj, //指令集 json字符串
919
+                    'tpzl' => $zlj_end,
920
+                    'sjcy' => $is_sj, //随机创意
921
+                    'lyjlid' => $row['id'], //来源id
922
+                    'sblx' => 3,//设别类型 电脑A
923
+                    'is_sc' => 0, //是否生成文章
924
+                    'pic_html' => '0',
925
+                    'imgs' => '{}'
926
+                ];
927
+                $run = Db::name('cms_ai')->insert($data);
928
+                Db::name('cms_zl')->where('id',$row['id'])->update(['is_cf'=>2]); //已检测 同步
929
+                echo $run;
930
+            }else{
931
+                //更新为重复记录
932
+                Db::name('cms_zl')->where('id',$row['id'])->update(['is_cf'=>1]);
933
+                echo $row['title']."已存在,更新为重复记录";
934
+            }
935
+        }
936
+    }
937
+
938
+    /*
939
+     * 自动范文 根据标题生成指令
940
+     * http://console.zx2049.com/api/ai/getTitleZl
941
+     */
942
+     public function getTitleZl(){
943
+         $title = request()->get('title');
944
+         $zl = [
945
+            '你是一位资深的职称评审专家,你非常擅长于在职场评审领域利用用户的痛点来构思和创作文章,你写的每一篇关于“职称评审”的文章都能被百度搜索引擎收录,并能获得大量的用户点击和阅读,你写的文章非常具有可阅读性和实用性,你写的文章结构非常的简洁明了,你写的文章的原创度达到100%,现在请你以这个身份来帮我写文章可以吗?如果可以,请回复可以!并等到我下一步指令',
946
+            '以你最擅长的“职场评审”这个领域为切入点,以这个“'.$title.'”为关键词,根据百度SEO软文的规则生成爆款文章的标题,具体要求如下:1、{'.$title.'}这个只是关键词,并非标题,但需要在标题中完整的出现或以分段的方式出现。 2、标题控制在20个文字以内。 3、标题要从用户的角度出发,以用户在”职称评审“过程中的痛点为切入。'
947
+         ];
948
+         $res = [
949
+             'code' => 0,
950
+             'msg' => ''.$title,
951
+             'data' => $zl
952
+         ];
953
+         return json($res);
954
+     }
955
+
956
+     /*
957
+      * 获取文章指令
958
+      * http://console.zx2049.com/api/ai/getContentZl?id=1863
959
+      */
960
+     public function getContentZl(){
961
+         $id = request()->get('id');
962
+         //查询文章
963
+         $row = Db::name('cms_ai')->where('id',$id)->find();
964
+         //var_dump($row);
965
+         $title_html = strip_tags($row['title_html']);
966
+         $title_html = str_replace('"','',$title_html);
967
+
968
+         $zl = ['文章标题:“'.$title_html.'”。文章内容:请根据用户的述求或痛点来提供实质性的内容以达到充分解决用户的问题。文章关键词:'.$row['title'].'(强调:文章中的“'.$row['title'].'”这个词完整的出现次数不低于6次,不高于8次,且必须语句通顺,并合理安排出现的位置)。文章要求:1、文章的长度不低于1500字。2、文章的段落结构分明,具有很好的可观赏性,每个段落不超过150个字。3、文章中以第一人称的视角来进行经验阐述。4、文章尽可能简洁明了,并增加文章的感染力和节奏感;5、文章让别人一看就认为这篇文章是人工撰写的,所以请尽量使用口语化的表述方式(口语化是指:人与人之间常规沟通使用的语气、语调、用词等)。6、文章具有非常好的可阅读性,能够充分的调动用户的情绪!7、确保文章中的语句在全网的任何文章中都没有使用过!!!8、再次强调:文章中使用的语句在全网的任何文章中都没有使用过!!!'];
969
+         $res = [
970
+             'code' => 0,
971
+             'msg' => ''.$id,
972
+             'data' => $zl
973
+         ];
974
+         return json($res);
975
+     }
976
+
977
+     /*
978
+      * 5118获取文章内容
979
+      * http://console.zx2049.com/api/ai/getContent5188Zl?id=1864
980
+      */
981
+    public function getContent5188Zl(){
982
+        $id = request()->get('id');
983
+        //查询文章
984
+        $row = Db::name('cms_ai')->where('id',$id)->find();
985
+        //var_dump($row);
986
+        //判断是否被转义
987
+        if(strpos($row['content'],'&lt;') !== false) {
988
+            $content = htmlspecialchars_decode($row['content']);
989
+        } else {
990
+            $content = $row['content'];
991
+        }
992
+
993
+        //使用采集插件进行html代码解析
994
+        //发送post进行处理
995
+        //http://workerman.dev.zx2049.com/index/index/hello
996
+        $post_data = ['html'=>$content];
997
+        $html = $this->curl_request('http://workerman.dev.zx2049.com/index/index/handleHtmlDom',$post_data);
998
+        //var_dump($html);die;
999
+
1000
+        //$title_html = strip_tags($row['title_html']);
1001
+        //$title_html = str_replace('"','',$title_html);
1002
+
1003
+        $str = $this->html2text($html);
1004
+        $str = explode('-换行-',$str);
1005
+        //var_dump($str);die;
1006
+        //echo '<textarea id="div1 js-do=" inpttxt"="" class="inptTxt fontfamily" placeholder="请输入要检测的文本内容,不超过3000字">'.$str.'</textarea>';die;
1007
+
1008
+        //去除空
1009
+        $zl = [];
1010
+        foreach ($str as $k=>$r){
1011
+            if(!empty($r)){
1012
+                $zl[] = $r;
1013
+            }
1014
+        }
1015
+
1016
+        $res = [
1017
+            'code' => 0,
1018
+            'msg' => ''.$id,
1019
+            'data' => $zl
1020
+        ];
1021
+        return json($res);
1022
+    }
1023
+
1024
+    public function html2text($str){
1025
+        $str = preg_replace("/<style .*?<\\/style>/is", "", $str);
1026
+        $str = preg_replace("/<script .*?<\\/script>/is", "", $str);
1027
+        $str = preg_replace("/<br \\s*\\/>/i", "-换行-", $str);
1028
+        $str = preg_replace("/<\\/?p>/i", "-换行-", $str);
1029
+        $str = preg_replace("/<\\/?td>/i", "", $str);
1030
+        $str = preg_replace("/<\\/?div>/i", "-换行-", $str);
1031
+        $str = preg_replace("/<\\/?blockquote>/i", "", $str);
1032
+        $str = preg_replace("/<\\/?li>/i", "-换行-", $str);
1033
+        $str = preg_replace("/ /i", " ", $str);
1034
+        $str = preg_replace("/ /i", " ", $str);
1035
+        $str = preg_replace("/&/i", "&", $str);
1036
+        $str = preg_replace("/&/i", "&", $str);
1037
+        $str = preg_replace("/</i", "<", $str);
1038
+        $str = preg_replace("/</i", "<", $str);
1039
+        $str = preg_replace("/“/i", '"', $str);
1040
+        $str = preg_replace("/&ldquo/i", '"', $str);
1041
+        $str = preg_replace("/‘/i", "'", $str);
1042
+        $str = preg_replace("/&lsquo/i", "'", $str);
1043
+        $str = preg_replace("/'/i", "'", $str);
1044
+        $str = preg_replace("/&rsquo/i", "'", $str);
1045
+        $str = preg_replace("/>/i", ">", $str);
1046
+        $str = preg_replace("/>/i", ">", $str);
1047
+        $str = preg_replace("/”/i", '"', $str);
1048
+        $str = preg_replace("/&rdquo/i", '"', $str);
1049
+        $str = strip_tags($str);
1050
+        $str = html_entity_decode($str, ENT_QUOTES, "utf-8");
1051
+        $str = preg_replace("/&#.*?;/i", "", $str);
1052
+        return $str;
1053
+    }
807 1054
 
1055
+    //参数1:访问的URL,参数2:post数据(不填则为GET),参数3:提交的$cookies,参数4:是否返回$cookies
1056
+    public function curl_request( $url , $post = '' , $cookie = '' ,  $returnCookie = 0 ) {
1057
+        $curl  =  curl_init ( ) ;
1058
+        curl_setopt ( $curl , CURLOPT_URL ,  $url ) ;
1059
+        curl_setopt ( $curl , CURLOPT_USERAGENT ,  'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)' ) ;
1060
+        curl_setopt ( $curl , CURLOPT_FOLLOWLOCATION ,  1 ) ;
1061
+        curl_setopt ( $curl , CURLOPT_AUTOREFERER ,  1 ) ;
1062
+        curl_setopt ( $curl , CURLOPT_REFERER ,  "http://XXX" ) ;
1063
+        if ( $post )  {
1064
+            curl_setopt ( $curl , CURLOPT_POST ,  1 ) ;
1065
+            curl_setopt ( $curl , CURLOPT_POSTFIELDS ,  http_build_query ( $post ) ) ;
1066
+        }
1067
+        if ( $cookie )  {
1068
+            curl_setopt ( $curl , CURLOPT_COOKIE ,  $cookie ) ;
1069
+        }
1070
+        curl_setopt ( $curl , CURLOPT_HEADER ,  $returnCookie ) ;
1071
+        curl_setopt ( $curl , CURLOPT_TIMEOUT ,  10 ) ;
1072
+        curl_setopt ( $curl , CURLOPT_RETURNTRANSFER ,  1 ) ;
1073
+        $data  =  curl_exec ( $curl ) ;
1074
+        if  ( curl_errno ( $curl ) )  {
1075
+            return  curl_error ( $curl ) ;
1076
+        }
1077
+        curl_close ( $curl ) ;
1078
+        if ( $returnCookie ) {
1079
+            list ( $header ,  $body )  =  explode ( "\r\n\r\n" ,  $data ,  2 ) ;
1080
+            preg_match_all ( "/Set\-Cookie:([^;]*);/" ,  $header ,  $matches ) ;
1081
+            $info [ 'cookie' ]   =  substr ( $matches [ 1 ] [ 0 ] ,  1 ) ;
1082
+            $info [ 'content' ]  =  $body ;
1083
+            return  $info ;
1084
+        } else {
1085
+            return  $data ;
1086
+        }
1087
+    }
808 1088
 }

Notiek ielāde…
Atcelt
Saglabāt