This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | $pathToRoot = '../'; |
||
3 | require __DIR__ . '/' . $pathToRoot . 'config.default.php'; |
||
4 | |||
5 | use Fwlib\Base\ReturnValue; |
||
6 | use Fwlib\Config\GlobalConfig; |
||
7 | use Fwlib\Html\Generator\Component\Form\Form; |
||
0 ignored issues
–
show
|
|||
8 | use Fwlib\Html\Generator\Element\Text; |
||
9 | use Fwlib\Html\Generator\Element\Textarea; |
||
10 | use Fwlib\Html\Generator\ElementMode; |
||
11 | use Fwlib\Net\Curl; |
||
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
Curl .
Let’s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let’s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
![]() |
|||
12 | use Fwlib\Util\UtilContainer; |
||
13 | use Fwlib\Validator\ConstraintContainer; |
||
14 | use FwlibTest\Aide\TestServiceContainer; |
||
15 | |||
16 | /*************************************** |
||
17 | * Read post data |
||
18 | **************************************/ |
||
19 | $utilContainer = UtilContainer::getInstance(); |
||
20 | $httpUtil = $utilContainer->getHttp(); |
||
21 | |||
22 | $userTitle = $httpUtil->getPost('userTitle'); |
||
23 | $userAge = $httpUtil->getPost('userAge'); |
||
24 | $hiddenValue = $httpUtil->getPost('hiddenValue'); |
||
25 | $remark = $httpUtil->getPost('remark'); |
||
26 | |||
27 | $frontendCheck = 'checked="checked"'; |
||
28 | if (!empty($_POST) && is_null($httpUtil->getPost('frontendCheck'))) { |
||
29 | $frontendCheck = ''; |
||
30 | } |
||
31 | |||
32 | |||
33 | /*************************************** |
||
34 | * Treat ajax post |
||
35 | **************************************/ |
||
36 | $action = $httpUtil->getGet('a'); |
||
37 | View Code Duplication | if ('checkAge' == $action) { |
|
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. ![]() |
|||
38 | $age = trim($userAge); |
||
39 | |||
40 | // Age must be positive, between 0~200 |
||
41 | // Assign message when new ReturnValue instance is not needed, but keep |
||
42 | // return additional information is good for debug. |
||
43 | if (is_numeric($age) && 0 <= $age && 200 >= $age) { |
||
44 | $rv = new ReturnValue(0, 'success'); |
||
45 | } else { |
||
46 | $rv = new ReturnValue(-1, 'fail'); |
||
47 | } |
||
48 | |||
49 | echo $rv->toJson(); |
||
50 | exit; |
||
51 | } |
||
52 | |||
53 | |||
54 | /*************************************** |
||
55 | * Prepare FormValidator instance |
||
56 | **************************************/ |
||
57 | $curl = new Curl; |
||
58 | $curl->setSslVerify(false); |
||
59 | $serviceContainer = TestServiceContainer::getInstance(); |
||
60 | $serviceContainer->register('Curl', $curl); |
||
61 | |||
62 | $constraintContainer = ConstraintContainer::getInstance(); |
||
63 | $urlConstraint = $constraintContainer->getUrl(); |
||
64 | |||
65 | $validator = $serviceContainer->getValidator(); |
||
66 | $validator->setConstraintContainer($constraintContainer); |
||
67 | |||
68 | $form = new Form(); |
||
69 | $form->setMode(ElementMode::EDIT) |
||
70 | ->setClass('formWithValidator') |
||
71 | ->setId('demoForm'); |
||
72 | $form->getValidator()->setValidator($validator); |
||
73 | |||
74 | (new Text('userTitle'))->setTitle('名称') |
||
75 | ->setValidateRules(['required']) |
||
0 ignored issues
–
show
array('required') is of type array<integer,string,{"0":"string"}> , but the function expects a array<integer,object<string>> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
76 | ->setTip('Should not be empty') |
||
77 | ->setCheckOnKeyup(true) |
||
78 | ->appendTo($form); |
||
79 | (new Text('userAge'))->setTitle('Age') |
||
80 | ->setValidateRules(['required', 'url: ?a=checkAge , userAge , ']) |
||
0 ignored issues
–
show
array('required', 'url: ...checkAge , userAge , ') is of type array<integer,string,{"0":"string","1":"string"}> , but the function expects a array<integer,object<string>> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
81 | ->setTip('Age should be a valid age') |
||
82 | ->appendTo($form); |
||
83 | // :TODO: Need drop down list select box |
||
84 | (new Text('hiddenValue'))->setTitle('Hidden Input') |
||
85 | ->setValidateRules(['required', 'regex: /11/']) |
||
0 ignored issues
–
show
array('required', 'regex: /11/') is of type array<integer,string,{"0":"string","1":"string"}> , but the function expects a array<integer,object<string>> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
86 | ->setTip('Must select one, must equals 11') |
||
87 | ->appendTo($form); |
||
88 | (new Textarea('remark'))->setTitle('Remark') |
||
89 | ->setValidateRules(['required', 'regex: /g/i']) |
||
0 ignored issues
–
show
array('required', 'regex: /g/i') is of type array<integer,string,{"0":"string","1":"string"}> , but the function expects a array<integer,object<string>> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
90 | ->setTip('不能为空,必须包含字母 g 或者 G') |
||
91 | ->setCheckOnKeyup(true) |
||
92 | ->appendTo($form); |
||
93 | |||
94 | |||
95 | /*************************************** |
||
96 | * Prepare for output, backend validate |
||
97 | **************************************/ |
||
98 | if (!empty($_POST)) { |
||
99 | $form->validate(); |
||
100 | } |
||
101 | |||
102 | |||
103 | ?> |
||
104 | |||
105 | <!DOCTYPE HTML> |
||
106 | <html lang='en'> |
||
107 | <head> |
||
108 | <meta charset='utf-8'/> |
||
109 | <title>FormValidator Demo</title> |
||
110 | |||
111 | <link rel='stylesheet' href='<?php echo $pathToRoot; ?>css/reset.css' |
||
112 | type='text/css' media='all'/> |
||
113 | <link rel='stylesheet' href='<?php echo $pathToRoot; ?>css/default.css' |
||
114 | type='text/css' media='all'/> |
||
115 | |||
116 | <style type='text/css' media='all'> |
||
117 | /* Write CSS below */ |
||
118 | |||
119 | form { |
||
120 | margin: auto; |
||
121 | margin-top: 2em; |
||
122 | text-align: left; |
||
123 | width: 33em; |
||
124 | } |
||
125 | |||
126 | form label { |
||
127 | display: inline-block; |
||
128 | font-weight: bold; |
||
129 | text-align: right; |
||
130 | width: 8em; |
||
131 | } |
||
132 | |||
133 | form label.right-side-label { |
||
134 | font-weight: normal; |
||
135 | text-align: left; |
||
136 | width: 30em; |
||
137 | } |
||
138 | |||
139 | form input, form textarea { |
||
140 | line-height: 150%; |
||
141 | margin-bottom: 0.5em; |
||
142 | margin-top: 0.5em; |
||
143 | } |
||
144 | |||
145 | .submit { |
||
146 | margin-top: 0.5em; |
||
147 | text-align: center; |
||
148 | } |
||
149 | |||
150 | #div-remark label, #div-remark textarea { |
||
151 | vertical-align: middle; |
||
152 | } |
||
153 | |||
154 | #validate-fail-message { |
||
155 | margin: auto; |
||
156 | margin-bottom: -2em; |
||
157 | width: 33em; |
||
158 | } |
||
159 | </style> |
||
160 | |||
161 | |||
162 | <script type="text/javascript" |
||
163 | src="<?php echo GlobalConfig::getInstance()->get('lib.path.jquery'); ?>"> |
||
164 | </script> |
||
165 | |||
166 | <script type="text/javascript" |
||
167 | src="<?php echo $pathToRoot; ?>js/form-validator.js"> |
||
168 | </script> |
||
169 | |||
170 | |||
171 | </head> |
||
172 | <body> |
||
173 | |||
174 | <h2>FormValidator Demo</h2> |
||
175 | |||
176 | |||
177 | <?php echo $form->getOutput(); ?> |
||
178 | |||
179 | |||
180 | <script type="text/javascript"> |
||
181 | <!-- |
||
182 | |||
183 | /* Attach event for frontendCheck option */ |
||
184 | (function (global) { |
||
185 | var setCheckOnSubmit = function (event) { |
||
186 | /* Html element maybe faster */ |
||
187 | /*if ($(this).prop('checked')) {*/ |
||
188 | if (event.target.checked) { |
||
189 | global.formValidator_demoForm.enableCheckOnSubmit(); |
||
190 | } else { |
||
191 | global.formValidator_demoForm.disableCheckOnSubmit(); |
||
192 | } |
||
193 | }; |
||
194 | |||
195 | $('#frontendCheck') |
||
196 | /* Need not click event */ |
||
197 | /*.on('click', setCheckOnSubmit)*/ |
||
198 | .on('change', setCheckOnSubmit) |
||
199 | .trigger('change'); |
||
200 | })(window); |
||
201 | |||
202 | --> |
||
203 | </script> |
||
204 | |||
205 | |||
206 | </body> |
||
207 | </html> |
||
208 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: