phpBB
Statistics
| Revision:

root / tags / milestone_3 / phpBB / adm / pagestart.php

History | View | Annotate | Download (11.5 kB)

1
<?php
2
/** 
3
*
4
* @package acp
5
* @version $Id: pagestart.php 5244 2005-10-02 18:25:30Z acydburn $
6
* @copyright (c) 2005 phpBB Group 
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
8
*
9
*/
10
11
if (!defined('IN_PHPBB'))
12
{
13
        exit;
14
}
15
16
/**
17
*/
18
define('NEED_SID', true);
19
define('IN_ADMIN', true);
20
require($phpbb_root_path . 'common.'.$phpEx);
21
require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
22
23
// Start session management
24
$user->session_begin();
25
$auth->acl($user->data);
26
$user->setup('admin');
27
// End session management
28
29
// Did user forget to login? Give 'em a chance to here ...
30
if (!$user->data['is_registered'])
31
{
32
        if ($user->data['is_bot'])
33
        {
34
                redirect("../index.$phpEx$SID");
35
        }
36
37
        login_box('', $user->lang['LOGIN_ADMIN'], $user->lang['LOGIN_ADMIN_SUCCESS'], true);
38
}
39
40
// Have they authenticated (again) as an admin for this session?
41
if (!$user->data['session_admin'])
42
{
43
        login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false);
44
}
45
46
// Is user any type of admin? No, then stop here, each script needs to
47
// check specific permissions but this is a catchall
48
if (!$auth->acl_get('a_'))
49
{
50
        trigger_error($user->lang['NO_ADMIN']);
51
}
52
53
// Some oft used variables
54
$safe_mode        = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false;
55
$file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
56
57
58
// -----------------------------
59
// Functions
60
function adm_page_header($sub_title, $meta = '', $table_html = true)
61
{
62
        global $config, $db, $user, $phpEx;
63
64
        define('HEADER_INC', true);
65
66
        // gzip_compression
67
        if ($config['gzip_compress'])
68
        {
69
                if (extension_loaded('zlib') && !headers_sent())
70
                {
71
                        ob_start('ob_gzhandler');
72
                }
73
        }
74
75
        header("Content-type: text/html; charset=" . $user->lang['ENCODING']);
76
77
?>
78
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
79
<html>
80
<head>
81
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $user->lang['ENCODING']; ?>">
82
<meta http-equiv="Content-Style-Type" content="text/css">
83
<link rel="stylesheet" href="subSilver.css" type="text/css">
84
<?php
85
86
        echo $meta;
87
88
?>
89
<style type="text/css">
90
<!--
91
th                { background-image: url('images/cellpic3.gif') }
92
td.cat        { background-image: url('images/cellpic1.gif') }
93
//-->
94
</style>
95
<title><?php echo $config['sitename'] . ' - ' . $page_title; ?></title>
96
</head>
97
<body>
98
99
<?php
100
101
        if ($table_html)
102
        {
103
104
?>
105
<a name="top"></a>
106
107
<table width="100%" cellspacing="0" cellpadding="0" border="0">
108
        <tr>
109
                <td colspan="2" height="25" align="right" nowrap="nowrap"><span class="subtitle">&#0187; <i><?php echo $sub_title; ?></i></span> &nbsp;&nbsp;</td>
110
        </tr>
111
</table>
112
113
<table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
114
        <tr>
115
                <td><br clear="all" />
116
117
<?php
118
119
        }
120
121
}
122
123
function adm_page_footer($copyright_html = true)
124
{
125
        global $cache, $config, $db, $phpEx;
126
127
        if (!empty($cache))
128
        {
129
                $cache->unload();
130
        }
131
132
        // Close our DB connection.
133
        $db->sql_close();
134
135
?>
136
137
                </td>
138
        </tr>
139
</table>
140
<?php
141
142
        if ($copyright_html)
143
        {
144
145
?>
146
147
<div class="copyright" align="center">Powered by phpBB <?php echo $config['version']; ?> &copy; 2002 <a href="http://www.phpbb.com/" target="_phpbb">phpBB Group</a></div>
148
149
<br clear="all" />
150
151
</body>
152
</html>
153
<?php
154
155
        }
156
157
        exit;
158
}
159
160
function adm_page_message($title, $message, $show_header = false)
161
{
162
        global $phpEx, $SID, $user;
163
164
        if ($show_header)
165
        {
166
167
?>
168
169
<table width="100%" cellspacing="0" cellpadding="0" border="0">
170
        <tr>
171
                <td><a href="<?php echo "../index.$phpEx$SID"; ?>"><img src="images/header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></a></td>
172
                <td width="100%" background="images/header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle"><?php echo $user->lang['ADMIN_TITLE']; ?></span> &nbsp; &nbsp; &nbsp;</td>
173
        </tr>
174
</table>
175
176
<?php
177
178
        }
179
180
?>
181
182
<br /><br />
183
184
<table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0" align="center">
185
        <tr>
186
                <th><?php echo $title; ?></th>
187
        </tr>
188
        <tr>
189
                <td class="row1" align="center"><?php echo $message; ?></td>
190
        </tr>
191
</table>
192
193
<br />
194
195
<?php
196
197
}
198
199
function adm_page_confirm($title, $message)
200
{
201
        global $phpEx, $SID, $user;
202
203
        // Grab data from GET and POST arrays ... note this is _not_
204
        // validated! Everything is typed as string to ensure no
205
        // funny business on displayed hidden field data. Validation
206
        // will be carried out by whatever processes this form.
207
        $var_ary = array_merge($_GET, $_POST);
208
209
        $s_hidden_fields = '';
210
        foreach ($var_ary as $key => $var)
211
        {
212
                if (empty($var))
213
                {
214
                        continue;
215
                }
216
217
                if (is_array($var))
218
                {
219
                        foreach ($var as $k => $v)
220
                        {
221
                                if (is_array($v))
222
                                {
223
                                        foreach ($v as $_k => $_v)
224
                                        {
225
                                                set_var($var[$k][$_k], $_v, 'string');
226
                                                $s_hidden_fields .= "<input type=\"hidden\" name=\"${key}[$k][$_k]\" value=\"" . addslashes($_v) . '" />';
227
                                        }
228
                                }
229
                                else
230
                                {
231
                                        set_var($var[$k], $v, 'string');
232
                                        $s_hidden_fields .= "<input type=\"hidden\" name=\"${key}[$k]\" value=\"" . addslashes($v) . '" />';
233
                                }
234
                        }
235
                }
236
                else
237
                {
238
                        set_var($var, $var, 'string');
239
                        $s_hidden_fields .= '<input type="hidden" name="' . $key . '" value="' . addslashes($var) . '" />';
240
                }
241
                unset($var_ary[$key]);
242
        }
243
244
?>
245
246
<br /><br />
247
248
<form name="confirm" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'] . $SID; ?>">
249
<table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0" align="center">
250
        <tr>
251
                <th><?php echo $title; ?></th>
252
        </tr>
253
        <tr>
254
                <td class="row1" align="center"><?php echo $message; ?><br /><br /><input class="btnlite" type="submit" name="confirm" value="<?php echo $user->lang['YES']; ?>" />&nbsp;&nbsp;<input class="btnmain" type="submit" name="cancel" value="<?php echo $user->lang['NO']; ?>" /></td>
255
        </tr>
256
</table>
257
258
<?php echo $s_hidden_fields; ?>
259
</form>
260
261
<br />
262
263
<?php
264
265
        adm_page_footer();
266
267
}
268
269
270
function build_cfg_template($tpl_type, $config_key, $options = '')
271
{
272
        global $new, $user;
273
274
        $tpl = '';
275
        $name = 'config[' . $config_key . ']';
276
277
        switch ($tpl_type[0])
278
        {
279
                case 'text':
280
                case 'password':
281
                        $size = (int) $tpl_type[1];
282
                        $maxlength = (int) $tpl_type[2];
283
284
                        $tpl = '<input class="post" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $new[$config_key] . '" />';
285
                        break;
286
287
                case 'dimension':
288
                        $size = (int) $tpl_type[1];
289
                        $maxlength = (int) $tpl_type[2];
290
291
                        $tpl = '<input class="post" type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_height]" value="' . $new[$config_key . '_height'] . '" /> x <input class="post" type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_width]" value="' . $new[$config_key . '_width'] . '" />';
292
                        break;
293
294
                case 'textarea':
295
                        $rows = (int) $tpl_type[1];
296
                        $cols = (int) $tpl_type[2];
297
298
                        $tpl = '<textarea name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $new[$config_key] . '</textarea>';
299
                        break;
300
301
                case 'radio':
302
                        $key_yes        = ($new[$config_key]) ? ' checked="checked"' : '';
303
                        $key_no                = (!$new[$config_key]) ? ' checked="checked"' : '';
304
305
                        $tpl_type_cond = explode('_', $tpl_type[1]);
306
                        $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
307
308
                        $tpl_no = '<input type="radio" name="' . $name . '" value="0"' . $key_no . ' />' . (($type_no) ? $user->lang['NO'] : $user->lang['DISABLED']);
309
                        $tpl_yes = '<input type="radio" name="' . $name . '" value="1"' . $key_yes . ' />' . (($type_no) ? $user->lang['YES'] : $user->lang['ENABLED']);
310
311
                        $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . '&nbsp;&nbsp;' . $tpl_no : $tpl_no . '&nbsp;&nbsp;' . $tpl_yes;
312
                        break;
313
314
                case 'select':
315
                        eval('$s_options = ' . str_replace('{VALUE}', $new[$config_key], $options) . ';');
316
                        $tpl = '<select name="' . $name . '">' . $s_options . '</select>';
317
                        break;
318
319
                case 'custom':
320
                        eval('$tpl = ' . str_replace('{VALUE}', $new[$config_key], $options) . ';');
321
                        break;
322
323
                default:
324
                        break;
325
        }
326
327
        return $tpl;
328
}
329
330
331
/**
332
* @package acp
333
* General ACP module class
334
*/
335
class module
336
{
337
        var $id = 0;
338
        var $type;
339
        var $name;
340
        var $mode;
341
342
        // Private methods, should not be overwritten
343
        function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
344
        {
345
                global $template, $auth, $db, $user, $config;
346
347
                $sql = 'SELECT module_id, module_title, module_filename, module_subs, module_acl
348
                        FROM ' . MODULES_TABLE . "
349
                        WHERE module_type = 'acp'
350
                                AND module_enabled = 1
351
                        ORDER BY module_order ASC";
352
                $result = $db->sql_query($sql);
353
354
                while ($row = $db->sql_fetchrow($result))
355
                {
356
                        // Authorisation is required for the basic module
357
                        if ($row['module_acl'])
358
                        {
359
                                $is_auth = false;
360
361
                                eval('$is_auth = (' . preg_replace(array('#acl_([a-z_]+)#e', '#cfg_([a-z_]+)#e'), array('$auth->acl_get("\\1")', '$config["\\1"]'), $row['module_acl']) . ');');
362
363
                                // The user is not authorised to use this module, skip it
364
                                if (!$is_auth)
365
                                {
366
                                        continue;
367
                                }
368
                        }
369
370
                        $selected = ($row['module_filename'] == $selected_mod || $row['module_id'] == $selected_mod || (!$selected_mod && !$i)) ?  true : false;
371
/*
372
                        // Get the localised lang string if available, or make up our own otherwise
373
                        $template->assign_block_vars($module_type . '_section', array(
374
                                'L_TITLE'                => (isset($user->lang[strtoupper($module_type) . '_' . $row['module_title']])) ? $user->lang[strtoupper($module_type) . '_' . $row['module_title']] : ucfirst(str_replace('_', ' ', strtolower($row['module_title']))),
375
                                'S_SELECTED'        => $selected,
376
                                'U_TITLE'                => $module_url . '&amp;i=' . $row['module_id'])
377
                        );
378
*/
379
                        if ($selected)
380
                        {
381
                                $module_id = $row['module_id'];
382
                                $module_name = $row['module_filename'];
383
384
                                if ($row['module_subs'])
385
                                {
386
                                        $j = 0;
387
                                        $submodules_ary = explode("\n", $row['module_subs']);
388
                                        foreach ($submodules_ary as $submodule)
389
                                        {
390
                                                $submodule = explode(',', trim($submodule));
391
                                                $submodule_title = array_shift($submodule);
392
393
                                                $is_auth = true;
394
                                                foreach ($submodule as $auth_option)
395
                                                {
396
                                                        if (!$auth->acl_get($auth_option))
397
                                                        {
398
                                                                $is_auth = false;
399
                                                        }
400
                                                }
401
402
                                                if (!$is_auth)
403
                                                {
404
                                                        continue;
405
                                                }
406
407
                                                $selected = ($submodule_title == $selected_submod || (!$selected_submod && !$j)) ? true : false;
408
/*
409
                                                // Get the localised lang string if available, or make up our own otherwise
410
                                                $template->assign_block_vars("{$module_type}_section.{$module_type}_subsection", array(
411
                                                        'L_TITLE'                => (isset($user->lang[strtoupper($module_type) . '_' . strtoupper($submodule_title)])) ? $user->lang[strtoupper($module_type) . '_' . strtoupper($submodule_title)] : ucfirst(str_replace('_', ' ', strtolower($submodule_title))),
412
                                                        'S_SELECTED'        => $selected,
413
                                                        'U_TITLE'                => $module_url . '&amp;i=' . $module_id . '&amp;mode=' . $submodule_title
414
                                                ));
415
*/
416
                                                if ($selected)
417
                                                {
418
                                                        $this->mode = $submodule_title;
419
                                                }
420
421
                                                $j++;
422
                                        }
423
                                }
424
                        }
425
426
                        $i++;
427
                }
428
                $db->sql_freeresult($result);
429
430
                if (!$module_id)
431
                {
432
                        trigger_error('MODULE_NOT_EXIST');
433
                }
434
435
                $this->type = $module_type;
436
                $this->id = $module_id;
437
                $this->name = $module_name;
438
        }
439
440
        // Public methods to be overwritten by modules
441
        function module()
442
        {
443
                // Module name
444
                // Module filename
445
                // Module description
446
                // Module version
447
                // Module compatibility
448
                return false;
449
        }
450
451
        function init()
452
        {
453
                return false;
454
        }
455
456
        function install()
457
        {
458
                return false;
459
        }
460
461
        function uninstall()
462
        {
463
                return false;
464
        }
465
}
466
// End Functions
467
// -----------------------------
468
469
?>