function index_static($cnstr = '', $addno = 0, $needwri = 1) { global $db, $tblprefix, $cms_abs, $liststaticnum, $sid, $enablestatic, $timestamp, $templatedir, $G, $_no_dbhalt, $btags, $mconfigs, $_mp, $_actid, $_midarr, $_a_vars, $_a_var, $mpnav, $mptitle, $mpstart, $mpend, $mppre, $mpnext, $mppage, $mpcount, $mpacount; @extract($mconfigs, EXTR_SKIP); @extract($btags); $nenablestatic = $enablestatic; $_da = array(); if (!$cnstr) { if ($addno) { return false; } $tplname = !$sid ? $hometpl : $btags['hometpl']; if (!$nenablestatic || !$tplname || !($template = load_tpl($tplname))) { //子站的各种配置切换 index_unstatic($cnstr, $addno, $needwri); return false; } $cnformat = idx_format($sid); $_da['rss'] = $cms_abs . 'rss.php' . ($sid ? "?sid={$sid}" : ''); } else { if (!($cnode = cnodearr($cnstr, $sid))) { return false; } $statics = empty($cnode['statics']) ? array() : explode(',', $cnode['statics']); $nenablestatic = empty($statics[$addno]) ? $enablestatic : ($statics[$addno] == 1 ? 0 : 1); if (!$nenablestatic || !cn_allowstatic($cnstr, $sid) || !($tplname = cn_tplname($cnstr, $cnode, $addno))) { index_unstatic($cnstr, $addno, $needwri); return false; } $cnformat = cn_format($cnstr, $addno, $cnode); $_da = cn_parse($cnstr, $sid, -1); re_cnode($_da, $cnstr, $cnode); } $_o_content = ob_get_contents(); ob_clean(); $_no_dbhalt = true; $pcount = 1; for ($_pp = 1; $_pp <= $pcount; $_pp++) { $G = array(); $_mp = array('durlpre' => view_url(en_virtual("index.php?" . substr(($cnstr ? "&{$cnstr}" : '') . ($addno ? "&addno={$addno}" : '') . ($sid ? "&sid={$sid}" : '') . '&page={$page}', 1), 1)), 'surlpre' => view_url($cnformat), 'static' => 1, 'nowpage' => $_pp, 's_num' => $liststaticnum); _aenter($_da, 1); extract($_da, EXTR_OVERWRITE); tpl_refresh($tplname); @(include M_ROOT . "template/{$templatedir}/pcache/{$tplname}.php"); $_content = ob_get_contents(); ob_clean(); $_content .= "<script language=\"javascript\" src=\"" . $cms_abs . "tools/static.php?mode=cnindex" . ($sid ? "&sid={$sid}" : '') . ($cnstr ? "&{$cnstr}" : '') . ($addno ? "&addno={$addno}" : '') . "\"></script>"; @str2file($_content, M_ROOT . m_parseurl($cnformat, array('page' => $_pp))); unset($_content); $pcount = empty($liststaticnum) ? @$_mp['pcount'] : min(@$_mp['pcount'], $liststaticnum); } echo $_o_content; unset($_o_content, $_da, $cnode); $_no_dbhalt = false; if ($needwri) { cn_update_needstatic($cnstr, $sid, $addno, 1); } return true; }
function arc_un_static($aid = 0, $addno = 0, $needwri = 1, $clearold = 0) { global $db, $tblprefix, $arc, $archivecircle, $timestamp; if ($aid) { $arc->arcid($aid); } if (empty($arc->aid)) { return false; } $filepre = $arc->filepre($addno); $clearold && m_unlink($filepre); arc_blank($arc->aid, $addno, M_ROOT . m_parseurl($filepre, array('page' => 1)), 1); //强制将初始文件写入 if ($needwri) { $arc->update_needstatic($addno, 1); } return true; }
$fromstr = empty($fromid) ? "" : "cnid>{$fromid}"; $nwheresql = !$wheresql ? $fromstr ? "WHERE {$fromstr}" : "" : $wheresql . ($fromstr ? " AND " : "") . $fromstr; $query = $db->query("SELECT cnid,ename {$fromsql} {$nwheresql} ORDER BY cnid ASC LIMIT 0,{$atpp}"); while ($item = $db->fetch_array($query)) { $selectid[] = $item['cnid']; } } if (empty($selectid)) { amessage('selectcnode', "?entry={$entry}&action={$action}{$param_suffix}&page={$page}{$filterstr}"); } } if (!empty($cndeal['delete'])) { $query = $db->query("SELECT * {$fromsql} WHERE cnid " . multi_str($selectid)); while ($r = $db->fetch_array($query)) { for ($i = 0; $i <= $r['addnum']; $i++) { m_unlink(m_parseurl(cn_format($r['ename'], $i, $r), array('addno' => $i))); } } $db->query("DELETE {$fromsql} WHERE cnid " . multi_str($selectid), 'UNBUFFERED'); } else { if (!empty($cndeal['addnum'])) { $db->query("UPDATE {$tblprefix}cnodes SET addnum='" . min(empty($cn_max_addno) ? 0 : $cn_max_addno, max(0, intval($cnaddnum))) . "' WHERE cnid " . multi_str($selectid)); } $tplarr = $wtplarr = $urlarr = $staticarr = $periodarr = array(); for ($i = 0; $i <= $cn_max_addno; $i++) { foreach (array('tpl', 'wtpl', 'url', 'static', 'period') as $var) { if (!empty($cndeal[$var . $i])) { ${$var . 'arr'}[$i] = ${'cn' . $var . $i}; } } }
function m_unlink($filepre = '', $num = 50) { //以带可变参数{$page}的文件名来删除多页同名文件 if (!$filepre) { return; } for ($i = 1; $i <= $num; $i++) { if (@(!unlink(M_ROOT . m_parseurl($filepre, array('page' => $i))))) { break; } } }
function mcn_format($cnstr, $addno) { //含{$page}的节点文件(相对系统根目录) global $memberdir, $homedefault; if (!$cnstr) { return $memberdir . '/' . $homedefault; } $cnode = read_mcnode($cnstr); $urlarr = empty($cnode['urls']) ? array() : explode(',', $cnode['urls']); return $memberdir . '/' . m_parseurl(empty($urlarr[$addno]) ? '{$cndir}/index' . ($addno ? $addno : '') . '_{$page}.html' : $urlarr[$addno], array('cndir' => mcn_dir($cnstr))); }
function mcn_blank($cnstr, $addnos = array(), $force = 0) { //force:强行覆盖第一个文件,为0时为修复链接 global $enablestatic, $memberdir; if (!$cnstr || !($cnode = read_mcnode($cnstr))) { return; } if (!is_array($addnos)) { $addnos = array($addnos); } if (!$addnos) { return; } $statics = empty($cnode['statics']) ? array() : explode(',', $cnode['statics']); for ($i = 0; $i <= $cnode['addnum']; $i++) { if (in_array($i, $addnos)) { if (empty($statics[$i]) ? $enablestatic : ($statics[$i] == 1 ? 0 : 1)) { $cnfile = M_ROOT . m_parseurl(mcn_format($cnstr, $i), array('page' => 1)); if ($force || !is_file($cnfile)) { @str2file(direct_html("{$memberdir}/index.php?{$cnstr}" . ($i ? "&&addno={$i}" : '')), $cnfile); } } } } }
function filepre($addno = 0) { return m_parseurl(arc_format($this->archive), array('addno' => arc_addno($addno, $this->channel['addnos']))); }
function arc_delete($isuser = 0) { global $db, $tblprefix, $enablestatic, $cotypes; if (empty($this->aid)) { return false; } $this->basic_data(); if ($isuser && $this->archive['checked']) { return false; } //删除相应的txt存储文本 $this->detail_data(); foreach ($this->namepres as $k) { txtunlink($k); } $wherestr = "WHERE aid='" . $this->aid . "'"; foreach (array('comments', 'favorites', 'subscribes', 'answers', 'arecents', 'purchases', 'offers', 'replys') as $var) { //???????????????? $db->query("DELETE FROM {$tblprefix}{$var} {$wherestr}", 'UNBUFFERED'); } $db->query("DELETE FROM {$tblprefix}albums WHERE aid='" . $this->aid . "' OR pid='" . $this->aid . "'", 'UNBUFFERED'); //合辑关系全部删除 //删除相关已生成的静态文件 $arcurl = arc_format($this->archive); for ($i = 1; $i <= $this->channel['addnum']; $i++) { m_unlink(m_parseurl($arcurl, array('addno' => $i))); } $db->query("DELETE FROM {$tblprefix}archives_" . $this->archive['chid'] . " {$wherestr}", 'UNBUFFERED'); $db->query("DELETE FROM {$tblprefix}archives_sub {$wherestr}", 'UNBUFFERED'); $db->query("DELETE FROM {$tblprefix}archives_rec {$wherestr}", 'UNBUFFERED'); $db->query("DELETE FROM {$tblprefix}archives {$wherestr}", 'UNBUFFERED'); //数量统计 $this->auser->basedeal('archive', 0); $this->archive['checked'] && $this->auser->basedeal('check', 0); $uploadsize = 0; $query = $db->query("SELECT * FROM {$tblprefix}userfiles WHERE tid='1' AND aid='" . $this->aid . "'"); while ($item = $db->fetch_array($query)) { $ufile = local_file($item['url']); @unlink($ufile); clear_dir($ufile . '_s', true); $uploadsize += ceil($item['size'] / 1024); } $this->auser->updateuptotal($uploadsize, 'reduce', 1); $db->query("DELETE FROM {$tblprefix}userfiles {$wherestr}", 'UNBUFFERED'); $this->init(); return true; }
function arc_format(&$item) { //保留page与addno的文档静态格式 global $arccustomurl; $catalog = read_cache('catalog', $item['caid'], '', $item['sid']); return m_parseurl(!$item['customurl'] ? !$catalog['customurl'] ? !$arccustomurl ? '{$topdir}/{$y}{$m}/{$aid}/{$addno}_{$page}.html' : $arccustomurl : $catalog['customurl'] : $item['customurl'], array('topdir' => arc_topdir($item), 'cadir' => $catalog['dirname'], 'chid' => $item['chid'], 'aid' => $item['aid'], 'y' => date('Y', $item['createdate']), 'm' => date('m', $item['createdate']), 'd' => date('d', $item['createdate']), 'h' => date('H', $item['createdate']), 'i' => date('i', $item['createdate']), 's' => date('s', $item['createdate']))); }