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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350 |
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
if (!defined('IN_ICYPHOENIX'))
{
die('Hacking attempt');
}
/**
* Alias for user class
*/
class user
{
var $lang = array();
var $help = array();
var $theme = array();
var $date_format;
var $timezone;
var $dst;
var $lang_name = false;
var $lang_id = false;
var $lang_path;
var $img_lang;
var $img_array = array();
// Able to add new option (id 7)
var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'popuppm' => 10);
var $keyvalues = array();
var $cookie_data = array();
var $page = array();
var $data = array();
var $browser = '';
var $forwarded_for = '';
var $host = '';
var $session_id = '';
var $ip = '';
var $load = 0;
var $time_now = 0;
var $update_session_page = true;
/**
* Session begin
*/
function session_begin()
{
global $board_config, $config, $userdata, $user_ip;
$config = &$board_config;
$userdata = session_pagestart($user_ip);
return true;
}
/**
* User setup
*/
function setup()
{
global $userdata, $lang;
init_userprefs($userdata);
$this->data = &$userdata;
$this->lang = &$lang;
$this->data['is_registered'] = $userdata['session_logged_in'] ;
return true;
}
/**
* More advanced language substitution
* Function to mimic sprintf() with the possibility of using phpBB's language system to substitute nullar/singular/plural forms.
* Params are the language key and the parameters to be substituted.
* This function/functionality is inspired by SHS` and Ashe.
*
* Example call: <samp>$user->lang('NUM_POSTS_IN_QUEUE', 1);</samp>
*/
function lang()
{
$args = func_get_args();
$key = $args[0];
if (is_array($key))
{
$lang = &$this->lang[array_shift($key)];
foreach ($key as $_key)
{
$lang = &$lang[$_key];
}
}
else
{
$lang = &$this->lang[$key];
}
// Return if language string does not exist
if (!isset($lang) || (!is_string($lang) && !is_array($lang)))
{
return $key;
}
// If the language entry is a string, we simply mimic sprintf() behaviour
if (is_string($lang))
{
if (sizeof($args) == 1)
{
return $lang;
}
// Replace key with language entry and simply pass along...
$args[0] = $lang;
return call_user_func_array('sprintf', $args);
}
// It is an array... now handle different nullar/singular/plural forms
$key_found = false;
// We now get the first number passed and will select the key based upon this number
for ($i = 1, $num_args = sizeof($args); $i < $num_args; $i++)
{
if (is_int($args[$i]))
{
$numbers = array_keys($lang);
foreach ($numbers as $num)
{
if ($num > $args[$i])
{
break;
}
$key_found = $num;
}
}
}
// Ok, let's check if the key was found, else use the last entry (because it is mostly the plural form)
if ($key_found === false)
{
$numbers = array_keys($lang);
$key_found = end($numbers);
}
// Use the language string we determined and pass it to sprintf()
$args[0] = $lang[$key_found];
return call_user_func_array('sprintf', $args);
}
/**
* Add lang files
*/
function add_lang($lang_set, $use_db = false, $use_help = false)
{
global $board_config, $lang;
if (!empty($lang_set) && !is_array($lang_set))
{
$lang_file = IP_ROOT_PATH . 'language/lang_' . $board_config['default_lang'] . '/' . $lang_set . '.' . PHP_EXT;
if (@file_exists($lang_file))
{
@include($lang_file);
}
}
elseif (!empty($lang_set) && is_array($lang_set))
{
foreach ($lang_set as $key => $lang_file)
{
$lang_file = IP_ROOT_PATH . 'language/lang_' . $board_config['default_lang'] . '/' . $lang_file . '.' . PHP_EXT;
if (@file_exists($lang_file))
{
@include($lang_file);
}
}
}
$this->lang = &$lang;
return true;
}
/**
* Date format
*/
function format_date($timestamp)
{
global $board_config;
$output_date = create_date_ip($board_config['default_dateformat'], $timestamp, $board_config['board_timezone']);
return $output_date;
}
}
/**
* Alias for auth class
*/
class auth
{
var $acl = array();
var $cache = array();
var $acl_options = array();
var $acl_forum_ids = false;
/**
* ACL
*/
function acl(&$userdata)
{
return true;
}
/**
* ACL GET
*/
function acl_get($opt, $f = 0)
{
global $userdata;
$return_value = true;
if (substr($opt, 0, 2) === 'a_')
{
$return_value = (($userdata['user_level'] == ADMIN) ? true : false);
}
elseif ((substr($opt, 0, 2) === 'm_') || (substr($opt, 0, 2) === 'f_'))
{
$return_value = ((($userdata['user_level'] == ADMIN) || ($userdata['user_level'] == MOD)) ? true : false);
}
return $return_value;
}
}
/**
* Page Header
*/
function page_header($title)
{
global $page_title, $meta_description, $meta_keywords;
$page_title = !empty($page_title) ? $page_title : $title;
$meta_description = !empty($meta_description) ? $meta_description : '';
$meta_keywords = !empty($meta_keywords) ? $meta_keywords : '';
include(IP_ROOT_PATH . 'includes/page_header.' . PHP_EXT);
return true;
}
/**
* Page Footer
*/
function page_footer()
{
include(IP_ROOT_PATH . 'includes/page_tail.' . PHP_EXT);
return true;
}
/**
* BBCodes
*/
/**
* Censor
*/
function censor_text($message)
{
global $board_config, $userdata;
if (!$userdata['user_allowswearywords'])
{
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
}
if (!empty($orig_word) && count($orig_word) && !$userdata['user_allowswearywords'])
{
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
}
return $message;
}
/**
* nl2br
*/
function bbcode_nl2br($message)
{
return $message;
}
/**
* Smileys
*/
function smiley_text($message)
{
return $message;
}
if (empty($bbcode))
{
include_once(IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
}
class phpbb3_bbcode extends BBCode
{
/**
* Smileys
*/
function bbcode_second_pass($message, $bbcode_uid, $bbcode_bitfield)
{
global $board_config, $userdata;
$this->allow_html = ($userdata['user_allowhtml'] && $board_config['allow_html']) ? true : false;
$this->allow_bbcode = ($userdata['user_allowbbcode'] && $board_config['allow_bbcode']) ? true : false;
$this->allow_smilies = ($userdata['user_allowsmile'] && $board_config['allow_smilies']) ? true : false;
$message = $this->parse($message);
return $message;
}
}
// Initialazing classes...
$user = new user();
$auth = new auth();
unset($bbcode);
$bbcode = new phpbb3_bbcode();
?> |