-
Notifications
You must be signed in to change notification settings - Fork 24
/
selector.php
138 lines (122 loc) · 4.63 KB
/
selector.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
<?php
##################################################
#
# Copyright (c) 2004-2023 OIC Group, Inc.
#
# This file is part of Exponent
#
# Exponent 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.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
/** @define "BASE" "." */
global $db;
if (!defined('EXPONENT')) exit('');
function epb($buffer, $mode) {
// @ob_gzhandler($buffer, $mode);
// return $buffer; // uncomment if you're messing with output buffering so errors show. ~pb
return expProcessBuffer($buffer);
}
//Scrub Input
// strip out possible xss exploits via old school url
foreach ($_GET as $key=>$var) {
if (is_string($var) && strpos($var,'">')) {
unset(
$_GET[$key],
$_REQUEST[$key]
);
}
}
//fixme only old school url and forms have these variables here
// conventional method to ensure the 'id' is only an id
if (isset($_REQUEST['id'])) {
$_REQUEST['id'] = (int)($_REQUEST['id']);
if (isset($_GET['id']))
$_GET['id'] = $_REQUEST['id'];
if (isset($_POST['id']))
$_POST['id'] = $_REQUEST['id'];
}
// do the same for the other id's
foreach ($_REQUEST as $key=>$var) {
if (is_string($var) && strlen($key) >= 3 && strrpos($key,'_id',-3) !== false) {
$_REQUEST[$key] = (int)($_REQUEST[$key]);
if (isset($_GET[$key]))
$_GET[$key] = $_REQUEST[$key];
if (isset($_POST[$key]))
$_POST[$key] = $_REQUEST[$key];
}
if ($key == 'src') {
$_REQUEST[$key] = preg_replace("/[^A-Za-z0-9@\-_]/", '', $_REQUEST[$key]);
if (isset($_GET[$key]))
$_GET[$key] = $_REQUEST[$key];
if (isset($_POST[$key]))
$_POST[$key] = $_REQUEST[$key];
}
}
expString::sanitize($_REQUEST); // strip other exploits like sql injections
ob_start('epb');
$microtime_str = explode(' ',microtime());
$i_start = $microtime_str[0] + $microtime_str[1];
if (!expSession::is_set('last_section')) {
expSession::set('last_section',SITE_DEFAULT_SECTION);
}
$section = $db->selectObject('section','id='.expSession::get('last_section'));
// Handle sub themes
$page = ($section && $section->subtheme != '' && is_readable('themes/'.DISPLAY_THEME.'/subthemes/'.$section->subtheme.'.php') ?
'themes/'.DISPLAY_THEME.'/subthemes/'.$section->subtheme.'.php' :
'themes/'.DISPLAY_THEME.'/index.php'
);
if (is_readable(BASE.$page)) {
define('PREVIEW_READONLY',1); // for mods
define('SELECTOR',1);
$source_select = array();
if (expSession::is_set('source_select')) $source_select = expSession::get('source_select');
$count_orig = count($source_select);
if (isset($_REQUEST['vview'])) {
$source_select['view'] = expString::sanitize($_REQUEST['vview']);
} else if (!isset($source_select['view'])) {
$source_select['view'] = '_sourcePicker';
}
if (isset($_REQUEST['vmod'])) {
$source_select['module'] = expString::sanitize($_REQUEST['vmod']);
} else if (!isset($source_select['module'])) {
// $source_select['module'] = 'containermodule';
$source_select['module'] = 'container';
}
if (isset($_REQUEST['showmodules'])) {
if (is_array($_REQUEST['showmodules'])) $source_select['showmodules'] = expString::sanitize($_REQUEST['showmodules']);
else if ($_REQUEST['showmodules'] == 'all') $source_select['showmodules'] = null;
else $source_select['showmodules'] = explode(',',$_REQUEST['showmodules']);
} else if (!isset($source_select['showmodules'])) {
$source_select['showmodules'] = null;
}
if (isset($_REQUEST['dest'])) {
$source_select['dest'] = expString::sanitize($_REQUEST['dest']);
if (stripos($source_select['dest'], 'javascript:') !== FALSE) {
$source_select['dest'] = substr($source_select['dest'], 0, stripos($source_select['dest'], 'javascript:'));
}
} else if (!isset($source_select['dest'])) {
$source_select['dest'] = null;
}
// if (isset($_REQUEST['hideOthers'])) {
// $source_select['hideOthers'] = $_REQUEST['hideOthers'];
// } else if (!isset($source_select['hideOthers'])) {
// $source_select['hideOthers'] = 0;
// }
$source_select['hideOthers'] = !empty($_REQUEST['hideOthers']);
expSession::set('source_select',$source_select);
if (!defined('PRINTER_FRIENDLY')) define('PRINTER_FRIENDLY','0');
if (!defined('EXPORT_AS_PDF')) define('EXPORT_AS_PDF','0');
// Include the rendering page.
include(BASE.$page);
expTheme::satisfyThemeRequirements();
} else {
echo sprintf(gt('Page')." '%s' ".gt('not readable.'),BASE.$page);
}
ob_end_flush();
?>