function pre_deal() { $min = $this->field['min']; $max = $this->field['max']; if (in_array($this->field['datatype'], array('htmltext', 'date', 'multitext', 'text', 'select', 'mselect'))) { $this->field['nohtml'] && ($this->newvalue = strip_tags($this->newvalue)); if ($this->field['datatype'] == 'htmltext' && !preg_match('/^\\s*<[pP][^>]*>[\\x00-\\xff]*<[pP]\\b/', $this->newvalue)) { $this->newvalue = preg_replace('/^\\s*<[pP][^>]*>\\s*|(?:\\s| )*<\\/[pP]>(?:\\s| )*$/', '', $this->newvalue); } else { $this->newvalue = trim($this->newvalue); } if (in_array($this->field['datatype'], array('htmltext', 'multitext', 'text'))) { if ($min && strlen($this->newvalue) < $min) { $this->error = $this->field['cname'] . " " . lang('lengsmalmilim'); } if ($max && strlen($this->newvalue) > $max) { $this->error = $this->field['cname'] . " " . lang('lenglargmaxlimi'); } } } elseif ($this->field['datatype'] == 'int') { $this->newvalue = intval($this->newvalue); if ($min && $this->newvalue < $min) { $this->error = $this->field['cname'] . " " . lang('smallminilimi'); } if ($max && $this->newvalue > $max) { $this->error = $this->field['cname'] . " " . lang('largmaxlimi'); } } elseif ($this->field['datatype'] == 'float') { $this->newvalue = floatval($this->newvalue); if ($min && $this->newvalue < $min) { $this->error = $this->field['cname'] . " " . lang('smallminilimi'); } if ($max && $this->newvalue > $max) { $this->error = $this->field['cname'] . " " . lang('largmaxlimi'); } } elseif (in_array($this->field['datatype'], array('images', 'files', 'medias', 'flashs'))) { $counts = $this->newvalue ? count($this->newvalue) : 0; if ($min && $counts < $min) { $this->error = $this->field['cname'] . " " . lang('attatamosmaminili'); } if ($max && $counts > $max) { $this->newvalue = marray_slice($this->newvalue, 0, $max); } $this->newvalue = $this->newvalue ? addslashes(serialize($this->newvalue)) : ''; } return; }
function pre_deal() { $this->temparr['limits'] = empty($this->tag['limits']) ? 10 : $this->tag['limits']; switch ($this->tclass) { case 'archives': global $db, $tblprefix; if ($sqlstr = arc_sqlstr($this->tag, $this->temparr, $this->tmode)) { $sqlstr .= " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : (empty($this->tag['startno']) ? 0 : $this->tag['startno'])) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($archive = $db->fetch_array($query)) { $this->items[] = $archive; } } break; case 'marchives': global $db, $tblprefix; if ($sqlstr = marc_sqlstr($this->tag, $this->temparr, $this->tmode)) { $sqlstr .= " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : (empty($this->tag['startno']) ? 0 : $this->tag['startno'])) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($archive = $db->fetch_array($query)) { $this->items[] = $archive; } } break; case 'alarchives': //辑内文档列表 global $db, $tblprefix; if ($sqlstr = alarc_sqlstr($this->tag, $this->temparr, $this->tmode)) { $sqlstr .= " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : (empty($this->tag['startno']) ? 0 : $this->tag['startno'])) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($archive = $db->fetch_array($query)) { $this->items[] = $archive; } } break; case 'functions': //自定函数列表 global $templatedir; @(include_once M_ROOT . "./template/{$templatedir}/function/utags.fun.php"); $this->temparr['nowpage'] = $this->nowpage; $this->items = functions_arr($this->tag, $this->temparr, $this->tmode); break; case 'relates': //相关文档列表 global $db, $tblprefix; if ($sqlstr = rel_sqlstr($this->tag, $this->temparr, $this->tmode)) { $sqlstr .= " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : 0) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($archive = $db->fetch_array($query)) { $this->items[] = $archive; } } break; case 'farchives': //附属信息列表 global $db, $tblprefix, $m_thumb; if ($sqlstr = farc_sqlstr($this->tag, $this->temparr, $this->tmode)) { $sqlstr .= " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : (empty($this->tag['startno']) ? 0 : $this->tag['startno'])) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($row = $db->fetch_array($query)) { $row['arcurl'] = view_farcurl($row['aid'], $row['arcurl']); arr_tag2atm($row, 'f'); $this->items[] = $row; } } break; case 'commus': //交互记录列表 global $db, $tblprefix, $commus, $fields, $curuser; if ($sqlstr = cu_sqlstr($this->tag, $this->temparr, $this->tmode)) { $sqlstr .= " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : 0) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($row = $db->fetch_array($query)) { $this->items[] = $row; } } break; case 'mcommus': //交互记录列表 global $db, $tblprefix, $mcommus, $fields, $curuser; if ($sqlstr = mcu_sqlstr($this->tag, $this->temparr, $this->tmode)) { $sqlstr .= " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : 0) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($row = $db->fetch_array($query)) { $this->items[] = $row; } } break; case 'members': //会员列表 global $db, $tblprefix; if ($sqlstr = mem_sqlstr($this->tag, $this->temparr, $this->tmode)) { $sqlstr .= " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : 0) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($row = $db->fetch_array($query)) { $this->items[] = $row; } } $this->no_ctag = 1; break; case 'searchs': //搜索文档列表 global $db, $tblprefix, $timestamp; $sqlstr = empty($this->tag['detail']) || empty($this->temparr['chid']) ? "SELECT a.* " : "SELECT a.*,c.*"; $validstr = !empty($this->tag['validperiod']) ? " AND (a.enddate='0' OR a.enddate>'{$timestamp}')" : ''; //有效期分析 $sqlstr .= $this->temparr['sqlstr'] . $validstr . ' ' . $this->temparr['orderstr'] . " LIMIT " . ($this->nowpage - 1) * $this->temparr['limits'] . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($archive = $db->fetch_array($query)) { $this->items[] = $archive; } break; case 'masearchs': //搜索文档列表 global $db, $tblprefix, $timestamp, $coyptes; $sqlstr = 'ma.*,m.mchid,m.caid'; foreach ($cotypes as $k => $v) { $sqlstr .= ",m.ccid{$k}"; } $sqlstr .= $this->temparr['sqlstr'] . " LIMIT " . ($this->nowpage - 1) * $this->temparr['limits'] . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($archive = $db->fetch_array($query)) { $this->items[] = $archive; } break; case 'msearchs': //搜索文档列表 global $db, $tblprefix; if ($this->tmode == 'c') { //可以引用$timestamp及其它公用参数 $sqlstr = "SELECT m.*,s.* "; $this->tag['sqlstr'] = stripslashes(str_replace('{$tblprefix}', $tblprefix, $this->tag['sqlstr'])); $this->tag['sqlstr'] = sqlstr_replace($this->tag['sqlstr'], $this->temparr); } else { $sqlstr = empty($this->tag['detail']) || empty($this->temparr['mchid']) ? "SELECT m.*,s.* " : "SELECT m.*,s.*,c.*"; } $sqlstr .= ($this->tmode == 'p' ? $this->temparr['sqlstr'] : $this->tag['sqlstr']) . " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : 0) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($row = $db->fetch_array($query)) { $this->items[] = $row; } break; case 'outinfos': //自由调用列表 $this->items = outinfos_arr($this->tag, $this->temparr, $this->tmode, $this->nowpage); break; case 'catalogs': //类目列表//只需要先取出id global $acatalogs, $cotypes, $sid; $nsid = empty($this->tag['nsid']) ? 0 : intval($this->tag['nsid']); if (!$nsid) { $nsid = isset($temparr['nsid']) ? $temparr['nsid'] : $sid; //当前子站需要分析是否有传下来的id,否则认为是全局id } elseif ($nsid == -1) { $nsid = 0; } if ($nsid == -2) { $ncatalogs =& $acatalogs; $nsid = $sid; //为没有栏目因素的节点 } else { $ncatalogs = read_cache('catalogs', '', '', $nsid); } if ($this->tag['listby'] == 'ca') { $caids = array(); if (empty($this->tag['casource'])) { foreach ($ncatalogs as $k => $v) { if (empty($v['level'])) { $caids[] = $k; } } } elseif ($this->tag['casource'] == 1) { if (!empty($this->tag['caids'])) { $tcaids = explode(',', $this->tag['caids']); foreach ($tcaids as $k) { if (isset($ncatalogs[$k])) { $caids[] = $k; } } } } elseif ($this->tag['casource'] == 2) { //激活栏目的子栏目 if (!empty($this->temparr['caid'])) { foreach ($ncatalogs as $k => $v) { if ($v['pid'] == $this->temparr['caid']) { $caids[] = $k; } } } } elseif ($this->tag['casource'] == 3) { if (!empty($this->temparr['caid'])) { foreach ($ncatalogs as $k => $v) { if ($v['pid'] == $ncatalogs[$this->temparr['caid']]['pid']) { $caids[] = $k; } } } } elseif ($this->tag['casource'] == 4) { foreach ($ncatalogs as $k => $v) { if ($v['level'] == 1) { $caids[] = $k; } } } elseif ($this->tag['casource'] == 5) { foreach ($ncatalogs as $k => $v) { if ($v['level'] == 2) { $caids[] = $k; } } } if (!empty($this->tag['orderstr']) && $caids) { $dorder = array(); foreach ($caids as $k) { $catalog = read_cache('catalog', $k, '', $ncatalogs[$k]['sid']); if (!isset($catalog[$this->tag['orderstr']])) { break; } $dorder[] = $catalog[$this->tag['orderstr']]; } if ($dorder) { array_multisort($dorder, empty($this->tag['asc']) ? SORT_DESC : SORT_ASC, $caids); } } foreach ($caids as $k) { if ($this->temparr['limits'] > count($this->items)) { $this->items[] = array('caid' => $k, 'sid' => $ncatalogs[$k]['sid']); } } } else { $coid = str_replace('co', '', $this->tag['listby']); if (!($coclasses = read_cache('coclasses', $coid))) { return; } $ccids = array(); if (empty($this->tag['cosource' . $coid])) { foreach ($coclasses as $k => $v) { if (empty($v['level'])) { $ccids[] = $k; } } } elseif ($this->tag['cosource' . $coid] == 1 && !empty($this->tag['ccids' . $coid])) { $tccids = explode(',', $this->tag['ccids' . $coid]); foreach ($tccids as $k) { if (isset($coclasses[$k])) { $ccids[] = $k; } } } elseif ($this->tag['cosource' . $coid] == 2 && !empty($this->temparr['ccid' . $coid])) { foreach ($coclasses as $k => $v) { if ($v['pid'] == $this->temparr['ccid' . $coid]) { $ccids[] = $k; } } } elseif ($this->tag['cosource' . $coid] == 3 && !empty($this->temparr['ccid' . $coid])) { foreach ($coclasses as $k => $v) { if ($v['pid'] == $coclasses[$this->temparr['ccid' . $coid]]['pid']) { $ccids[] = $k; } } } elseif ($this->tag['cosource' . $coid] == 4) { foreach ($coclasses as $k => $v) { if ($v['level'] == 1) { $ccids[] = $k; } } } elseif ($this->tag['cosource' . $coid] == 5) { foreach ($coclasses as $k => $v) { if ($v['level'] == 2) { $ccids[] = $k; } } } if (!empty($this->tag['orderstr']) && $ccids) { $dorder = array(); foreach ($ccids as $k) { $coclass = read_cache('coclass', $coid, $k); if (!isset($coclass[$this->tag['orderstr']])) { break; } $dorder[] = $coclass[$this->tag['orderstr']]; } if ($dorder) { array_multisort($dorder, empty($this->tag['asc']) ? SORT_DESC : SORT_ASC, $ccids); } } foreach ($ccids as $k) { if ($this->temparr['limits'] > count($this->items)) { $this->items[] = array('ccid' => $k, 'sid' => $nsid); } } } unset($ncatalogs, $coclasses, $catalog, $coclass); break; case 'mcatalogs': //会员空间的类目列表 global $mcatalogs, $uclasses; //这里的空间栏目必须首先是当前所用模板方案的有效栏目 if ($this->tag['listby'] == 'ca') { //全部栏目 $caids = array(); if (empty($this->tag['casource'])) { foreach ($mcatalogs as $k => $v) { $this->items[] = $v; } } elseif ($this->tag['casource'] == 1) { //指定栏目 if (!empty($this->tag['caids'])) { $caids = explode(',', $this->tag['caids']); foreach ($mcatalogs as $k => $v) { if (in_array($k, $caids)) { $this->items[] = $v; } } } } } elseif ($this->tag['listby'] == 'uc') { if (!empty($this->temparr['mcaid'])) { //一定必须是激活栏目下的分类 foreach ($uclasses as $k => $v) { if ($v['mcaid'] == $this->temparr['mcaid']) { $this->items[] = $v; } } } } break; case 'vote': //投票模块 global $db, $tblprefix, $timestamp; $this->no_ctag = 1; $vid = empty($this->tag['vid']) ? empty($this->temparr['vid']) ? 0 : $this->temparr['vid'] : $this->tag['vid']; if (!$vid) { $this->ret_null = 1; return; } if (!($vote = $db->fetch_one("SELECT * FROM {$tblprefix}votes WHERE vid='{$vid}' AND checked=1 AND (enddate=0 OR enddate>{$timestamp})"))) { $this->ret_null = 1; return; } $vote['content'] = mnl2br($vote['content']); foreach (array('vid', 'subject', 'content', 'totalnum', 'enddate', 'mid', 'mname', 'createdate') as $var) { $this->temparr[$var] = $vote[$var]; } $query = $db->query("SELECT * FROM {$tblprefix}voptions WHERE vid='{$vid}' ORDER BY vieworder,vopid"); while ($item = $db->fetch_array($query)) { $item['input'] = !$vote['ismulti'] ? "<input type=\"radio\" value=\"" . $item['vopid'] . "\" name=\"vopids[]\">" : "<input type=\"checkbox\" value=\"" . $item['vopid'] . "\" name=\"vopids[]\">"; $item['percent'] = $vote['totalnum'] ? @round($item['votenum'] / $vote['totalnum'], 3) : 0; $item['percent'] = $item['percent'] * 100 . '%'; $this->items[] = $item; } unset($vote, $item); break; case 'votes': //投票列表 global $db, $tblprefix; if ($sqlstr = v_sqlstr($this->tag, $this->tmode)) { $sqlstr .= " LIMIT " . ($this->tmode == 'p' ? ($this->nowpage - 1) * $this->temparr['limits'] : 0) . "," . $this->temparr['limits']; $query = $db->query($sqlstr); while ($item = $db->fetch_array($query)) { $this->items[] = $item; } } break; case 'images': //有分页 $tempfiles = @marray_slice(unserialize($this->temparr[$this->tag['tname']]), ($this->nowpage - 1) * $this->temparr['limits'], $this->temparr['limits']); if (!empty($tempfiles)) { foreach ($tempfiles as $k => $v) { $v['fid'] = $k; $v['url'] = view_atmurl($v['remote']); $this->items[] = $v; } } unset($tempfiles, $v); $this->no_ctag = 1; break; case 'files': $tempfiles = @marray_slice(unserialize($this->temparr[$this->tag['tname']]), 0, $this->temparr['limits']); if (!empty($tempfiles)) { foreach ($tempfiles as $k => $v) { $item = array(); $item['fid'] = $k; $item['url'] = view_atmurl($v['remote']); $item['title'] = $v['title']; !empty($this->temparr['aid']) && ($item['aid'] = $this->temparr['aid']); $item['tname'] = $this->tag['tname']; $this->items[] = $item; } } unset($tempfiles, $v, $item); $this->no_ctag = 1; break; case 'medias': $tempfiles = @marray_slice(unserialize($this->temparr[$this->tag['tname']]), 0, $this->temparr['limits']); if (!empty($tempfiles)) { foreach ($tempfiles as $k => $v) { $item = array(); $item['fid'] = $k; $item['url'] = view_atmurl($v['remote']); $item['title'] = $v['title']; $item['player'] = empty($v['player']) ? 0 : $v['player']; !empty($this->temparr['aid']) && ($item['aid'] = $this->temparr['aid']); $item['tname'] = $this->tag['tname']; $this->items[] = $item; } } unset($tempfiles, $v, $item); $this->no_ctag = 1; break; case 'flashs': $tempfiles = @marray_slice(unserialize($this->temparr[$this->tag['tname']]), 0, $this->temparr['limits']); if (!empty($tempfiles)) { foreach ($tempfiles as $k => $v) { $item = array(); $item['fid'] = $k; $item['url'] = view_atmurl($v['remote']); $item['title'] = $v['title']; $item['player'] = empty($v['player']) ? 0 : $v['player']; !empty($this->temparr['aid']) && ($item['aid'] = $this->temparr['aid']); $item['tname'] = $this->tag['tname']; $this->items[] = $item; } } unset($tempfiles, $v, $item); $this->no_ctag = 1; break; case 'arcfee': $temps = fee_arr($this->tag, $this->temparr); empty($temps) && ($this->ret_null = 1); foreach ($temps as $k => $v) { $this->items[] = $v; } unset($temps, $v); $this->no_ctag = 1; break; case 'keywords': global $uwordlinks; load_cache('uwordlinks'); if (empty($uwordlinks)) { return; } $temps = @marray_slice($uwordlinks, 0, $this->temparr['limits']); foreach ($temps['swords'] as $k => $v) { $this->items[] = array('word' => $v, 'wordlink' => $temps['rwords'][$k]); } unset($temps, $k, $v); $this->no_ctag = 1; break; case 'subsites': global $subsites, $cmsname; if (empty($this->tag['source']) || $this->tag['source'] == 2 && is_array($this->tag['sids']) && in_array('0', $this->tag['sids'])) { $this->items[] = array('sid' => 0, 'siteurl' => view_siteurl(0), 'sitename' => $cmsname); } $i = 1; foreach ($subsites as $k => $v) { if ($i > $this->temparr['limits']) { break; } if ($this->tag['source'] < 2 || $this->tag['source'] == 2 && in_array($k, explode(',', $this->tag['sids']))) { $this->items[] = array('sid' => $k, 'siteurl' => view_siteurl($k), 'sitename' => $v['sitename']); $i++; } } break; case 'channels': global $channels; if (empty($channels) || !empty($this->tag['chsource']) && empty($this->tag['chids'])) { return; } $i = 1; foreach ($channels as $k => $v) { if ($i > $this->temparr['limits']) { break; } if (empty($this->tag['chsource']) || !empty($this->tag['chsource']) && in_array($k, explode(',', $this->tag['chids']))) { $this->items[] = array('chid' => $k, 'title' => $v['cname']); $i++; } } break; case 'mchannels': global $mchannels; if (empty($mchannels) || !empty($this->tag['chsource']) && empty($this->tag['chids'])) { return; } $i = 1; foreach ($mchannels as $k => $v) { if ($i > $this->temparr['limits']) { break; } if (empty($this->tag['chsource']) || !empty($this->tag['chsource']) && in_array($k, explode(',', $this->tag['chids']))) { $this->items[] = array('mchid' => $k, 'title' => $v['cname']); $i++; } } break; } }