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 remotepic($content, $remote = false, $aid = 0) { if (!$remote) { return $content; } iFS::$forceExt = "jpg"; $content = stripslashes($content); preg_match_all("/<img.*?src\\s*=[\"|'](.*?)[\"|']/is", $content, $match); $array = array_unique($match[1]); $uri = parse_url(iCMS_FS_URL); $fArray = array(); $fpArray = array(); foreach ($array as $key => $value) { $value = trim($value); if (stripos($value, $uri['host']) === false) { $filepath = iFS::http($value); if ($filepath) { if ($aid) { $filename = basename($filepath); $filename = substr($filename, 0, 32); $faid = articleTable::filedata_value($filename); empty($faid) && articleTable::filedata_update_indexid($aid, $filename); } $value = iFS::fp($filepath, '+http'); $fArray[$key] = $value; } } else { unset($array[$key]); } if ($remote === "autopic" && $key == 0) { return $value; } } if ($remote === "autopic" && empty($array)) { return; } if ($array && $fArray) { krsort($array); krsort($fArray); $content = str_replace($array, $fArray, $content); } return addslashes($content); }