forked from kakukeme/jms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.php
199 lines (189 loc) · 7.38 KB
/
header.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/**
* 页面显示预处理文件
*
* 载入模板,设定通用模板标签等
*
* 调用模板:无
*
* @category jieqicms
* @package system
* @copyright Copyright (c) Hangzhou Jieqi Network Technology Co.,Ltd. (http://www.jieqi.com)
* @author $Author: juny $
* @version $Id: header.php 344 2009-06-23 03:06:07Z juny $
*/
//利用浏览器缓存防止刷新和加速显示
$etagcheck=isset($_SESSION['jieqiUserId']) ? intval($_SESSION['jieqiUserId']) : '';
if(!empty($_SERVER['HTTP_IF_NONE_MATCH'])){
$etagary=explode('|', $_SERVER['HTTP_IF_NONE_MATCH']);
if(count($etagary > 1) && is_numeric($etagary[0]) && $etagcheck == $etagary[1]){
if(JIEQI_NOW_TIME - $etagary[0] < 3 || (defined('JIEQI_LAST_MODIFYED') && JIEQI_LAST_MODIFYED < $etagary[0])){
header("ETag:".JIEQI_NOW_TIME.'|'.$etagcheck, true, 304);
jieqi_freeresource();
exit;
}
}
}
@header("ETag:".JIEQI_NOW_TIME.'|'.$etagcheck);
//包含包含模板类
include_once(JIEQI_ROOT_PATH.'/lib/template/template.php');
$jieqiTpl =& JieqiTpl::getInstance();
//文件头变量赋值
$jieqiTpl->assign('jieqi_thisurl', jieqi_addurlvars(array(),true,false));
global $jieqiUsersStatus;
global $jieqiUsersGroup;
if($jieqiUsersStatus == JIEQI_GROUP_GUEST){
$jieqiTpl->assign('jieqi_newmessage', 0);
$jieqiTpl->assign('jieqi_userid', 0);
$jieqiTpl->assign('jieqi_username', '');
$jieqiTpl->assign('jieqi_useruname', '');
$jieqiTpl->assign('jieqi_group', JIEQI_GROUP_GUEST);
$jieqiTpl->assign('jieqi_groupname', $jieqiGroups[JIEQI_GROUP_GUEST]);
$jieqiTpl->assign('jieqi_score', 0);
$jieqiTpl->assign('jieqi_experience', 0);
$jieqiTpl->assign('jieqi_honor', '');
$jieqiTpl->assign('jieqi_vip', 0);
$jieqiTpl->assign('jieqi_egold', 0);
$jieqiTpl->assign('jieqi_avatar', 0);
}else{
$jieqiTpl->assign('jieqi_userid', $_SESSION['jieqiUserId']);
$jieqiTpl->assign('jieqi_username', jieqi_htmlstr($_SESSION['jieqiUserName']));
$jieqiTpl->assign('jieqi_useruname', jieqi_htmlstr($_SESSION['jieqiUserUname']));
$jieqiTpl->assign('jieqi_group', $_SESSION['jieqiUserGroup']);
$jieqiTpl->assign('jieqi_groupname', $jieqiGroups[$_SESSION['jieqiUserGroup']]);
$jieqiTpl->assign('jieqi_score', $_SESSION['jieqiUserScore']);
$jieqiTpl->assign('jieqi_experience', $_SESSION['jieqiUserExperience']);
$jieqiTpl->assign('jieqi_honor', $_SESSION['jieqiUserHonor']);
$jieqiTpl->assign('jieqi_vip', $_SESSION['jieqiUserVip']);
$jieqiTpl->assign('jieqi_egold', $_SESSION['jieqiUserEgold']);
$jieqiTpl->assign('jieqi_avatar', $_SESSION['jieqiUserAvatar']);
if(isset($_SESSION['jieqiNewMessage']) && $_SESSION['jieqiNewMessage']>0) $jieqiTpl->assign('jieqi_newmessage', $_SESSION['jieqiNewMessage']);
else $jieqiTpl->assign('jieqi_newmessage', 0);
}
$jieqiTpl->assign('jieqi_userstatus', $jieqiUsersStatus);
//$jieqiTpl->assign('jieqi_usergroup', $jieqiUsersGroup); //不赋值了,跟block_userstatus冲突
$langurl=jieqi_addurlvars(array('charset'=>''));
$jieqiTpl->assign('url_big5',$langurl.'big5');
$jieqiTpl->assign('url_gb2312',$langurl.'gbk');
$jieqiTpl->assign('url_gbk',$langurl.'gbk');
$jieqiTpl->assign('url_utf8',$langurl.'utf8');
unset($langurl);
//页标题
if(empty($jieqi_pagetitle)) $jieqi_pagetitle=JIEQI_SITE_NAME;
$jieqiTpl->assign_by_ref('jieqi_pagetitle', $jieqi_pagetitle);
$jieqiTpl->assign('jieqi_banner', JIEQI_BANNER);
//头部附加内容(javascript等)
if(!empty($jieqi_pagehead)) $jieqiTpl->assign('jieqi_head', $jieqi_pagehead);
else $jieqiTpl->assign('jieqi_head', '');
//顶部和底部通栏广告
$jieqiTpl->assign('jieqi_top_bar', JIEQI_TOP_BAR);
$jieqiTpl->assign('jieqi_bottom_bar', JIEQI_BOTTOM_BAR);
//载入header.php的钩子
if(function_exists('jieqi_hooks_header')) jieqi_hooks_header();
//调用区块 $retflag=0 返回数组 1 返回内容 2 返回标题
function jieqi_get_block($blockconfig, $retflag=0){
global $jieqiUsersStatus;
global $jieqi_blockside;
global $jieqi_showlblock;
global $jieqi_showcblock;
global $jieqi_showrblock;
global $jieqi_showtblock;
global $jieqi_showbblock;
global $jieqiModules;
global $jieqiTpl;
global $jieqiCache;
$blockret=array();
//判断是否显示
if ((($jieqiUsersStatus == JIEQI_GROUP_GUEST && ($blockconfig['publish'] & 1)>0) || ($jieqiUsersStatus != JIEQI_GROUP_GUEST && ($blockconfig['publish'] & 2)>0))){
//显示位置
$jieqi_blockside = '';
switch ($blockconfig['side']) {
case JIEQI_SIDEBLOCK_LEFT:
$jieqi_blockside = 'jieqi_lblocks';
$jieqi_showlblock = true;
break;
case JIEQI_CENTERBLOCK_LEFT:
$jieqi_blockside = 'jieqi_clblocks';
$jieqi_showcblock = true;
break;
case JIEQI_CENTERBLOCK_RIGHT:
$jieqi_blockside = 'jieqi_crblocks';
$jieqi_showcblock = true;
break;
case JIEQI_CENTERBLOCK_TOP:
$jieqi_blockside = 'jieqi_ctblocks';
$jieqi_showcblock = true;
break;
case JIEQI_CENTERBLOCK_MIDDLE:
$jieqi_blockside = 'jieqi_cmblocks';
$jieqi_showcblock = true;
break;
case JIEQI_CENTERBLOCK_BOTTOM:
$jieqi_blockside = 'jieqi_cbblocks';
$jieqi_showcblock = true;
break;
case JIEQI_SIDEBLOCK_RIGHT:
$jieqi_blockside = 'jieqi_rblocks';
$jieqi_showrblock = true;
break;
case JIEQI_TOPBLOCK_ALL:
$jieqi_blockside = 'jieqi_tblocks';
$jieqi_showtblock = true;
break;
case JIEQI_BOTTOMBLOCK_ALL:
$jieqi_blockside = 'jieqi_bblocks';
$jieqi_showbblock = true;
break;
default:
$jieqi_blockside = 'jieqi_oblocks';
break;
}
if (!empty($jieqi_blockside)){
//区块序号
//$blockindex = (empty($blockconfig['bid'])) ? 'cid'.$blockid : 'bid'.$blockconfig['bid'];
//区块路径
$blockpath = ($blockconfig['module'] == 'system') ? JIEQI_ROOT_PATH : $jieqiModules[$blockconfig['module']]['path'];
if($blockconfig['custom'] > 0){
//$blockconfig['filename'] = 'block_custom';
$blockfile = JIEQI_ROOT_PATH.'/blocks/block_custom.php';
}else{
$blockfile = $blockpath.'/blocks/'.trim($blockconfig['filename']).'.php';
}
$usecache=false;
//是否可以直接取缓存
if($blockconfig['contenttype'] != JIEQI_CONTENT_PHP && empty($blockconfig['hasvars'])){
if($blockconfig['custom'] > 0) $templatefile = empty($blockconfig['bid']) ? $blockconfig['filename'].'.html' : 'block_custom'.$blockconfig['bid'].'.html';
else $templatefile = empty($blockconfig['template']) ? $blockconfig['filename'].'.html' : $blockconfig['template'];
$templatefile = $blockpath.'/templates/blocks/'.$templatefile;
$cachefile = str_replace(JIEQI_ROOT_PATH, JIEQI_CACHE_PATH, $templatefile);
if($jieqiCache->iscached($cachefile)){
$usecache=true; //自定义的可以直接包含
}
}
if($usecache){
$blockret=array('title' => $blockconfig['title'], 'content' => $jieqiCache->get($cachefile));
}else{
$blockfile = @realpath($blockfile);
if(is_file($blockfile) && preg_match('/blocks[\/\\\]block_\w+\.php$/i', $blockfile)){
$tpl_bak_vars = $jieqiTpl->get_all_assign();
$tpl_bak_caching = $jieqiTpl->getCaching();
$tpl_bak_cachetime = $jieqiTpl->getCacheTime();
$tpl_bak_overtime = $jieqiTpl->getOverTime();
include_once($blockfile);
$jieqiBlock=new $blockconfig['classname']($blockconfig);
$blockret=array('title' => $jieqiBlock->getTitle(), 'content' => $jieqiBlock->getContent());
$jieqiTpl->set_all_assign($tpl_bak_vars);
$jieqiTpl->setCaching($tpl_bak_caching);
$jieqiTpl->setCacheTime($tpl_bak_cachetime);
$jieqiTpl->setOverTime($tpl_bak_overtime);
}else{
return false;
}
}
}
}
if($retflag == 1) return $blockret['content'];
elseif($retflag == 2) return $blockret['title'];
else return $blockret;
}
?>