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/list-table.test.php (8 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
 * Test - ListTable class
4
 * @package     fwolflib
5
 * @subpackage	class-test
6
 * @copyright   Copyright 2009, Fwolf
7
 * @author      Fwolf <[email protected]>
8
 * @since		2009-12-08
9
 */
10
11
// Define like this, so test can run both under eclipse and web alone.
12
// {{{
13
if (! defined('SIMPLE_TEST')) {
14
	define('SIMPLE_TEST', 'simpletest/');
15
	require_once(SIMPLE_TEST . 'autorun.php');
16
}
17
// Then set output encoding
18
//header('Content-Type: text/html; charset=utf-8');
19
// }}}
20
21
// Require library define file which need test
22
require_once('fwlib/class/list-table.php');
23
require_once('fwlib/func/ecl.php');
24
require_once('fwlib/func/request.php');
25
require_once('fwlib/func/string.php');
26
require_once('smarty/Smarty.class.php');
27
28
class TestListTable extends UnitTestCase {
29
30
	/**
31
	 * Table data, without title
32
	 * @var	array
33
	 */
34
	protected $aD = array();
35
36
	/**
37
	 * Table title
38
	 * @var	array
39
	 */
40
	protected $aT = array();
41
42
	/**
43
	 * ListTable instance
44
	 * @var	object
45
	 */
46
	protected $oLt = null;
47
48
	/**
49
	 * Css
50
	 * @var	string
51
	 */
52
	public $sCss = '';
53
54
	/**
55
	 * Js
56
	 * @var	string
57
	 */
58
	public $sJs = '';
59
60
	/**
61
	 * Tpl filename
62
	 * @var	string
63
	 */
64
	public $sTpl = 'list-table.test.tpl';
65
66
67
	/**
68
	 * Constructor
69
	 */
70
	public function __construct() {
71
		$o_tpl = new Smarty();
72
		// Configure dir
73
		$o_tpl->compile_dir = '/tmp/';
74
		$o_tpl->template_dir = '/tmp/';
75
		$o_tpl->cache_dir = '/tmp/';
76
77
		$this->oLt = new ListTable($o_tpl);
0 ignored issues
show
Deprecated Code introduced by
The class ListTable has been deprecated with message: Use Fwlib\Html\ListTable

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...
78
79
		$this->GenCss();
80
		$this->GenJs();
81
		$this->GenTbl();
82
		$this->GenTpl();
83
84
	} // end of func __construct
85
86
87
	/**
88
	 * Generate css for better table view
89
	 */
90
	protected function GenCss() {
91
		$this->sCss = '
92
<style type="text/css" media="screen, print">
93
<!--
94
div.fl_lt {
95
	border: 1px solid red;
96
	margin: auto;
97
	width: 70%;
98
}
99
/* Single line table */
100
table, td, th {
101
	border: 1px solid black;
102
	border-collapse: collapse;
103
	width: 100%;
104
	/* 等宽表格 */
105
	/*table-layout: fixed;*/
106
}
107
-->
108
</style>
109
110
<!-- This MUST before table code -->
111
<script type="text/javascript" src="/js/jquery.js">
112
</script>
113
114
';
115
	} // end of func GenCss
116
117
118
	/**
119
	 * Generate js for better table view
120
	 */
121
	protected function GenJs() {
122
		$this->sJs = '
123
<!-- This MUST be after table code -->
124
<script type="text/javascript">
125
<!--//--><![CDATA[//>
126
<!--
127
128
// Assign width for col n
129
130
// If "table-layout: fixed;" is assigned also,
131
// then td width is assigned + fixed_for_left,
132
// content width exceed limit will auto wrap,
133
// but overflow content can also been seen.
134
135
$(".fl_lt table").css("table-layout", "fixed");
136
137
$(".fl_lt tr > td:nth-child(2)").css("background-color", "green");
138
// * include th & td
139
$(".fl_lt tr > *:nth-child(1)").css("width", "12em");
140
//$(".fl_lt tr > td:nth-child(1)").css("width", "1em");
141
142
// If "table-layout: fixed;" is not assigned,
143
// width limit will work, but overflow content
144
// will make width raise.
145
$(".fl_lt-lt1 tr > *:nth-child(1)").css("width", "50%");
146
147
//--><!]]>
148
</script>
149
150
';
151
	} // end of func GenJs
152
153
154
	/**
155
	 * Generate random table title & data
156
	 */
157
	protected function GenTbl() {
158
		$i_col = 6;
159
		$i_row = 50;
160
161
		for ($i = 0; $i < $i_col; $i++) {
162
			$this->aT[$i] = RandomString(3, 'A');
0 ignored issues
show
Deprecated Code introduced by
The function RandomString() has been deprecated with message: Use Fwlib\Util\StringUtil::random()

This function 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 function will be removed from the class and what other function to use instead.

Loading history...
163
		}
164
165
		for ($j = 0; $j < $i_row; $j++) {
166
			$this->aD[$j][0] = "$j - <strong>0</strong> - " . RandomString(20, 'a');
0 ignored issues
show
Deprecated Code introduced by
The function RandomString() has been deprecated with message: Use Fwlib\Util\StringUtil::random()

This function 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 function will be removed from the class and what other function to use instead.

Loading history...
167
			for ($i = 1; $i < $i_col; $i++) {
168
				$this->aD[$j][$i] = "$j - $i";
169
			}
170
		}
171
172
	} // end of func GenTbl
173
174
175
	/**
176
	 * Generate tpl, this is also standard ListTable tpl
177
	 */
178
	protected function GenTpl() {
179
		$s = file_get_contents(FWOLFLIB . 'class/list-table.tpl');
180
		file_put_contents('/tmp/' . $this->sTpl, $s);
181
	} // end of func GenTpl
182
183
184
    function TestBasicTable() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
185
		$ar_conf = array(
186
			'tpl'		=> $this->sTpl,
187
			'page_size'	=> 3,
188
		);
189
		$this->oLt->SetCfg($ar_conf);
190
191
		$this->oLt->SetData($this->aD, $this->aT);
192
		//$this->oLt->SetId('');
193
		$this->oLt->SetPager();
194
195
		echo $this->sCss;
196
		echo($this->oLt->GetHtml());
197
198
		// Another table in same page
199
		$this->oLt->SetId('lt1');
200
		// Data is trimmed, need re-make
201
		$this->GenTbl();
202
		$this->oLt->SetData($this->aD, $this->aT);
203
		// Set sort
204
		$this->oLt->SetOrderby(0, 'asc');
205
		// MUST refresh pager
206
		$this->oLt->SetPager();
207
		echo($this->oLt->GetHtml());
208
209
		echo $this->sJs;
210
211
		Ecl('ListTable::GetSqlInfoFromUrl()');
0 ignored issues
show
Deprecated Code introduced by
The function Ecl() has been deprecated with message: Use Fwlib\Util\Env::ecl()

This function 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 function will be removed from the class and what other function to use instead.

Loading history...
212
		echo('<pre>'
213
			. var_export($this->oLt->GetSqlInfoFromUrl(), true)
214
			. '</pre>');
215
216
		Ecl('ListTable::GetSqlInfo()');
0 ignored issues
show
Deprecated Code introduced by
The function Ecl() has been deprecated with message: Use Fwlib\Util\Env::ecl()

This function 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 function will be removed from the class and what other function to use instead.

Loading history...
217
		echo('<pre>'
218
			. var_export($this->oLt->GetSqlInfo(), true)
219
			. '</pre>');
220
    } // end of func TestBasicTable
221
222
} // end of class TestListTable
223
224
225
// Change output charset in this way.
226
// {{{
227
$s_url = GetSelfUrl(false);
0 ignored issues
show
Deprecated Code introduced by
The function GetSelfUrl() has been deprecated with message: Use Fwlib\Util\HttpUtil::getSelfUrl()

This function 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 function will be removed from the class and what other function to use instead.

Loading history...
228
$s_url = substr($s_url, strrpos($s_url, '/') + 1);
229
if ('list-table.test.php' == $s_url) {
230
	$test = new TestListTable();
231
	$test->run(new HtmlReporter('utf-8'));
232
}
233
// }}}
234
?>
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...
235