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/disp_listtable.php (29 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
 * Obsoleted.
4
 *
5
* @package      MaGod
6
* @copyright    Copyright 2003, Fwolf
7
* @author       Fwolf <[email protected]>
8
*/
9
10
require_once('MaGod/MaGod.php');
11
12
/**
13
* 列表类,以包含表头、分页、数据表格的方式显示各种列表。
14
*
15
* 传入的数组值应为至少包含一条数据的二维数组,并且其第二维的值也是数组,这个数组的维数决定了将来生成的列表会有几列。
16
* 数组的第一行为表头,其余是各数据行。简单理解,数组和你要生成的列表的格式几乎是一样的。
17
* 没有必要将从数据库中读出的全部数据都放到数据中,只需要将本页要显示的数据(比如,20条)放进来即可。
18
* 本类使用了模板文件class/DispListTable1.html。
19
*
20
* [2003-08-26] V1.0 将采用SMARTY模板类改写,同时文件名命名为DispListTable1.php(为了以前的程序能够使用原来的类文件)。
21
*
22
* 用法示例:
23
*
24
* //先准备好$tpl模板变量和存储数据的数组$ar(数值已经存入)
25
*
26
* $lt = new DispListTable($tpl, $ar);
27
*
28
* $lt->mCurPage = 2;
29
*
30
* $lt->mTotalRows = 108;
31
*
32
* $lt->mRowsPerPage = 50;
33
*
34
* //以下变量可省略,采用默认值
35
*
36
* $lt->mIsDispTitle = 1;
37
*
38
* $lt->mIsDispIndex = 1;
39
*
40
* $lt->mIsDispHead = 1;
41
*
42
* $lt->mSubmitUrl = 'list.php?part=level1';
43
*
44
* $lt->mListTitle = '某某列表';
45
*
46
* $lt->Disp();
47
*
48
* //显示第二个列表
49
*
50
* $lt->SetData($ar2);
51
*
52
* $lt->Disp();
53
*
54
* // End of Example
55
*
56
* @package    MaGod
57
* @copyright  Copyright 2003, Fwolf
58
* @author     Fwolf <[email protected]>
59
* @since      2003-05-17 12:17:14
60
* @access     public
61
* @version    $Id$
62
*/
63
class DispListTable
64
{
65
	/**
66
	 * 显示列表之前是否重置模板数据
67
	 * @access	public
68
	 * @var	boolean
69
	 */
70
	var $mListClearAllAssign = true;
71
72
	/**
73
    * 列表的标题
74
    * @access   public
75
    * @var      string
76
    */
77
    var $mListTitle = '';
78
79
    /**
80
     * 索引的提示信息数组
81
     * 第一组的内容将被作为提示信息
82
     * @access  private
83
     * @var array
84
     */
85
    var $mIndexTips = array(array('第一页', '上一页', '下一页', '最后页'),
86
                            array('|<', '<<', '>>', '>|'),
87
                            array('<b>|</b><font face="Wingdings 3" style="font-family: \'Wingdings 3\';">&#161;</font>', '<font face="Wingdings 3" style="font-family: \'Wingdings 3\';">&#161;</font>', '<font face="Wingdings 3" style="font-family: \'Wingdings 3\';">&#162;</font>', '<font face="Wingdings 3" style="font-family: \'Wingdings 3\';">&#162;</font><b>|</b>'),  // 197/198
88
                            array('<font face="Webdings" style="font-family: \'Webdings\';">&#57;</font>', '<font face="Webdings" style="font-family: \'Webdings\';">&#55;</font>', '<font face="Webdings" style="font-family: \'Webdings\';">&#56;</font>', '<font face="Webdings" style="font-family: \'Webdings\';">&#58;</font>'));
89
90
    /**
91
     * 使用哪组索引提示信息,默认用第一组
92
     * @access  public
93
     * @var int
94
     */
95
    var $mIndexTipsId = 0;
96
97
    /**
98
    * 是否显示标题部分
99
    * @access   public
100
    * @var      int
101
    */
102
    var $mIsDispTitle = true;
103
    /**
104
    * 是否显示分页代码部分
105
    * @access   public
106
    * @var      int
107
    */
108
    var $mIsDispIndex = true;
109
    /**
110
    * 是否显示表头
111
    * @access   public
112
    * @var      int
113
    */
114
    var $mIsDispHead = true;
115
    /**
116
    * 当前页数
117
    * @access   public
118
    * @var      int
119
    */
120
    var $mCurPage = 1;
121
    /**
122
    * 每页显示多少条记录
123
    * @access   public
124
    * @var      int
125
    */
126
    var $mRowsPerPage = 20;
127
    /**
128
    * 一共有多少条记录
129
    * @access   public
130
    * @var      int
131
    */
132
    var $mTotalRows = 0;
133
    /**
134
    * 分页代码将要链接到的页面地址
135
    *
136
    * 此参数如省略,默认为$_SERVER['REQUEST_URI'],带参数的当前页
137
    * @access   public
138
    * @var      string
139
    */
140
    var $mSubmitUrl = '';
141
    /**
142
    * 最终生成的HTML字符串
143
    * @access   private
144
    * @var      string
145
    */
146
    var $mHtmlStr = '';
147
    /**
148
    * 模板变量,指向在构造函数中传入的全局模板变量
149
    * @access   private
150
    * @var      array
151
    */
152
    var $mrTpl;
153
    /**
154
    * 数组变量,指向要显示数据存放的数组,其格式见类说明
155
    * @access   private
156
    * @var      array
157
    */
158
    var $mrAr;
159
160
    // {{{ 列表显示样式等
161
162
    /**
163
     * 表格的宽度
164
     * @access  private
165
     * @var     string
166
     */
167
    var $mTableWidth = '80%';
168
169
    /**
170
     * 表格的背景颜色
171
     * @access  private
172
     * @var     string
173
     */
174
    var $mTableBgcolor = '#ffffff';
175
176
    /**
177
     * 表格边框的宽度,一般为2px
178
     * @access  private
179
     * @var     string
180
     */
181
    var $mTableBorderWidth = '2px';
182
183
    /**
184
     * 表格边框的颜色
185
     * @access  private
186
     * @var     string
187
     */
188
    var $mTableBorderColor = '#006699';
189
190
    /**
191
     * 表格边框的线型
192
     * @access  private
193
     * @var     string
194
     */
195
    var $mTableBorderLineStyle = 'solid';
196
197
    /**
198
     * 表格表头部分颜色
199
     * @access  private
200
     * @var     string
201
     */
202
    var $mThColor = '#FFA34F';
203
204
    /**
205
     * 表格表头部分字体大小
206
     * @access  private
207
     * @var     string
208
     */
209
    var $mThFontSize = '9pt';
210
211
    /**
212
     * 表格表头部分字体粗细
213
     * @access  private
214
     * @var     string
215
     */
216
    var $mThFontWeight = 'bold';
217
218
    /**
219
     * 表格表头部分背景颜色
220
     * @access  private
221
     * @var     string
222
     */
223
    var $mThBgcolor = '#006699';
224
225
    /**
226
     * 表格表头部分高度
227
     * @access  private
228
     * @var     string
229
     */
230
    var $mThHeight = '25px';
231
232
    /**
233
     * 表格行背景选用颜色1
234
     * @access  private
235
     * @var     string
236
     */
237
    var $mTrBgcolor1 = '#EFEFEF';
238
239
    /**
240
     * 表格行背景选用颜色2
241
     * @access  private
242
     * @var     string
243
     */
244
    var $mTrBgcolor2 = '#DEE3E7';
245
246
    /**
247
     * 表格行背景鼠标指向时的颜色
248
     * @access  private
249
     * @var     string
250
     */
251
    var $mTrPointedColor = '#CCFFCC';
252
253
    /**
254
     * 表格行背景被标记时的颜色
255
     * @access  private
256
     * @var     string
257
     */
258
    var $mTrMarkedColor = '#FFCC99';
259
260
    /**
261
     * 单元格线型
262
     * @access  private
263
     * @var     string
264
     */
265
    var $mTdLineStyle = 'solid';
266
267
    /**
268
     * 单元格高度
269
     * @access  private
270
     * @var     string
271
     */
272
    var $mTdHeight = '20px';
273
274
	// }}}
275
276
	/**
277
	 * 模板文件的路径
278
	 * @access	private
279
	 * @var		string
280
	 */
281
	var $mTemplatePath = 'class/disp_list_table.html';
282
283
284
    /**
285
    * 类构造函数
286
    *
287
    * @param    array   &$tpl   传入的模板变量,要赋值给{@link $mrTpl}。
288
    * @param    array   &$ar    传入的数组变量,要赋值给{@link $mrAr}。
289
    */
290
    function DispListTable(&$tpl, &$ar)
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...
291
    {
292
        $this->mrTpl = &$tpl;
293
		$this->SetData($ar);
294
    } // end of function DispListTable
295
296
297
    /**
298
    * 设置列表中的数据,当new一个实例后,要显示多个列表时,就要通过设置新的列表中的数据和改变相应的类变量来实现。而此时模板变量不变(其值会改变)。
299
    * @access   public
300
    * @param    object  &$ar    传入的数组变量,要赋值给{@link $mrAr}。
301
    */
302
    function SetData(&$ar)
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...
303
    {
304
        //$this->mrAr = &$ar;
305
		//将输入的数组转换成用数字作为索引的,因为SMARTY不支持ASSOC索引
306
		$this->mrAr = array();
307
        if (empty($ar))
308
        {
309
            return(false);
310
        }
311
		foreach ($ar as $key=>$val)
312
		{
313
		    array_push($this->mrAr, $val);
314
		}
315
		//
316
		$this->mTotalRows = count($this->mrAr);
317
    } // end of function SetData
318
319
    /**
320
    * 显示最终表格
321
    *
322
    * @access   public
323
	* @param	boolean	$isDirectOutput	是否直接输出
324
    */
325
    function Disp($isDirectOutput = true)
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...
326
    {
327
        $this->GerHtml(!$isDirectOutput);
328
        if ($isDirectOutput)
329
        {
330
            echo($this->mHtmlStr);
331
        }
332
    } // end function Disp
333
334
    /**
335
    * 生成分页索引代码
336
    *
337
    * 所有参数使用相关的类变量,如果类变量没有事先赋值,则会使用默认值
338
    * @access   private
339
    * @return   string
340
    */
341
    function GetIndex()
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...
342
    {
343
        //条件不满足时,返回空串
344
        if (0 == $this->mRowsPerPage)
345
        {
346
            return('');
347
        }
348
        //如果引用页的地址为.../dir/的话,那么将出错,因为document.URL是不包含参数的
349
        //此问题已通过在JS中增加判断的方法解决
350
        if (empty($this->mSubmitUrl))
351
        {
352
            $this->mSubmitUrl = $_SERVER['REQUEST_URI'];
353
        }
354
        //一共的页数
355
        $total_pages = ceil($this->mTotalRows / $this->mRowsPerPage);
356
        if (1 > $total_pages)           { $total_pages = 1; }
357
        if (1 > $this->mCurPage)               { $this->mCurPage = 1;     }
358
        if ($this->mCurPage > $total_pages)    { $this->mCurPage = $total_pages; }
0 ignored issues
show
Documentation Bug introduced by
It seems like $total_pages can also be of type double. However, the property $mCurPage is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
359
        //生成的HTML字符串
360
        $str_html = '<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center"><FORM METHOD="get" ACTION="' . $this->mSubmitUrl . '" onSubmit="return jump(page.value);"><tr><td align="right">';
361
362
        if (($this->mCurPage == 1) || ($total_pages == 1))
363
        {
364
            $str_html .= $this->mIndexTips[$this->mIndexTipsId][0] . ' ' . $this->mIndexTips[$this->mIndexTipsId][1] . ' ';
365
        }
366 View Code Duplication
        else
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
367
        {
368
            $s_url = $this->SetUrlParam($this->mSubmitUrl, 'page', '1');
369
            $str_html .= '<a href=' . $s_url . ' title="' . $this->mIndexTips[0][0] . '">' . $this->mIndexTips[$this->mIndexTipsId][0] . '</a> ';
370
            $s_url = $this->SetUrlParam($this->mSubmitUrl, 'page', strval($this->mCurPage - 1));
371
            $str_html .='<a href=' . $s_url . ' title="' . $this->mIndexTips[0][1] . '">' . $this->mIndexTips[$this->mIndexTipsId][1] . '</a> ';
372
        }
373
        if ($this->mCurPage == $total_pages)
374
        {
375
            $str_html .= $this->mIndexTips[$this->mIndexTipsId][2] . ' ' . $this->mIndexTips[$this->mIndexTipsId][3] . ' ';
376
        }
377 View Code Duplication
        else
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
378
        {
379
            $s_url = $this->SetUrlParam($this->mSubmitUrl, 'page', strval($this->mCurPage + 1));
380
            $str_html .= '<a href=' . $s_url . ' title="' . $this->mIndexTips[0][2] . '">' . $this->mIndexTips[$this->mIndexTipsId][2] . '</a> ';
381
            $s_url = $this->SetUrlParam($this->mSubmitUrl, 'page', strval($total_pages));
382
            $str_html .='<a href=' . $s_url . ' title="' . $this->mIndexTips[0][3] . '">' . $this->mIndexTips[$this->mIndexTipsId][3] . '</a> ';
383
        }
384
        $str_html .= '当前为第' . $this->mCurPage . '/' . $total_pages . '页,共' . $this->mTotalRows . '条记录 ';
385
        $str_html .= '跳转<input name="page" id="page" type="text" value="' . $this->mCurPage . '" size="3" align="right"> <input type="button" value="Go" onClick="return jump(page.value);"></td></tr></FORM></table>';
386
        $str_html .= '<script language="JavaScript" type="text/JavaScript">function jump(p) {if (document.URL.match(/(page=[0-9]+)/)){document.URL=(document.URL.replace(/(page=[0-9]+)/, "page=" + p));}else{if (document.URL.match(/[?]{1}/)) {document.URL=document.URL + "&page=" + p;} else {document.URL=document.URL + "?page=" + p;}}return false;}</script>';
387
388
        return($str_html);
389
    } // end function GetIndex
390
391
    /**
392
    * 生成最终的HTML代码
393
    *
394
    * @access   private
395
	* @param	boolean	$isDirectOutput	是否直接输出
396
    * @return   string
397
    */
398
    function GerHtml($isDirectOutput = false)
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...
399
    {
400
        $i_n = count($this->mrAr);
401
        if (1 > $i_n)
402
        {
403
            $this->mHtmlStr = '<p align="center">没有检索到任何数据。</p>';
404
			return(false);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by DispListTable::GerHtml of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
405
        }
406
407
        $s_index = $this->GetIndex();
408
409
		if ( true == $this->mListClearAllAssign )
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
410
		{
411
			$this->mrTpl->clear_all_assign();
0 ignored issues
show
The method clear_all_assign cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
412
		}
413
		$this->mrTpl->assign('Title', $this->mListTitle);
0 ignored issues
show
The method assign cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
414
		$this->mrTpl->assign('Data',$this->mrAr);
0 ignored issues
show
The method assign cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
415
		$style = array();
416
		$style['table_width']				= $this->mTableWidth;
417
		$style['table_bgcolor']				= $this->mTableBgcolor;
418
		$style['table_border_width']		= $this->mTableBorderWidth;
419
		$style['table_border_color']		= $this->mTableBorderColor;
420
		$style['table_border_line_style']	= $this->mTableBorderLineStyle;
421
		$style['th_color']			= $this->mThColor;
422
		$style['th_font_size']		= $this->mThFontSize;
423
		$style['th_font_weight']	= $this->mThFontWeight;
424
		$style['th_bgcolor']		= $this->mThBgcolor;
425
		$style['th_height']			= $this->mThHeight;
426
		$style['tr_pointed_color']	= $this->mTrPointedColor;
427
		$style['tr_marked_color']	= $this->mTrMarkedColor;
428
		$style['tr_bgcolor1']		= $this->mTrBgcolor1;
429
		$style['tr_bgcolor2']		= $this->mTrBgcolor2;
430
		$style['td_line_style']		= $this->mTdLineStyle;
431
		$style['td_height']			= $this->mTdHeight;
432
		$this->mrTpl->assign('Style', $style);
0 ignored issues
show
The method assign cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
433
		$this->mrTpl->assign('IsDispTitle',	$this->mIsDispTitle);
0 ignored issues
show
The method assign cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
434
		$this->mrTpl->assign('IsDispHead',	$this->mIsDispHead);
0 ignored issues
show
The method assign cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
435
		//分页索引
436
		if ($this->mIsDispIndex)
437
		{
438
		    $this->mrTpl->assign('Index',	$s_index);
0 ignored issues
show
The method assign cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
439
		}
440
		else
441
		{
442
		    $this->mrTpl->assign('Index',	'');
0 ignored issues
show
The method assign cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
443
		}
444
		if ($isDirectOutput)
445
		{
446
		    $this->mrTpl->display($this->mTemplatePath);
0 ignored issues
show
The method display cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
447
		}
448
		$this->mHtmlStr = $this->mrTpl->fetch($this->mTemplatePath);
0 ignored issues
show
The method fetch cannot be called on $this->mrTpl (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
449
/*
450
    var $mTrBgcolor1 = '#EFEFEF';
451
    var $mTrBgcolor2 = '#DEE3E7';
452
*/
453
		return($this->mHtmlStr);
454
/*
455
		$this->mrTpl->Clear();
456
        $this->mrTpl->set_file('lt', 'class/DispListTable.html');
457
        $this->mrTpl->set_blockF('lt', 'main');
458
        $this->mrTpl->set_blockF('main', 'title');
459
        $this->mrTpl->set_blockF('main', 'th');
460
        $this->mrTpl->set_blockF('main', 'tr');
461
        $this->mrTpl->set_blockF('th', 'thd');
462
        $this->mrTpl->set_blockF('tr', 'trd');
463
464
        $this->mrTpl->set_var('TITLE_TEXT', $this->mListTitle);
465
        $this->mrTpl->set_var('INDEX', (1 == $this->mIsDispIndex) ? $s_index : '');
466
        $this->mrTpl->shBlock('title', $this->mIsDispTitle);
467
468
        //表头
469
        $i_col = count($this->mrAr[0]);     //列数
470
        foreach ($this->mrAr[0] as $key=>$val)
471
        {
472
            $this->mrTpl->set_var('HEAD', $val);
473
            if (2 > $i_col)
474
            {
475
                $this->mrTpl->set_var('THC', 'thHead');
476
            }
477
            elseif (0 == $key)
478
            {
479
                $this->mrTpl->set_var('THC', 'thCornerL');
480
            }
481
            elseif (($i_col - 1) == $key)
482
            {
483
                $this->mrTpl->set_var('THC', 'thCornerR');
484
            }
485
            else
486
            {
487
                $this->mrTpl->set_var('THC', 'thHead');
488
            }
489
            $this->mrTpl->show_block('thd', 'o_', true);
490
        }
491
        $this->mrTpl->shBlock('th', $this->mIsDispHead);
492
493
        //表行
494
        $s_color = $this->mTrBgcolor2;
495
        for ($i = 1; $i < $i_n; $i++)
496
        {
497
            //用于表格行颜色区分与标记的行号和颜色
498
            $s_color = ($s_color == $this->mTrBgcolor1) ? $this->mTrBgcolor2 : $this->mTrBgcolor1;
499
            $this->mrTpl->set_var('tr_num',     $i);
500
            $this->mrTpl->set_var('tr_bgcolor', $s_color);
501
502
            $this->mrTpl->set_var('o_trd', '');
503
            for ($j = 0; $j < $i_col; $j++)
504
            {
505
                $this->mrTpl->set_var('VALUE', $this->mrAr[$i][$j]);
506
                $this->mrTpl->show_block('trd', 'o_', true);
507
            }
508
            $this->mrTpl->show_block('tr', 'o_', true);
509
510
        }
511
512
        //表格样式
513
        $this->mrTpl->set_var('table_width',                $this->mTableWidth);
514
        $this->mrTpl->set_var('table_bgcolor',              $this->mTableBgcolor);
515
        $this->mrTpl->set_var('table_border_width',         $this->mTableBorderWidth);
516
        $this->mrTpl->set_var('table_border_color',         $this->mTableBorderColor);
517
        $this->mrTpl->set_var('table_border_line_style',    $this->mTableBorderLineStyle);
518
        $this->mrTpl->set_var('th_color',                   $this->mThColor);
519
        $this->mrTpl->set_var('th_font_size',               $this->mThFontSize);
520
        $this->mrTpl->set_var('th_font_weight',             $this->mThFontWeight);
521
        $this->mrTpl->set_var('th_bgcolor',                 $this->mThBgcolor);
522
        $this->mrTpl->set_var('th_height',                  $this->mThHeight);
523
        $this->mrTpl->set_var('tr_pointed_color',           $this->mTrPointedColor);
524
        $this->mrTpl->set_var('tr_marked_color',            $this->mTrMarkedColor);
525
        $this->mrTpl->set_var('td_line_style',              $this->mTdLineStyle);
526
        $this->mrTpl->set_var('td_height',                  $this->mTdHeight);
527
528
        $this->mrTpl->show_block('main');
529
530
        $this->mHtmlStr = $this->mrTpl->get('o_main');
531
        return($this->mHtmlStr);
532
*/
533
    } // end function GetHtml
534
535
536
	/**
537
	 * 设置列表的模板文件
538
	 *
539
	 * @param	string	$fileName
540
	 */
541
	function SetTemplate($fileName)
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...
542
	{
543
	    if (!empty($fileName) )
544
	    {
545
			$this->mTemplatePath = $fileName;
546
	    }
547
	} // end of function SetTemplate
548
549
550
	//--------------------------以下为从func_url.php中的URL函数----------------
551
    /**
552
    * 增加或设置/更改URL参数
553
    * @access   private
554
    * @see      UnsetUrlParam()
555
    * @param    string  $urlStr     要进行处理的URL地址
556
    * @param    string  $strName    要添加的参数等号左边,参数名
557
    * @param    string  $strValue   要添加的参数等号右边,参数值
558
    * @return   string
559
    */
560
    function SetUrlParam($urlStr, $strName, $strValue = '')
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...
561
    {
562
        if (empty($strName) && empty($strValue))
563
        {
564
            return($urlStr);
565
        }
566
        $ar = $this->UrlToArray($urlStr);
567
        $i = 1;
568
        $is_found = 0;
569 View Code Duplication
        while (count($ar) > $i)
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
570
        {
571
            if ($strName == $ar[$i][0])
572
            {
573
                //已经有同名的参数了
574
                $ar[$i][1] = $strValue;
575
                $is_found ++;
576
            }
577
            $i++;
578
        }
579
        if (1 > $is_found)
580
        {
581
            //没有找到同名的参数
582
            array_push($ar, array($strName, $strValue));
583
        }
584
        return($this->ArrayToUrl($ar));
585
    } // end function SetUrlParam
586
587
    /**
588
    * 去掉URL参数
589
    * @access   private
590
    * @see      SetUrlParam()
591
    * @param    string  $urlStr     要进行处理的URL地址
592
    * @param    string  $strName    要删除的参数名
593
    * @return   string
594
    */
595
    function UnsetUrlParam($urlStr, $strName)
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...
596
    {
597
        if (empty($strName))
598
        {
599
            return($urlStr);
600
        }
601
        $ar = $this->UrlToArray($urlStr);
602
        $ar2 = array();
603
        foreach ($ar as $key=>$val)
604
        {
605
            if ($strName == $val[0])
606
            {
607
                //找到指定的参数了,因为要删除他,所有就不复制,什么都不作
608
            }
609
            else
610
            {
611
                array_push($ar2, $val);
612
            }
613
        }
614
        return($this->ArrayToUrl($ar2));
615
    } // end function UnsetUrlParam
616
617
    /**
618
    * 将URL地址转换为数组
619
    *
620
    * {@source 4 21}
621
    * @access   private
622
    * @see      ArrayToUrl()
623
    * @param    string  $urlStr URL地址
624
    * @return   array
625
    */
626
    function UrlToArray($urlStr)
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...
627
    {
628
        /*
629
        示例:转换 'http://localhost/index.php?a=1&b=&c=d.php?e=5&f=6'的结果为
630
        Array(
631
            [0] => Array(
632
                    [0] => http://localhost/working/hebca/source/test/index.php
633
                    [1] =>)
634
            [1] => Array(
635
                    [0] => a
636
                    [1] => 1)
637
            [2] => Array(
638
                    [0] => b
639
                    [1] =>)
640
            [3] => Array(
641
                    [0] => c
642
                    [1] => d.php?e
643
                    [2] => 5)
644
            [4] => Array(
645
                    [0] => f
646
                    [1] => 6) )
647
        */
648
        $ar = array();
649
        $str = $urlStr;
650
        $i = 0;
0 ignored issues
show
$i is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
651
        //先寻找“?”
652
        $i = strpos($str, '?');
653
        if (1 > $i)
654
        {
655
            //URL中没有?,说明其没有参数
656
            array_push($ar, array($str, ''));
657
        }
658
        else
659
        {
660
            array_push($ar, array(substr($str, 0, $i), ''));
661
            $str = substr($str, $i + 1) . '&';
662
            //解析用&间隔的参数
663
            while (!empty($str))
664
            {
665
                $i = strpos($str, '&');
666
                if (0 < $i)
667
                {
668
                    $sub_str = substr($str, 0, $i);
669
                    //分析$sub_str这个等式
670
                    array_push($ar, split('[=]', $sub_str));
671
                    $str = substr($str, $i + 1);
672
                }
673 View Code Duplication
                else
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
674
                {
675
                    //剩下的不可识别字符
676
                    array_push($ar, array(substr($str, 0, 1), ''));
677
                    $str = substr($str, 1);
678
                }
679
            }
680
        }
681
        return($ar);
682
    } // end function UrlToArray
683
684
    /**
685
    * 将数组转换为URL地址
686
    *
687
    * 要进行转换的源数组必须是{@link UrlToArray()}结果的格式,即数组的第一个元素为文件地址,其余为各参数
688
    * @access   private
689
    * @see      UrlToArray()
690
    * @param    array   $ar 数组
691
    * @return   string
692
    */
693 View Code Duplication
    function ArrayToUrl(&$ar)
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...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
694
    {
695
        $i = count($ar);
696
        $s_url = '';
697
        if (0 < $i)
698
        {
699
            $s_url .= $ar[0][0] . '?';
700
            for ($j = 1; $j < $i; $j++)
701
            {
702
                foreach ($ar[$j] as $key=>$val)
703
                {
704
                    $s_url .= $val . '=';
705
                }
706
                $s_url = substr($s_url, 0, strlen($s_url) - 1);
707
                $s_url .= '&';
708
            }
709
            $s_url = substr($s_url, 0, strlen($s_url) - 1);
710
        }
711
        //去掉URL尾端的无效字符
712
        $s_url = str_replace('&=', '', $s_url);
713
        $s_url = ereg_replace ('[&]+$', '', $s_url);
714
        return($s_url);
715
    } // end function ArrayToUrl
716
    //-------------------------------------end---------------------------------
717
718
} // end class DispListTable
719
720
?>
721
722
<script type="text/javascript" language="javascript">
723
<!--
724
// {{{ 让表格的行具备标记功能,取自phpMyAdmin中的相关部分。
725
726
/**
727
 * This array is used to remember mark status of rows in browse mode
728
 */
729
var marked_row = new Array;
730
731
/**
732
 * Sets/unsets the pointer and marker in browse mode
733
 *
734
 * @param   object    the table row
735
 * @param   interger  the row number
736
 * @param   string    the action calling this script (over, out or click)
737
 * @param   string    the default background color
738
 * @param   string    the color to use for mouseover
739
 * @param   string    the color to use for marking a row
740
 *
741
 * @return  boolean  whether pointer is set or not
742
 */
743
function DispListTable_SetPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
744
{
745
    var theCells = null;
746
747
    // 1. Pointer and mark feature are disabled or the browser can't get the
748
    //    row -> exits
749
    if ((thePointerColor == '' && theMarkColor == '')
750
        || typeof(theRow.style) == 'undefined') {
751
        return false;
752
    }
753
754
    // 2. Gets the current row and exits if the browser can't get it
755
    if (typeof(document.getElementsByTagName) != 'undefined') {
756
        theCells = theRow.getElementsByTagName('td');
757
    }
758
    else if (typeof(theRow.cells) != 'undefined') {
759
        theCells = theRow.cells;
760
    }
761
    else {
762
        return false;
763
    }
764
765
    // 3. Gets the current color...
766
    var rowCellsCnt  = theCells.length;
767
    var domDetect    = null;
768
    var currentColor = null;
769
    var newColor     = null;
770
    // 3.1 ... with DOM compatible browsers except Opera that does not return
771
    //         valid values with "getAttribute"
772
    if (typeof(window.opera) == 'undefined'
773
        && typeof(theCells[0].getAttribute) != 'undefined') {
774
        currentColor = theCells[0].getAttribute('bgcolor');
775
        domDetect    = true;
776
    }
777
    // 3.2 ... with other browsers
778
    else {
779
        currentColor = theCells[0].style.backgroundColor;
780
        domDetect    = false;
781
    } // end 3
782
783
    // 4. Defines the new color
784
    // 4.1 Current color is the default one
785
    if (currentColor == ''
786
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
787
        if (theAction == 'over' && thePointerColor != '') {
788
            newColor              = thePointerColor;
789
        }
790
        else if (theAction == 'click' && theMarkColor != '') {
791
            newColor              = theMarkColor;
792
        }
793
    }
794
    // 4.1.2 Current color is the pointer one
795
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
796
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
797
        if (theAction == 'out') {
798
            newColor              = theDefaultColor;
799
        }
800
        else if (theAction == 'click' && theMarkColor != '') {
801
            newColor              = theMarkColor;
802
            marked_row[theRowNum] = true;
803
        }
804
    }
805
    // 4.1.3 Current color is the marker one
806
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
807
        if (theAction == 'click') {
808
            newColor              = (thePointerColor != '')
809
                                  ? thePointerColor
810
                                  : theDefaultColor;
811
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
812
                                  ? true
813
                                  : null;
814
        }
815
    } // end 4
816
817
    // 5. Sets the new color...
818
    if (newColor) {
819
        var c = null;
820
        // 5.1 ... with DOM compatible browsers except Opera
821
        if (domDetect) {
822
            for (c = 0; c < rowCellsCnt; c++) {
823
                theCells[c].setAttribute('bgcolor', newColor, 0);
824
            } // end for
825
        }
826
        // 5.2 ... with other browsers
827
        else {
828
            for (c = 0; c < rowCellsCnt; c++) {
829
                theCells[c].style.backgroundColor = newColor;
830
            }
831
        }
832
    } // end 5
833
834
    return true;
835
} // end of the 'DispListTable_SetPointer()' function
836
837
// }}}
838
839
//-->
840
</script>
841