Beispiel #1
0
 public function display($tplname)
 {
     //$tplname=str_replace('..','',$tplname);
     if (is_readable(realpath($this->template_dir . '/' . $tplname))) {
         $tplpath = realpath($this->template_dir . '/' . $tplname);
         //}elseif(is_readable(APP_PATH.'/'.$tplname)){
         //$tplpath = APP_PATH.'/'.$tplname;
     } else {
         $this->template_err('无法找到模板 ' . $tplname);
     }
     $templateverify = stripos($tplpath, realpath($this->template_dir));
     if ($templateverify === false || $templateverify !== 0) {
         $this->template_err('路径超出模板文件夹');
     }
     $this->template_err_tpl = $tplname;
     extract($this->_vars);
     if (syExt("view_admin") == 'admin' || $tplname == $GLOBALS['WWW'] . 'include/uploads.php') {
         $template_tpl = $tplpath;
     } else {
         $cache_time = syExt("cache_time");
         if ($cache_time > 0) {
             $this->sycache = 'syCache(' . $cache_time . ')->';
         }
         $template_tpl = str_replace('/', '_', $tplname);
         $template_tpl = str_replace('.html', '.php', $template_tpl);
         $template_tpl = realpath($this->template_tpl) . '/' . $template_tpl;
         if (syExt("cache_auto") == 1 || !is_readable($template_tpl) || filemtime($tplpath) > filemtime($template_tpl)) {
             if (!is_dir($GLOBALS['G_DY']['view']['config']['template_tpl'] . '/')) {
                 __mkdirs($GLOBALS['G_DY']['view']['config']['template_tpl'] . '/');
             }
             $fp_tp = @fopen($tplpath, "r");
             $fp_txt = @fread($fp_tp, filesize($tplpath));
             @fclose($fp_tp);
             $fp_txt = $this->template_html($fp_txt);
             $fpt_tpl = @fopen($template_tpl, "w");
             @fwrite($fpt_tpl, $fp_txt);
             @fclose($fpt_tpl);
             if (is_readable($template_tpl) !== true) {
                 $this->template_err('无法找到模板缓存,请刷新后重试,或者检查系统文件夹权限');
             }
         }
     }
     $enable_gzip = syExt('enable_gzip');
     if ($enable_gzip == 1) {
         global $__template_compression_level;
         $__template_compression_level = syExt('enable_gzip_level');
         ob_start('template_ob_gzip');
     }
     include $template_tpl;
 }
Beispiel #2
0
function html_url($type, $c, $pages = 0, $ispage, $molds)
{
    if ($c['gourl'] != '') {
        return $c['gourl'];
    }
    $sh = syExt("site_html");
    $sr = $GLOBALS['G_DY']['url']["url_path_base"];
    $sg = $GLOBALS["WWW"];
    $re = $GLOBALS['G_DY']['rewrite']["rewrite_open"];
    switch ($type) {
        case 'channel':
            if ($re == 1) {
                $re_url = $sg . $GLOBALS['G_DY']['rewrite']["rewrite_channel"];
                if ($c['htmlfile'] == '') {
                    $c['htmlfile'] = $c['id'];
                }
                $go_url = str_replace(array('{id}', '{file}', '{molds}'), array($c['id'], $c['htmlfile'], $molds), $re_url);
                $go_url = str_replace(array('{channel}'), 'channel', $go_url);
                if ($pages !== 0) {
                    $go_url = str_replace('{page}', '[p]', $go_url);
                    $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                } else {
                    $go_url = str_replace('{page}', 1, $go_url);
                }
            } else {
                if ($sh == 1 && $c['mrank'] == 0 && $c['mgold'] == 0 && $c['htmlurl'] != '') {
                    $go_url = $sg . $c['htmlurl'];
                    $go_url = str_replace(array("///", "//"), "/", $go_url);
                    if ($pages !== 0) {
                        $go_url = str_replace('.', '[p].', $go_url);
                        $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                    }
                } else {
                    $go_url = $sr . '?c=channel&molds=' . $molds . '&id=' . $c['id'];
                    if ($pages !== 0) {
                        $go_url = pagetxt($pages);
                    }
                }
            }
            break;
        case 'article':
            if ($re == 1) {
                $re_url = $sg . $GLOBALS['G_DY']['rewrite']["rewrite_article"];
                if ($c['htmlfile'] == '') {
                    $c['htmlfile'] = $c['id'];
                }
                $go_url = str_replace(array('{id}', '{file}'), array($c['id'], $c['htmlfile']), $re_url);
                $go_url = str_replace(array('{article}'), 'article', $go_url);
                if ($pages !== 0) {
                    $go_url = str_replace('{page}', '[p]', $go_url);
                    $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                } else {
                    $go_url = str_replace('{page}', 1, $go_url);
                }
            } else {
                if ($sh == 1 && $c['mrank'] == 0 && $c['mgold'] == 0 && $c['htmlurl'] != '') {
                    $go_url = $sg . $c['htmlurl'];
                    $go_url = str_replace(array("///", "//"), "/", $go_url);
                    if ($pages !== 0) {
                        $go_url = str_replace('.', '[p].', $go_url);
                        $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                    }
                } else {
                    $go_url = $sr . '?c=article&id=' . $c['id'];
                    if ($pages !== 0) {
                        $go_url = pagetxt($pages);
                    }
                }
            }
            break;
        case 'product':
            if ($re == 1) {
                $re_url = $sg . $GLOBALS['G_DY']['rewrite']["rewrite_product"];
                if ($c['htmlfile'] == '') {
                    $c['htmlfile'] = $c['id'];
                }
                $go_url = str_replace(array('{id}', '{file}'), array($c['id'], $c['htmlfile']), $re_url);
                $go_url = str_replace(array('{product}'), 'product', $go_url);
                if ($pages !== 0) {
                    $go_url = str_replace('{page}', '[p]', $go_url);
                    $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                } else {
                    $go_url = str_replace('{page}', 1, $go_url);
                }
            } else {
                if ($sh == 1 && $c['mrank'] == 0 && $c['mgold'] == 0 && $c['htmlurl'] != '') {
                    $go_url = $sg . $c['htmlurl'];
                    $go_url = str_replace(array("///", "//"), "/", $go_url);
                    if ($pages !== 0) {
                        $go_url = str_replace('.', '[p].', $go_url);
                        $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                    }
                } else {
                    $go_url = $sr . '?c=product&id=' . $c['id'];
                    if ($pages !== 0) {
                        $go_url = pagetxt($pages);
                    }
                }
            }
            break;
        case 'message':
            break;
        case 'classtype':
            if ($re == 1) {
                if ($c["molds"] != 'article' && $c["molds"] != 'product' && $c["molds"] != 'message') {
                    $re_url = $sg . $GLOBALS['G_DY']['rewrite']['rewrite_channel_type'];
                } else {
                    $re_url = $sg . $GLOBALS['G_DY']['rewrite']['rewrite_' . $c['molds'] . '_type'];
                }
                $go_url = str_replace(array('{tid}', '{file}'), array($c['tid'], $c['htmlfile']), $re_url);
                $go_url = str_replace(array('{' . $c['molds'] . '}', '{type}', '{channel}'), array($c['molds'], type, 'channel'), $go_url);
                if ($pages !== 0) {
                    $go_url = str_replace('{page}', '[p]', $go_url);
                    $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                } else {
                    $go_url = str_replace('{page}', 1, $go_url);
                }
            } else {
                if ($sh == 1 && $c['mrank'] == 0) {
                    $noindex = syExt("site_html_index");
                    if ($noindex == 1 && $pages == 0) {
                        $html_file == '';
                    } else {
                        if ($c["htmlfile"] != '') {
                            $html_file = $c["htmlfile"] . syExt("site_html_suffix");
                        } else {
                            $html_file = 'index' . syExt("site_html_suffix");
                        }
                    }
                    if ($c["htmldir"] == '') {
                        $go_url = $sg . syExt("site_html_dir") . "/c/" . $c["tid"] . "/" . $html_file;
                    } else {
                        $go_url = $sg . $c["htmldir"] . "/" . $html_file;
                    }
                    $go_url = str_replace(array("///", "//"), "/", $go_url);
                    if ($pages !== 0) {
                        $go_url = str_replace('.', '[p].', $go_url);
                        $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                    }
                } else {
                    if ($c["molds"] != 'article' && $c["molds"] != 'product' && $c["molds"] != 'message') {
                        $go_url = $sr . "?c=channel&a=type&tid=" . $c["tid"];
                    } else {
                        $go_url = $sr . "?c=" . $c["molds"] . "&a=type&tid=" . $c["tid"];
                    }
                    if ($pages !== 0) {
                        $go_url = pagetxt($pages);
                    }
                }
            }
            break;
        case 'special':
            if ($re == 1) {
                $re_url = $sg . $GLOBALS['G_DY']['rewrite']["rewrite_special"];
                $go_url = str_replace(array('{sid}', '{file}'), array($c['sid'], $c['htmlfile']), $re_url);
                $go_url = str_replace(array('{special}'), 'special', $go_url);
                if ($pages !== 0) {
                    $go_url = str_replace('{page}', '[p]', $go_url);
                    $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                } else {
                    $go_url = str_replace('{page}', 1, $go_url);
                }
            } else {
                if ($sh == 1) {
                    if ($c["htmlfile"] != '') {
                        $html_file = $c["htmlfile"] . syExt("site_html_suffix");
                    } else {
                        $html_file = 'index' . syExt("site_html_suffix");
                    }
                    if ($c["htmldir"] == '') {
                        $go_url = $sg . syExt("site_html_dir") . "/s/" . $c["sid"] . "/" . $html_file;
                    } else {
                        $go_url = $sg . $c["htmldir"] . "/" . $html_file;
                    }
                    $go_url = str_replace(array("///", "//"), "/", $go_url);
                    if ($pages !== 0) {
                        $go_url = str_replace('.', '[p].', $go_url);
                        $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                    }
                } else {
                    $go_url = $sr . "?c=special&sid=" . $c["sid"];
                    if ($pages !== 0) {
                        $go_url = pagetxt($pages);
                    }
                }
            }
            break;
        case 'labelcus_custom':
            if ($re == 1) {
                $re_url = $sg . $GLOBALS['G_DY']['rewrite']["rewrite_labelcus_custom"];
                $go_url = str_replace(array('{file}'), array($c['file']), $re_url);
                if ($pages !== 0) {
                    $go_url = str_replace('{page}', '[p]', $go_url);
                    $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                } else {
                    $go_url = str_replace('{page}', 1, $go_url);
                }
            } else {
                if ($c["html"] == 1) {
                    $html_file = $c["file"];
                    if ($c["dir"] == '') {
                        $go_url = $sg . syExt("site_html_dir") . "/" . $html_file;
                    } else {
                        $go_url = $sg . $c["dir"] . "/" . $html_file;
                    }
                    $go_url = str_replace(array("///", "//"), "/", $go_url);
                    if ($pages !== 0) {
                        $go_url = str_replace('.', '[p].', $go_url);
                        $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                    }
                } else {
                    $go_url = "index.php?file=" . $c["file"];
                    if ($pages !== 0) {
                        $go_url = pagetxt($pages);
                    }
                }
            }
            break;
        default:
            if ($re == 1) {
                $re_url = $sg . $GLOBALS['G_DY']['rewrite']["rewrite_channel"];
                if ($c['htmlfile'] == '') {
                    $c['htmlfile'] = $c['id'];
                }
                $go_url = str_replace(array('{id}', '{file}', '{molds}'), array($c['id'], $c['htmlfile'], $type), $re_url);
                $go_url = str_replace(array('{channel}'), 'channel', $go_url);
                if ($pages !== 0) {
                    $go_url = str_replace('{page}', '[p]', $go_url);
                    $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                } else {
                    $go_url = str_replace('{page}', 1, $go_url);
                }
            } else {
                if ($sh == 1 && $c['mrank'] == 0 && $c['mgold'] == 0 && $c['htmlurl'] != '') {
                    $go_url = $sg . $c['htmlurl'];
                    $go_url = str_replace(array("///", "//"), "/", $go_url);
                    if ($pages !== 0) {
                        $go_url = str_replace('.', '[p].', $go_url);
                        $go_url = pagetxt_html($go_url, $pages['total_page'], $ispage);
                    }
                } else {
                    $go_url = $sr . '?c=channel&molds=' . $type . '&id=' . $c['id'];
                    if ($pages !== 0) {
                        $go_url = pagetxt($pages);
                    }
                }
            }
            break;
    }
    return $go_url;
}
Beispiel #3
0
        $GLOBALS['G_DY']['url']["url_path_base"] = $_SERVER['PHP_SELF'];
    } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === basename($_SERVER['SCRIPT_FILENAME'])) {
        $GLOBALS['G_DY']['url']["url_path_base"] = $_SERVER['ORIG_SCRIPT_NAME'];
    }
}
$GLOBALS['WWW'] = pathinfo($GLOBALS['G_DY']['url']["url_path_base"]);
$GLOBALS['WWW'] = str_replace($GLOBALS['WWW']["basename"], '', $GLOBALS['G_DY']['url']["url_path_base"]);
$GLOBALS['skin'] = $GLOBALS['WWW'] . 'skin/' . $doyoConfig['ext']['view_themes'] . '/';
if (TRUE == $GLOBALS['G_DY']['url']["url_path_info"] && !empty($_SERVER['PATH_INFO'])) {
    $url_args = explode("/", $_SERVER['PATH_INFO']);
    $url_sort = array();
    for ($u = 1; $u < count($url_args); $u++) {
        if ($u == 1) {
            $url_sort[$GLOBALS['G_DY']["url_controller"]] = $url_args[$u];
        } elseif ($u == 2) {
            $url_sort[$GLOBALS['G_DY']["url_action"]] = $url_args[$u];
        } else {
            $url_sort[$url_args[$u]] = isset($url_args[$u + 1]) ? $url_args[$u + 1] : "";
            $u += 1;
        }
    }
    if ("POST" == strtoupper($_SERVER['REQUEST_METHOD'])) {
        $_REQUEST = $_POST = $_POST + $url_sort;
    } else {
        $_REQUEST = $_GET = $_GET + $url_sort;
    }
}
$__controller = isset($_REQUEST[$GLOBALS['G_DY']["url_controller"]]) ? $_REQUEST[$GLOBALS['G_DY']["url_controller"]] : $GLOBALS['G_DY']["default_controller"];
$__action = isset($_REQUEST[$GLOBALS['G_DY']["url_action"]]) ? $_REQUEST[$GLOBALS['G_DY']["url_action"]] : $GLOBALS['G_DY']["default_action"];
$GLOBALS['S'] = array('http' => syExt('http_path'), 'title' => syExt('site_title'), 'keywords' => syExt('site_keywords'), 'description' => syExt('site_description'));