求助大神看一眼这个代码

Carlos_Liu 2015-05-21 01:27:56
这个文件(u.php)打开后是一个登录页面,但是在代码里面我找不到任何关于页面格式设计的代码。作为初学者,看懂一个网站模板的代码实在是太难了,跪求大神帮助啊!
<?php
$__FILE__ = __FILE__;//当前文档的绝对路径

$LABEL_PAGE = 'member';

require_once dirname($__FILE__).'/inc/init.php';//加载一次文件

if(empty($core->CONFIG['site_open']) && !$IS_ADMIN){

    //关闭网站,管理员放行
    message($core->CONFIG['site_close_reason']);
}

//用户状态有异常
if(!empty($_P8SESSION['status']) && $_P8SESSION['status'] == 2){
    message('member_locked');
}

//header('Pragma: no-cache');
//header('Cache-Control: no-cache, must-revalidate');

define('P8_MEMBER', true);//定义常量,大小写不敏感(true)


if(!$UID){
    
    //if(P8_AJAX_REQUEST){
    //    exit('{}');
    //}else{
        if(HTTP_REFERER != $core->U_controller){
            //如果不是请求/u.php, 设置登录后的跳转
            $forward = HTTP_REFERER;
        }
        
        //更改当前URL路由到登录页面
        $_SERVER['_REQUEST_URI'] = PHP_SELF .'/core/member-login';
    //}
}

//获取URL路由
$router = $core->get_router();

$SYSTEM = $MODULE = $script = '';
$ACTION = 'index';
//默认动作index

$URL_PARAMS = array();

if(($count = count($router)) > 0){    //参数大于0
    
    if($action_router = match_action($router[0])){
        //匹配到是系统操作 system-action-...
        $SYSTEM = $action_router[0];
        $ACTION = $action_router[1];
        
        $URL_PARAMS = array_slice($action_router, 2);
    }else{
        
        //匹配到是模块操作 system/module-action-...
        $SYSTEM = $router[0];
        if($count > 1 && $action_router = match_action($router[1])){
            $MODULE = $action_router[0];
            $ACTION = $action_router[1];
            
            $URL_PARAMS = array_slice($action_router, 2);
        }else{
            $MODULE = empty($router[1]) ? '' : $router[1];
        }
        
    }
    
    $ACTION = empty($ACTION) ? 'index' : basename($ACTION);
    
    if($SYSTEM != 'core'){
        if(isset($core->modules[$SYSTEM])){
            //核心模块
            $MODULE = $SYSTEM;
            $SYSTEM = 'core';
        }else if(empty($core->systems[$SYSTEM]['enabled'])){
            message('no_such_system');
        }
    }
    
    if($SYSTEM == 'core'){
        //如果当前系统是核心
        
        $this_system = &$core;
        
        if($MODULE){
            if(empty($core->modules[$MODULE]['enabled'])) message('no_such_module');
            
            //核心模块 core/module-action-...
            $this_module = &$core->load_module($MODULE);
            $this_router = $this_module->U_controller;
            $script_path = $this_module->path .'member/';
            
            $this_controller = &$core->controller($this_module);
            
        }else{
            $this_router = $core->U_controller;
            $script_path = $core->path .'member/';
        }
        
        $SKIN = $RESOURCE .'/skin/'. $core->CONFIG['member_template'] .'/'. $this_system->name .'/';
        
    }else{
        //其他系统
        
        $this_system = &$core->load_system($SYSTEM);
        
        if($MODULE){
            if(empty($this_system->modules[$MODULE]['enabled'])) message('no_such_module');
            
            //模块action system/module-action-...
            $this_module = &$this_system->load_module($MODULE);
            $this_router = $this_module->U_controller;
            $script_path = $this_module->path .'member/';
            
            $this_controller = &$core->controller($this_module);
            
        }else{
            //系统action system-action-...
            $script_path = $this_system->path .'member/';
            $this_router = $this_system->U_controller;
            
            $this_controller = &$core->controller($this_system);
        }
        
        $SKIN = $RESOURCE .'/skin/'. $core->CONFIG['member_template'] .'/'. $this_system->name .'/';
    }
    if(isset($_GET['forward'])){
        $forward = html_entities($_GET['forward']);
    }else if(isset($forward)){
        $forward = html_entities($forward);
    }else{
        $forward = $this_module->U_controller;
    }
    $this_url = $this_router .'-'. $ACTION;
    $script = $script_path . $ACTION .'.php';
    
}else{
    
    //没有任何动作,请求首页
    
    $SYSTEM = 'core';
    $this_system = &$core;
    $this_module = &$core->load_module('member');
    $this_controller = &$core->controller($this_module);
    $script = $this_module->path .'member/index.php';
    $this_url = $core->U_controller;
    $SKIN = $RESOURCE .'/skin/'. $core->CONFIG['member_template'] .'/'. $this_system->name .'/';
    
}

defined('P8_SYSTEM') or define('P8_SYSTEM', $SYSTEM);
defined('P8_MODULE') or define('P8_MODULE', $MODULE);
defined('P8_ACTION') or define('P8_ACTION', $ACTION);

$MEMBERSKIN = $RESOURCE .'/skin/'. $core->CONFIG['member_template'];
//脚本不存在
is_file($script) or message('access_denied');

$LABEL_URL = xss_url($this_url .($URL_PARAMS ? '-'. implode('-', $URL_PARAMS) : '').'?'. $_SERVER['QUERY_STRING']);

if($UID && !get_cookie('USERNAME')){
    set_cookie('USERNAME', jsonencode($USERNAME));
    set_cookie('UID', $UID);
    set_cookie('ROLE', $ROLE);
    $IS_ADMIN && set_cookie('IS_ADMIN', $IS_ADMIN);
}

load_language($this_system, 'global');
if($MODULE) load_language($this_module, 'global');

//插件        插件数据    标签数据
$PLUGIN = $__plugin = $__label = array();

$TEMPLATE = $core->CONFIG['member_template'];

//gzip
if(function_exists('ob_gzhandler') && !empty($core->CONFIG['gzip'])) ob_start('ob_gzhandler');


if(isset($_GET['main_page']))$_GET['main_page'] = xss_url($_GET['main_page']);


//执行脚本
require $script;



/*
echo 'skin:'.$SKIN;

echo '<pre>';
echo 'script:'.$script.'<br>';
print_r(get_included_files());
echo '<br />';
echo 'Time: '. (get_timer() - $P8['start_time']) .'<br />';
echo 'Memory: '. (memory_usage() - $P8['memory_usage'])/1000 .' KB<br />';
echo 'Querys: '. $core->DB_master->query_num .'<br />';
echo 'UID:'. $UID .'<br />';
echo 'ROLE:'. $core->ROLE .'<br />';
echo 'ROLE_GROUP:'. $ROLE_GROUP .'<br />';
echo 'USERNAME:'. $USERNAME .'<br />';

echo '</pre>';
*/
?>
...全文
127 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2015-05-21
  • 打赏
  • 举报
回复
188 行以前的代码都是为 require $script; 这一句服务的 你把 $script 打印出来就可看到实际执行的是哪个程序文件了 这是一个网站入口的路由程序,写的实在太烂了
yiluka123 2015-05-21
  • 打赏
  • 举报
回复
引用 1 楼 PhpNewnew 的回复:
类似于 $SKIN = $RESOURCE .'/skin/'. $core->CONFIG['member_template'] . 你都可以跟过去看一下是什么内容.
我看到这段代码里出现了很多$core,但是不知道他是咋定义的,存储的内容是什么。
黄袍披身 2015-05-21
  • 打赏
  • 举报
回复
类似于 $SKIN = $RESOURCE .'/skin/'. $core->CONFIG['member_template'] . 你都可以跟过去看一下是什么内容.

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧