function diff($Ntags, $Otags, $uId = "0", $indexId = "0", $sortid = '0', $modelId = '0') { $N = self::_array($Ntags); $O = self::_array($Otags); $diff = array_diff_values($N, $O); if ($diff['+']) { foreach ($diff['+'] as $tag) { //新增 self::update($tag, $uId, $indexId, $sortid, $modelId); } } if ($diff['-']) { foreach ($diff['-'] as $tid => $tag) { //减少 $_count = iCMS_DB::getValue("SELECT `count` FROM `#iCMS@__tags` WHERE `id`='{$tid}'"); if ($_count == 1) { iCMS_DB::query("DELETE FROM `#iCMS@__tags` WHERE `id`='{$tid}'"); iCMS_DB::query("DELETE FROM `#iCMS@__taglist` WHERE `tid`='{$tid}'"); } else { iCMS_DB::query("UPDATE `#iCMS@__tags` SET `count`=count-1,`updatetime`='" . time() . "' WHERE `id`='{$tid}'"); iCMS_DB::query("DELETE FROM `#iCMS@__taglist` WHERE `indexId`='{$indexId}' and `tid`='{$tid}' and `modelId`='{$modelId}'"); } } } }
public static function diff($Nnodes, $Onodes, $iid = "0") { $N = explode(',', $Nnodes); $O = explode(',', $Onodes); $diff = array_diff_values($N, $O); $varsArray = array(); foreach ((array) $N as $i => $_node) { //新增 $varsArray[$i] = self::addnew($_node, $iid); } foreach ((array) $diff['-'] as $_node) { //减少 iDB::query("DELETE FROM `" . self::table() . "` WHERE `" . self::$field . "`='{$_node}' AND `iid`='{$iid}' AND `appid`='" . self::$appid . "'"); } return json_encode($varsArray); }
function dosave() { include_once iPATH . 'include/tag.class.php'; $id = $_POST['id']; $mid = $_POST['mid']; $FArray = model::field($mid); $model = model::data($mid); $content = array(); if ($_POST['content']) { foreach ($_POST['content'] as $field => $value) { if (model::isDefField($field)) { switch ($field) { case "userid": $value = intval($value); break; case "fid": $value = $fid = intval($value); empty($value) && javascript::alert('请选择所属栏目'); break; case "orderNum": $value = _int($value); break; case "top": $value = _int($value); break; case "title": $value = dhtmlspecialchars($value); empty($value) && javascript::alert('标题不能为空!'); break; case "editor": $value = dhtmlspecialchars($value); break; case "tags": $value = iTAG::split(dhtmlspecialchars($value), true); break; case "type": $value = intval($value); break; case "vlink": $value = implode(',', $value); break; case "postype": $value = empty($value) ? intval($value) : "1"; break; case "pubdate": $value = _strtotime($value); break; case "clink": $value = dhtmlspecialchars($value); if ($value) { $clinklen = strlen($value); for ($i = 0; $i < $clinklen; $i++) { !preg_match("/[a-zA-Z0-9_\\-~" . preg_quote($this->iCMS->config['CLsplit'], '/') . "]/", $value[$i]) && javascript::alert('自定链接只能由英文字母、数字或_-~组成(不支持中文)'); } } break; } } elseif ($F = $FArray[$field]) { switch ($F['type']) { case "number": $value = intval($value); break; case "calendar": $value = _strtotime($value); break; case in_array($F['type'], array('text', 'textarea', 'radio', 'select', 'email', 'url', 'image', 'upload')): $value = dhtmlspecialchars($value); break; case in_array($F['type'], array('checkbox', 'multiple')): $value = implode(',', $value); break; case 'editor': $this->iCMS->config['autoformat'] && ($value = autoformat($value)); break; default: $value = dhtmlspecialchars($value); } } WordFilter($value) && javascript::alert($field . '字段包含被系统屏蔽的字符,请返回重新填写。'); $content[$field] = $value; $PF[] = $field; } } if (empty($content['clink'])) { include iPATH . 'include/cn.class.php'; $content['clink'] = CN::pinyin($content['title'], $this->iCMS->config['CLsplit']); } $table = model::tbn($_POST['table']); $MF = explode(',', $model['field']); $diff = array_diff_values($PF, $MF); if ($diff['-']) { foreach ($diff['-'] as $field) { $content[$field] = ''; } } //缺少的字段 填认空值 $SELFURL = __SELF__ . (empty($_POST['REFERER']) ? '?mo=content&do=manage' : $_POST['REFERER']); $forum = new forum(); if (empty($id)) { empty($content['userid']) && ($content['userid'] = member::$uId); $content['hits'] = $content['good'] = $content['bad'] = $content['comments'] = 0; $content['status'] = "1"; $checkCL = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `clink` ='" . $content['clink'] . "'"); if ($this->iCMS->config['repeatitle']) { iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `title` = '{$title}'") && alert('该标题内容已经存在!请检查是否重复'); $checkCL && javascript::alert('该自定链接已经存在!请另选一个'); } else { $checkCL && ($clink .= $this->iCMS->config['CLsplit'] . random(6, 1)); } iCMS_DB::insert($table, $content); $id = iCMS_DB::$insert_id; model::upload($table, $id, $title); iTAG::add($content['tags'], $content['userid'], $id, $forum->rootid($fid), $mid); $vlink = empty($content['vlink']) ? $fid : $content['vlink'] . ',' . $fid; vlinkDiff($vlink, '', $id, $mid); if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $content['status']) { include iPATH . 'include/iHtml.class.php'; iHtml::content($id, $mid, $table); iHtml::forum($fid, 1, 0, 1); } iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 "); // $moreaction=array( // array("text"=>"编辑该内容","url"=>__SELF__."?do=content&operation=add&table=".$table."&mid=".$mid."&id=".$id), // array("text"=>"继续添加内容","url"=>__SELF__."?do=content&operation=add&table=".$table."&mid=".$mid."&cid=".$cid), // array("text"=>"查看该内容","url"=>$iCMS->iurl('content',array('mId'=>$mid,'id'=>$id,'link'=>$clink,'pubdate'=>$pubdate,'cid'=>$cid,'dir'=>$catalog->catalog[$cid]['dir'],'domain'=>$catalog->catalog[$cid]['domain'],'htmlext'=>$catalog->catalog[$cid]['htmlext']))->href,"o"=>'target="_blank"'), // array("text"=>"查看网站首页","url"=>"../index.php","o"=>'target="_blank"') // ); javascript::dialog("添加完成!", 'url:' . __SELF__ . "?mo=content&do=manage&table=" . $table . "&mid=" . $mid); } else { $checkCL = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `clink` ='{$clink}' AND `id` !='{$id}'"); if ($this->iCMS->config['repeatitle']) { $checkCL && alert('该自定链接已经存在!请另选一个'); } else { $checkCL && ($clink .= $this->iCMS->config['CLsplit'] . random(6, 1)); } $art = iCMS_DB::getRow("SELECT `fid`,`tags`,`vlink` FROM `#iCMS@__{$table}` where `id` ='{$id}'"); iTAG::diff($content['tags'], member::$uId, $art->tags, $id, $forum->rootid($fid)); iCMS_DB::update($table, $content, array('id' => $id)); model::upload($table, $id, $title); $vlink = empty($content['vlink']) ? $fid : $content['vlink'] . ',' . $fid; vlinkDiff($vlink, $art->vlink, $id); if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) { include iPATH . 'include/iHtml.class.php'; iHtml::content($id, $mid, $table); iHtml::forum($fid, 1, 0, 1); } if ($art->fid != $fid) { iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='{$art->fid}' LIMIT 1 "); iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 "); } javascript::dialog('编辑完成!<br />3秒后返回项目列表', 'url:' . $SELFURL); } }
function vlinkDiff($Nsid, $Osid, $indexId = "0") { global $iCMS; $N = explode(',', $Nsid); $O = explode(',', $Osid); $diff = array_diff_values($N, $O); foreach ((array) $diff['+'] as $sortid) { //新增 if (!iCMS_DB::getValue("SELECT indexId FROM `#iCMS@__vlink` WHERE `indexId`='{$indexId}' and `sortId`='{$sortid}' and `modelId`='0'")) { iCMS_DB::query("INSERT INTO `#iCMS@__vlink` (`indexId`, `sortId`, `modelId` ) VALUES ('{$indexId}', '{$sortid}', '0' )"); } } foreach ((array) $diff['-'] as $sortid) { //减少 iCMS_DB::query("DELETE FROM `#iCMS@__vlink` WHERE `indexId`='{$indexId}' and `sortId`='{$sortid}' and `modelId`='0'"); } }
public static function diff($Ntags, $Otags, $uid = "0", $iid = "0", $cid = '0', $tcid = '0') { $N = explode(',', $Ntags); $O = explode(',', $Otags); $diff = array_diff_values($N, $O); $tagArray = array(); foreach ((array) $N as $i => $tag) { //新增 $tagArray[$i] = self::update($tag, $uid, $iid, $cid, $tcid); } foreach ((array) $diff['-'] as $tag) { //减少 $tA = iDB::row("SELECT `id`,`count` FROM `#iCMS@__tags` WHERE `name`='{$tag}' LIMIT 1;"); if ($tA->count <= 1) { //$iid && $sql="AND `iid`='$iid'"; iDB::query("DELETE FROM `#iCMS@__tags` WHERE `name`='{$tag}'"); iDB::query("DELETE FROM `#iCMS@__tags_map` WHERE `node`='{$tA->id}'"); } else { iDB::query("UPDATE `#iCMS@__tags` SET `count`=count-1,`pubdate`='" . time() . "' WHERE `name`='{$tag}' and `count`>0"); iDB::query("DELETE FROM `#iCMS@__tags_map` WHERE `iid`='{$iid}' and `node`='{$tA->id}' AND `appid`='" . TAG_APPID . "'"); } } return implode(',', (array) $tagArray); }
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] = ''; } } //缺少的字段 填认空值 if (empty($id)) { empty($userid) && ($varArray['userid'] = $Admin->uId); $varArray['hits'] = $varArray['digg'] = $varArray['comments'] = 0; $varArray['visible'] = "1"; $checkCL = $iCMS->db->getValue("SELECT `id` FROM `#iCMS@__{$__TABLE__}` where `customlink` ='{$customlink}'"); if ($iCMS->config['repeatitle']) { $iCMS->db->getValue("SELECT `id` FROM `#iCMS@__{$__TABLE__}` where `title` = '{$title}'") && alert('该标题内容已经存在!请检查是否重复'); $checkCL && alert('该自定链接已经存在!请另选一个'); } else {
} redirect("{$t}<br />优化表完成", __SELF__ . "?do=model&operation=manage"); break; case 'truncate': $table = $_GET['table'] . '_content'; $table && $iCMS->db->query("TRUNCATE TABLE `#iCMS@__{$table}`"); redirect("内容已清空!", __SELF__ . "?do=model&operation=manage", '3'); break; case 'post': if ($action == 'editfield') { $id = (int) $_POST['id']; if ($rs = getmodel($id)) { $table = $rs['table']; $fArray = explode(',', $rs['field']); $order = $_POST['order']; $diff = array_diff_values($order, $fArray); if ($diff['+']) { foreach ($diff['+'] as $field) { //新增 //增加自定义数据库模型中的字段 $col = $iCMS->db->getCol("describe `#iCMS@__{$table}`"); $sql = "ALTER TABLE `#iCMS@__{$table}`"; if (in_array($field, $col)) { $sql .= " CHANGE COLUMN `{$field}` `{$field}`"; } else { $sql .= " ADD COLUMN `{$field}`"; } $type = $_POST['type'][$field][$id] ? $_POST['type'][$field][$id] : $_POST['type'][$field][0]; $len = $_POST['len'][$field][$id] ? $_POST['len'][$field][$id] : $_POST['len'][$field][0]; $default = $_POST['default'][$field][$id] ? $_POST['default'][$field][$id] : $_POST['default'][$field][0]; $sql .= getSqlType($type, $len, $default);
function content($mId, $argv, $tpl = true) { $catalog = $this->cache('catalog.cache', 'include/syscache', 0, true); $sql = $this->linkmodeSQL('id', 'customlink', $argv); $__MODEL__ = $this->cache('model.id', 'include/syscache', 0, true); $model = $__MODEL__[$mId]; $__TABLE__ = $model['table'] . '_content'; $rs = $this->db->getRow("SELECT * FROM `#iCMS@__{$__TABLE__}` WHERE {$sql} AND `visible` ='1'"); empty($rs) && $this->error('error:page'); if ($catalog[$rs->cid]['ishidden']) { return false; } $rs->catalogdir = $this->cdir($catalog[$rs->cid]); $_urlArray = array('mId' => $mId, 'id' => $rs->id, 'cid' => $rs->cid, 'link' => $rs->customlink, 'dir' => $rs->catalogdir, 'domain' => $catalog[$rs->cid]['domain'], 'pubdate' => $rs->pubdate); $_iurlArray = array('mId' => $mId, 'id' => $rs->id, 'link' => $rs->customlink, 'dir' => $rs->catalogdir, 'pubdate' => $rs->pubdate); $iHtml = $this->iurl('show', $_iurlArray, $page - 1, iPATH); $rs->url = $this->iurl('content', $_urlArray); $tpl && $this->jumptohtml($iHtml, $rs->url); $rs->mid = $mId; $this->get['id'] = $rs->id; $this->get['title'] = $rs->title; if ($this->config['linkmode'] == 'id') { $this->iList($rs->cid, false); } elseif ($this->config['linkmode'] == 'title') { $this->iList($rs->catalogdir, false); } if ($this->config['ishtm']) { $rs->hits = "<script src=\"" . $this->config['url'] . "/action.php?do=hits&mid={$mId}&id={$rs->id}&action=show\" language=\"javascript\"></script>"; $rs->digg = "<script src=\"" . $this->config['url'] . "/action.php?do=digg&mid={$mId}&id={$rs->id}&action=show\" language=\"javascript\"></script>"; $rs->comments = "<script src=\"" . $this->config['url'] . "/action.php?do=comment&mid={$mId}&id={$rs->id}\" language=\"javascript\"></script>"; } if ($rs->tags) { $tagarray = explode(',', $rs->tags); if (count($tagarray) > 1) { foreach ($tagarray as $tk => $tag) { if ($this->chkTagVisible($tag)) { $rs->tag[$tk]['name'] = $tag; $rs->tag[$tk]['url'] = $this->config['url'] . '/tag.php?t=' . rawurlencode($tag) . '&mid=' . $mId; $rs->taglink .= '<a href="' . $rs->tag[$tk]['url'] . '" class="tag" target="_self">' . $rs->tag[$tk]['name'] . '</a> '; } } } else { if ($this->chkTagVisible($tagarray[0])) { $rs->tag[0]['name'] = $tagarray[0]; $rs->tag[0]['url'] = $this->config['url'] . '/tag.php?t=' . rawurlencode($tagarray[0]) . '&mid=' . $mId; $rs->taglink = '<a href="' . $this->config['url'] . '/tag.php?t=' . $rs->tag[0]['url'] . '" class="tag" target="_self">' . $tagarray[0] . '</a>'; } } } if ($fArray = explode(',', $model['field'])) { $SField = getSystemField(); $diff = array_diff_values($fArray, $SField); if ($diff['+']) { foreach ($rs as $field => $val) { if (in_array($field, $diff['+'])) { $FV = getFieldValue($mId, $field, $val); $FV !== Null && ($rs->{$field} = $FV); } } } } $prers = $this->db->getRow("SELECT * FROM `#iCMS@__{$__TABLE__}` WHERE `id` < '{$rs->id}' AND `cid`='{$rs->cid}' AND `visible`='1' order by id DESC Limit 1"); $rs->prev = $prers ? '<a href="' . $this->iurl('content', array('mId' => $mId, 'id' => $prers->id, 'cid' => $prers->cid, 'link' => $prers->customlink, 'dir' => $rs->catalogdir, 'domain' => $catalog[$rs->cid]['domain'], 'pubdate' => $prers->pubdate)) . '" class="prev" target="_self">' . $prers->title . '</a>' : $this->language('content:first'); $nextrs = $this->db->getRow("SELECT * FROM `#iCMS@__{$__TABLE__}` WHERE `id` > '{$rs->id}' and `cid`='{$rs->cid}' AND `visible`='1' order by id ASC Limit 1"); $rs->next = $nextrs ? '<a href="' . $this->iurl('content', array('mId' => $mId, 'id' => $nextrs->id, 'cid' => $nextrs->cid, 'link' => $nextrs->customlink, 'dir' => $rs->catalogdir, 'domain' => $catalog[$rs->cid]['domain'], 'pubdate' => $nextrs->pubdate)) . '" class="next" target="_self">' . $nextrs->title . '</a>' : $this->language('content:last'); $this->mode != 'CreateHtml' && $this->db->query("UPDATE `#iCMS@__{$__TABLE__}` SET hits=hits+1 WHERE `id` ='{$rs->id}' LIMIT 1"); $rs->link = "<a href='{$rs->selfurl}'>{$rs->title}</a>"; $this->result = $rs; $this->assign(array('id' => $rs->id, 'mid' => $rs->mid, 'selfurl' => $rs->selfurl, 'link' => $rs->link, 'title' => $rs->title, 'userid' => $rs->userid, 'postype' => $rs->postype, 'pubdate' => $rs->pubdate, 'hits' => $rs->hits, 'digg' => $rs->digg, 'comments' => $rs->comments, 'tag' => $rs->tag, 'taglink' => $rs->taglink, 'prev' => $rs->prev, 'next' => $rs->next)); $this->assign('content', (array) $rs); //3.1 所有内容 if ($tpl) { $tpl = empty($rs->tpl) ? $catalog[$rs->cid]['tpl_contents'] : $rs->tpl; return $this->iPrint($tpl, 'content'); } }
function iCMS_model($vars, &$iCMS) { $cache = $iCMS->cache(array('catalog.cache', 'catalog.hidden', 'model.id', 'model.table', 'field.model'), 'include/syscache', 0, true); $cache['catalog.hidden'] && ($whereSQL .= GetIDSQL($cache['catalog.hidden'], 'cid', 'not')); if (isset($vars['mid'])) { $mId = (int) $vars['mid']; $model = $cache['model.id'][$mId]; $__TABLE__ = $model['table'] . '_content'; } elseif (isset($vars['name'])) { $model = $cache['model.table'][$vars['name']]; $mKey = array_keys($model); $mId = $mKey[0]; $model = $model[$mId]; $__TABLE__ = $vars['name'] . '_content'; } else { echo $iCMS->language('error:model.empty'); return; } if (empty($model)) { echo $iCMS->language('error:model.exit'); return; } if ($fArray = explode(',', $model['field'])) { $SField = getSystemField(); $diff = array_diff_values($fArray, $SField); } //---------------------------- $whereSQL = " visible='1'"; $maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10; $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1; isset($vars['top']) && ($whereSQL .= " AND `top`='{$vars['top']}'"); $vars['call'] == 'user' && ($whereSQL .= " AND `postype`='0'"); $vars['call'] == 'admin' && ($whereSQL .= " AND `postype`='1'"); $catalog = $cache['catalog.cache']; if (isset($vars['sortid!'])) { $_NCID = TplCid($vars['sortid!']); $_NCID && ($NcIds[] = $_NCID); $vars['sub'] == 'all' && ($NcIds[] = $vars['sortid!']); $ids = $NcIds && $vars['sub'] == 'all' ? implode(',', $NcIds) : $vars['sortid!']; $whereSQL .= GetIDSQL($ids, 'cid', 'not'); } if (isset($vars['sortid'])) { $_CID = TplCid($vars['sortid']); $_CID && ($cIds[] = $_CID); $vars['sub'] == 'all' && ($cIds[] = $vars['sortid']); $ids = $cIds && $vars['sub'] == 'all' ? implode(',', $cIds) : $vars['sortid']; $whereSQL .= GetIDSQL($ids, '( cid') . " OR `vlink` REGEXP '[[:<:]]" . preg_quote(str_replace(',', '|', $ids), '/') . "[[:>:]]')"; } if (isset($vars['type'])) { if (strpos($vars['type'], ',')) { $vars['type'] = str_replace(',', '|', $vars['type']); $whereSQL .= " AND `type` REGEXP '[[:<:]]" . preg_quote($vars['type'], '/') . "[[:>:]]'"; } elseif (strpos($vars['type'], '&')) { $typeArray = explode('&', $vars['type']); foreach ($typeArray as $_type) { $whereSQL .= " AND `type` REGEXP '[[:<:]]" . preg_quote($_type, '/') . "[[:>:]]'"; } } else { $whereSQL .= " AND `type` REGEXP '[[:<:]]" . preg_quote($vars['type'], '/') . "[[:>:]]'"; } } $vars['id'] && ($whereSQL .= GetIDSQL($vars['id'], 'id')); $vars['id!'] && ($whereSQL .= GetIDSQL($vars['id!'], 'id', 'not')); $by = $vars['by'] == "ASC" ? "ASC" : "DESC"; // if($vars['keywords']){ // if(strpos($vars['keywords'],',')!==false){ // $kw=explode(',',$vars['keywords']); // foreach($kw AS $v){ // $keywords.=addslashes($v)."|"; // } // $keywords=substr($keywords,0,-1); // $whereSQL.= " And CONCAT(title,keywords,description) REGEXP '$keywords' "; // }else{ // $vars['keywords']=str_replace(array('%','_'),array('\%','\_'),$vars['keywords']); // $whereSQL.= " AND `keywords` like '%".addslashes($vars['keywords'])."%'"; // } // } if ($vars['action'] == 'search' || $vars['action'] == 'tag') { $whereSQL .= $iCMS->actionSQL; } switch ($vars['orderby']) { case "digg": $orderSQL = " ORDER BY `digg` {$by}"; break; case "hot": $orderSQL = " ORDER BY `hits` {$by}"; break; case "id": $orderSQL = " ORDER BY `id` {$by}"; break; case "comments": $orderSQL = " ORDER BY `comments` {$by}"; break; case "pubdate": $orderSQL = " ORDER BY `pubdate` {$by}"; break; case "disorder": $orderSQL = " ORDER BY `order`,`id` {$by}"; break; case "rand": $orderSQL = " ORDER BY rand() {$by}"; break; default: $orderSQL = " ORDER BY `id` {$by}"; } isset($vars['date']) && (list($iCMS->date['y'], $iCMS->date['m'], $iCMS->date['d']) = explode('-', $vars['date'])); if ($iCMS->date) { $day = empty($iCMS->date['d']) ? '01' : $iCMS->date['d']; $start = strtotime($iCMS->date['y'] . $iCMS->date['m'] . $day); $end = empty($iCMS->date['d']) ? $start + 84600 * $iCMS->date['total'] : $start + 84600; $whereSQL .= " AND `pubdate`<='{$end}' AND `pubdate`>='{$start}'"; } else { isset($vars['startdate']) && ($whereSQL .= " AND `pubdate`>='" . strtotime($vars['startdate']) . "'"); isset($vars['enddate']) && ($whereSQL .= " AND `pubdate`<='" . strtotime($vars['enddate']) . "'"); } isset($vars['where']) && ($whereSQL .= $vars['where']); $offset = 0; if ($vars['page']) { $total = $iCMS->db->getValue("SELECT count(*) FROM `#iCMS@__{$__TABLE__}` WHERE {$whereSQL} {$orderSQL}"); $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:list'), '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 = 'model/' . md5($whereSQL . $orderSQL); $rs = $iCMS->cache($cacheName); } if (empty($rs)) { $rs = $iCMS->db->getArray("SELECT * FROM `#iCMS@__{$__TABLE__}` WHERE {$whereSQL} {$orderSQL} LIMIT {$offset} , {$maxperpage}"); // echo $iCMS->db->func_call; $_count = count($rs); for ($i = 0; $i < $_count; $i++) { $rs[$i]['sort']['name'] = $catalog[$rs[$i]['cid']]['name']; $rs[$i]['sort']['url'] = $rs['attr'] == 'page' ? $iCMS->iurl('page', array('link' => $catalog[$rs[$i]['cid']]['dir'], 'url' => $catalog[$rs[$i]['cid']]['url'], 'domain' => $catalog[$rs[$i]['cid']]['domain'])) : $iCMS->iurl('list', array('id' => $rs[$i]['cid'], 'link' => $catalog[$rs[$i]['cid']]['dir'], 'url' => $catalog[$rs[$i]['cid']]['url'], 'domain' => $catalog[$rs[$i]['cid']]['domain'])); $rs[$i]['sort']['link'] = "<a href='{$rs[$i]['sort']['url']}'>{$rs[$i]['sort']['name']}</a>"; $rs[$i]['url'] = $iCMS->iurl('content', array('mId' => $mId, 'id' => $rs[$i]['id'], 'cid' => $rs[$i]['cid'], 'link' => $rs[$i]['link'], 'url' => $rs[$i]['url'], 'dir' => $iCMS->cdir($catalog[$rs[$i]['cid']]), 'pubdate' => $rs[$i]['pubdate'], 'domain' => $catalog[$rs[$i]['cid']]['domain'])); $rs[$i]['link'] = "<a href='{$rs[$i]['url']}'>{$rs[$i]['title']}</a>"; if ($rs[$i]['tags'] && isset($vars['tags'])) { $tagarray = explode(',', $rs[$i]['tags']); if (count($tagarray) > 1) { foreach ($tagarray as $tag) { $iCMS->chkTagVisible($tag) && ($tags .= '<a href="' . $iCMS->config['url'] . '/tag.php?t=' . rawurlencode($tag) . '&mid=' . $mId . '" class="tag" target="_self">' . $tag . '</a> '); } } else { $iCMS->chkTagVisible($tagarray[0]) && ($tags = '<a href="' . $iCMS->config['url'] . '/tag.php?t=' . rawurlencode($tagarray[0]) . '&mid=' . $mId . '" class="tag" target="_self">' . $tagarray[0] . '</a>'); } $rs[$i]['tags'] = $tags; } if ($diff['+']) { foreach ($rs[$i] as $field => $val) { if (in_array($field, $diff['+'])) { $FV = getFieldValue($mId, $field, $val); $FV !== Null && ($rs[$i][$field] = $FV); } } } } $iCMS->cache(false)->addcache($cacheName, $rs, $cacheTime); } // var_dump($rs); return $rs; }
function TagsDiff($Ntags, $Otags) { global $iCMS, $Admin; $N = TagsArray($Ntags); $O = TagsArray($Otags); $diff = array_diff_values($N, $O); if ($diff['+']) { foreach ($diff['+'] as $tag) { //新增 TagUI($tag); } } if ($diff['-']) { foreach ($diff['-'] as $tid => $tag) { //减少 $c = $iCMS->db->getValue("SELECT `count` FROM `#iCMS@__tags` WHERE `id`='{$tid}'"); if ($c == "1") { $iCMS->db->query("DELETE FROM `#iCMS@__tags` WHERE `id`='{$tid}'"); } else { $iCMS->db->query("UPDATE `#iCMS@__tags` SET `count`=count-1 WHERE `id`='{$tid}'"); } } } }