日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

添加操作。。。

發(fā)布時(shí)間:2024/4/13 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 添加操作。。。 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<?php /*** 對(duì)關(guān)鍵詞的增刪改查* ======================================================* 代碼生產(chǎn)日期: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|';/***************************關(guān)鍵詞列表***************************/if ($_REQUEST['act'] == 'list') {/* 檢查權(quán)限 */admin_priv('keyword');/* 取得過(guò)濾條件 */$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') {/* 權(quán)限判斷 */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') {/* 權(quán)限判斷 */admin_priv('keyword');/*檢查是否重復(fù)*/ // $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); // }//處理接收來(lái)的數(shù)據(jù)if(!empty($_POST)){$arr = array();foreach($_POST['title'] as $k => $v){$arr[] = array('title' => $v,'url' => $_POST['url'][$k],'num' => $_POST['num'][$k]);}}/* 拼接數(shù)據(jù) */$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(); // 清除相關(guān)的緩存文件sys_msg('添加成功',0, $link);}/*------------------------------------------------------ */ //-- 編輯字 /*------------------------------------------------------ */elseif ($_REQUEST['act'] == 'edit_title') {check_authz_json('keyword');$id = intval($_POST['id']);$title = json_str_iconv(trim($_POST['val']));/* 檢查文章標(biāo)題是否重復(fù) */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']));/* 檢查文章標(biāo)題是否重復(fù) */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());}}}/*------------------------------------------------------ */ //-- 編輯數(shù)量 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'edit_num') {check_authz_json('keyword');$id = intval($_POST['id']);$num = json_str_iconv(trim($_POST['val']));/* 檢查文章標(biāo)題是否重復(fù) */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());}}}//獲得關(guān)鍵字列表 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']) . "%'";}/* 關(guān)鍵字總數(shù) */$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);/* 獲取關(guān)鍵字?jǐn)?shù)據(jù) */$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']); }

  

轉(zhuǎn)載于:https://www.cnblogs.com/Abner3721/p/5472164.html

總結(jié)

以上是生活随笔為你收集整理的添加操作。。。的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。