Issues (1940)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

programs/utilit/statistics.class.php (19 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/************************************************************************
3
 * OVIDENTIA http://www.ovidentia.org                                   *
4
 ************************************************************************
5
 * Copyright (c) 2003 by CANTICO ( http://www.cantico.fr )              *
6
 *                                                                      *
7
 * This file is part of Ovidentia.                                      *
8
 *                                                                      *
9
 * Ovidentia is free software; you can redistribute it and/or modify    *
10
 * it under the terms of the GNU General Public License as published by *
11
 * the Free Software Foundation; either version 2, or (at your option)  *
12
 * any later version.													*
13
 *																		*
14
 * This program is distributed in the hope that it will be useful, but  *
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of			*
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.					*
17
 * See the  GNU General Public License for more details.				*
18
 *																		*
19
 * You should have received a copy of the GNU General Public License	*
20
 * along with this program; if not, write to the Free Software			*
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,*
22
 * USA.																	*
23
************************************************************************/
24
25
26
require_once dirname(__FILE__).'/xls.class.php';
27
28
29
/**
30
 * days by year and by right types
31
 *
32
 */
33
class absences_StatisticsXls extends absences_Xls
34
{
35
	/**
36
	 *
37
	 * @var array
38
	 */
39
	private $type_rows = null;
40
41
	/**
42
	 *
43
	 * @var Worksheet
44
	 */
45
	private $type_worksheet = null;
46
47
48
	/**
49
	 *
50
	 * @var array
51
	 */
52
	private $type_years = array();
53
54
55
	/**
56
	 *
57
	 * @var array
58
	 */
59
	private $filter = array();
60
61
62
63
	public function __construct(Array $filter)
64
	{
65
		parent::__construct(absences_translate('Statistics'));
66
67
		$this->filter = $filter;
68
69
		$this->year_format = $this->workbook->addFormat();
0 ignored issues
show
The property year_format does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Deprecated Code introduced by
The method Workbook::addformat() has been deprecated with message: Use add_format instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
70
		$this->year_format->setBold();
0 ignored issues
show
The method setBold() does not seem to exist on object<Format>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
71
		$this->year_format->setPattern(1);
0 ignored issues
show
The method setPattern() does not seem to exist on object<Format>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
72
		$this->year_format->setFgColor(15);
0 ignored issues
show
The method setFgColor() does not seem to exist on object<Format>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
73
		$this->year_format->setAlign('center');
0 ignored issues
show
The method setAlign() does not seem to exist on object<Format>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
74
75
		$this->addTypesWorksheet();
76
77
78
		$this->workbook->close();
79
	}
80
81
82
	/**
83
	 *
84
	 */
85
	private function getRows()
86
	{
87
88
		if (!isset($this->type_rows))
89
		{
90
91
			global $babDB;
92
93
94
			$res = $babDB->db_query('
95
				SELECT
96
					id,
97
					name
98
				FROM
99
					absences_types
100
				ORDER BY name
101
					');
102
103
			$row = 2;
104
			while ($arr = $babDB->db_fetch_assoc($res))
105
			{
106
				$this->type_rows[$arr['id']] = array(
107
					'name' 	=> $arr['name'],
108
					'row' 	=> $row++
109
				);
110
			}
111
112
		}
113
114
115
		return $this->type_rows;
116
	}
117
118
119
	/**
120
	 * Get row number by id type
121
	 */
122
	private function getRow($id_type)
123
	{
124
		$rows = $this->getRows();
125
		return $rows[$id_type]['row'];
126
	}
127
128
129
130
131
	private function getTypeWorksheet()
132
	{
133
		if (!isset($this->type_worksheet))
134
		{
135
			$this->type_worksheet = $this->workbook->addWorksheet(absences_translate('Vacation rights'));
0 ignored issues
show
Deprecated Code introduced by
The method Workbook::addworksheet() has been deprecated with message: Use add_worksheet instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
136
137
			// create first column
138
			$this->type_worksheet->setColumn(0, 0, 30);
0 ignored issues
show
The method setColumn() does not seem to exist on object<Worksheet>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
139
			$this->type_worksheet->writeString(1, 0, absences_translate('Vacation type')		, $this->header);
0 ignored issues
show
The property header does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
The method writeString() does not seem to exist on object<Worksheet>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
140
141
			foreach($this->getRows() as $arr)
0 ignored issues
show
The expression $this->getRows() of type null|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
142
			{
143
				$this->type_worksheet->writeString($arr['row'], 0, $arr['name']);
0 ignored issues
show
The method writeString() does not seem to exist on object<Worksheet>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
144
			}
145
		}
146
147
		return $this->type_worksheet;
148
	}
149
150
151
152
	private function prepareTypeData()
153
	{
154
		global $babDB;
155
156
		$years = array();
157
		$types = array();
158
159
		$organization = '';
160
		if(isset($this->filter['organization']) && $this->filter['organization']){
161
			$organization = 'AND p.id_organization='.$babDB->quote($this->filter['organization']);
162
		}
163
164
		$res = $babDB->db_query('
165
			SELECT
166
				t.id,
167
				YEAR(e.date_begin) year,
168
				SUM(ee.quantity) total,
169
				quantity_unit
170
			FROM
171
				absences_types t,
172
				absences_rights r,
173
				absences_entries_elem ee,
174
				absences_entries e,
175
				absences_personnel p
176
			WHERE r.id_type=t.id
177
			AND ee.id_right=r.id
178
			AND ee.id_entry=e.id 
179
		    AND e.status=\'Y\' 
180
 			AND p.id_user=e.id_user
181
			'.$organization.'
182
			GROUP BY year, t.id, r.quantity_unit
183
			ORDER BY year
184
				');
185
186
		while ($arr = $babDB->db_fetch_assoc($res))
187
		{
188
			$years[$arr['year']] = $arr['year'];
189
			$types[$arr['id']][$arr['year']][$arr['quantity_unit']] = $arr['total'];
190
		}
191
192
193
		return array($years, $types);
194
	}
195
196
197
	protected function addTypesWorksheet()
198
	{
199
		$worksheet = $this->getTypeWorksheet();
200
		list($years, $types) = $this->prepareTypeData();
201
202
		$col_index = array();
203
204
		// first an second row
205
		$col = 1;
206
		foreach($years as $y)
207
		{
208
			$worksheet->mergeCells(0, $col, 0, 1+$col);
0 ignored issues
show
The method mergeCells() does not seem to exist on object<Worksheet>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
209
210
			$worksheet->setColumn(0, 0, 30);
0 ignored issues
show
The method setColumn() does not seem to exist on object<Worksheet>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
211
			$worksheet->writeString(0, $col, $y		, $this->year_format);
0 ignored issues
show
The method writeString() does not seem to exist on object<Worksheet>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
212
			$col_index[$y]['D'] = $col;
213
			$worksheet->writeString(1, $col++, absences_translate('days')		, $this->header);
0 ignored issues
show
The method writeString() does not seem to exist on object<Worksheet>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
214
			$col_index[$y]['H'] = $col;
215
			$worksheet->writeString(1, $col++, absences_translate('hours')		, $this->header);
0 ignored issues
show
The method writeString() does not seem to exist on object<Worksheet>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
216
		}
217
218
219
		foreach($types as $id_type => $yearly)
220
		{
221
			$row = $this->getRow($id_type);
222
			foreach($yearly as $year => $quantities)
223
			{
224
				foreach($quantities as $quantity_unit => $total)
225
				{
226
					$col = $col_index[$year][$quantity_unit];
227
					$worksheet->writeNumber($row, $col, $total, $this->quantity);
0 ignored issues
show
The property quantity does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
The method writeNumber() does not seem to exist on object<Worksheet>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
228
				}
229
			}
230
		}
231
	}
232
}