添加操作。。。

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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?php
/**
 * 对关键词的增删改查
 * ======================================================
 * 代码生产日期:2016-05-07 21:19
 * @author: Abner
 * @qq: 346882795
 * @website: www.liyanzhi.com
 * ======================================================
 *
 * */
define('IN_ECS', true);
 
require(dirname(__FILE__) . '/includes/init.php');
include_once(ROOT_PATH . '/includes/cls_image.php');
$exc = new exchange($ecs->table('keyword_url'), $db, 'key_id', 'title');
/* 允许上传的文件类型 */
$allow_file_types = '|GIF|JPG|PNG|BMP|SWF|DOC|XLS|PPT|MID|WAV|ZIP|RAR|PDF|CHM|RM|TXT|';
 
 
/**
 *************************关键词列表*************************
 **/
  
if ($_REQUEST['act'] == 'list')
{
    /* 检查权限 */
    admin_priv('keyword');
    /* 取得过滤条件 */
    $keyword = get_keywordlist();
    $smarty->assign('article_list',    $keyword['arr']);
    $smarty->assign('filter',          $keyword['filter']);
    $smarty->assign('record_count',    $keyword['record_count']);
    $smarty->assign('page_count',      $keyword['page_count']);
     
    $smarty->assign('full_page',    1);
    $smarty->assign('cat_select',  article_cat_list(0));
    $smarty->assign('action_link'array('text' => $_LANG['02_key_add'], 'href' => 'keyword.php?act=add'));
    assign_query_info();
    $smarty->display('keyword.htm');
}
 
/*------------------------------------------------------ */
//-- 添加文章
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'add')
{
    /* 权限判断 */
    admin_priv('keyword');
     
    /*初始化*/
    $article = array();
    $article['is_open'] = 1;
    $smarty->assign('article',     $article);
    $smarty->assign('ur_here',     $_LANG['02_key_add']);
    $smarty->assign('action_link', array('text' => $_LANG['01_key_list'], 'href' => 'keyword.php?act=list'));
    $smarty->assign('form_action', 'insert');
     
    assign_query_info();
    $smarty->display('keyword_info.htm');
}
elseif ($_REQUEST['act']  == 'insert')
{
    /* 权限判断 */
    admin_priv('keyword');
    /*检查是否重复*/
//     $is_only = $exc->is_only('title', $_POST['title'],0, " cat_id ='$_POST[article_cat]'");
     
//     if (!$is_only)
//     {
//         sys_msg(sprintf($_LANG['title_exist'], stripslashes($_POST['title'])), 1);
//     }
     
    //处理接收来的数据
    if(!empty($_POST))
    {
        $arr = array();
        foreach($_POST['title'as $k => $v){
            $arr[] = array(
                  'title'   => $v,
                  'url'     => $_POST['url'][$k],
                  'num'     => $_POST['num'][$k]
                );
             
        }
    }
     
    /* 拼接数据 */
    $val = '';
    foreach($arr as $k2 => $v2)
    {
        $val .= "('{$v2['title']}', '{$v2['url']}', '{$v2['num']}'),";
    }
   $val = rtrim($val, ',');
  $sql = "INSERT INTO " .$ecs->table('keyword_url'). "(`title`, `url`, `num`) VALUES " .$val;
  $db->query($sql);
   
  $link[0]['text'] = $_LANG['continue_add'];
  $link[0]['href'] = 'keyword.php?act=add';
   
  $link[1]['text'] = $_LANG['back_list'];
  $link[1]['href'] = 'keyword.php?act=list';
   
  admin_log($_POST['title'],'add','keyword');
  clear_cache_files(); // 清除相关的缓存文件
  sys_msg('添加成功',0, $link);
     
}
 
 
/*------------------------------------------------------ */
//-- 编辑字
/*------------------------------------------------------ */
 
elseif ($_REQUEST['act'] == 'edit_title')
{
    check_authz_json('keyword');
    $id    = intval($_POST['id']);
    $title = json_str_iconv(trim($_POST['val']));
     
    /* 检查文章标题是否重复 */
    if ($exc->num("title", $title, $id) != 0)
    {
        make_json_error(sprintf($_LANG['title_exist'], $title));
    }
    else
    {
         
        if ($exc->edit("title = '$title'", $id))
        {
            clear_cache_files();
            admin_log($title, 'edit', 'keyword');
            make_json_result(stripslashes($title));
        }
        else
        {
            make_json_error($db->error());
        }
    }
     
}
/*------------------------------------------------------ */
//-- 编辑url
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_url')
{
    check_authz_json('keyword');
    $id    = intval($_POST['id']);
    $url = json_str_iconv(trim($_POST['val']));
    /* 检查文章标题是否重复 */
    if ($exc->num("title", $title, $id) != 0)
    {
        make_json_error(sprintf($_LANG['title_exist'], $title));
    }
    else
    {
 
        if ($exc->edit("url = '$url'", $id))
        {
            clear_cache_files();
            admin_log($url, 'edit', 'keyword');
            make_json_result(stripslashes($url));
        }
        else
        {
            make_json_error($db->error());
        }
    }
 
}
 
 
/*------------------------------------------------------ */
//-- 编辑数量
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_num')
{
    check_authz_json('keyword');
    $id    = intval($_POST['id']);
    $num = json_str_iconv(trim($_POST['val']));
    /* 检查文章标题是否重复 */
    if ($exc->num("num", $title, $id) != 0)
    {
        make_json_error(sprintf($_LANG['title_exist'], $title));
    }
    else
    {
 
        if ($exc->edit("num = '$num'", $id))
        {
            clear_cache_files();
            admin_log($num, 'edit', 'keyword');
            make_json_result(stripslashes($num));
        }
        else
        {
            make_json_error($db->error());
        }
    }
 
}
 
//获得关键字列表
function get_keywordlist()
{
     
    $result = get_filter();
    if ($result === false)
    {
        $filter = array();
        $filter['keyword']    = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1)
        {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by']    = empty($_REQUEST['sort_by']) ? 'key_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
         
        $where = '';
        if (!empty($filter['keyword']))
        {
            $where = " AND a.title LIKE '%" . mysql_like_quote($filter['keyword']) . "%'";
        }
         
        /* 关键字总数 */
        $sql = 'SELECT COUNT(*) FROM ' .$GLOBALS['ecs'] -> table('keyword_url').' WHERE 1 '.$where;
        $filter['record_count'] = $GLOBALS['db'] -> getOne($sql);
        $filter = page_and_size($filter);
//         var_dump($filter);
         
        /* 获取关键字数据 */
        $sql = 'SELECT * FROM ' .$GLOBALS['ecs'] -> table('keyword_url'). ' WHERE 1' .$where. ' ORDER BY ' .$filter['sort_by'].' '.$filter['sort_order'];;
        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
         
    }
    else
    {
        $sql    = $result['sql'];
        $filter = $result['filter'];
    }
//     var_dump($filter);
    $arr = array();
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
    while ($rows = $GLOBALS['db']->fetchRow($res))
    {
        $rows['date'] = local_date($GLOBALS['_CFG']['time_format'], $rows['add_time']);
     
        $arr[] = $rows;
    }
    return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}

  

posted @   Abner3721  阅读(221)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示