These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * /classes/DomainMOD/Export.php |
||
4 | * |
||
5 | * This file is part of DomainMOD, an open source domain and internet asset manager. |
||
6 | * Copyright (c) 2010-2017 Greg Chetcuti <[email protected]> |
||
7 | * |
||
8 | * Project: http://domainmod.org Author: http://chetcuti.com |
||
9 | * |
||
10 | * DomainMOD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public |
||
11 | * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later |
||
12 | * version. |
||
13 | * |
||
14 | * DomainMOD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
||
15 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License along with DomainMOD. If not, see |
||
18 | * http://www.gnu.org/licenses/. |
||
19 | * |
||
20 | */ |
||
21 | //@formatter:off |
||
22 | namespace DomainMOD; |
||
23 | |||
24 | class Export |
||
25 | { |
||
26 | |||
27 | public function openFile($base_filename, $append_data) |
||
28 | { |
||
29 | header('Content-Encoding: UTF-8'); |
||
30 | header('Content-Type: text/csv; charset=UTF-8'); |
||
31 | header("Content-Disposition: attachment; filename=\"" . $base_filename . "_" . $append_data . ".csv\""); |
||
32 | header('Content-Transfer-Encoding: binary'); |
||
33 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||
34 | header("Pragma: no-cache"); |
||
35 | |||
36 | $open_file = fopen('php://output', 'w'); |
||
37 | fprintf($open_file, chr(0xEF) . chr(0xBB) . chr(0xBF)); |
||
38 | |||
39 | return $open_file; |
||
40 | } |
||
41 | |||
42 | public function writeRow($open_file, $row_contents) |
||
43 | { |
||
44 | fputcsv($open_file, $row_contents); |
||
45 | } |
||
46 | |||
47 | public function writeBlankRow($open_file) |
||
48 | { |
||
49 | $blank_line = array(''); |
||
50 | fputcsv($open_file, $blank_line); |
||
51 | } |
||
52 | |||
53 | public function closeFile($open_file) |
||
54 | { |
||
55 | fclose($open_file); |
||
56 | return exit; |
||
1 ignored issue
–
show
|
|||
57 | } |
||
58 | |||
59 | } //@formatter:on |
||
60 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.