Issues (1752)

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.

class/excel.php (3 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
 * @package		fwolflib
4
 * @subpackage	class
5
 * @copyright	Copyright 2003-2009, Fwolf
6
 * @author		Fwolf <[email protected]>
7
 * @since		2009-12-22
8
 */
9
10
11
require_once(dirname(__FILE__) . '/fwolflib.php');
12
13
14
/**
15
 * @package		fwolflib
16
 * @subpackage	class
17
 * @copyright	Copyright 2003-2009, Fwolf
18
 * @author		Fwolf <[email protected]>
19
 * @since		2009-12-22
20
 * @link http://www.phplamp.org/2008/06/php-to-excel-clas/
21
 */
22
class Excel extends Fwolflib {
0 ignored issues
show
Deprecated Code introduced by
The class Fwolflib has been deprecated with message: Use classes in Fwlib namespace, see PSR-0/1/2

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

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

Loading history...
23
24
	/**
25
	 * Array of row in xml
26
	 * @var	array
27
	 */
28
	protected $aRow = array();
29
30
    /**
31
     * Footer of excel xml
32
     * @var string
33
     */
34
    protected $sFooter = "</Workbook>";
35
36
    /**
37
     * Header of excel xml
38
     * @var string
39
     */
40
    protected $sHeader = '<?xml version="1.0" encoding="utf-8"?>
41
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
42
	xmlns:x="urn:schemas-microsoft-com:office:excel"
43
	xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
44
	xmlns:html="http://www.w3.org/TR/REC-html40">
45
	';
46
47
	/**
48
	 * Title of sheet
49
	 * @var	string
50
	 */
51
	public $sSheetTitle = 'Sheet1';
52
53
54
    /**
55
     * Set a single row(add mode)
56
     *
57
     * @param	array	$ar	1-dimensional array
58
     */
59
    protected function SetRow($ar) {
60
        $s_cell = '';
61
62
		if (!empty($ar)) {
63
			foreach ($ar as $v) {
64
				// Attention: data type
65
				if(is_numeric($v)) {
66
					$v = strval($v);
67
					// First letter is '0' ?
68
					if(0 == $v{0}) {
69
						$s_cells.= '<Cell><Data ss:Type="string">' . $v . '</Data></Cell>
0 ignored issues
show
The variable $s_cells does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
70
						';
71
					} else {
72
						$s_cell .= '<Cell><Data ss:Type="number">' . $v . '</Data></Cell>
73
						';
74
					}
75
				} else {
76
					$s_cell .= '<Cell><Data ss:Type="string">' . $v . '</Data></Cell>
77
					';
78
				}
79
			}
80
			$this->aRow[] = "<Row>\n$s_cell</Row>\n";
81
		}
82
    } // end of func SetRow
83
84
85
    /**
86
     * Set data rows, multi row, clean mode
87
     *
88
     * @param	array	$ar	2-dimensional array
89
     */
90
    public function SetRows ($ar) {
91
        if (!empty($ar))
92
			foreach ($ar as $v)
93
				$this->SetRow($v);
94
    } // end of func SetRows
95
96
97
    /**
98
     * Set the worksheet title
99
     *
100
     * Checks the string for not allowed characters (:\/?*),
101
     * cuts it to maximum 31 characters and set the title. Damn
102
     * why are not-allowed chars nowhere to be found? Windows
103
     * help's no help...
104
     *
105
     * @param	string	$title
106
     */
107
    public function SetSheetTitle($title) {
108
        // Strip special chars
109
        $title = str_replace (
110
			array(':', '\\', '/', '?', '*'),
111
			'', $title);
112
113
        // Cut it to the allowed length
114
        $title = substr($title, 0, 31);
115
116
        $this->sSheetTitle = $title;
117
    } // end of func SetSheetTitle
118
119
120
    /**
121
     * Output the excel file
122
     *
123
     * @param	string	$fn	Filename without '.xls'
124
     */
125
    public function Output($fn) {
126
        // Set header
127
        header('Content-Type: application/vnd.ms-excel;  charset=utf-8');
128
        header('Content-Disposition: inline; filename="'
129
			. $fn . '.xls"');
130
131
        // Print
132
        echo ($this->sHeader);
133
        echo '<Worksheet ss:Name="'
134
			. $this->sSheetTitle
135
			. '">
136
			<Table>
137
		';
138
        echo '<Column ss:Index="1" ss:AutoFitWidth="0" ss:Width="110"/>
139
		';
140
        echo implode("\n", $this->aRow);
141
        echo '</Table>
142
			</Worksheet>
143
		';
144
        echo $this->sFooter;
145
    }
146
147
} // end of class Excel
148
149
/*
150
// Usage
151
// Need high version of microsoft office
152
153
$ar = array (
154
	array ('列1', '列2', '列3列3列3', '123456'),
155
);
156
$xls = new Excel;
157
$xls->SetRows($ar);
158
$xls->Output('test');
159
*/
160
161
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
162