2010-01-27 08:54:31 +00:00
|
|
|
<?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 <flo@syscp.org> (2003-2009)
|
|
|
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
|
|
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
|
|
|
* @package Panel
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2010-01-27 08:54:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
define('AREA', 'admin');
|
2013-11-18 11:53:33 +00:00
|
|
|
require './lib/init.php';
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if ($action == 'logout') {
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "logged out");
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
$params = array('adminid' => (int)$userinfo['adminid']);
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
if (Settings::Get('session.allow_multiple_login') == '1') {
|
2013-10-29 07:22:17 +00:00
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
|
|
|
|
WHERE `userid` = :adminid
|
|
|
|
AND `adminsession` = '1'
|
|
|
|
AND `hash` = :hash"
|
|
|
|
);
|
|
|
|
$params['hash'] = $s;
|
|
|
|
} else {
|
|
|
|
$stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_SESSIONS . "`
|
|
|
|
WHERE `userid` = :adminid
|
|
|
|
AND `adminsession` = '1'"
|
|
|
|
);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2013-10-29 07:22:17 +00:00
|
|
|
Database::pexecute($stmt, $params);
|
2010-01-27 08:54:31 +00:00
|
|
|
|
|
|
|
redirectTo('index.php');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (isset($_POST['id'])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$id = intval($_POST['id']);
|
2013-10-29 07:22:17 +00:00
|
|
|
} elseif(isset($_GET['id'])) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$id = intval($_GET['id']);
|
|
|
|
}
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if ($page == 'overview') {
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_index");
|
2013-10-29 07:22:17 +00:00
|
|
|
$overview_stmt = Database::prepare("SELECT COUNT(*) AS `number_customers`,
|
2010-01-27 08:54:31 +00:00
|
|
|
SUM(`diskspace_used`) AS `diskspace_used`,
|
|
|
|
SUM(`mysqls_used`) AS `mysqls_used`,
|
|
|
|
SUM(`emails_used`) AS `emails_used`,
|
|
|
|
SUM(`email_accounts_used`) AS `email_accounts_used`,
|
|
|
|
SUM(`email_forwarders_used`) AS `email_forwarders_used`,
|
|
|
|
SUM(`email_quota_used`) AS `email_quota_used`,
|
|
|
|
SUM(`ftps_used`) AS `ftps_used`,
|
|
|
|
SUM(`tickets_used`) AS `tickets_used`,
|
|
|
|
SUM(`subdomains_used`) AS `subdomains_used`,
|
2013-12-05 07:37:58 +00:00
|
|
|
SUM(`traffic_used`) AS `traffic_used`
|
2013-10-29 07:22:17 +00:00
|
|
|
FROM `" . TABLE_PANEL_CUSTOMERS . "`" . ($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = :adminid "));
|
2013-11-06 10:08:48 +00:00
|
|
|
$overview = Database::pexecute_first($overview_stmt, array('adminid' => $userinfo['adminid']));
|
2013-10-29 07:22:17 +00:00
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$dec_places = Settings::Get('panel.decimal_places');
|
|
|
|
$overview['traffic_used'] = round($overview['traffic_used'] / (1024 * 1024), $dec_places);
|
|
|
|
$overview['diskspace_used'] = round($overview['diskspace_used'] / 1024, $dec_places);
|
2013-10-31 07:01:50 +00:00
|
|
|
|
|
|
|
$number_domains_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(*) AS `number_domains` FROM `" . TABLE_PANEL_DOMAINS . "`
|
|
|
|
WHERE `parentdomainid`='0'" . ($userinfo['customers_see_all'] ? '' : " AND `adminid` = :adminid")
|
|
|
|
);
|
2013-11-06 10:08:48 +00:00
|
|
|
$number_domains = Database::pexecute_first($number_domains_stmt, array('adminid' => $userinfo['adminid']));
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$overview['number_domains'] = $number_domains['number_domains'];
|
2013-10-31 07:01:50 +00:00
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$phpversion = phpversion();
|
2013-11-17 17:35:38 +00:00
|
|
|
$mysqlserverversion = Database::getAttribute(PDO::ATTR_SERVER_VERSION);
|
2010-01-27 08:54:31 +00:00
|
|
|
$webserverinterface = strtoupper(@php_sapi_name());
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if ((isset($_GET['lookfornewversion']) && $_GET['lookfornewversion'] == 'yes')
|
|
|
|
|| (isset($lookfornewversion) && $lookfornewversion == 'yes')
|
|
|
|
) {
|
2010-01-27 12:39:42 +00:00
|
|
|
$update_check_uri = 'http://version.froxlor.org/Froxlor/legacy/' . $version;
|
2010-02-23 09:19:41 +00:00
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (ini_get('allow_url_fopen')) {
|
2010-01-27 12:39:42 +00:00
|
|
|
$latestversion = @file($update_check_uri);
|
2010-02-23 09:19:41 +00:00
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (isset($latestversion[0])) {
|
2010-02-23 09:19:41 +00:00
|
|
|
$latestversion = explode('|', $latestversion[0]);
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (is_array($latestversion)
|
|
|
|
&& count($latestversion) >= 1
|
|
|
|
) {
|
2010-02-23 09:19:41 +00:00
|
|
|
$_version = $latestversion[0];
|
2010-05-17 07:01:46 +00:00
|
|
|
$_message = isset($latestversion[1]) ? $latestversion[1] : '';
|
2010-02-23 09:19:41 +00:00
|
|
|
$_link = isset($latestversion[2]) ? $latestversion[2] : htmlspecialchars($filename . '?s=' . urlencode($s) . '&page=' . urlencode($page) . '&lookfornewversion=yes');
|
|
|
|
|
2013-03-20 20:14:56 +00:00
|
|
|
// add the branding so debian guys are not gettings confused
|
|
|
|
// about their version-number
|
|
|
|
$lookfornewversion_lable = $_version.$branding;
|
2010-02-23 09:19:41 +00:00
|
|
|
$lookfornewversion_link = $_link;
|
|
|
|
$lookfornewversion_addinfo = $_message;
|
2011-06-13 15:21:02 +00:00
|
|
|
|
2013-12-12 10:20:19 +00:00
|
|
|
// not numeric -> error-message
|
2013-12-30 16:14:26 +00:00
|
|
|
if (!preg_match('/^((\d+\\.)(\d+\\.)(\d+\\.)?(\d+)?(\-(svn|dev|rc)(\d+))?)$/', $_version)) {
|
2013-12-12 10:20:19 +00:00
|
|
|
// check for customized version to not output
|
|
|
|
// "There is a newer version of froxlor" besides the error-message
|
|
|
|
$isnewerversion = 2;
|
|
|
|
} elseif (version_compare2($version, $_version) == -1) {
|
2010-02-23 09:19:41 +00:00
|
|
|
$isnewerversion = 1;
|
|
|
|
} else {
|
|
|
|
$isnewerversion = 0;
|
|
|
|
}
|
2013-10-29 07:22:17 +00:00
|
|
|
} else {
|
2014-02-19 10:08:43 +00:00
|
|
|
redirectTo($update_check_uri.'/pretty', NULL, false);
|
2010-01-27 12:39:42 +00:00
|
|
|
}
|
2013-10-29 07:22:17 +00:00
|
|
|
} else {
|
2014-02-19 10:08:43 +00:00
|
|
|
redirectTo($update_check_uri.'/pretty', NULL, false);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2013-10-29 07:22:17 +00:00
|
|
|
} else {
|
2014-02-19 10:08:43 +00:00
|
|
|
redirectTo($update_check_uri.'/pretty', NULL, false);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
2013-10-29 07:22:17 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$lookfornewversion_lable = $lng['admin']['lookfornewversion']['clickhere'];
|
|
|
|
$lookfornewversion_link = htmlspecialchars($filename . '?s=' . urlencode($s) . '&page=' . urlencode($page) . '&lookfornewversion=yes');
|
|
|
|
$lookfornewversion_addinfo = '';
|
2010-02-23 09:19:41 +00:00
|
|
|
$isnewerversion = 0;
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$dec_places = Settings::Get('panel.decimal_places');
|
|
|
|
$userinfo['diskspace'] = round($userinfo['diskspace'] / 1024, $dec_places);
|
|
|
|
$userinfo['diskspace_used'] = round($userinfo['diskspace_used'] / 1024, $dec_places);
|
|
|
|
$userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), $dec_places);
|
|
|
|
$userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), $dec_places);
|
2013-12-05 07:37:58 +00:00
|
|
|
$userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains');
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2015-01-15 21:19:28 +00:00
|
|
|
$userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : '';
|
|
|
|
|
2010-01-28 11:17:55 +00:00
|
|
|
$cron_last_runs = getCronjobsLastRun();
|
2010-01-29 11:15:15 +00:00
|
|
|
$outstanding_tasks = getOutstandingTasks();
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (function_exists('sys_getloadavg')) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$loadArray = sys_getloadavg();
|
|
|
|
$load = number_format($loadArray[0], 2, '.', '') . " / " . number_format($loadArray[1], 2, '.', '') . " / " . number_format($loadArray[2], 2, '.', '');
|
2013-10-29 07:22:17 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$load = @file_get_contents('/proc/loadavg');
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (!$load) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$load = $lng['admin']['noloadavailable'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (function_exists('posix_uname')) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$showkernel = 1;
|
|
|
|
$kernel_nfo = posix_uname();
|
|
|
|
$kernel = $kernel_nfo['release'] . ' (' . $kernel_nfo['machine'] . ')';
|
2013-10-29 07:22:17 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
$showkernel = 0;
|
|
|
|
$kernel = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try to get the uptime
|
2010-09-20 07:56:32 +00:00
|
|
|
// First: With exec (let's hope it's enabled for the Froxlor - vHost)
|
2010-01-27 08:54:31 +00:00
|
|
|
$uptime_array = explode(" ", @file_get_contents("/proc/uptime"));
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (is_array($uptime_array)
|
|
|
|
&& isset($uptime_array[0])
|
|
|
|
&& is_numeric($uptime_array[0])
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
// Some calculatioon to get a nicly formatted display
|
|
|
|
$seconds = round($uptime_array[0], 0);
|
|
|
|
$minutes = $seconds / 60;
|
|
|
|
$hours = $minutes / 60;
|
|
|
|
$days = floor($hours / 24);
|
|
|
|
$hours = floor($hours - ($days * 24));
|
|
|
|
$minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60));
|
|
|
|
$seconds = floor($seconds - ($days * 24 * 60 * 60) - ($hours * 60 * 60) - ($minutes * 60));
|
|
|
|
$uptime = "{$days}d, {$hours}h, {$minutes}m, {$seconds}s";
|
|
|
|
|
|
|
|
// Just cleanup
|
|
|
|
unset($uptime_array, $seconds, $minutes, $hours, $days);
|
2013-10-29 07:22:17 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
// Nothing of the above worked, show an error :/
|
|
|
|
$uptime = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
eval("echo \"" . getTemplate("index/index") . "\";");
|
2013-10-29 07:22:17 +00:00
|
|
|
|
|
|
|
} elseif($page == 'change_password') {
|
|
|
|
|
|
|
|
if (isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$old_password = validate($_POST['old_password'], 'old password');
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (md5($old_password) != $userinfo['password']) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('oldpasswordnotcorrect');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$new_password = validate($_POST['new_password'], 'new password');
|
|
|
|
$new_password_confirm = validate($_POST['new_password_confirm'], 'new password confirm');
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if ($old_password == '') {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error(array('stringisempty', 'oldpassword'));
|
2013-10-29 07:22:17 +00:00
|
|
|
} elseif($new_password == '') {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error(array('stringisempty', 'newpassword'));
|
2013-10-29 07:22:17 +00:00
|
|
|
} elseif($new_password_confirm == '') {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error(array('stringisempty', 'newpasswordconfirm'));
|
2013-10-29 07:22:17 +00:00
|
|
|
} elseif($new_password != $new_password_confirm) {
|
2010-01-27 08:54:31 +00:00
|
|
|
standard_error('newpasswordconfirmerror');
|
2013-10-29 07:22:17 +00:00
|
|
|
} else {
|
|
|
|
$chgpwd_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
|
|
|
SET `password`= :newpasswd
|
|
|
|
WHERE `adminid`= :adminid
|
|
|
|
AND `password`= :oldpasswd"
|
|
|
|
);
|
|
|
|
Database::pexecute($chgpwd_stmt, array(
|
|
|
|
'newpasswd' => md5($new_password),
|
|
|
|
'adminid' => (int)$userinfo['adminid'],
|
|
|
|
'oldpasswd' => md5($old_password)
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, 'changed password');
|
|
|
|
redirectTo($filename, Array('s' => $s));
|
|
|
|
}
|
2013-10-29 07:22:17 +00:00
|
|
|
} else {
|
2010-01-27 08:54:31 +00:00
|
|
|
eval("echo \"" . getTemplate("index/change_password") . "\";");
|
|
|
|
}
|
2013-10-29 07:22:17 +00:00
|
|
|
|
|
|
|
} elseif($page == 'change_language') {
|
|
|
|
|
|
|
|
if (isset($_POST['send'])
|
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
2010-01-27 08:54:31 +00:00
|
|
|
$def_language = validate($_POST['def_language'], 'default language');
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
if (isset($languages[$def_language])) {
|
|
|
|
$lng_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
|
|
|
SET `def_language`= :deflng
|
|
|
|
WHERE `adminid`= :adminid"
|
|
|
|
);
|
|
|
|
Database::pexecute($lng_stmt, array(
|
|
|
|
'deflng' => $def_language,
|
|
|
|
'adminid' => (int)$userinfo['adminid']
|
|
|
|
));
|
|
|
|
|
|
|
|
$lng_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
|
|
|
SET `language`= :lng
|
|
|
|
WHERE `hash`= :hash"
|
|
|
|
);
|
|
|
|
Database::pexecute($lng_stmt, array(
|
|
|
|
'lng' => $def_language,
|
|
|
|
'hash' => $s
|
|
|
|
));
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "changed his/her default language to '" . $def_language . "'");
|
2013-10-29 07:22:17 +00:00
|
|
|
redirectTo($filename, array('s' => $s));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2010-01-27 08:54:31 +00:00
|
|
|
$language_options = '';
|
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$default_lang = Settings::Get('panel.standardlanguage');
|
2013-10-29 07:22:17 +00:00
|
|
|
if ($userinfo['def_language'] != '') {
|
2010-08-05 06:32:40 +00:00
|
|
|
$default_lang = $userinfo['def_language'];
|
|
|
|
}
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
while (list($language_file, $language_name) = each($languages)) {
|
2010-08-05 06:32:40 +00:00
|
|
|
$language_options.= makeoption($language_name, $language_file, $default_lang, true);
|
2010-01-27 08:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
eval("echo \"" . getTemplate("index/change_language") . "\";");
|
|
|
|
}
|
2013-10-29 07:22:17 +00:00
|
|
|
|
|
|
|
} elseif ($page == 'change_theme') {
|
|
|
|
|
|
|
|
if (isset($_POST['send'])
|
2011-02-08 11:53:24 +00:00
|
|
|
&& $_POST['send'] == 'send'
|
|
|
|
) {
|
|
|
|
$theme = validate($_POST['theme'], 'theme');
|
|
|
|
|
2013-10-29 07:22:17 +00:00
|
|
|
$theme_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_ADMINS . "`
|
|
|
|
SET `theme`= :theme
|
|
|
|
WHERE `adminid`= :adminid"
|
|
|
|
);
|
|
|
|
Database::pexecute($theme_stmt, array(
|
|
|
|
'theme' => $theme,
|
|
|
|
'adminid' => (int)$userinfo['adminid']
|
|
|
|
));
|
|
|
|
|
|
|
|
$theme_stmt = Database::prepare("
|
|
|
|
UPDATE `" . TABLE_PANEL_SESSIONS . "`
|
|
|
|
SET `theme`= :theme
|
|
|
|
WHERE `hash`= :hash"
|
|
|
|
);
|
|
|
|
Database::pexecute($theme_stmt, array(
|
|
|
|
'theme' => $theme,
|
|
|
|
'hash' => $s
|
|
|
|
));
|
2011-02-08 11:53:24 +00:00
|
|
|
|
|
|
|
$log->logAction(ADM_ACTION, LOG_NOTICE, "changed his/her theme to '" . $theme . "'");
|
2013-10-29 07:22:17 +00:00
|
|
|
redirectTo($filename, array('s' => $s));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2011-02-08 11:53:24 +00:00
|
|
|
$theme_options = '';
|
2010-01-27 08:54:31 +00:00
|
|
|
|
2013-12-15 10:47:23 +00:00
|
|
|
$default_theme = Settings::Get('panel.default_theme');
|
2013-10-29 07:22:17 +00:00
|
|
|
if ($userinfo['theme'] != '') {
|
2011-02-08 11:53:24 +00:00
|
|
|
$default_theme = $userinfo['theme'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$themes_avail = getThemes();
|
2013-12-29 16:35:03 +00:00
|
|
|
foreach ($themes_avail as $t => $d) {
|
|
|
|
$theme_options.= makeoption($d, $t, $default_theme, true);
|
2011-02-08 11:53:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
eval("echo \"" . getTemplate("index/change_theme") . "\";");
|
|
|
|
}
|
2013-11-29 10:09:16 +00:00
|
|
|
|
2013-12-02 19:26:39 +00:00
|
|
|
} elseif ($page == 'send_error_report'
|
2013-12-15 10:47:23 +00:00
|
|
|
&& Settings::Get('system.allow_error_report_admin') == '1'
|
2013-12-02 19:26:39 +00:00
|
|
|
) {
|
2013-11-29 10:09:16 +00:00
|
|
|
|
|
|
|
// 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";
|
2013-11-29 10:28:48 +00:00
|
|
|
$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";
|
2013-11-29 10:09:16 +00:00
|
|
|
$mail_body .= "End of report";
|
2013-12-13 07:14:01 +00:00
|
|
|
$mail_html = nl2br($mail_body);
|
2013-11-29 10:09:16 +00:00
|
|
|
|
|
|
|
// 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);
|
2013-11-29 22:13:26 +00:00
|
|
|
$mail->AddAddress('error-reports@froxlor.org', 'Froxlor Developer Team');
|
2013-11-29 10:09:16 +00:00
|
|
|
$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
|
2013-12-02 19:26:39 +00:00
|
|
|
standard_error('send_report_error', $mailerr_msg);
|
2013-11-29 10:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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));
|
|
|
|
}
|
2011-02-08 11:53:24 +00:00
|
|
|
}
|