1<?php
2
3/**
4 * This file is part of the Froxlor project.
5 * Copyright (c) 2003-2009 the SysCP Team (see authors).
6 * Copyright (c) 2010 the Froxlor Team (see authors).
7 *
8 * For the full copyright and license information, please view the COPYING
9 * file that was distributed with this source code. You can also view the
10 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
11 *
12 * @copyright  (c) the authors
13 * @author     Florian Lippert <flo@syscp.org> (2003-2009)
14 * @author     Froxlor team <team@froxlor.org> (2010-)
15 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
16 * @package    Functions
17 *
18 */
19
20/**
21 * Prints one ore more errormessages on screen
22 *
23 * @param array Errormessages
24 * @param string A %s in the errormessage will be replaced by this string.
25 * @author Florian Lippert <flo@syscp.org>
26 * @author Ron Brand <ron.brand@web.de>
27 */
28function standard_error($errors = '', $replacer = '') {
29
30	global $userinfo, $s, $header, $footer, $lng, $theme;
31
32	$_SESSION['requestData'] = $_POST;
33	$replacer = htmlentities($replacer);
34
35	if (!is_array($errors)) {
36		$errors = array(
37			$errors
38		);
39	}
40
41	$link = '';
42	if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
43		$link = '<a href="'.htmlentities($_SERVER['HTTP_REFERER']).'">'.$lng['panel']['back'].'</a>';
44	}
45
46	$error = '';
47	foreach ($errors as $single_error) {
48		if (isset($lng['error'][$single_error])) {
49			$single_error = $lng['error'][$single_error];
50			$single_error = strtr($single_error, array('%s' => $replacer));
51		} else {
52			$error = 'Unknown Error (' . $single_error . '): ' . $replacer;
53			break;
54		}
55
56		if (empty($error)) {
57			$error = $single_error;
58		} else {
59			$error.= ' ' . $single_error;
60		}
61	}
62
63	eval("echo \"" . getTemplate('misc/error', '1') . "\";");
64	exit;
65}
66