function arc_mid($mid = 0, $matid = 0) { //从会员id读取档案资料 global $db, $tblprefix, $cotypes; if (!($mid = max(0, intval($mid)))) { return false; } $this->matid = max(0, intval($matid)); if (!($this->matid = max(0, intval($matid)))) { return false; } if (!($this->matype = read_cache('matype', $this->matid))) { return false; } $sqlstr = 'm.mchid,m.caid'; foreach ($cotypes as $k => $v) { $sqlstr .= ",m.ccid{$k}"; } if (!($this->archive = $db->fetch_one("SELECT ma.*,{$sqlstr} FROM {$tblprefix}members m LEFT JOIN {$tblprefix}marchives_{$this->matid} ma ON ma.mid=m.mid WHERE mid='{$mid}'"))) { $this->init(); return false; } if (!($this->maid = @$this->archive['maid'])) { $this->init(); return false; } arr_tag2atm($this->archive, 'ma'); return true; }
function marc_parse(&$item) { global $cms_abs; view_marcurl($item); $item['cms_counter'] = "<script type=\"text/javascript\" src=\"" . $cms_abs . "tools/counter.php?maid=" . $item['maid'] . "&matid=" . $item['matid'] . "\"></script>"; arr_tag2atm($item, 'ma'); }
function detail_data($auser = 1) { global $db, $tblprefix; if (empty($this->aid) || $this->detailed) { return; } $this->basic_data($auser); $customtable = 'farchives_' . $this->archive['chid']; if ($archive = $db->fetch_one("SELECT * FROM {$tblprefix}{$customtable} WHERE aid='{$this->archive['aid']}'")) { $this->archive = array_merge($this->archive, $archive); } arr_tag2atm($this->archive, 'f'); $this->detailed = 1; unset($archive); }
function arcid($aid) { global $db, $tblprefix, $fcatalogs, $fchannels; $aid = max(0, intval($aid)); if (!$aid) { return false; } if (!($this->archive = $db->fetch_one("SELECT * FROM {$tblprefix}farchives WHERE aid='{$aid}'"))) { $this->init(); return false; } $this->aid = $this->archive['aid']; $this->channel = $fchannels[$this->archive['chid']]; $this->catalog = read_cache('fcatalog', $this->archive['fcaid']); if ($archive = $db->fetch_one("SELECT * FROM {$tblprefix}farchives_" . $this->archive['chid'] . " WHERE aid='" . $this->aid . "'")) { $this->archive = array_merge($this->archive, $archive); unset($archive); } arr_tag2atm($this->archive, 'f'); $this->archive['catalog'] = $fcatalogs[$this->archive['fcaid']]['title']; $this->archive['channle'] = $this->channel['cname']; return true; }
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; } }
<?php //进入空间页面一定需要读取空间主的会员资料 $mid = empty($mid) ? 0 : max(0, intval($mid)); if (!($_da = $db->fetch_one("SELECT m.*,s.* FROM {$tblprefix}members m LEFT JOIN {$tblprefix}members_sub s ON s.mid=m.mid WHERE m.mid='{$mid}'"))) { message(lang('plepoimemid')); } $_da = array_merge($_da, $db->fetch_one("SELECT * FROM {$tblprefix}members_{$_da['mchid']} WHERE mid='{$mid}'")); arr_tag2atm($_da, 'm'); $_da['cms_counter'] = "<script type=\"text/javascript\" src=\"" . $cms_abs . "tools/counter.php?mid={$mid}\"></script>"; load_cache('mtconfigs,mcatalogs'); $uclasses = loaduclasses($mid); $mstpls = load_mtconfig($mid, 'setting'); $mcatalogs = marray_intersect_key($mcatalogs, $mstpls); //提取当前模板中的全部生效栏目 function mcn_tpl($temparr = array(), $addno = 0) { //首页直接读取而不用分析 global $mstpls; $tplname = @$mstpls[$temparr['mcaid']][$addno ? 'list' : 'index']; return $tplname ? $tplname : ''; } function ms_arctpl($chid, $mode = 'archive') { global $mid; $arctpls = load_mtconfig($mid, 'arctpls'); return @$arctpls[$mode][$chid]; } function mcn_parse($temparr = array()) { global $mcatalogs, $uclasses;
function arc_parse(&$item) { //一个文档解析时需要分析的相关内容 global $acatalogs, $cotypes, $channels, $subsites, $cms_abs; view_arcurl($item, -1); $item['sitename'] = empty($item['sid']) ? lang('msite') : $subsites[$item['sid']]['sitename']; $item['siteurl'] = view_siteurl($item['sid']); $item['catalog'] = $acatalogs[$item['caid']]['title']; $item['channel'] = @$channels[$item['chid']]['cname']; foreach ($cotypes as $k => $cotype) { $item['ccid' . $k . 'title'] = ''; if ($item["ccid{$k}"]) { $coclasses = read_cache('coclasses', $k); $item['ccid' . $k . 'title'] = cnstitle($item["ccid{$k}"], $cotype['asmode'], $coclasses); } } $item['cms_counter'] = "<script type=\"text/javascript\" src=\"" . $cms_abs . "tools/counter.php?aid=" . $item['aid'] . "&mid=" . $item['mid'] . "\"></script>"; fetch_txt($item); arr_tag2atm($item); foreach (array(0, 1) as $k) { str_arcfee($item, $k); } //得到arcfee,atmfee }