-
Notifications
You must be signed in to change notification settings - Fork 1
/
portal.php
176 lines (156 loc) · 5.32 KB
/
portal.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
<?php
/***************************************************************************
* portal.php
* -------------------
* begin : Sunday, March 21, 2004
* copyright : (C) 2004 masterdavid - Ronald John David
* website : http://www.integramod.com
* email : [email protected]
*
* note: removing the original copyright is illegal even you have modified
* the code. Just append yours if you have modified it.
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
//
// Set up for phpBB integration.
//
define('IN_PHPBB', true);
$phpbb_root_path = './';
//
// phpBB related files
//
include_once( $phpbb_root_path . 'extension.inc' );
include_once( $phpbb_root_path . 'common.' . $phpEx );
//
// Start session management
//
$userdata = session_pagestart( $user_ip, PAGE_INDEX );
init_userprefs( $userdata );
if (file_exists('portalinstall.php'))
{
message_die(GENERAL_MESSAGE, 'Please ensure the <b>IM Portal</b> Install file (portalinstall.php) is deleted');
}
define('PORTAL_INIT', TRUE);
include($phpbb_root_path . 'includes/functions_portal.' . $phpEx);
portal_config_init($portal_config);
include_once($phpbb_root_path . 'includes/lite.'.$phpEx);
$options = array(
'cacheDir' => $phpbb_root_path . 'var_cache/',
'fileLocking' => $portal_config['md_cache_file_locking'],
'writeControl' => $portal_config['md_cache_write_control'],
'readControl' => $portal_config['md_cache_read_control'],
'readControlType' => $portal_config['md_cache_read_type'],
'fileNameProtection' => $portal_config['md_cache_filename_protect'],
'automaticSerialization' => $portal_config['md_cache_serialize']
);
$var_cache = new Cache_Lite($options);
if(isset($HTTP_GET_VARS['page']))
{
$layout = intval($HTTP_GET_VARS['page']);
}else
{
$layout = $portal_config['default_portal'];
}
if($portal_config['cache_enabled'])
$layout_row=$var_cache->get('lr' . strval($layout), 86400, 'layout');
if(!$layout_row)
{
$sql = "SELECT template, forum_wide, view, groups, pagetitle FROM " . LAYOUT_TABLE . " WHERE lid = '" . $layout . "'";
if( !($layout_result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, "Could not query portal layout information", "", __LINE__, __FILE__, $sql);
}
$layout_row = $db->sql_fetchrow($layout_result);
if(($layout_row['template']!='')&&$portal_config['cache_enabled'])
$var_cache->save($layout_row, 'lr' . strval($layout), 'layout');
}
$layout_template = $layout_row['template'];
$layout_forum_wide_flag = ($layout_row['forum_wide']) ? FALSE : TRUE;
if ($userdata['user_id'] == ANONYMOUS)
{
$lview = in_array($layout_row['view'], array(0,1));
}else
{
switch($userdata['user_level'])
{
case USER:
$lview = in_array($layout_row['view'], array(0,2));
break;
case MOD:
$lview = in_array($layout_row['view'], array(0,2,3));
break;
case ADMIN:
$lview = in_array($layout_row['view'], array(0,1,2,3,4));
break;
default:
$lview = in_array($layout_row['view'], array(0));
}
}
$not_group_allowed = FALSE;
if(!empty($layout_row['groups']))
{
$not_group_allowed = TRUE;
$group_content = explode(",",$layout_row['groups']);
for ($i = 0; $i < count($group_content); $i++)
{
if(in_array(intval($group_content[$i]), portal_groups($userdata['user_id'])))
{
$not_group_allowed = FALSE;
}
}
}
if(($layout_template=='') || (!$lview) || ($not_group_allowed))
{
$layout = $portal_config['default_portal'];
if($portal_config['cache_enabled'])
$layout_row=$var_cache->get('lr' . strval($layout), 86400, 'layout');
if(!$layout_row)
{
$sql = "SELECT template, forum_wide FROM " . LAYOUT_TABLE . " WHERE lid = '" . $layout . "'";
if( !($layout_result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, "Could not query portal layout information", "", __LINE__, __FILE__, $sql);
}
$layout_row = $db->sql_fetchrow($layout_result);
if($portal_config['cache_enabled'])
$var_cache->save($layout_row, 'lr' . strval($layout), 'layout');
}
$layout_template = $layout_row['template'];
$layout_forum_wide_flag = ($layout_row['forum_wide']) ? FALSE : TRUE;
}
//
// Start output of page
//
$page_title = $layout_row['pagetitle'];
define('SHOW_ONLINE', true);
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
// Tell the template class which template to use.
$template->set_filenames( array( 'body' => 'layout/' . $layout_template ) );
$forum = $lang['Forum'];
$faq = $lang['Faq'];
$home = $lang['Home'];
$memberlist = $lang['Memberlist'];
$portal = $lang['Portal'];
$search = $lang['Search'];
$template->assign_vars(array(
'L_FORUM' => $lang['Forum'],
'L_FAQ' => $lang['Faq'],
'L_HOME' => $lang['Home'],
'L_MEMBERLIST' => $lang['Memberlist'],
'L_PORTAL' => $lang['Portal'],
'L_SEARCH' => $lang['Search'])
);
//
// Start Blocks
//
portal_parse_blocks($layout);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>