Example #1
0
 protected function display($tpl = null)
 {
     if (is_null($tpl)) {
         $tpl = $this->method;
     }
     $this->tpl = $tpl;
     if (Application::$act == $this->act && Application::$mod == $this->method) {
         Application::$tpl = $tpl;
     } else {
         $GLOBALS['_FileCount']++;
         return;
     }
     $content = file_get_contents(APP_TPL . Application::$controller_obj->act . '/' . Application::$tpl . '.html');
     //parse include
     $ret = preg_match_all('/<\\{\\s*include\\s*=\\s*"(.*?)"\\}>/i', $content, $match);
     if ($ret) {
         foreach ($match[1] as $k => $v) {
             $tArr = explode('/', $v);
             $act_name = ucfirst($tArr[0] . 'Action');
             $act_name = new $act_name();
             $act_name->{$tArr}[1]();
             unset($tArr);
         }
     }
     if (is_array(Application::$controller_obj->valArr) && !empty(Application::$controller_obj->valArr)) {
         foreach (Application::$controller_obj->valArr as $k => $v) {
             ${$k} = $v;
         }
         unset(Application::$controller_obj->valArr);
     }
     $GLOBALS['_FileCount']++;
     require_once load_tpl(APP_TPL . Application::$controller_obj->act . '/' . Application::$tpl . '.html', Application::$controller_obj->open_token);
 }
Example #2
0
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;
}
Example #3
0
function m_tagsmap($tplname)
{
    $tagsarr = array();
    $template = load_tpl($tplname, 0);
    if (!$template) {
        return $tagsarr;
    }
    foreach (array('b', 'u', 'c', 'p', 'tpl') as $k) {
        $tagsarr = array_merge($tagsarr, findtags($template, $k));
    }
    return $tagsarr;
}
Example #4
0
function tpl_refresh($tplname)
{
    global $templatedir, $debugtag;
    $tpl_dir = M_ROOT . "template/{$templatedir}/";
    if (file_exists($utags = $tpl_dir . "function/utags.fun.php")) {
        include_once $utags;
    }
    mmkdir($tpl_dir . 'pcache/');
    if ($debugtag || !file_exists($tpl_dir . 'pcache/' . $tplname . '.php')) {
        $str = load_tpl($tplname);
        $str = preg_replace("/<\\?(?!php\\s|=|\\s)/i", '<?=\'<?\'?>', $str);
        $str = preg_replace("/\\<\\!\\-\\-\\{(.+?)\\}\\-\\-\\>/s", "{\\1}", $str);
        breplace($str, '');
        mp_pre($str);
        nreplace($str, 'p');
        nreplace($str, 'c');
        nreplace($str, 'u');
        quit_avar();
        $str = tpl_basecode($str);
        str2file($str, $tpl_dir . 'pcache/' . $tplname . '.php');
    }
}
Example #5
0
 protected function display($tpl = null)
 {
     $suffix = C('template-suffix');
     $mood = $GLOBALS['_Module'];
     if (self::$is_smarty === true) {
         if (is_null($tpl)) {
             if (empty($this->act)) {
                 $templates = Application::$act;
             } else {
                 $templates = $this->act;
             }
             $temp = debug_backtrace();
             if (isset($temp[1]['function']) && !empty($temp[1]['function'])) {
                 $tpl = $temp[1]['function'];
             } elseif (!empty($this->method)) {
                 $tpl = $this->method;
             } else {
                 $tpl = Application::$mod;
             }
             unset($temp);
         } else {
             $arr = explode('/', $tpl);
             $cnt = count($arr);
             if ($cnt == 1) {
                 //这种格式为index
                 if (empty($this->act)) {
                     $templates = Application::$act;
                 } else {
                     $templates = $this->act;
                 }
                 $tpl = $arr[0];
             } elseif ($cnt == 2) {
                 //这种格式为Index/index
                 $templates = $arr[0];
                 $tpl = $arr[1];
             } elseif ($cnt == 3) {
                 //这种格式为Index/Index/index
                 $mood = $arr[0];
                 $templates = $arr[1];
                 $tpl = $arr[2];
             } else {
                 //否则就出错了
                 SL('Template file format error', '设置的Template: ' . $tpl . ' format error', '访问日志', 1);
                 if (APP_DEBUG) {
                     die('Template file format error');
                 }
             }
         }
         $this->smarty->setTemplateDir(APP_TPL . $mood . DS . $templates . DS);
         spl_autoload_unregister('my_autoload');
         $this->smarty->display($tpl . '.' . $suffix);
     } else {
         if (is_null($tpl)) {
             $tpl = $this->method;
         }
         $this->tpl = $tpl;
         if (Application::$act == $this->act && Application::$mod == $this->method) {
             Application::$tpl = $tpl;
         } else {
             $GLOBALS['_FileCount']++;
             return;
         }
         $content = file_get_contents(APP_TPL . $mood . DS . Application::$controller_obj->act . DS . Application::$tpl . '.' . $suffix);
         //parse include
         $ret = preg_match_all('/' . C('template-left_delimiter') . '\\s*include\\s*=\\s*"(.*?)"' . C('template-right_delimiter') . '/i', $content, $match);
         if ($ret) {
             foreach ($match[1] as $k => $v) {
                 $tArr = explode('/', $v);
                 $act_name = ucfirst($tArr[0] . 'Action');
                 $act_name = new $act_name();
                 $act_name->{$tArr}[1]();
                 unset($tArr);
             }
         }
         if (is_array(Application::$controller_obj->valArr) && !empty(Application::$controller_obj->valArr)) {
             foreach (Application::$controller_obj->valArr as $k => $v) {
                 ${$k} = $v;
             }
             unset(Application::$controller_obj->valArr);
         }
         $GLOBALS['_FileCount']++;
         require_once load_tpl(APP_TPL . $mood . DS . Application::$controller_obj->act . DS . Application::$tpl . '.' . $suffix, Application::$controller_obj->open_token);
     }
 }
Example #6
0
     message('chooseflinkofmember');
 }
 $actuser = new cls_userinfo();
 $actuser->activeuser($mid);
 if (!$actuser->info['mid']) {
     message('chooseflinkofmember');
 }
 if (!$curuser->pmbypmids('cuadd', $mcommu['setting']['apmid'])) {
     message('younoflinkpermis');
 }
 $fieldsarr = empty($mcommu['setting']['fields']) ? array() : explode(',', $mcommu['setting']['fields']);
 if (!submitcheck('newcommu')) {
     if (!empty($mcommu['setting']['norepeat']) && ($cid = $db->result_one("SELECT cid FROM {$tblprefix}mflinks WHERE mid='{$mid}' AND fromid='{$memberid}' ORDER BY cid"))) {
         message('dorepeataddflink');
     }
     if (empty($mcommu['addtpl']) || !($template = load_tpl($mcommu['addtpl']))) {
         load_cache('mlangs,mlfields');
         include_once M_ROOT . "./include/fields.cls.php";
         include_once M_ROOT . "./include/cheader.inc.php";
         _header();
         if (!($oldmsg = $db->fetch_one("SELECT * FROM {$tblprefix}mflinks WHERE fromid='{$memberid}' ORDER BY cid DESC LIMIT 0,1"))) {
             $oldmsg = array();
         }
         tabheader(lang('add') . $mcommu['cname'], 'flinkadd', "?mid={$mid}{$forwardstr}", 2, 1, 1);
         $submitstr = '';
         $a_field = new cls_field();
         foreach ($mlfields as $k => $v) {
             if (!$v['isadmin'] && !$v['isfunc'] && in_array($k, $fieldsarr)) {
                 $a_field->init();
                 $a_field->field = $v;
                 if (isset($oldmsg[$k])) {
Example #7
0
function template($spname = '', $_da = array())
{
    global $sptpls, $templatedir, $btags, $mconfigs;
    if (!($tplname = @$sptpls[$spname]) || !($template = load_tpl($tplname))) {
        return '';
    }
    extract($mconfigs, EXTR_SKIP);
    extract($btags);
    _aenter($_da, 1);
    extract($_da, EXTR_OVERWRITE);
    tpl_refresh($tplname);
    @(include M_ROOT . "template/{$templatedir}/pcache/{$tplname}.php");
    $_content = ob_get_contents();
    ob_clean();
    return $_content;
}
Example #8
0
                $v['cname'] = empty($v['cname']) ? $mtpls[$k]['cname'] : $v['cname'];
                if ($v['cname'] != $mtpls[$k]['cname']) {
                    $mtpls[$k]['cname'] = stripslashes($v['cname']);
                }
            }
        }
        cache2file($mtpls, 'mtpls', 'mtpls', $sid);
        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')) {
Example #9
0
<?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);
    }
}