forked from froxlor/Froxlor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customer_index.php
315 lines (272 loc) · 11.1 KB
/
customer_index.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
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
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <[email protected]> (2003-2009)
* @author Froxlor team <[email protected]> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Panel
*
*/
define('AREA', 'customer');
require './lib/init.php';
if ($action == 'logout') {
$log->logAction(USR_ACTION, LOG_NOTICE, 'logged out');
$params = array("customerid" => $userinfo['customerid']);
if (Settings::Get('session.allow_multiple_login') == '1') {
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :customerid
AND `adminsession` = '0'
AND `hash` = :hash"
);
$params["hash"] = $s;
} else {
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
WHERE `userid` = :customerid
AND `adminsession` = '0'"
);
}
Database::pexecute($stmt, $params);
redirectTo('index.php');
exit;
}
if ($page == 'overview') {
$log->logAction(USR_ACTION, LOG_NOTICE, "viewed customer_index");
$domain_stmt = Database::prepare("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :customerid
AND `parentdomainid` = '0'
AND `id` <> :standardsubdomain
");
Database::pexecute($domain_stmt, array("customerid" => $userinfo['customerid'], "standardsubdomain" => $userinfo['standardsubdomain']));
$domains = '';
$domainArray = array();
while ($row = $domain_stmt->fetch(PDO::FETCH_ASSOC)) {
$domainArray[] = $idna_convert->decode($row['domain']);
}
natsort($domainArray);
$domains = implode(',<br />', $domainArray);
// standard-subdomain
$stdsubdomain = '';
if ($userinfo['standardsubdomain'] != '0') {
$std_domain_stmt = Database::prepare("
SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `customerid` = :customerid
AND `id` = :standardsubdomain
");
$std_domain = Database::pexecute_first($std_domain_stmt, array("customerid" => $userinfo['customerid'], "standardsubdomain" => $userinfo['standardsubdomain']));
$stdsubdomain = $std_domain['domain'];
}
$userinfo['email'] = $idna_convert->decode($userinfo['email']);
$yesterday = time() - (60 * 60 * 24);
$month = date('M Y', $yesterday);
$userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, Settings::Get('panel.decimal_places'));
$userinfo['diskspace_used'] = round($userinfo['diskspace_used'] / 1024, Settings::Get('panel.decimal_places'));
$userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), Settings::Get('panel.decimal_places'));
$userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), Settings::Get('panel.decimal_places'));
$userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains');
$userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : '';
$services_enabled = "";
$se = array();
if ($userinfo['imap'] == '1') $se[] = "IMAP";
if ($userinfo['pop3'] == '1') $se[] = "POP3";
if ($userinfo['phpenabled'] == '1') $se[] = "PHP";
if ($userinfo['perlenabled'] == '1') $se[] = "Perl/CGI";
$services_enabled = implode(", ", $se);
eval("echo \"" . getTemplate('index/index') . "\";");
} elseif ($page == 'change_password') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$old_password = validate($_POST['old_password'], 'old password');
if (!validatePasswordLogin($userinfo,$old_password,TABLE_PANEL_CUSTOMERS,'customerid')) {
standard_error('oldpasswordnotcorrect');
exit;
}
$new_password = validatePassword($_POST['new_password'], 'new password');
$new_password_confirm = validatePassword($_POST['new_password_confirm'], 'new password confirm');
if ($old_password == '') {
standard_error(array('stringisempty', 'oldpassword'));
} elseif ($new_password == '') {
standard_error(array('stringisempty', 'newpassword'));
} elseif ($new_password_confirm == '') {
standard_error(array('stringisempty', 'newpasswordconfirm'));
} elseif ($new_password != $new_password_confirm) {
standard_error('newpasswordconfirmerror');
} else {
// Update user password
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
SET `password` = :newpassword
WHERE `customerid` = :customerid"
);
$params = array(
"newpassword" => makeCryptPassword($new_password),
"customerid" => $userinfo['customerid']
);
Database::pexecute($stmt, $params);
$log->logAction(USR_ACTION, LOG_NOTICE, 'changed password');
// Update ftp password
if (isset($_POST['change_main_ftp']) && $_POST['change_main_ftp'] == 'true') {
$cryptPassword = makeCryptPassword($new_password);
$stmt = Database::prepare("UPDATE `" . TABLE_FTP_USERS . "`
SET `password` = :password
WHERE `customerid` = :customerid
AND `username` = :username"
);
$params = array(
"password" => $cryptPassword,
"customerid" => $userinfo['customerid'],
"username" => $userinfo['loginname']
);
Database::pexecute($stmt, $params);
$log->logAction(USR_ACTION, LOG_NOTICE, 'changed main ftp password');
}
// Update webalizer password
if (isset($_POST['change_webalizer']) && $_POST['change_webalizer'] == 'true') {
if (CRYPT_STD_DES == 1) {
$saltfordescrypt = substr(md5(uniqid(microtime(), 1)), 4, 2);
$new_webalizer_password = crypt($new_password, $saltfordescrypt);
} else {
$new_webalizer_password = crypt($new_password);
}
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_HTPASSWDS . "`
SET `password` = :password
WHERE `customerid` = :customerid
AND `username` = :username"
);
$params = array(
"password" => $new_webalizer_password,
"customerid" => $userinfo['customerid'],
"username" => $userinfo['loginname']
);
Database::pexecute($stmt, $params);
}
redirectTo($filename, array('s' => $s));
}
} else {
eval("echo \"" . getTemplate('index/change_password') . "\";");
}
} elseif ($page == 'change_language') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$def_language = validate($_POST['def_language'], 'default language');
if (isset($languages[$def_language])) {
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
SET `def_language` = :lang
WHERE `customerid` = :customerid"
);
Database::pexecute($stmt, array("lang" => $def_language, "customerid" => $userinfo['customerid']));
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `language` = :lang
WHERE `hash` = :hash"
);
Database::pexecute($stmt, array("lang" => $def_language, "hash" => $s));
$log->logAction(USR_ACTION, LOG_NOTICE, "changed default language to '" . $def_language . "'");
}
redirectTo($filename, array('s' => $s));
} else {
$default_lang = Settings::Get('panel.standardlanguage');
if ($userinfo['def_language'] != '') {
$default_lang = $userinfo['def_language'];
}
$language_options = '';
while (list($language_file, $language_name) = each($languages)) {
$language_options .= makeoption($language_name, $language_file, $default_lang, true);
}
eval("echo \"" . getTemplate('index/change_language') . "\";");
}
} elseif ($page == 'change_theme') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
$theme = validate($_POST['theme'], 'theme');
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_CUSTOMERS . "`
SET `theme` = :theme
WHERE `customerid` = :customerid"
);
Database::pexecute($stmt, array("theme" => $theme, "customerid" => $userinfo['customerid']));
$stmt = Database::prepare("UPDATE `" . TABLE_PANEL_SESSIONS . "`
SET `theme` = :theme
WHERE `hash` = :hash"
);
Database::pexecute($stmt, array("theme" => $theme, "hash" => $s));
$log->logAction(USR_ACTION, LOG_NOTICE, "changed default theme to '" . $theme . "'");
redirectTo($filename, array('s' => $s));
} else {
$default_theme = Settings::Get('panel.default_theme');
if ($userinfo['theme'] != '') {
$default_theme = $userinfo['theme'];
}
$theme_options = '';
$themes_avail = getThemes();
foreach ($themes_avail as $t => $d) {
$theme_options.= makeoption($d, $t, $default_theme, true);
}
eval("echo \"" . getTemplate('index/change_theme') . "\";");
}
} elseif ($page == 'send_error_report' && Settings::Get('system.allow_error_report_customer') == '1') {
// only show this if we really have an exception to report
if (isset($_GET['errorid']) && $_GET['errorid'] != '') {
$errid = $_GET['errorid'];
// read error file
$err_dir = makeCorrectDir(FROXLOR_INSTALL_DIR."/logs/");
$err_file = makeCorrectFile($err_dir."/".$errid."_sql-error.log");
if (file_exists($err_file)) {
$error_content = file_get_contents($err_file);
$error = explode("|", $error_content);
$_error = array(
'code' => str_replace("\n", "", substr($error[1], 5)),
'message' => str_replace("\n", "", substr($error[2], 4)),
'file' => str_replace("\n", "", substr($error[3], 5 + strlen(FROXLOR_INSTALL_DIR))),
'line' => str_replace("\n", "", substr($error[4], 5)),
'trace' => str_replace(FROXLOR_INSTALL_DIR, "", substr($error[5], 6))
);
// build mail-content
$mail_body = "Dear froxlor-team,\n\n";
$mail_body .= "the following error has been reported by a user:\n\n";
$mail_body .= "-------------------------------------------------------------\n";
$mail_body .= $_error['code'].' '.$_error['message']."\n\n";
$mail_body .= "File: ".$_error['file'].':'.$_error['line']."\n\n";
$mail_body .= "Trace:\n".trim($_error['trace'])."\n\n";
$mail_body .= "-------------------------------------------------------------\n\n";
$mail_body .= "Froxlor-version: ".$version."\n\n";
$mail_body .= "End of report";
$mail_html = str_replace("\n", "<br />", $mail_body);
// send actual report to dev-team
if (isset($_POST['send'])
&& $_POST['send'] == 'send'
) {
// send mail and say thanks
$_mailerror = false;
try {
$mail->Subject = '[Froxlor] Error report by user';
$mail->AltBody = $mail_body;
$mail->MsgHTML($mail_html);
$mail->AddAddress('[email protected]', 'Froxlor Developer Team');
$mail->Send();
} catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
// error when reporting an error...LOLFUQ
standard_error('send_report_error', $mailerr_msg);
}
// finally remove error from fs
@unlink($err_file);
redirectTo($filename, array('s' => $s));
}
// show a nice summary of the error-report
// before actually sending anything
eval("echo \"" . getTemplate("index/send_error_report") . "\";");
} else {
redirectTo($filename, array('s' => $s));
}
} else {
redirectTo($filename, array('s' => $s));
}
}