function do_save() { $id = (int) $_POST['id']; $cid = (int) $_POST['cid']; $pid = (int) $_POST['pid']; $name = iS::escapeStr($_POST['name']); $key = iS::escapeStr($_POST['key']); $data = $_POST['data']; $status = (int) $_POST['status']; $name or iPHP::alert('标记名称不能为空!'); // $key OR iPHP::alert('标记key值不能为空!'); $key or $key = pinyin($name); $fields = array('cid', 'pid', 'name', 'key', 'data', 'status'); $data = compact($fields); if ($id) { iDB::update('marker', $data, array('id' => $id)); $msg = "标记更新完成!"; } else { iDB::value("SELECT `id` FROM `#iCMS@__marker` where `key` ='{$key}'") && iPHP::alert('该标记已经存在!请另选一个'); $id = iDB::insert('marker', $data); $msg = "新标记添加完成!"; } $this->cache($id); iPHP::success($msg, 'url:' . APP_URI); }
function iCMS_tag($vars, &$iCMS) { $whereSQL = " visible='1'"; isset($vars['sortid']) && ($whereSQL .= " AND sortid='" . (int) $vars['sortid'] . "'"); $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10"; $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1; $by = $vars['by'] == 'ASC' ? "ASC" : "DESC"; switch ($vars['orderby']) { case "hot": $orderSQL = " ORDER BY `count` {$by}"; break; case "new": $orderSQL = " ORDER BY `id` {$by}"; break; case "addtime": $orderSQL = " ORDER BY `addtime` {$by}"; break; case "updatetime": $orderSQL = " ORDER BY `updatetime` {$by}"; break; case "rand": $orderSQL = " ORDER BY rand() {$by}"; break; default: $orderSQL = " ORDER BY `id` {$by}"; } $offset = 0; if ($vars['page']) { $total = $iCMS->db->getValue("SELECT count(*) FROM `#iCMS@__tags` WHERE {$whereSQL} {$orderSQL}"); $iCMS->assign("total", $total); $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav"; $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0; $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:tag'), 'url' => $iCMS->url, 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle)); } if ($vars['cache'] == false || isset($vars['page'])) { $iCMS->config['iscache'] = false; $rs = ''; } else { $iCMS->config['iscache'] = true; $cacheName = 'tags/' . md5($whereSQL . $orderSQL); $rs = $iCMS->cache($cacheName); } if (empty($rs)) { $rs = $iCMS->db->getArray("SELECT * FROM `#iCMS@__tags` WHERE {$whereSQL} {$orderSQL} LIMIT {$offset},{$maxperpage}"); //$iCMS->db->last_query='explain '.$iCMS->db->last_query; //$explain=$iCMS->db->getRow($iCMS->db->last_query); //var_dump($explain); $_count = count($rs); include_once iPATH . 'include/pinyin.php'; for ($i = 0; $i < $_count; $i++) { $rs[$i]['url'] = $iCMS->iurl('tag', array('id' => $rs[$i]['id'], 'link' => pinyin($rs[$i]['name'], $iCMS->config['CLsplit']), 'name' => $rs[$i]['name'])); $rs[$i]['tags'] .= '<a href="' . $rs[$i]['url'] . '" class="tag" target="_self">' . $rs[$i]['name'] . '</a> '; } $iCMS->cache(false)->addcache($cacheName, $rs, $cacheTime); } return $rs; }
function aryOption($ary, $def = null, $py = true, $desc = true) { if ($py) { foreach ($ary as $k => $val) { $py = pinyin($val['name']); $ary[$k]['py'] = strtoupper($py[0]); } } if ($desc) { $ary = aryDesc($ary, 'py'); } foreach ($ary as $val) { if ($val['id'] == $def) { $selected = 'selected'; } else { $selected = ''; } $str .= '<option value="' . $val['id'] . '" ' . $selected . '>' . $val['py'] . ' ' . $val['name'] . '</option>'; } return $str; }
function do_save() { $id = (int) $_POST['id']; $uid = (int) $_POST['uid']; $cid = implode(',', (array) $_POST['cid']); $tcid = implode(',', (array) $_POST['tcid']); $pid = implode(',', (array) $_POST['pid']); $_cid = iS::escapeStr($_POST['_cid']); $_tcid = iS::escapeStr($_POST['_tcid']); $_pid = iS::escapeStr($_POST['_pid']); $name = iS::escapeStr($_POST['name']); $subtitle = iS::escapeStr($_POST['subtitle']); $tkey = iS::escapeStr($_POST['tkey']); $seotitle = iS::escapeStr($_POST['seotitle']); $keywords = iS::escapeStr($_POST['keywords']); $pic = iS::escapeStr($_POST['pic']); $description = iS::escapeStr($_POST['description']); $url = iS::escapeStr($_POST['url']); $related = iS::escapeStr($_POST['related']); $tpl = iS::escapeStr($_POST['tpl']); $weight = _int($_POST['weight']); $ordernum = _int($_POST['ordernum']); $status = (int) $_POST['status']; $haspic = $pic ? '1' : '0'; $pubdate = time(); $metadata = iS::escapeStr($_POST['metadata']); $uid or $uid = iMember::$userid; $name or iPHP::alert('标签名称不能为空!'); $cid or iPHP::alert('请选择标签所属栏目!'); if ($metadata) { $md = array(); foreach ($metadata['key'] as $_mk => $_mval) { !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->name_text . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)'); $md[$_mval] = $metadata['value'][$_mk]; } $metadata = addslashes(serialize($md)); } if (empty($id)) { iDB::value("SELECT `id` FROM `#iCMS@__tags` where `name` = '{$name}'") && iPHP::alert('该标签已经存在!请检查是否重复'); } if (empty($tkey) && $url) { $tkey = substr(md5($url), 8, 16); iDB::value("SELECT `id` FROM `#iCMS@__tags` where `tkey` = '{$tkey}'") && iPHP::alert('该自定义链接已经存在!请检查是否重复'); } $tkey or $tkey = strtolower(pinyin($name)); strstr($pic, 'http://') && ($pic = iFS::http($pic)); iPHP::import(iPHP_APP_CORE . '/iMAP.class.php'); $fields = array('uid', 'cid', 'tcid', 'pid', 'tkey', 'name', 'seotitle', 'subtitle', 'keywords', 'description', 'metadata', 'haspic', 'pic', 'url', 'related', 'count', 'weight', 'tpl', 'ordernum', 'pubdate', 'status'); $data = compact($fields); if (empty($id)) { $data['count'] = '0'; $data['comments'] = '0'; $id = iDB::insert('tags', $data); tag::cache($id, 'id'); map::init('prop', $this->appid); $pid && map::add($pid, $id); map::init('category', $this->appid); map::add($cid, $id); $tcid && map::add($tcid, $id); iPHP::success('标签添加完成', "url:" . APP_URI); } else { unset($data['count'], $data['comments']); iDB::update('tags', $data, array('id' => $id)); tag::cache($id, 'id'); map::init('prop', $this->appid); map::diff($pid, $_pid, $id); map::init('category', $this->appid); map::diff($cid, $_cid, $id); map::diff($tcid, $_tcid, $id); iPHP::success('标签更新完成', "url:" . APP_URI); } }
function do_save() { $id = (int) $_POST['id']; $uid = (int) $_POST['uid']; $rootid = (int) $_POST['rootid']; $cid = implode(',', (array) $_POST['cid']); $tcid = implode(',', (array) $_POST['tcid']); $pid = implode(',', (array) $_POST['pid']); $_cid = iS::escapeStr($_POST['_cid']); $_tcid = iS::escapeStr($_POST['_tcid']); $_pid = iS::escapeStr($_POST['_pid']); $name = iS::escapeStr($_POST['name']); $subtitle = iS::escapeStr($_POST['subtitle']); $tkey = iS::escapeStr($_POST['tkey']); $seotitle = iS::escapeStr($_POST['seotitle']); $keywords = iS::escapeStr($_POST['keywords']); $pic = iS::escapeStr($_POST['pic']); $bpic = iS::escapeStr($_POST['bpic']); $mpic = iS::escapeStr($_POST['mpic']); $spic = iS::escapeStr($_POST['spic']); $description = iS::escapeStr($_POST['description']); $url = iS::escapeStr($_POST['url']); $related = iS::escapeStr($_POST['related']); $tpl = iS::escapeStr($_POST['tpl']); $weight = _int($_POST['weight']); $ordernum = _int($_POST['ordernum']); $status = (int) $_POST['status']; $haspic = $pic ? '1' : '0'; $pubdate = time(); $metadata = $_POST['metadata']; $uid or $uid = iMember::$userid; if ($callback) { if (empty($name)) { echo '标签名称不能为空!'; return false; } } $name or iPHP::alert('标签名称不能为空!'); $cid or iPHP::alert('请选择标签所属栏目!'); if ($metadata) { if ($metadata['key']) { $md = array(); foreach ($metadata['key'] as $_mk => $_mval) { !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->name_text . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)'); $md[$_mval] = $metadata['value'][$_mk]; } } else { $md = $metadata; } $metadata = addslashes(json_encode($md)); } if (empty($id)) { $hasNameId = iDB::value("SELECT `id` FROM `#iCMS@__tags` where `name` = '{$name}'"); if ($hasNameId) { if (isset($_POST['spider_update'])) { $id = $hasNameId; } else { iPHP::alert('该标签已经存在!请检查是否重复'); } } } if (empty($tkey) && $url) { $tkey = substr(md5($url), 8, 16); $hasTkey = iDB::value("SELECT `id` FROM `#iCMS@__tags` where `tkey` = '{$tkey}'"); if ($hasTkey) { if (isset($_POST['spider_check_tkey'])) { echo '该自定义链接已经存在!请检查是否重复'; return false; } else { iPHP::alert('该自定义链接已经存在!请检查是否重复'); } } } $tkey or $tkey = strtolower(pinyin($name)); iFS::$forceExt = "jpg"; iFS::checkHttp($pic) && ($pic = iFS::http($pic)); iFS::checkHttp($bpic) && ($bpic = iFS::http($bpic)); iFS::checkHttp($mpic) && ($mpic = iFS::http($mpic)); iFS::checkHttp($spic) && ($spic = iFS::http($spic)); iPHP::import(iPHP_APP_CORE . '/iMAP.class.php'); $fields = array('uid', 'rootid', 'cid', 'tcid', 'pid', 'tkey', 'name', 'seotitle', 'subtitle', 'keywords', 'description', 'metadata', 'haspic', 'pic', 'bpic', 'mpic', 'spic', 'url', 'related', 'count', 'weight', 'tpl', 'ordernum', 'pubdate', 'status'); $data = compact($fields); if (empty($id)) { $data['postime'] = $pubdate; $data['count'] = '0'; $data['comments'] = '0'; $id = iDB::insert('tags', $data); tag::cache($id, 'id'); map::init('prop', $this->appid); $pid && map::add($pid, $id); map::init('category', $this->appid); map::add($cid, $id); $tcid && map::add($tcid, $id); $msg = '标签添加完成'; } else { if (isset($_POST['spider_update'])) { // $data = array(); $hasTag = iDB::row("SELECT * FROM `#iCMS@__tags` where `id` = '{$id}'", ARRAY_A); $this->check_spider_data($data, $hasTag, 'subtitle', $subtitle); $this->check_spider_data($data, $hasTag, 'description', $description); $this->check_spider_data($data, $hasTag, 'seotitle', $seotitle); $this->check_spider_data($data, $hasTag, 'keywords', $keywords); $this->check_spider_data($data, $hasTag, 'related', $related); $hasTag['cid'] && $cid && ($data['cid'] = $cid); $_cid = $hasTag['cid']; $hasTag['tcid'] && $tcid && ($data['tcid'] = $tcid); $_tcid = $hasTag['tcid']; $hasTag['pid'] && $pid && ($data['pid'] = $pid); $_pid = $hasTag['pid']; } unset($data['count'], $data['comments']); iDB::update('tags', $data, array('id' => $id)); tag::cache($id, 'id'); map::init('prop', $this->appid); map::diff($pid, $_pid, $id); map::init('category', $this->appid); map::diff($cid, $_cid, $id); map::diff($tcid, $_tcid, $id); $msg = '标签更新完成'; } iACP::callback($id, $this); if ($this->callback['code']) { return array("code" => $this->callback['code'], 'indexid' => $id); } iPHP::success($msg, "url:" . APP_URI); }
function do_save() { $appid = $this->appid; $cid = (int) $_POST['cid']; $rootid = (int) $_POST['rootid']; $status = (int) $_POST['status']; $isucshow = (int) $_POST['isucshow']; $issend = (int) $_POST['issend']; $isexamine = (int) $_POST['isexamine']; $ordernum = (int) $_POST['ordernum']; $mode = (int) $_POST['mode']; $pid = implode(',', (array) $_POST['pid']); $_pid = iS::escapeStr($_POST['_pid']); $_rootid_hash = iS::escapeStr($_POST['_rootid_hash']); $name = iS::escapeStr($_POST['name']); $subname = iS::escapeStr($_POST['subname']); $domain = iS::escapeStr($_POST['domain']); $htmlext = iS::escapeStr($_POST['htmlext']); $url = iS::escapeStr($_POST['url']); $password = iS::escapeStr($_POST['password']); $pic = iS::escapeStr($_POST['pic']); $mpic = iS::escapeStr($_POST['mpic']); $spic = iS::escapeStr($_POST['spic']); $dir = iS::escapeStr($_POST['dir']); $title = iS::escapeStr($_POST['title']); $keywords = iS::escapeStr($_POST['keywords']); $description = iS::escapeStr($_POST['description']); $categoryURI = iS::escapeStr($_POST['categoryURI']); $categoryRule = iS::escapeStr($_POST['categoryRule']); $contentRule = iS::escapeStr($_POST['contentRule']); $urlRule = iS::escapeStr($_POST['urlRule']); $indexTPL = iS::escapeStr($_POST['indexTPL']); $listTPL = iS::escapeStr($_POST['listTPL']); $contentTPL = iS::escapeStr($_POST['contentTPL']); $metadata = iS::escapeStr($_POST['metadata']); $contentprop = iS::escapeStr($_POST['contentprop']); $body = $_POST['body']; $hasbody = (int) $_POST['hasbody']; $hasbody or $hasbody = $body ? 1 : 0; if ($_rootid_hash) { $_rootid = authcode($_rootid_hash); if ($rootid != $_rootid) { iPHP::alert('非法数据提交!'); } else { iACP::CP($_rootid, 'a', 'alert'); exit; } } $cid && $cid == $rootid && iPHP::alert('不能以自身做为上级' . $this->category_name); empty($name) && iPHP::alert($this->category_name . '名称不能为空!'); if ($metadata) { $md = array(); foreach ($metadata['key'] as $_mk => $_mval) { !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->category_name . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)'); $md[$_mval] = $metadata['value'][$_mk]; } $metadata = addslashes(serialize($md)); } if ($contentprop) { $ca = array(); foreach ($contentprop['key'] as $_cak => $_caval) { $_caval or $_caval = strtolower(pinyin($contentprop['name'][$_cak])); !preg_match("/[a-zA-Z0-9_\\-]/", $_caval) && iPHP::alert('内容附加属性字段只能由英文字母、数字或_-组成(不支持中文)'); $ca[$_caval] = $contentprop['name'][$_cak]; } $contentprop = addslashes(serialize($ca)); } if ($mode == "2") { if (strpos($categoryRule, '{CDIR}') === FALSE && strpos($categoryRule, '{CID}') === FALSE && strpos($categoryRule, '{0xCID}') === FALSE) { iPHP::alert('伪静态模式下版块URL规则<hr />必需要有<br />{CDIR}版块目录<br />或者<br />{CID},{0xCID}版块ID'); } if (strpos($contentRule, '{ID}') === FALSE && strpos($contentRule, '{0xID}') === FALSE && strpos($contentRule, '{LINK}') === FALSE) { iPHP::alert('伪静态模式下内容URL规则<hr />必需要有<br />{ID}' . $this->_app_name . 'ID <br />或者<br />{0xID}' . $this->_app_name . 'ID补零<br />或者<br />{LINK}' . $this->_app_name . '自定义链接'); } } iPHP::import(iPHP_APP_CORE . '/iMAP.class.php'); map::init('prop', iCMS_APP_CATEGORY); $fields = array('rootid', 'appid', 'ordernum', 'name', 'subname', 'password', 'title', 'keywords', 'description', 'dir', 'mode', 'domain', 'url', 'pic', 'mpic', 'spic', 'htmlext', 'categoryURI', 'categoryRule', 'contentRule', 'urlRule', 'indexTPL', 'listTPL', 'contentTPL', 'metadata', 'contentprop', 'hasbody', 'pid', 'isexamine', 'issend', 'isucshow', 'status'); $data = compact($fields); if (empty($cid)) { iACP::CP($rootid, 'a', 'alert'); $nameArray = explode("\n", $name); $_count = count($nameArray); foreach ($nameArray as $nkey => $_name) { $_name = trim($_name); if (empty($_name)) { continue; } if ($_count == "1") { if (empty($dir) && empty($url)) { $dir = strtolower(pinyin($_name)); } } else { empty($url) && ($dir = strtolower(pinyin($_name))); } $this->check_dir($dir, $appid, $url); $data['name'] = $_name; $data['dir'] = $dir; $data['userid'] = iMember::$userid; $data['creator'] = iMember::$nickname; $data['createtime'] = time(); $data['count'] = '0'; $data['comments'] = '0'; $cid = iDB::insert('category', $data); $pid && map::add($pid, $cid); $this->cache(false, $this->appid); $this->cahce_one($cid); } $msg = $this->category_name . "添加完成!"; } else { if (empty($dir) && empty($url)) { $dir = strtolower(pinyin($name)); } iACP::CP($cid, 'e', 'alert'); $this->check_dir($dir, $appid, $url, $cid); $data['dir'] = $dir; iDB::update('category', $data, array('cid' => $cid)); map::diff($pid, $_pid, $cid); $this->cahce_one($cid); $msg = $this->category_name . "编辑完成!"; } $hasbody && iCache::set('iCMS/category/' . $cid . '.body', $body, 0); iPHP::success($msg, 'url:' . $this->category_uri); }
/** * 新增与更新数据 *@param $act add为新增、edit为编辑 *@param $go 为1时,获取post *@param $id 传人数据id *@examlpe */ public function add($act = NULL, $go = false, $id = NULL) { $Loop = A('Loop', 'Public'); $Loop->table = 'Linkage'; //main $linkage = M('Linkage'); if ($go == false) { $this->assign('uniqid', uniqid()); if ($act == 'add') { $this->assign('act', 'add'); $this->display(); } else { if (!is_int((int) $id)) { $id = NULL; $this->show('无法获取ID'); } else { $map['id'] = array('eq', $id); $info = $linkage->where($map)->find(); if ($info['_parentId'] == 0) { $info['_parentId'] = ''; } unset($map); $this->assign('id', $id); $this->assign('act', 'edit'); $this->assign('info', $info); $this->display(); unset($info); } } } else { $data = $linkage->create(); if ($data['val'] == '') { $data['val'] = $data['text']; } if ($data['_parentId']) { $tdeep = $linkage->where('id=' . $data['_parentId'])->getField('deep'); $data['deep'] = $tdeep + 1; $layer = $Loop->getLayer($data['_parentId']); $data['layer'] = $layer; $tcode = $linkage->where('id=' . $data['_parentId'])->getField('code'); if (strstr($tcode, '_menu')) { $has_menu = 1; } else { $has_menu = 0; } } if ($act == 'add') { $Public = A('Index', 'Public'); $role = $Public->check('Linkage', array('c')); if ($role < 0) { echo $role; exit; } if ($data['code'] == '') { $data['code'] = pinyin($data['text']); } if ($has_menu == 1 && !strstr($data['code'], '_menu')) { $data['code'] = $data['code'] . '_menu'; } $add = $linkage->add($data); if ($add > 0) { if ($data['_parentId'] == 0) { $ids = $Loop->rowId($add); $datas = array('layer' => $data['layer']); $edit = $linkage->where('id in (' . $ids . ')')->save($datas); } $this->json(NULL); echo 1; } else { echo 0; } } elseif ($act == 'edit') { $Public = A('Index', 'Public'); $role = $Public->check('Linkage', array('u')); if ($role < 0) { echo $role; exit; } if (!is_int((int) $id)) { echo 0; } else { $map['id'] = array('eq', $id); if ($data['code'] == '') { $data['code'] = pinyin($data['text']); } if ($has_menu == 1 && !strstr($data['code'], '_menu')) { $data['code'] = $data['code'] . '_menu'; } $edit = $linkage->where($map)->save($data); unset($map); if ($edit !== false) { if (!$data['_parentId']) { $ids = $Loop->rowId($id); $datas = array('layer' => $data['layer']); $edit = $linkage->where('id in (' . $ids . ')')->save($datas); } $this->json(NULL); echo 1; } else { echo 0; } } } unset($data, $Public); } unset($linkage); }
public function testtt() { include '/html/NginxServer/tips/application/libraries/pinyin.php'; // $this->load->library('stringtopy'); // $a = new StringToPY(); $word = '素媛'; $tr = pinyin($word); var_dump($tr); }
/** * 新增与更新数据 *@param $act add为新增、edit为编辑 *@param $go 为1时,获取post *@param $id 传人数据id *@examlpe */ public function add($act = NULL, $go = false, $id = NULL) { $app = A('App', 'Public'); import('ORG.Net.FileSystem'); $sys = new FileSystem(); import('ORG.Net.UploadFile'); $up = new UploadFile(); $arr_type = C('UPLOAD_TYPE'); $arr_type = explode(',', $arr_type); $up->allowExts = $arr_type; $upload = C('TMPL_PARSE_STRING.__UPLOAD__'); $up->savePath = ROOT . '/' . $upload . '/'; $up->maxSize = C('UPLOAD_SIZE'); $up->charset = 'UTF-8'; $up->autoSub = true; $up->allowNull = true; //main $Bug = D('Bug_table'); $userid = $_SESSION['login']['se_id']; $username = $_SESSION['login']['se_user']; if ($go == false) { $this->assign('uniqid', uniqid()); if ($act == 'add') { $this->assign('act', 'add'); $this->display(); } else { if (!is_int((int) $id)) { $id = NULL; $this->show('无法获取ID'); } else { $map['id'] = array('eq', $id); $info = $Bug->relation(true)->where($map)->find(); $this->assign('constr', $constr); $constr = ''; $this->assign('id', $id); $this->assign('act', 'edit'); $this->assign('info', $info); $this->display(); unset($info, $uinfo, $map); } } } else { $data = $Bug->create(); $content = $_POST['content']; $fulltext = strip_tags($content); $fulltext = preg_replace("/[\n\r\t\v]/iu", "", $fulltext); $fulltext = pinyin($fulltext, ' '); $fulltext = preg_replace("/\\s+/u", " ", $fulltext); $fulltext = trim($fulltext); $solution = $_POST['solution']; $data['baseinfo'] = array('content' => $content, 'solution' => $solution); $data['fulltext'] = array('content_index' => $fulltext); $ischg = 0; if ($up->upload()) { $info = $up->getUploadFileInfo(); $data['files'] = $info[0]['savename']; $ischg = 1; } else { $errorNo = $up->getErrorNo(); if ($errorNo != 2) { echo $info = $up->getErrorMsg(); exit; } } if ($act == 'add') { $Public = A('Index', 'Public'); $role = $Public->check('Bug', array('c')); if ($role < 0) { echo $role; exit; } $data['user_id'] = $userid; $data['addtime'] = date("Y-m-d H:i:s", time()); $add = $Bug->relation(true)->add($data); if ($add > 0) { echo 1; } else { $path = ROOT . '/' . $upload . '/' . $info[0]['savename']; if ($info[0]['savename'] && file_exists($path)) { $sys->delFile($path); } echo 0; } unset($data, $Public); } elseif ($act == 'edit') { $Public = A('Index', 'Public'); $role = $Public->check('Bug', array('u')); if ($role < 0) { echo $role; exit; } if (!is_int((int) $id)) { echo 0; } else { if ($role != 'all' && !in_array('a', $role)) { $user_id = $Bug->where('id=' . $id)->getField('user_id'); if ($userid != $user_id) { echo 2; exit; } } if ($ischg == 1) { $oldfile = I('oldfile'); $path = ROOT . '/' . $upload . '/' . $oldfile; if ($oldfile && file_exists($path)) { $sys->delFile($path); } } $map['id'] = array('eq', $id); $edit = $Bug->relation(true)->where($map)->save($data); unset($map); if ($edit !== false) { echo 1; } else { echo 0; } unset($data, $Public); } } } unset($Bug); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(ArticleRequest $request, Guard $auth, $slug) { // find or create category $category = Category::firstOrCreate(['name' => e($request->input('category')), 'slug' => e(str_slug(pinyin($request->input('category')))), 'user_id' => $auth->user()->id]); // find or create tags foreach ($request->input('tags') as $tag) { $tagids[] = Tag::firstOrCreate(['name' => e($tag), 'slug' => e(str_slug(pinyin($tag))), 'user_id' => $auth->user()->id])->id; } // create article $article = Article::where('slug', $slug)->firstOrFail(); $article->fill($request->all()); $article->slug = empty($article->slug) ? str_slug(pinyin($article->title)) : $article->slug; $article->cover = $this->saveCover($request, $article); $article->user_id = $auth->user()->id; $article->category_id = $category->id; $article->public = $request->has('public') ? 1 : 0; $article->published_at = Carbon::now(); $article->update(); $article->tags()->sync($tagids); flash()->success(trans('flash_messages.article_update_success')); return redirect('admin/articles/hub'); }
<form action="<?php echo __SELF__; ?> ?do=tag&operation=post" method="post"> <table class="tb tb2 "> <tr> <td> </td> <th>ID</th> <th>TAG</th> <th>TAG归类</th> <th>使用数</th> <th>管理</th> </tr> <?php for ($i = 0; $i < $_count; $i++) { $iurlArray = array('id' => $rs[$i]['id'], 'link' => pinyin($rs[$i]['name'], $iCMS->config['CLsplit']), 'name' => $rs[$i]['name']); $htmlurl = $iCMS->iurl('tag', $iurlArray, '', iPATH); $rs[$i]['url'] = $iCMS->iurl('tag', $iurlArray); ?> <tr> <td><input type="checkbox" class="checkbox" name="id[]" value="<?php echo $rs[$i]['id']; ?> " /></td> <td><a href="<?php echo $rs[$i]['url']; ?> " target="_blank"><?php echo $rs[$i]['id']; ?> </a></td>
function tags_cache() { global $iCMS; $rs = $iCMS->db->getArray("SELECT `id`,`name`,`count`,`visible` FROM `#iCMS@__tags` order by id DESC"); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { $key = substr(md5($rs[$i]['name']), 8, 16); $rs[$i]['link'] = pinyin($rs[$i]['name'], $iCMS->config['CLsplit']); $res[$key] = $rs[$i]; $resID[$rs[$i]['id']] = $rs[$i]; } $iCMS->cache(false, 'include/syscache', 0, true, false); $iCMS->addcache('tags.cache', $res, 0); $iCMS->addcache('tags.id', $resID, 0); }
function pinyin2($str) { $substr = mb_substr($str, 0, 1, 'utf-8'); if ("魏" == $substr) { return "W"; } else { if ("闫" == $substr) { return "Y"; } else { return pinyin($substr); } } }
/** * 更新属性信息 */ public function personUpdate_action($id) { $u = $this->getPostJson(); isset($u->name) && ($u->pinyin = pinyin($u->name, 'UTF-8')); $u = (array) $u; if (empty($u)) { return new \ResponseData(0); } $rst = $this->model()->update('xxt_ab_person', $u, "mpid='{$this->mpid}' and id='{$id}'"); return new \ResponseData($rst); }
function do_save($callback = false) { $aid = (int) $_POST['aid']; $cid = (int) $_POST['cid']; $userid = (int) $_POST['userid']; $scid = implode(',', (array) $_POST['scid']); $pid = implode(',', (array) $_POST['pid']); $status = (int) $_POST['status']; $chapter = (int) $_POST['chapter']; $ordernum = _int($_POST['ordernum']); $_cid = iS::escapeStr($_POST['_cid']); $_pid = iS::escapeStr($_POST['_pid']); $_scid = iS::escapeStr($_POST['_scid']); $_tags = iS::escapeStr($_POST['_tags']); $title = iS::escapeStr($_POST['title']); $stitle = iS::escapeStr($_POST['stitle']); $pic = iS::escapeStr($_POST['pic']); $mpic = iS::escapeStr($_POST['mpic']); $spic = iS::escapeStr($_POST['spic']); $source = iS::escapeStr($_POST['source']); $author = iS::escapeStr($_POST['author']); $editor = iS::escapeStr($_POST['editor']); $description = iS::escapeStr($_POST['description']); $keywords = iS::escapeStr($_POST['keywords']); $tags = str_replace(',', ',', iS::escapeStr($_POST['tags'])); $clink = iS::escapeStr($_POST['clink']); $url = iS::escapeStr($_POST['url']); $tpl = iS::escapeStr($_POST['tpl']); $metadata = iS::escapeStr($_POST['metadata']); $metadata = $metadata ? addslashes(serialize($metadata)) : ''; $body = (array) $_POST['body']; $creative = (int) $_POST['creative']; iACP::CP($cid, $aid ? 'ce' : 'ca', 'alert'); empty($_POST['pubdate']) && ($_POST['pubdate'] = get_date(0, 'Y-m-d H:i:s')); $pubdate = iPHP::str2time($_POST['pubdate']); $weight = _int($_POST['weight']); $postype = $_POST['postype'] ? $_POST['postype'] : 0; $ischapter = isset($_POST['ischapter']) ? 1 : 0; isset($_POST['inbox']) && ($status = "0"); $tags && ($tags = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $tags)); empty($title) && iPHP::alert('标题不能为空!'); empty($cid) && iPHP::alert('请选择所属栏目'); empty($body) && empty($url) && iPHP::alert('文章内容不能为空!'); $userid or $userid = iMember::$userid; iFS::$userid = $userid; if (empty($aid) && iCMS::$config['publish']['repeatitle']) { articleTable::check_title($title) && iPHP::alert('该标题的文章已经存在!请检查是否重复'); } if (strstr($this->category[$cid]['contentRule'], '{LINK}') !== false) { empty($clink) && ($clink = strtolower(pinyin($title))); if (empty($aid) && $clink) { articleTable::check_clink($clink) && iPHP::alert('该文章自定义链接已经存在!请检查是否重复'); } } if (empty($description) && empty($url)) { $description = $this->autodesc($body); } stripos($pic, 'http://') === false or $pic = iFS::http($pic); stripos($mpic, 'http://') === false or $mpic = iFS::http($mpic); stripos($spic, 'http://') === false or $spic = iFS::http($spic); $haspic = empty($pic) ? 0 : 1; $SELFURL = __SELF__ . $_POST['REFERER']; if (empty($_POST['REFERER']) || strstr($_POST['REFERER'], '=save')) { $SELFURL = __SELF__ . '?app=article&do=manage'; } $editor or $editor = empty(iMember::$data->nickname) ? iMember::$data->username : iMember::$data->nickname; // if($aid && $ischapter){ // $this->article_data($body,$aid); // iDB::query("UPDATE `#iCMS@__article` SET `chapter`=chapter+1 WHERE `id` = '$aid'"); // iPHP::success('章节添加完成!','url:'.$SELFURL); // } iPHP::import(iPHP_APP_CORE . '/iMAP.class.php'); $picdata = ''; $ucid = 0; $fields = articleTable::fields($aid); if (empty($aid)) { $postime = $pubdate; $hits = 0; $good = $bad = $comments = 0; $ischapter && ($chapter = 1); $mobile = 0; $aid = articleTable::insert(compact($fields)); if ($this->callback['primary']) { $PCB = $this->callback['primary']; $handler = $PCB[0]; $params = (array) $PCB[1] + array('indexid' => $aid); if (is_callable($handler)) { call_user_func_array($handler, $params); } } if ($tags) { iPHP::app('tag.class', 'static'); tag::add($tags, $userid, $aid, $cid); //articleTable::update(compact('tags'),array('id'=>$aid)); } map::init('prop', $this->appid); $pid && map::add($pid, $aid); map::init('category', $this->appid); map::add($cid, $aid); $scid && map::add($scid, $aid); $tagArray && tag::map_iid($tagArray, $aid); $url or $this->article_data($body, $aid, $haspic); $this->categoryApp->update_count_one($cid); $article_url = iURL::get('article', array(array('id' => $aid, 'url' => $url, 'cid' => $cid, 'pubdate' => $pubdate), $this->category[$cid]))->href; if ($status && iCMS::$config['api']['baidu']['sitemap']['sync']) { baidu_ping($article_url); } if ($callback) { return array("code" => $callback, 'indexid' => $aid); } $moreBtn = array(array("text" => "查看该文章", "target" => '_blank', "url" => $article_url, "o" => 'target="_blank"'), array("text" => "编辑该文章", "url" => APP_URI . "&do=add&id=" . $aid), array("text" => "继续添加文章", "url" => APP_URI . "&do=add&cid=" . $cid), array("text" => "返回文章列表", "url" => $SELFURL), array("text" => "查看网站首页", "url" => iCMS_URL, "target" => '_blank')); iPHP::$dialog['lock'] = true; iPHP::dialog('success:#:check:#:文章添加完成!<br />10秒后返回文章列表', 'url:' . $SELFURL, 10, $moreBtn); } else { if ($tags) { iPHP::app('tag.class', 'static'); tag::diff($tags, $_tags, iMember::$userid, $aid, $cid); } $picdata = $this->picdata($pic, $mpic, $spic); articleTable::update(compact($fields), array('id' => $aid)); if ($this->callback['primary']) { $PCB = $this->callback['primary']; $handler = $PCB[0]; $params = (array) $PCB[1] + array('indexid' => $aid); if (is_callable($handler)) { call_user_func_array($handler, $params); } } map::init('prop', $this->appid); map::diff($pid, $_pid, $aid); map::init('category', $this->appid); map::diff($cid, $_cid, $aid); map::diff($scid, $_scid, $aid); $url or $this->article_data($body, $aid, $haspic); //$ischapter && $this->chapter_count($aid); if ($_cid != $cid) { $this->categoryApp->update_count_one($_cid, '-'); $this->categoryApp->update_count_one($cid); } if ($callback) { return array("code" => $callback, 'indexid' => $aid); } // if(!strstr($this->category[$cid]['contentRule'],'{PHP}')&&!$this->category[$cid]['url']&&$this->category[$cid]['mode']=="1" && $status) { // $htmlApp = iACP::app('html'); // $htmlApp->Article($aid); // } iPHP::success('文章编辑完成!<br />3秒后返回文章列表', 'url:' . $SELFURL); } }
function register($email, $userName, $passwd) { $dsql = array(); $dsql[] = "'" . s($userName) . "'"; $dsql[] = "'" . s(pinyin(strtolower($userName))) . "'"; $dsql[] = "'" . s($email) . "'"; $dsql[] = "'" . s(md5($passwd)) . "'"; $dsql[] = "'" . s(date("Y-m-d H:i:s")) . "'"; $sql = "REPLACE INTO `user` ( `name` , `pinyin` , `email` , `password` , `timeline` ) VALUES ( " . join(' , ', $dsql) . " )"; run_sql($sql); if (db_errno() != 0) { die('DATABASE_ERROR' . db_error()); } }
/** * 用户注册 * * 只有以管理员的token才能注册用户,否则需要激活码 * * @param string name * @param string email * @param string password * @return user array * @author EasyChen */ public function user_sign_up() { if (!not_empty(v('name'))) { return $this->send_error(LR_API_ARGS_ERROR, 'name FIELD REQUIRED'); } if (!is_email(v('email'))) { return $this->send_error(LR_API_ARGS_ERROR, 'email FORMAT ERROR'); } if (strlen(v('password')) < 1) { return $this->send_error(LR_API_ARGS_ERROR, 'password FIELD REQUIRED'); } // actions // admin add user derictly $jump = false; $token = z(t(v('token'))); if (strlen($token) > 2) { session_id($token); session_set_cookie_params(c('session_time')); @session_start(); if ($_SESSION['level'] == '9') { $jump = true; } } if (!$jump) { if (!not_empty(v('code'))) { return $this->send_error(LR_API_ARGS_ERROR, 'activecode REQUIRED'); } $code = z(t(v('code'))); if (get_var("SELECT COUNT(*) FROM `activecode` WHERE `code` = '" . s($code) . "' AND `timeline` > '" . date("Y-m-d H:i:s ", strtotime("-1day")) . "'") < 1) { return $this->send_error(LR_API_ARGS_ERROR, 'activecode error or expired'); } } if (get_var("SELECT COUNT(*) FROM `user` WHERE `email` = '" . s(t(v('email'))) . "'") > 0) { return $this->send_error(LR_API_ARGS_ERROR, 'email EXISTS'); } $dsql = array(); $dsql[] = "'" . s(v('name')) . "'"; $dsql[] = "'" . s(pinyin(v('name'))) . "'"; $dsql[] = "'" . s(v('email')) . "'"; $dsql[] = "'" . s(md5(v('password'))) . "'"; $dsql[] = "'" . s(date("Y-m-d H:i:s")) . "'"; $sql = "INSERT INTO `user` ( `name` , `pinyin` , `email` , `password` , `timeline` ) VALUES ( " . join(' , ', $dsql) . " )"; run_sql($sql); if (db_errno() != 0) { return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . db_error()); } $lid = last_id(); if ($lid < 1) { return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . db_error()); } if (!($data = get_user_info_by_id($lid))) { return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . db_error()); } else { // one code for multi-people /* $sql = "DELETE FROM `activecode` WHERE `code` = '" . s($code) . "' LIMIT 1"; run_sql( $sql ); */ publish_feed($data['name'] . '加入了TeamToy', $data['uid'], 3); return $this->send_result($data); } }
empty($name) && alert("栏目名称不能为空!"); switch ($attr) { case "list": $tpl['list'] ? $tpl_list = $tpl['list'] : alert("请选择栏目模板"); $tpl['content'] ? $tpl_contents = $tpl['content'] : alert("请选择内容模板"); break; case "channel": $tpl['channel'] ? $tpl_index = $tpl['channel'] : alert("请选择频道封面模板"); break; case "page": $tpl['page'] ? $tpl_index = $tpl['page'] : alert("请选择栏目模板"); break; default: alert('怪事!你怎么跑这里来了!!\\n你想干嘛??'); } ($pinyin == 1 || empty($dir)) && ($dir = pinyin($name)); $attr == "page" && ($issend = '0'); if (empty($cid)) { $iCMS->db->getValue("SELECT `dir` FROM `#iCMS@__catalog` where `dir` ='{$dir}'") && alert('该栏目别名/目录已经存在!请另选一个'); $iCMS->db->query("INSERT INTO `#iCMS@__catalog` (`rootid`,`mid`,`order`,`name`,`password`,`keywords`,`description`,`dir`,`domain`,`url`,`icon`,`tpl_index`,`tpl_list`,`tpl_contents`,`attr`,`isexamine`,`ishidden`,`issend`) \r\n\t \t\tVALUES ('{$rootid}','{$mid}', '{$order}', '{$name}','{$password}','{$keywords}', '{$description}', '{$dir}','{$domain}', '{$url}','{$icon}','{$tpl_index}', '{$tpl_list}', '{$tpl_contents}', '{$attr}','{$isexamine}','{$ishidden}','{$issend}')"); $catalog = new catalog(); $catalog->cache(); redirect("栏目添加完成!", __SELF__ . '?do=catalog'); } else { $Admin->CP($cid, 'Permission_Denied', __SELF__ . '?do=catalog'); $rootid != $catalog->catalog[$cid]['rootid'] && $Admin->CP($rootid, 'Permission_Denied', __SELF__ . '?do=catalog'); $iCMS->db->getValue("SELECT `dir` FROM `#iCMS@__catalog` where `dir` ='{$dir}' AND `id` !='{$cid}'") && alert('该栏目别名/目录已经存在!请另选一个'); $iCMS->db->query("UPDATE `#iCMS@__catalog` SET `rootid` = '{$rootid}',`mid` = '{$mid}',`order` = '{$order}',`name` = '{$name}',`password`='{$password}',`keywords` = '{$keywords}',`description` = '{$description}',`dir` = '{$dir}',`url` = '{$url}',`domain` = '{$domain}',`icon`='{$icon}',`tpl_index` = '{$tpl_index}',`tpl_list` = '{$tpl_list}',`tpl_contents` = '{$tpl_contents}',`attr` = '{$attr}',`isexamine`='{$isexamine}',`ishidden`='{$ishidden}',`issend`='{$issend}' WHERE `id` ='{$cid}' "); $catalog = new catalog(); $catalog->cache(); redirect("栏目编辑完成!", __SELF__ . '?do=catalog');
// redirect("内容已清空!",__SELF__."?do=model&operation=manage",'3'); // break; case 'post': if ($action == 'edit') { $id = (int) $_POST['id']; $name = $_POST['name']; $field = $_POST['field']; $mid = $_POST['mid']; $type = $_POST['type']; $default = $_POST['default']; $validate = $_POST['validate']; $description = $_POST['description']; $hidden = $_POST['hidden'] == "1" ? '1' : '0'; $rules = addslashes(serialize($_POST['rules'][$type])); empty($name) && alert('字段名称不能为空!'); empty($field) && ($field = pinyin($name)); !preg_match("/[a-zA-Z]/", $field[0]) && alert('字段名只能以英文字母开头'); for ($i = 0; $i < strlen($field); $i++) { !preg_match("/[a-zA-Z0-9_\\-~]/", $field[$i]) && alert('字段名只能由英文字母或数字组成'); } $SystemField = getSystemField(); in_array($field, $SystemField) && alert('该字段是系统默认字段!请重新填写'); if (empty($id)) { $mid && $iCMS->db->getValue("SELECT `id` FROM `#iCMS@__field` where `field` = '{$field}' and mid='{$mid}'") && alert('该字段已经存在!请检查是否重复'); $iCMS->db->insert('field', compact('name', 'field', 'description', 'mid', 'type', 'default', 'validate', 'hidden', 'rules')); field_cache(); redirect("新增字段完成!", __SELF__ . "?do=field&operation=manage", '3'); } else { $oField = $iCMS->db->getRow("SELECT `mid`,`field`,`type`,`default` FROM `#iCMS@__field` where `id` ='{$id}'", ARRAY_A); if ($oField['field'] != $field || $oField['type'] != $type || $oField['default'] != $default) { //更改所有使用该字段的表
empty($title) && alert('标题不能为空!'); empty($cid) && alert('请选择所属栏目'); empty($body) && empty($url) && alert('文章内容不能为空!'); WordFilter($title) && alert('标题包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($pic) && alert('缩略图包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($source) && alert('出处包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($author) && alert('作者包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($description) && alert('摘要包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($keywords) && alert('关键字包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($body) && alert('文章内容包含被系统屏蔽的字符,请返回重新填写。'); if ($iCMS->config['autodesc'] == "1" && !empty($iCMS->config['descLen']) && empty($description) && empty($url)) { $description = csubstr(HtmToText($body), $iCMS->config['descLen']); } // $remote && remote($body); // (!$remote&&$autopic) && remote($body,true); empty($customlink) && ($customlink = pinyin($title, $iCMS->config['CLsplit'])); $catalog = new catalog(); $isexamine = $catalog->catalog[$cid]['isexamine']; $visible = $isexamine ? '0' : '1'; if (empty($aid)) { empty($userid) && ($userid = $member->uId); $hits = $digg = $comments = 0; $iCMS->db->getValue("SELECT `id` FROM `#iCMS@__article` where `title` = '{$title}'") && alert('该标题的文章已经存在!请检查是否重复'); $iCMS->db->insert('article', compact('cid', 'title', 'stitle', 'customlink', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'pic', 'pubdate', 'hits', 'digg', 'comments', 'type', 'vlink', 'top', 'visible')); $aid = $iCMS->db->insert_id; $iCMS->db->insert('articledata', compact('aid', 'subtitle', 'tpl', 'body')); //insert_db_remote($body,$aid); addtags($tags); tags_cache(); if ($isexamine) { alert("此栏目文章需要管理员审核,请稍候..", 'url:' . __SELF__ . "?do=article&operation=manage");
} $mField = implode(',', $order); $iCMS->db->query("update `#iCMS@__model` SET `field`='{$mField}' where id='{$id}'"); model_cache(); } redirect("模型字段更新成功!", __SELF__ . "?do=model&operation=editfield&mid=" . $id, '3'); } if ($action == 'edit') { $id = (int) $_POST['id']; $name = $_POST['name']; $table = $_POST['table']; $description = $_POST['desc']; $listpage = $_POST['listpage']; $showpage = $_POST['showpage']; empty($name) && alert('模型名称不能为空!'); empty($table) && ($table = pinyin($name)); !preg_match("/[a-zA-Z]/", $table[0]) && alert('模型表名只能以英文字母开头'); for ($i = 0; $i < strlen($table); $i++) { !preg_match("/[a-zA-Z0-9_\\-~]/", $table[$i]) && alert('模型表名只能由英文字母或数字组成'); } if (empty($id)) { $addtime = time(); $iCMS->db->getValue("SELECT `id` FROM `#iCMS@__model` where `table` = '{$table}'") && alert('该模型已经存在!请检查是否重复'); // $field='cid,order,title,customlink,tags,pubdate,hits,digg,comments,type,vlink,top,visible'; $field = 'cid,order,title,customlink,editor,tags,pubdate,type,vlink,top'; $iCMS->db->insert('model', compact('name', 'table', 'description', 'field', 'listpage', 'showpage', 'addtime')); $mid = $iCMS->db->insert_id; //创建模型基础表 $sql = "CREATE TABLE `" . DB_PREFIX . $table . "_content` (\r\n `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n `cid` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `order` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',\r\n `title` VARCHAR(255) NOT NULL DEFAULT '',\r\n `customlink` VARCHAR(255) NOT NULL DEFAULT '',\r\n `editor` VARCHAR(200) NOT NULL DEFAULT '',\r\n `userid` INT(10) UNSIGNED NOT NULL DEFAULT '0', \r\n `tags` VARCHAR(255) NOT NULL DEFAULT '',\r\n `pubdate` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `hits` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `digg` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `comments` INT(10) UNSIGNED NOT NULL DEFAULT '0',\r\n `type` VARCHAR(255) NOT NULL DEFAULT '',\r\n `vlink` VARCHAR(255) NOT NULL DEFAULT '',\r\n `top` SMALLINT(6) NOT NULL DEFAULT '0',\r\n `visible` ENUM('0','1') NOT NULL DEFAULT '1',\r\n `postype` TINYINT(1) NOT NULL DEFAULT '0',\r\n PRIMARY KEY (`id`),\r\n\t\t\t\t KEY `cid` (`visible`,`cid`),\r\n\t\t\t\t KEY `hits` (`visible`,`hits`),\r\n\t\t\t\t KEY `digg` (`visible`,`digg`),\r\n\t\t\t\t KEY `comments` (`visible`,`comments`),\r\n\t\t\t\t KEY `id` (`visible`,`id`),\r\n\t\t\t\t KEY `pubdate` (`visible`,`pubdate`),\r\n\t\t\t\t KEY `customlink` (`visible`,`customlink`)\r\n ) ENGINE=MYISAM DEFAULT CHARSET=" . DB_CHARSET; $iCMS->db->query($sql); model_cache();
public static function update($tag, $uid = "0", $iid = "0", $cid = '0', $tcid = '0') { if (empty($tag)) { return; } $tag = htmlspecialchars_decode($tag); $tag = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $tag); $tid = iDB::value("SELECT `id` FROM `#iCMS@__tags` WHERE `name`='{$tag}'"); if ($tid) { $tlid = iDB::value("SELECT `id` FROM `#iCMS@__tags_map` WHERE `iid`='{$iid}' and `node`='{$tid}' and `appid`='" . TAG_APPID . "'"); if (empty($tlid)) { iDB::query("INSERT INTO `#iCMS@__tags_map` (`node`, `iid`, `appid`) VALUES ('{$tid}', '{$iid}', '" . TAG_APPID . "')"); iDB::query("UPDATE `#iCMS@__tags` SET `count`=count+1,`pubdate`='" . time() . "' WHERE `id`='{$tid}'"); } } else { $tkey = pinyin($tag, iCMS::$config['other']['py_split']); // $fields = array('uid', 'cid', 'tcid', 'pid', 'tkey', 'name', 'seotitle', 'subtitle', 'keywords', 'description', 'haspic', 'pic', 'url', 'related', 'count', 'weight', 'tpl', 'ordernum', 'pubdate', 'status'); // $data = compact ($fields); // $data['pid'] = '0'; // iDB::insert('tags',$data); iDB::query("INSERT INTO `#iCMS@__tags`\n (`uid`, `cid`, `tcid`, `pid`, `tkey`, `name`, `seotitle`, `subtitle`, `keywords`, `description`, `haspic`, `pic`, `url`, `related`, `count`, `weight`, `tpl`, `ordernum`, `pubdate`, `status`)\nVALUES ('{$uid}', '{$cid}', '{$tcid}', '0', '{$tkey}', '{$tag}', '', '', '', '', '', '', '', '', '1', '0', '', '0', '" . time() . "', '1');"); $tid = iDB::$insert_id; self::cache($tag); iDB::query("INSERT INTO `#iCMS@__tags_map` (`node`, `iid`, `appid`) VALUES ('{$tid}', '{$iid}', '" . TAG_APPID . "')"); $tmid = iDB::$insert_id; } return $tag; }
<?php echo pinyin("汉"), "\n"; echo pinyin("わたしわ阿飞, and my English name is Rex Lee. 网名是独孤影! ^_^。下面是一段多音分词歧义测试,这个人无伤无臭味磕头如捣蒜。"), "\n";
<div class="form-group col-xs-12"> <label for="select2" ><?php echo $multilingual_project_touser; ?> <span id="csa_to_user_msg"></span></label> <div > <select id="select2" name="project_to_user" onChange="option_gourl(this.value)" class="form-control"> <?php foreach ($user_arr as $key => $val) { ?> <option value='<?php echo $val["uid"]; ?> ' ><?php $py = substr(pinyin($val["name"]), 0, 1); echo $py . "-" . $val["name"]; ?> </option> <?php } ?> <?php if ($_SESSION['MM_rank'] > "4") { ?> <option value="-1" class="gray" >+<?php echo $multilingual_user_new; ?>
public function find_tags($tag = '', $limit = 10) { if (!$tag) { return false; } $it = $this->db->select('*')->like('en', pinyin($tag), 'after')->from($this->table)->limit($limit)->get()->result_array(); return $it; }
/** * * $mpid * $name * $email * $tels * $strict email is unique. true:error,false:return exist id. */ public function createPerson($mpid, $abid, $name, $email = null, $tels = null, $strict = true) { if (empty($email)) { $q[] = 'id,name'; $q[] = 'xxt_ab_person'; $q[] = "mpid='{$mpid}' and ab_id={$abid} and name='{$name}'"; if ($p = $this->query_obj_ss($q)) { // data replicated } } else { $q[] = 'id,name'; $q[] = 'xxt_ab_person'; $q[] = "mpid='{$mpid}' and ab_id={$abid} and email='{$email}'"; if ($p = $this->query_obj_ss($q)) { if ($p->name != $name) { // data inconsistent. } if ($strict) { // data replicated. } return $p->id; } } $i['mpid'] = $mpid; $i['ab_id'] = $abid; $i['name'] = $name; $i['pinyin'] = pinyin($name, 'UTF-8'); $i['email'] = $email; $i['tels'] = $tels; $person_id = $this->insert('xxt_ab_person', $i, true); return $person_id; }
case in_array($info['type'], array('checkbox', 'multiple')): $value = implode(',', $value); break; case 'editor': $value = $value; break; default: $value = dhtmlspecialchars($value); } } WordFilter($value) && alert($field . '字段包含被系统屏蔽的字符,请返回重新填写。'); $varArray[$field] = $value; $PF[] = $field; } } empty($varArray['customlink']) && ($varArray['customlink'] = pinyin($varArray['title'], $iCMS->config['CLsplit'])); // $remote = isset($_POST['remote']) ?true:false; // $dellink = isset($_POST['dellink']) ?true:false; // $autopic = isset($_POST['autopic']) ?true:false; // $visible = isset($_POST['draft'])?"0":"1"; // $remote && remote($body); // (!$remote&&$autopic) && remote($body,true); // $col = $iCMS->db->getCol("describe `#iCMS@__$__TABLE__`"); $__TABLE__ = $table . '_content'; $MF = explode(',', $model['field']); $diff = array_diff_values($PF, $MF); if ($diff['-']) { foreach ($diff['-'] as $field) { $varArray[$field] = ''; } }
/** * 用户注册 * * 只有以管理员的token才能注册用户,否则需要激活码 * * @param string name * @param string email * @param string password * @return user array * @author EasyChen */ public function user_sign_up() { if (!not_empty(v('name'))) { return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ARGS', 'NAME')); } if (!is_email(v('email'))) { return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_EMAIL')); } if (strlen(v('password')) < 1) { return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ARGS', 'PASSWORD')); } // actions // admin add user derictly $jump = false; $token = z(t(v('token'))); if (strlen($token) > 2) { session_id($token); session_set_cookie_params(c('session_time')); @session_start(); if ($_SESSION['level'] == '9') { $jump = true; } } if (!$jump) { if (!not_empty(v('code'))) { return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ARGS', 'CODE')); } $code = z(t(v('code'))); if (get_var("SELECT COUNT(*) FROM `activecode` WHERE `code` = '" . s($code) . "' AND `timeline` > '" . date("Y-m-d H:i:s ", strtotime("-1day")) . "'") < 1) { return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_BAD_ACTVECODE')); } } if (get_var("SELECT COUNT(*) FROM `user` WHERE `email` = '" . s(t(v('email'))) . "'") > 0) { return self::send_error(LR_API_ARGS_ERROR, __('INPUT_CHECK_EMAIL_EXISTS')); } $dsql = array(); $dsql[] = "'" . s(v('name')) . "'"; $dsql[] = "'" . s(pinyin(strtolower(v('name')))) . "'"; $dsql[] = "'" . s(v('email')) . "'"; $dsql[] = "'" . s(md5(v('password'))) . "'"; $dsql[] = "'" . s(date("Y-m-d H:i:s")) . "'"; $sql = "INSERT INTO `user` ( `name` , `pinyin` , `email` , `password` , `timeline` ) VALUES ( " . join(' , ', $dsql) . " )"; run_sql($sql); if (db_errno() != 0) { return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . db_error()); } $lid = last_id(); if ($lid < 1) { return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . db_error()); } if (!($data = get_user_info_by_id($lid))) { return self::send_error(LR_API_DB_ERROR, __('API_MESSAGE_DATABASE_ERROR') . db_error()); } else { // one code for multi-people /* $sql = "DELETE FROM `activecode` WHERE `code` = '" . s($code) . "' LIMIT 1"; run_sql( $sql ); */ publish_feed(__('API_TEXT_JOINT_TEAMTOY', $data['name']), $data['uid'], 3); return self::send_result($data); } }
/** * 字典修改保存 * 和添加基本上差不多 */ public function editDatalibSubmit() { if ($_FILES) { $arr = array_keys($_FILES); import('ORG.Net.UploadFile'); $upload = new UploadFile(); // 实例化上传类 $upload->maxSize = 3145728; // 设置附件上传大小 $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg'); // 设置附件上传类型 $upload->savePath = './Public/ybimg/'; // 设置附件上传目录 if (!$upload->upload()) { // 上传错误提示错误信息 $this->ajaxReturn('错误', $upload->getErrorMsg(), false); } else { // 上传成功 获取上传文件信息 $info = $upload->getUploadFileInfo(); $upfile = $info[0]['savepath'] . $info[0]['savename']; $upfile = substr($upfile, 1); session('upfile', $upfile); session('typename', $arr[0]); $this->ajaxReturn('成功', '图片上传成功', true); } } $name = $this->_get('action'); $M = M('datalib' . $name); $data = $M->create(); //是否上传过图片信息 $sessionupfile = session('upfile'); if (!empty($sessionupfile)) { $data[session('typename')] = session('upfile'); } $pinyin = pinyin($data[$name . '_name'], UTF8); $data[$name . '_pinyin'] = $pinyin; $save = $M->save($data); if (false !== $save) { $this->ajaxReturn('修改成功', '修改成功', true); } else { $this->ajaxReturn('修改失败', '修改失败', false); } }