chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/*
* $Author :PHPYUN开发团队
*
* 官网: http://www.phpyun.com
*
* 版权所有 2009-2021 宿迁鑫潮信息技术有限公司,并保留所有权利。
*
* 软件声明:未经授权前提下,不得用于商业运营、二次开发以及任何形式的再次发布。
 */
class news_controller extends common{
    function addnews_action(){//新闻添加
        include(APP_PATH."data/api/locoy/locoy_config.php");
        if($locoyinfo['locoy_online']!=1){
            echo 4;die;
        }
        if($locoyinfo['locoy_key']!=trim($_GET['key'])){
            echo 5;die;
        }
        if(!$_POST['title'] || !$_POST['content'] || !$_POST['nid']){
            echo 2;die;
        }
        $row=$this->obj->DB_select_once("news_base","`title`='".trim($_POST['title'])."' and `nid`='".$_POST['nid']."'");
        if(is_array($row)){
            echo 3;die;
        }
        $content=$_POST['content'];
        
        $value="";
        $value.="`title`='".trim($_POST['title'])."',";
        $value.="`nid`='".$_POST['nid']."',";
        
        if($_POST['did']){
            $value.="`did`='".$_POST['did']."',";
        }else{
            $value.="`did`='0',";
        }
        $value.="`author`='".$_POST['author']."',";
        $description=mb_substr(strip_tags(html_entity_decode($content,ENT_NOQUOTES,"GB2312")),0,180,"utf-8");
        $description=$_POST['description']?$_POST['description']:$description;
        $description=str_replace(array(' ',"\n","\r","\r\n"," "),array(''),$description);
        $value.="`description`='".$description."',";
        $value.="`source`='".$_POST['source']."'";
        if($_POST['ctime']){
            $value.=",`datetime`='".strtotime($_POST['ctime'])."',`starttime`='".strtotime($_POST['ctime'])."'";
        }else{
            $value.=",`datetime`='".time()."',`starttime`='".strtotime('today')."'";
        }
        if($_POST['hits']){
            $value.=",`hits`='".trim($_POST['hits'])."'";
        }else{
            $row=explode('-',$locoyinfo['locoy_rand']);
            if(is_array($row)){
                $rand=rand(trim($row[0]),trim($row[1]));
            }else{
                $rand=!trim($row)?0:$row;
            }
            $value.=",`hits`='".$rand."'";
        }
        if($_POST['sort']){
            $value.=",`sort`='".trim($_POST['sort'])."'";
        }else{
            $row=explode('-',$locoyinfo['locoy_sort']);
            if(is_array($row)){
                $rand=rand(trim($row[0]),trim($row[1]));
            }else{
                $rand=!trim($row)?0:$row;
            }
            $value.=",`sort`='".$rand."'";
        }
        if($_POST['newsphoto']){
            $value.=",`newsphoto`='".trim($_POST['newsphoto'])."'";
        }
        if($_POST['s_thumb']){
            $value.=",`s_thumb`='".trim($_POST['s_thumb'])."'";
        }
       if(!$_POST['keyword'] && $locoyinfo['locoy_keyword']==1){
            require(LIB_PATH."lib_splitword_class.php");
            $sp = new SplitWord();
            $keywordarr=$sp->getkeyword(strip_tags(html_entity_decode($content)));
            $value.=",`keyword`='".strip_tags(@implode(",",$keywordarr))."'";
        }elseif($_POST['keyword']){
            $value.=",`keyword`='".str_replace(",",",",$_POST['keyword'])."'";
        }
         $new_base = $this->obj->DB_insert_once("news_base",$value);
        $news_content = $this->obj->DB_insert_once("news_content", "`nbid`='$new_base',`content`='".html_entity_decode($content,ENT_NOQUOTES,"GB2312")."'");
        if($new_base){
            echo 1;die;
        }else{
            echo 0;die;    
        }
    }
}
?>