function cn_blank($cnstr, $sid, $addnos = array(), $force = 0) { //force:强行覆盖第一个文件,为0时为修复链接 global $enablestatic; $suffix = $sid ? ($cnstr ? '&' : '') . "sid={$sid}" : ''; if ($cnstr) { if (!($cnode = read_cnode($cnstr, $sid))) { 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(cn_format($cnstr, $i, $cnode), array('page' => 1)); if ($force || !is_file($cnfile)) { @str2file(direct_html("index.php?{$cnstr}{$suffix}" . ($i ? "&&addno={$i}" : '')), $cnfile); } } } } } elseif ($sid) { $cnfile = M_ROOT . m_parseurl(idx_format($sid), array('page' => 1)); if ($force || !is_file($cnfile)) { @str2file(direct_html("index.php?{$suffix}"), $cnfile); } } }
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_static($aid = 0, $addno = 0, $needwri = 1) { //可能需要多个页面同时进行 global $db, $tblprefix, $arc, $sid, $timestamp, $cms_abs, $enablestatic, $archivecircle, $templatedir, $G, $_no_dbhalt, $btags, $mconfigs, $_mp, $_actid, $_midarr, $_a_vars, $_a_var, $mpnav, $mptitle, $mpstart, $mpend, $mppre, $mpnext, $mppage, $mpcount, $mpacount; if ($aid) { $arc->arcid($aid); } if (empty($arc->aid) || $addno > $arc->channel['addnum']) { return false; } @extract($mconfigs, EXTR_SKIP); switch_cache($arc->archive['sid']); $sid = $arc->archive['sid']; @extract($btags); $tplname = arc_tplname($addno, $arc->archive['arctpls'], $arc->channel['arctpls']); $staticarr = empty($arc->channel['statics']) ? array() : explode(',', $arc->channel['statics']); $nenablestatic = empty($staticarr[$addno]) ? $enablestatic : ($staticarr[$addno] == 1 ? 0 : 1); if (!$nenablestatic || !arc_allowstatic($arc->archive) || !$tplname) { arc_un_static(0, $addno, $needwri, 1); return false; } $arc->detail_data(); $surlpre = $arc->urlpre($addno, 1); $filepre = $arc->filepre($addno); $_da =& $arc->archive; arc_parse($_da); $_o_content = ob_get_contents(); ob_clean(); $_no_dbhalt = true; $pcount = 1; for ($_pp = 1; $_pp <= $pcount; $_pp++) { $_mp = $G = array(); $_mp['surlpre'] = $surlpre; $_mp['static'] = 1; $_mp['nowpage'] = $_pp; _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=arc&aid={$aid}" . ($addno ? "&addno={$addno}" : '') . ($sid ? "&sid={$sid}" : '') . "\"></script>"; $arcfile = m_parseurl($filepre, array('page' => $_pp)); str2file($_content, M_ROOT . $arcfile); unset($_content); $pcount = @$_mp['pcount']; } echo $_o_content; unset($_o_content); $_no_dbhalt = false; if ($needwri) { $arc->update_needstatic($addno, 1); } return true; }
function marc_static($maid = 0, $matid = 0) { //只是将公示页生成静态,受限页不生成静态 global $db, $tblprefix, $arc, $cms_abs, $marchtmldir, $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); if ($maid) { $arc->init(); $arc->arcid($maid, $matid); } if (empty($arc->maid)) { return false; } if (!$arc->archive['checked']) { marc_un_static(0); return false; } if (!($tplname = $arc->matype['arctpl'])) { return false; } $subpath = $arc->archive['matid'] . '/' . date('Ym', $arc->archive['createdate']) . '/'; mmkdir(M_ROOT . $marchtmldir . '/' . $subpath); $namepre = $subpath . $arc->maid . '_'; $arc->archive['arcurl'] = $cms_abs . $marchtmldir . '/' . $namepre . '1.html'; $_da =& $arc->archive; marc_parse($_da); $_o_content = ob_get_contents(); ob_clean(); $_no_dbhalt = true; $pcount = 1; for ($_pp = 1; $_pp <= $pcount; $_pp++) { $_mp = $G = array(); $_mp['surlpre'] = $cms_abs . $marchtmldir . '/' . $namepre . '{$page}.html'; $_mp['static'] = 1; $_mp['nowpage'] = $_pp; _aenter($_da, 1); extract($_da, EXTR_OVERWRITE); tpl_refresh($tplname); @(include M_ROOT . "template/{$templatedir}/pcache/{$tplname}.php"); $_content = ob_get_contents(); ob_clean(); str2file($_content, M_ROOT . $marchtmldir . '/' . $namepre . "{$_pp}.html"); unset($_content); $pcount = @$_mp['pcount']; } echo $_o_content; unset($_o_content); $_no_dbhalt = false; $db->query("UPDATE {$tblprefix}marchives_{$matid} SET arcurl='" . $namepre . "1.html' WHERE maid='" . $arc->maid . "'"); return true; }
function farc_static($aid = 0) { global $db, $tblprefix, $arc, $timestamp, $cms_abs, $infohtmldir, $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); if ($aid) { $arc->init(); $arc->arcid($aid); } if (empty($arc->aid)) { return false; } if (!$arc->archive['checked'] || !$arc->archive['startdate'] || $arc->archive['enddate'] && $arc->archive['enddate'] < $timestamp) { //失效信息,取消静态 farc_unstatic(0); return false; } if (!($tplname = $arc->catalog['arctpl'])) { return false; } $namepre = $infohtmldir . '/a-' . $arc->aid . '-'; $_da =& $arc->archive; $_o_content = ob_get_contents(); ob_clean(); $_no_dbhalt = true; $pcount = 1; for ($_pp = 1; $_pp <= $pcount; $_pp++) { $_mp = $G = array(); $_mp['surlpre'] = $cms_abs . $namepre . '{$page}.html'; $_mp['static'] = 1; $_mp['nowpage'] = $_pp; _aenter($_da, 1); @extract($btags); extract($_da, EXTR_OVERWRITE); tpl_refresh($tplname); @(include M_ROOT . "template/{$templatedir}/pcache/{$tplname}.php"); $_content = ob_get_contents(); ob_clean(); str2file($_content, M_ROOT . $namepre . "{$_pp}.html"); unset($_content); $pcount = @$_mp['pcount']; } echo $_o_content; unset($_o_content); $_no_dbhalt = false; $db->query("UPDATE {$tblprefix}farchives SET arcurl='a-" . $arc->aid . "-1.html' WHERE aid='" . $arc->aid . "'"); return true; }
function fcn_static($fid = 0) { //静态是在确定的子站环境下 global $db, $tblprefix, $cms_abs, $sid, $timestamp, $freeinfos, $infohtmldir, $subsites, $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); if (!$fid || empty($freeinfos[$fid])) { return; } if (!($tplname = $freeinfos[$fid]['tplname'])) { return; } $namepre = (empty($freeinfos[$fid]['sid']) ? $infohtmldir : $subsites[$freeinfos[$fid]['sid']]['dirname']) . '/f-' . $fid . '-'; $_da = array('sid' => $sid, 'fid' => $fid); $_o_content = ob_get_contents(); ob_clean(); $_no_dbhalt = true; $pcount = 1; for ($_pp = 1; $_pp <= $pcount; $_pp++) { $_mp = $G = array(); $_mp['surlpre'] = $cms_abs . $namepre . '{$page}.html'; $_mp['static'] = 1; $_mp['nowpage'] = max(1, intval($_pp)); _aenter($_da, 1); extract($_da, EXTR_OVERWRITE); tpl_refresh($tplname); @(include M_ROOT . "template/{$templatedir}/pcache/{$tplname}.php"); $_content = ob_get_contents(); ob_clean(); @str2file($_content, M_ROOT . $namepre . "{$_pp}.html"); unset($_content); $pcount = @$_mp['pcount']; } echo $_o_content; unset($_o_content, $_da); $_no_dbhalt = false; $db->query("UPDATE {$tblprefix}freeinfos SET arcurl='f-{$fid}-1.html' WHERE fid={$fid}"); return true; }
adminlog(lang('edinortemmanli')); amessage('tplmodfin', "?entry=mtpls&action=mtplsedit{$param_suffix}&ftpclass={$ftpclass}"); } } elseif ($action == 'mtpldetail' && $tplname) { $mtpl = $mtpls[$tplname]; $forward = empty($forward) ? M_REFERER : $forward; $forwardstr = '&forward=' . rawurlencode($forward); if (!submitcheck('bmtpldetail')) { $template = load_tpl($tplname, 0); tabheader("{$mtpl['cname']}" . lang('setting') . '-' . $mtpl['cname'], 'mtpldetail', "?entry=mtpls&action=mtpldetail&tplname={$tplname}{$param_suffix}{$forwardstr}"); trbasic(lang('templateclass'), 'mtplnew[tpclass]', makeoption($tpclasses, $mtpl['tpclass']), 'select'); templatebox(lang('page_template'), 'templatenew', $template, 30, 110); tabfooter('bmtpldetail'); a_guide('mtpldetail'); } else { @str2file(stripslashes($templatenew), $true_tpldir . '/' . $tplname); $mtpls[$tplname]['tpclass'] = $mtpl['tpclass'] = $mtplnew['tpclass']; cache2file($mtpls, 'mtpls', 'mtpls', $sid); adminlog(lang('detamodnormtem')); amessage('tplmodfin', axaction(6, $forward)); } } elseif ($action == 'mtplcopy' && $tplname) { $mtpl = $mtpls[$tplname]; if (!submitcheck('bmtplcopy')) { !is_file($true_tpldir . '/' . $tplname) && amessage('poisotemfino'); tabheader(lang('copnormapagetemp'), 'mtplcopy', "?entry=mtpls&action=mtplcopy{$param_suffix}&tplname={$tplname}"); trbasic(lang('templatecname'), 'mtpladd[cname]'); trbasic(lang('templateclass'), 'mtpladd[tpclass]', makeoption($tpclasses, $mtpl['tpclass']), 'select'); trbasic(lang('soctemfi'), '', $tplname, ''); trbasic(lang('tempfilsav'), 'mtpladd[tplname]'); tabfooter('bmtplcopy');
$tplname = empty($sptpls[$spid]) ? '' : $sptpls[$spid]; if (!submitcheck('bsptpldetail')) { if (empty($tplname) || !is_file($true_tpldir . '/' . $tplname)) { if (@(!touch($true_tpldir . '/' . $tplname))) { amessage('sptplnoexist', axaction(2, M_REFERER)); } } $template = load_tpl($tplname, 0); tabheader(lang('sptemset') . '-' . $dbtpl['cname'], 'sptpldetail', "?entry=sptpls&action=sptpldetail&spid={$spid}{$param_suffix}"); trbasic(lang('templatecontent'), '', $tplname, ''); templatebox(lang('templatecontent'), 'templatenew', $template, 30, 110); tabfooter('bsptpldetail', lang('modify')); a_guide('sptpldetail'); } else { empty($templatenew) && amessage('temconnot', "?entry=sptpls&action=sptplsedit{$param_suffix}"); !str2file(stripslashes($templatenew), $true_tpldir . '/' . $tplname) && amessage('tplerrsave', "?entry=sptpls&action=sptplsedit{$param_suffix}"); adminlog(lang('detmosptemp')); amessage('tplmodfin', axaction(6, "?entry=sptpls&action=sptplsedit{$param_suffix}")); } } elseif ($action == 'sptplmap' && $spid) { $dbtpl = $dbtpls[$spid]; $tplname = empty($sptpls[$spid]) ? '' : $sptpls[$spid]; if (empty($tplname) || !is_file($true_tpldir . '/' . $tplname)) { if (@(!touch($true_tpldir . '/' . $tplname))) { amessage('sptplnoexist', M_REFERER); } } load_cache('ctags,utags,ptags,rtags', $sid); $tagsarr = m_tagsmap($tplname); tabheader(lang('tagmap') . " - {$dbtpl['cname']}", '', '', '6'); trcategory(array(lang('sn'), lang('tagstyle'), lang('tagname'), lang('tagtype'), lang('tagmodify'), lang('referror')));
function convert_file($scode, $tcode, $sfile = '') { //gbk,big5,utf-8 if (!$sfile || !is_file($sfile)) { return; } if (empty($scode) || empty($tcode) || $scode == $tcode) { return; } $str = @file2str($sfile); $str && ($str = convert_encoding($scode, $tcode, $str)); str2file($str, $sfile); }
/** * 将sql写入到文件中 * @staticvar int $i * @staticvar string $file * @param type $string */ function write2file($string) { static $i = 0; static $file = ''; if ($file == '') { $file = ROOT_PATH . './Backup/database/' . C('DB_NAME') . date("_Ymd_") . rand_string(3, 1); } str2file($string, $file . "_" . $i . ".sql"); $i++; }
function arc_blank($aid, $addno = '', $arcfile, $force = 0) { //$arcfile完全服务器路径 if ($force || !is_file($arcfile)) { str2file(direct_html("archive.php?aid={$aid}" . ($addno ? "&addno={$addno}" : '')), $arcfile); } }
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 js_refresh($tname, &$tag) { global $templatedir, $debugtag; $tpl_dir = M_ROOT . "template/{$templatedir}/"; $jsname = 'js_' . (empty($tag['pmid']) ? '' : 'p_') . $tname; if ($debugtag || !file_exists($tpl_dir . 'pcache/' . $jsname . '.php')) { !empty($tag['pmid']) && ($tag['_pmid'] = $tag['pmid']); unset($tag['js'], $tag['pmid']); $str = ctag_val($tname, $tag); $str = tpl_basecode($str); str2file($str, $tpl_dir . 'pcache/' . $jsname . '.php'); } }
<?php (!defined('M_COM') || !defined('M_ADMIN')) && exit('No Permission'); $true_tpldir = M_ROOT . "./template/{$templatedir}/"; if (!submitcheck('bmtagadd') && !submitcheck('bmtagsdetail')) { $template = load_tpl(@$mtag['template'], 0); trbasic(lang('temfilecna'), 'mtagnew[template]', empty($mtag['template']) ? '' : $mtag['template']); templatebox(lang('page_template'), 'templatenew', $template, 30, 110); tabfooter(); } else { $mtagnew['template'] = trim($mtagnew['template']); if (empty($mtagnew['template'])) { amessage('tag_data_miss', M_REFERER); } if (preg_match("/[^a-z_A-Z0-9\\.]+/", $mtagnew['template'])) { amessage('tpl_file_name_illegal', M_REFERER); } if (@(!str2file(stripslashes($templatenew), $true_tpldir . $mtagnew['template']))) { amessage('tpl_save_failed', M_REFERER); } }
amessage('telcopyerror'); } $tagsarr = $tplsarr = array(); $omtpls = oread_cache('mtpls', '', '', 'template'); foreach ($omtpls as $k => $v) { $tplsarr[] = $k; } $osptpls = oread_cache('sptpls', '', '', 'template'); foreach ($osptpls as $k => $v) { $tplsarr[] = $v; } foreach ($tplsarr as $v) { $str = @file2str($subsetupdir . 'template/' . $v); oreplace($str, 'p'); oreplace($str, 'c'); str2file($str, $true_tpldir . $v); } $tagsarr[] = array('mtpls', ''); $tagsarr[] = array('sptpls', ''); $tagsarr[] = array('rtags', ''); $ortags = oread_cache('rtags', '', '', 'template'); foreach ($ortags as $k => $v) { $tagsarr[] = array('rtag', $k); } $tagsarr[] = array('ptags', ''); $optags = oread_cache('ptags', '', '', 'template'); foreach ($optags as $k => $v) { $tagsarr[] = array('ptag', $k); } $tagsarr[] = array('ctags', ''); $octags = oread_cache('ctags', '', '', 'template');
<?php error_reporting(0); //error_reporting(2047); define('M_COM', TRUE); define('M_ROOT', ''); $timestamp = time(); include_once M_ROOT . './base.inc.php'; include_once M_ROOT . './include/general.fun.php'; load_cache('sitemaps'); empty($sitemaps['google']) && exit; $sitemap = $sitemaps['google']; $cachefile = M_ROOT . './google.xml'; if (empty($sitemap['setting']['life']) || $timestamp - @filemtime($cachefile) > $sitemap['setting']['life'] * 3600 || !($datastr = file2str($cachefile))) { require M_ROOT . './dynamic/cache/mconfigs.cac.php'; @extract($mconfigs_0); include_once M_ROOT . './include/mysql.cls.php'; $db = new cls_mysql(); $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset); include_once M_ROOT . './include/common.fun.php'; include_once M_ROOT . './include/sitemap.inc.php'; str2file($datastr, $cachefile); } echo $datastr; header("Content-type: application/xml"); exit;
} if (empty($confirm)) { $message = lang('del_alert') . "<br><br>"; $message .= lang('confirmclick') . "[<a href='?entry=csstpls&action=filedel&filename={$filename}{$param_suffix}&jsmode={$jsmode}&confirm=1{$forwardstr}'>" . lang('delete') . "</a>] "; $message .= lang('giveupclick') . "[<a href='?entry=csstpls'>" . lang('goback') . "</a>]"; amessage($message); } @unlink($true_tpldir . $filename); adminlog(lang('delete_file', $jsmode ? 'JS' : 'CSS')); amessage('filedelfinish', $forward, $jsmode ? 'JS' : 'CSS'); } elseif ($action == 'fileupdate') { include_once M_ROOT . "./include/parse.fun.php"; if (empty($filename)) { amessage('pointfilename', M_REFERER); } $tplname = empty($jstpls[$filename]['tplname']) ? '' : $jstpls[$filename]['tplname']; if (!$tplname) { amessage('definejsfiletemplate', M_REFERER); } $filename = $js_tpldir . $filename; $data = array(); _aenter($data, 1); @extract($btags); tpl_refresh($tplname); @(include M_ROOT . "template/{$templatedir}/pcache/{$tplname}.php"); $_content = ob_get_contents(); ob_clean(); @str2file($_content, $filename); adminlog(lang('update_js_file')); amessage('jsfileupdatefinish', M_REFERER); }