public function search($tpl = false) { $q = htmlspecialchars(rawurldecode($_GET['q'])); $encode = mb_detect_encoding($q, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); if (strtoupper($encode) != 'UTF-8') { if (function_exists('iconv')) { $q = iconv($encode, 'UTF-8//IGNORE', $q); } elseif (function_exists('mb_convert_encoding')) { $q = mb_convert_encoding($q, 'UTF-8//IGNORE', $encode); } } $q = iS::escapeStr($q); //empty($q) && iPHP::throw404('应用程序运行出错.亲!搜点什么吧!!', 60001); $fwd = iCMS::filter($q); $fwd && iPHP::throw404('非法搜索词!', 60002); $search['title'] = stripslashes($q); $search['keyword'] = $q; $tpl === false && ($tpl = '{iTPL}/search.htm'); $q && $this->slog($q); iPHP::assign("search", $search); return iPHP::view($tpl, 'search'); }
public function ACTION_add_category() { $uid = user::$userid; $name = iS::escapeStr($_POST['name']); empty($name) && iPHP::code(0, 'user:category:empty', 'add_category', 'json'); $fwd = iCMS::filter($name); $fwd && iPHP::code(0, 'user:category:filter', 'add_category', 'json'); $max = iDB::value("SELECT COUNT(cid) FROM `#iCMS@__user_category` WHERE `uid`='{$uid}' AND `appid`='" . iCMS_APP_ARTICLE . "'"); $max >= 10 && iPHP::code(0, 'user:category:max', 'add_category', 'json'); $count = 0; $appid = iCMS_APP_ARTICLE; $fields = array('uid', 'name', 'description', 'count', 'mode', 'appid'); $data = compact($fields); $cid = iDB::insert('user_category', $data); $cid && iPHP::code(1, 'user:category:success', $cid, 'json'); iPHP::code(0, 'user:category:failure', 0, 'json'); }
function do_save() { $aid = (int) $_POST['aid']; $cid = (int) $_POST['cid']; iACP::CP($cid, $aid ? 'ce' : 'ca', 'alert'); $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']; empty($title) && iPHP::alert('标题不能为空!'); empty($cid) && iPHP::alert('请选择所属栏目'); empty($body) && empty($url) && iPHP::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; isset($_POST['inbox']) && ($status = "0"); $userid or $userid = iMember::$userid; iFS::$userid = $userid; $tags && ($tags = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $tags)); if (iCMS::$config['article']['filter']) { $fwd = iCMS::filter($title); $fwd && iPHP::alert('标题中包含被系统屏蔽的字符,请重新填写。'); $fwd = iCMS::filter($description); $fwd && iPHP::alert('简介中包含被系统屏蔽的字符,请重新填写。'); // $fwd = iCMS::filter($body); // $fwd && iPHP::alert('内容中包含被系统屏蔽的字符,请重新填写。'); } 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; iPHP::import(iPHP_APP_CORE . '/iMAP.class.php'); $picdata = ''; $ucid = 0; $fields = articleTable::fields($aid); if (empty($aid)) { $postime = $pubdate; $hits = $good = $bad = $comments = $chapter = 0; $mobile = 0; $aid = articleTable::insert(compact($fields)); iACP::callback($aid, $this, 'primary'); if ($tags) { iPHP::app('tag.class', 'static'); if (isset($_POST['tag_status'])) { tag::$addStatus = $_POST['tag_status']; } 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 ($this->callback['code']) { return array("code" => $this->callback['code'], '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 { isset($_POST['ischapter']) or $chapter = 0; 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)); iACP::callback($aid, $this, 'primary'); 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); if ($_cid != $cid) { $this->categoryApp->update_count_one($_cid, '-'); $this->categoryApp->update_count_one($cid); } if ($this->callback['code']) { return array("code" => $this->callback['code'], '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); } }
public function ACTION_add() { if (!iCMS::$config['comment']['enable']) { iPHP::code(0, 'iCMS:comment:close', 0, 'json'); } iPHP::app('user.class', 'static'); user::get_cookie() or iPHP::code(0, 'iCMS:!login', 0, 'json'); $seccode = iS::escapeStr($_POST['seccode']); if (iCMS::$config['comment']['seccode']) { iPHP::seccode($seccode, true) or iPHP::code(0, 'iCMS:seccode:error', 'seccode', 'json'); } iPHP::app('user.msg.class', 'static'); $appid = (int) $_POST['appid']; $iid = (int) $_POST['iid']; $cid = (int) $_POST['cid']; $suid = (int) $_POST['suid']; $reply_id = (int) $_POST['id']; $reply_uid = (int) $_POST['userid']; $reply_name = iS::escapeStr($_POST['name']); $title = iS::escapeStr($_POST['title']); $content = iS::escapeStr($_POST['content']); $iid or iPHP::code(0, 'iCMS:article:empty_id', 0, 'json'); $content or iPHP::code(0, 'iCMS:comment:empty', 0, 'json'); $fwd = iCMS::filter($content); $fwd && iPHP::code(0, 'iCMS:comment:filter', 0, 'json'); $appid or $appid = iCMS_APP_ARTICLE; $addtime = $_SERVER['REQUEST_TIME']; $ip = iPHP::getIp(); $userid = user::$userid; $username = user::$nickname; $status = iCMS::$config['comment']['examine'] ? '0' : '1'; $up = '0'; $down = '0'; $quote = '0'; $floor = '0'; $fields = array('appid', 'cid', 'iid', 'suid', 'title', 'userid', 'username', 'content', 'reply_id', 'reply_uid', 'reply_name', 'addtime', 'status', 'up', 'down', 'ip', 'quote', 'floor'); $data = compact($fields); $id = iDB::insert('comment', $data); iDB::query("UPDATE `#iCMS@__article` SET comments=comments+1 WHERE `id` ='{$iid}' limit 1"); user::update_count($userid, 1, 'comments'); if (iCMS::$config['comment']['examine']) { iPHP::code(0, 'iCMS:comment:examine', $id, 'json'); } iPHP::code(1, 'iCMS:comment:success', $id, 'json'); }
/** * [ACTION_create 创建新收藏夹] */ public function ACTION_create() { $this->__login(); $uid = user::$userid; $nickname = user::$nickname; $title = iS::escapeStr($_POST['title']); $description = iS::escapeStr($_POST['description']); $mode = (int) $_POST['mode']; empty($title) && iPHP::code(0, 'iCMS:favorite:create_empty', 0, 'json'); $fwd = iCMS::filter($title); $fwd && iPHP::code(0, 'iCMS:favorite:create_filter', 0, 'json'); if ($description) { $fwd = iCMS::filter($description); $fwd && iPHP::code(0, 'iCMS:favorite:create_filter', 0, 'json'); } $max = iDB::value("SELECT COUNT(id) FROM `#iCMS@__favorite` WHERE `uid`='{$uid}'"); $max >= 10 && iPHP::code(0, 'iCMS:favorite:create_max', 0, 'json'); $count = 0; $follow = 0; $fields = array('uid', 'nickname', 'title', 'description', 'follow', 'count', 'mode'); $data = compact($fields); $cid = iDB::insert('favorite', $data); $cid && iPHP::code(1, 'iCMS:favorite:create_success', $cid, 'json'); iPHP::code(0, 'iCMS:favorite:create_failure', 0, 'json'); }