forked from sitracker/sitracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.php
More file actions
253 lines (226 loc) · 7.76 KB
/
config.php
File metadata and controls
253 lines (226 loc) · 7.76 KB
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
<?php
// config.php - Interface for configuring SiT
//
// NOTE: This is not the configuration file, see config.inc.php
// or config.inc.php-dist - except for database settings
// everything is can be configured from the GUI now anyway
//
// SiT (Support Incident Tracker) - Support call tracking system
// Copyright (C) 2010-2014 The Support Incident Tracker Project
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
//
// Author: Ivan Lucas, <ivanlucas[at]users.sourceforge.net
require ('core.php');
if (empty($_REQUEST['userid']))
{
$permission = PERM_ADMIN; // Administrate
}
else
{
$permision = PERM_EDIT_USER_SETTINGS;
}
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');
// External variables
$selcat = cleanvar($_REQUEST['cat']);
$seltab = cleanvar($_REQUEST['tab']);
$action = cleanvar($_REQUEST['action']);
$userid = cleanvar($_REQUEST['userid']);
$edituserpermission = user_permission($sit[2], PERM_USER_EDIT); // edit user
if ($userid == 'current' OR (empty($userid) != FALSE AND $edituserpermission == FALSE))
{
$edituserid = mysqli_real_escape_string($db, $sit[2]);
}
// Check the users permission
if (empty($userid))
{
require(APPLICATION_LIBPATH . 'configvars.inc.php');
}
else
{
require(APPLICATION_LIBPATH . 'userconfigvars.inc.php');
}
if ($action == 'save' AND ($CONFIG['demo'] !== TRUE OR $_SESSION['userid'] == 1))
{
$formtoken = cleanvar($_POST['formtoken']);
if (!check_form_token($formtoken))
{
html_redirect("main.php", FALSE, $strFormInvalidExpired);
exit;
}
plugin_do('config_submitted');
if (!empty($selcat))
{
$savevar = array();
foreach ($CFGCAT[$selcat] AS $catvar)
{
$value = $_REQUEST[$catvar]; // NOTE: we don't clean here we do this after we've manipulated the value but before insert
// Type conversions
switch ($CFGVAR[$catvar]['type'])
{
case 'checkbox':
if ($value == '')
{
$value = 'FALSE';
}
break;
case '1darray':
if ($value != '')
{
$parts = explode(',', $value);
foreach ($parts AS $k => $v)
{
$parts[$k] = "'{$v}'";
}
$value = 'array(' . implode(',', $parts) . ')';
}
else
{
$value = 'array()';
}
break;
case '2darray':
$value = cleanvar($value);
if (!empty($value))
{
$value = str_replace('\n', ',', $value);
$value = str_replace('\r', '', $value);
$value = str_replace("\r", '', $value);
$value = str_replace("\n", '', $value);
$parts = explode(",", $value);
foreach ($parts AS $k => $v)
{
$y = explode('=>', $v);
$parts[$k] = "'{$y[0]}'=>'{$y[1]}'";
}
}
$value = 'array(' . implode(',', $parts) . ')';
break;
case 'languagemultiselect':
if ($_REQUEST['available_i18ncheckbox'] != '')
{
$value = '';
}
else
{
foreach ($value AS $k => $v)
{
$parts[$k] = "'{$v}'";
}
$value = 'array(' . implode(',', $parts) . ')';
}
break;
case 'timeselector':
$hour = cleanvar($_REQUEST[$catvar."time_picker_hour"]);
$minute = cleanvar($_REQUEST[$catvar."time_picker_minute"]);
$value = ($hour * 60 * 60) + ($minute * 60);
break;
case 'weekdayselector':
$value = 'array(' . implode(',', cleanvar($_REQUEST[$catvar])) . ')';
break;
case 'number':
$value = intval($value);
break;
}
$savevar[$catvar] = mysqli_real_escape_string($db, $value);
if (mb_substr($value, 0, 6) == 'array(')
{
eval("\$val = $value;");
$value = $val;
}
if (empty($userid))
{
$CONFIG[$catvar] = $value;
}
else
{
$_SESSION['userconfig'][$catvar] = $value;
// Change the language in use if it's been changed in the user config
if (!empty($_SESSION['userconfig']['language']))
{
$_SESSION['lang'] = $_SESSION['userconfig']['language'];
}
}
}
if ($CONFIG['debug']) $dbg .= "<pre>".print_r($savevar,true)."</pre>";
if (!empty($userid))
{
cfgSave($savevar, NAMESPACE_USER, $userid);
}
else
{
cfgSave($savevar, NAMESPACE_SIT);
}
}
plugin_do('config_saved');
}
$pagescripts = array('FormProtector.js');
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
if (empty($userid))
{
echo "<h2>".icon('settings', 32, $strConfiguration);
echo " {$CONFIG['application_shortname']} {$strConfiguration}</h2>";
}
else
{
echo "<h2>".icon('user', 32, $strDisplayPreferences);
echo " {$strSettings}</h2>";
}
plugin_do('config');
if (empty($seltab)) $seltab = 'application';
if (empty($selcat)) $selcat = $CFGTAB[$seltab][0];
$tabs = array();
foreach ($CFGTAB AS $tab => $cat)
{
$tabs[$TABI18n[$tab]] = "{$_SERVER['PHP_SELF']}?tab={$tab}&userid={$userid}";
}
echo draw_tabs($tabs, $seltab);
$smalltabs = array();
foreach ($CFGTAB[$seltab] AS $cat)
{
$catname = $CATI18N[$cat];
if (empty($catname)) $catname = $cat;
$smalltabs[$catname] = "{$_SERVER['PHP_SELF']}?tab={$seltab}&cat={$cat}&userid={$userid}";
}
echo draw_tabs($smalltabs, $CATI18N[$selcat], 'smalltabs');
echo "<div style='clear: both;'></div>";
echo "<form id='configform' action='{$_SERVER['PHP_SELF']}' method='post'>";
echo "<fieldset>";
$catname = $CATI18N[$selcat];
if (empty($catname)) $catname = $selcat;
echo "<legend>{$catname}</legend>";
if (!empty($CATINTRO[$selcat]))
{
echo "<div id='catintro'>{$CATINTRO[$selcat]}</div>";
}
if (!empty($selcat))
{
foreach ($CFGCAT[$selcat] AS $catvar)
{
echo cfgVarInput($catvar, $userid, $CONFIG['debug']);
}
}
plugin_do('config_tab');
echo "</fieldset>";
echo "<input type='hidden' name='cat' value='{$selcat}' />";
echo "<input type='hidden' name='tab' value='{$seltab}' />";
if (!empty($userid))
{
echo "<input type='hidden' name='userid' value='{$userid}' />";
}
echo "<input type='hidden' name='action' value='save' />";
echo "<input type='hidden' name='formtoken' value='" . gen_form_token() . "' />";
if ($CONFIG['demo'] !== TRUE OR $_SESSION['userid'] == 1)
{
echo "<p class='formbuttons'><input type='reset' value=\"{$strReset}\" /> ";
echo "<input type='submit' value=\"{$strSave}\" />";
echo "</p>";
}
echo "</form>";
echo protectform('configform');
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
?>