Issues (4868)

calendar/freebusy.php (2 issues)

1
<?php
2
/**
3
 * iCal import and export via Horde iCalendar classes
4
 *
5
 * @link http://www.egroupware.org
6
 * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
7
 * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
8
 * @package calendar
9
 * @subpackage export
10
 * @version $Id$
11
 */
12
13
use EGroupware\Api;
14
15
$GLOBALS['egw_info'] = array(
16
	'flags' => array(
17
		'currentapp' => 'calendar',
18
		'noheader'   => True,
19
		'nofooter'   => True,
20
	),
21
);
22
// check if we are loged in, by checking sessionid and kp3, as the sessionid get set automaticaly by php for php4-sessions
23
if (!($loged_in = !empty($_COOKIE['sessionid'])))
24
{
25
	$GLOBALS['egw_info']['flags']['currentapp'] = 'login';
26
	$GLOBALS['egw_info']['flags']['noapi'] = True;
27
}
28
include ('../header.inc.php');
29
30
function fail_exit($msg)
31
{
32
	echo "<html>\n<head>\n<title>$msg</title>\n<meta http-equiv=\"content-type\" content=\"text/html; charset=".
33
		Api\Translation::charset()."\" />\n</head>\n<body><h1>$msg</h1>\n</body>\n</html>\n";
34
35
	exit();
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
36
}
37
38
if (!$loged_in)
39
{
40
	include ('../api/src/loader.php');
41
	$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
42
}
43
// fix for SOGo connector, which does not decode the = in our f/b url
44
if (strpos($_SERVER['QUERY_STRING'],'=3D') !== false && substr($_GET['user'],0,2) == '3D')
45
{
46
	$_GET['user'] = substr($_GET['user'],2);
47
	if (isset($_GET['password'])) $_GET['password'] = substr($_GET['password'],2);
48
	if (isset($_GET['cred'])) $_GET['cred'] = substr($_GET['cred'],2);
49
}
50
if (!is_numeric($user = $_GET['user']))
51
{
52
	// check if user contains the current domain --> remove it
53
	list(,$domain) = explode('@',$user);
54
	if ($domain === $GLOBALS['egw_info']['user']['domain'])
55
	list($user) = explode('@',$user);
56
	$user = $GLOBALS['egw']->accounts->name2id($user,'account_lid','u');
57
}
58
if ($user === false || !($username = $GLOBALS['egw']->accounts->id2name($user)))
59
{
60
	fail_exit(lang("freebusy: unknown user '%1', wrong password or not available to not logged in users !!!"." $username($user)",$_GET['user']));
0 ignored issues
show
The call to lang() has too many arguments starting with $_GET['user']. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
	fail_exit(/** @scrutinizer ignore-call */ lang("freebusy: unknown user '%1', wrong password or not available to not logged in users !!!"." $username($user)",$_GET['user']));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
61
}
62
if (!$loged_in)
63
{
64
	if (empty($_GET['cred']))
65
	{
66
		$GLOBALS['egw_info']['user']['account_id'] = $user;
67
		$GLOBALS['egw_info']['user']['account_lid'] = $username;
68
		$GLOBALS['egw']->preferences->account_id = $user;
69
		$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
70
		$cal_prefs = &$GLOBALS['egw_info']['user']['preferences']['calendar'];
71
		$loged_in = !empty($cal_prefs['freebusy']) &&
72
			(empty($cal_prefs['freebusy_pw']) || $cal_prefs['freebusy_pw'] == $_GET['password']);
73
	}
74
	else
75
	{
76
		$credentials = base64_decode($_GET['cred']);
77
		list($authuser, $password) = explode(':', $credentials, 2);
78
		if (strpos($authuser, '@') === false)
79
		{
80
			$domain = $GLOBALS['egw_info']['server']['default_domain'];
81
			$authuser .= '@' . $domain;
82
		}
83
		else
84
		{
85
			list(, $domain) = explode('@',$authuser, 2);
86
		}
87
		if (array_key_exists($domain, $GLOBALS['egw_domain']))
88
		{
89
			$_POST['login'] = $authname;
90
			$_REQUEST['domain'] = $domain;
91
			$GLOBALS['egw_info']['server']['default_domain'] = $domain;
92
			$GLOBALS['egw_info']['user']['domain'] = $domain;
93
			$GLOBALS['egw_info']['flags']['currentapp'] = 'login';
94
			$GLOBALS['egw_info']['flags']['noapi'] = false;
95
			$loged_in =  $GLOBALS['egw']->session->create($authuser, $password, 'text');
96
			session_unset();
97
			session_destroy();
98
		}
99
	}
100
	if (!$loged_in)
101
	{
102
		fail_exit(lang("freebusy: unknown user '%1', or not available for unauthenticated users!", $_GET['user']));
103
	}
104
}
105
if ($_GET['debug'])
106
{
107
	echo "<pre>";
108
}
109
else
110
{
111
	Api\Header\Content::type('freebusy.ifb','text/calendar');
112
}
113
$ical = new calendar_ical();
114
echo $ical->freebusy($user, $_GET['end']);
115