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 | |||
3 | class WebToLeadFormBuilder { |
||
4 | |||
5 | // ---- html outputs ---- |
||
6 | |||
7 | private static function getFormStartHTML($suiteGrp1Js, $webPostUrl, $webFormHeader, $webFormDescription) { |
||
8 | $formSel = 'form#WebToLeadForm'; |
||
9 | $html = <<<HTML |
||
10 | <style type="text/css"> |
||
11 | $formSel, $formSel * {margin: 0; padding: 0; border: none; color: #333; font-size: 12px; line-height: 1.6em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;} |
||
12 | $formSel {float: left; border: 1px solid #ccc; margin: 10px;} |
||
13 | $formSel h1 {font-size: 32px; font-weight: bold; background-color: rgb(60, 141, 188); color: rgb(247, 247, 247); padding: 10px 20px;} |
||
14 | $formSel h2 {font-size: 24px; font-weight: bold; background-color: rgb(60, 141, 188); color: rgb(247, 247, 247); padding: 10px 20px;} |
||
15 | $formSel h3 {font-size: 12px; font-weight: bold; padding: 10px 20px;} |
||
16 | $formSel h4 {font-size: 10px; font-weight: bold; padding: 10px 20px;} |
||
17 | $formSel h5 {font-size: 8px; font-weight: bold; padding: 10px 20px;} |
||
18 | $formSel h6 {font-size: 6px; font-weight: bold; padding: 10px 20px;} |
||
19 | $formSel p {padding: 10px 20px;} |
||
20 | $formSel input, |
||
21 | $formSel select, |
||
22 | $formSel textarea {border: 1px solid #ccc; display: block; float: left; min-width: 170px; padding: 5px;} |
||
23 | $formSel select {background-color: white;} |
||
24 | $formSel input[type="button"], |
||
25 | $formSel input[type="submit"] {display: inline; float: none; padding: 5px 10px; width: auto; min-width: auto;} |
||
26 | $formSel input[type="checkbox"], |
||
27 | $formSel input[type="radio"] {width: 18px; min-width: auto;} |
||
28 | $formSel div.col {display: block; float: left; width: 330px; padding: 10px 20px;} |
||
29 | $formSel div.clear {display: block; float: none; clear: both; height: 0px; overflow: hidden;} |
||
30 | $formSel div.center {text-align: center;} |
||
31 | $formSel div.buttons {padding: 10px 0; border-top: 1px solid #ccc; background-color: #f7f7f7} |
||
32 | $formSel label {display: block; float: left; width: 160px; font-weight: bold;} |
||
33 | $formSel span.required {color: #FF0000;} |
||
34 | </style> |
||
35 | <!-- TODO ??? |
||
36 | <script type="text/javascript" src='$suiteGrp1Js'></script> |
||
37 | --> |
||
38 | <form action='$webPostUrl' name='WebToLeadForm' method='POST' id='WebToLeadForm'> |
||
39 | <h2>$webFormHeader</h2> |
||
40 | <p>$webFormDescription</p> |
||
41 | HTML; |
||
42 | return $html; |
||
43 | } |
||
44 | |||
45 | private static function getFormFooterHTML($webFormFooter, $webFormSubmitLabel, $webFormCampaign, $webRedirectURL, $webAssignedUser, $booleanFields, $moduleDir) { |
||
46 | $webFormCampaignInput = $webFormCampaign ? "<input type='hidden' id='campaign_id' name='campaign_id' value='$webFormCampaign'>" : ''; |
||
47 | $webRedirectURLInput = $webRedirectURL ? "<input type='hidden' id='redirect_url' name='redirect_url' value='$webRedirectURL'>" : ''; |
||
48 | $webAssignedUserInput = $webAssignedUser ? "<input type='hidden' id='assigned_user_id' name='assigned_user_id' value='$webAssignedUser'>" : ''; |
||
49 | $booleanFieldsInput = $booleanFields ? "<input type='hidden' id='bool_id' name='bool_id' value='$booleanFields'>" : ''; |
||
50 | $moduleDirInput = "<input type='hidden' id='moduleDir' name='moduleDir' value='$moduleDir'>"; |
||
51 | |||
52 | |||
53 | $html = <<<HTML |
||
54 | $webFormFooter |
||
55 | <div class="row center buttons"> |
||
56 | <input type="submit" onclick="submit_form();" class="button" name="Submit" value="$webFormSubmitLabel" /> |
||
57 | <div class="clear"> </div> |
||
58 | </div> |
||
59 | $webFormCampaignInput |
||
60 | $webRedirectURLInput |
||
61 | $webAssignedUserInput |
||
62 | $booleanFieldsInput |
||
63 | $moduleDirInput |
||
64 | HTML; |
||
65 | return $html; |
||
66 | } |
||
67 | |||
68 | private static function getFormFinishHTML($webFormRequiredFieldsMsg) { |
||
69 | $html = <<<HTML |
||
70 | </form> |
||
71 | <script type='text/javascript'> |
||
72 | function submit_form() { |
||
73 | if (typeof(validateCaptchaAndSubmit) != 'undefined') { |
||
74 | validateCaptchaAndSubmit(); |
||
75 | } else { |
||
76 | check_webtolead_fields(); |
||
77 | //document.WebToLeadForm.submit(); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | function check_webtolead_fields() { |
||
82 | if (document.getElementById('bool_id') != null) { |
||
83 | var reqs = document.getElementById('bool_id').value; |
||
84 | bools = reqs.substring(0, reqs.lastIndexOf(';')); |
||
85 | var bool_fields = new Array(); |
||
86 | var bool_fields = bools.split(';'); |
||
87 | nbr_fields = bool_fields.length; |
||
88 | for (var i = 0; i < nbr_fields; i++) { |
||
89 | if (document.getElementById(bool_fields[i]).value == 'on') { |
||
90 | document.getElementById(bool_fields[i]).value = 1; |
||
91 | } else { |
||
92 | document.getElementById(bool_fields[i]).value = 0; |
||
93 | } |
||
94 | } |
||
95 | } |
||
96 | } |
||
97 | </script> |
||
98 | HTML; |
||
99 | return $html; |
||
100 | } |
||
101 | |||
102 | private static function getRowStartHTML() { |
||
103 | return '<div class="row">'; |
||
104 | } |
||
105 | |||
106 | private static function getRowFinishHTML() { |
||
107 | return ' <div class="clear"> </div> |
||
108 | </div>'; |
||
109 | } |
||
110 | |||
111 | private static function getColFieldStartHTML() { |
||
112 | return '<div class="col">'; |
||
113 | } |
||
114 | |||
115 | private static function getColFieldFinishHTML() { |
||
116 | return '</div>'; |
||
117 | } |
||
118 | |||
119 | // -- fields |
||
120 | |||
121 | private static function getFieldLabelHTML($fieldLabel, $fieldRequired, $webRequiredSymbol) { |
||
122 | $html = '<label>' . $fieldLabel . ($fieldRequired ? "<span class='required'>$webRequiredSymbol</span>" : '') . '</label>'; |
||
123 | return $html; |
||
124 | } |
||
125 | |||
126 | private static function getFieldEmptyHTML() { |
||
127 | $html = ' '; |
||
128 | return $html; |
||
129 | } |
||
130 | |||
131 | // enums |
||
132 | |||
133 | private static function getFieldEnumHTML($lead, $fieldName, $appListStringsFieldOptions, $fieldRequired, $fieldLabel, $webRequiredSymbol, $colsField) { |
||
134 | $html = ''; |
||
135 | |||
136 | $leadOptions = get_select_options_with_id($appListStringsFieldOptions, !empty($lead->$fieldName) ? unencodeMultienum($lead->$fieldName) : ''); |
||
137 | |||
138 | $html .= self::getFieldLabelHTML($fieldLabel, $fieldRequired, $webRequiredSymbol); |
||
139 | |||
140 | if(isset($lead->field_defs[$colsField]['isMultiSelect']) && $lead->field_defs[$colsField]['isMultiSelect'] ==1){ |
||
141 | $html .= self::getFieldEnumMultiSelectHTML($fieldName, $leadOptions, $fieldRequired); |
||
142 | }elseif(ifRadioButton($lead->field_defs[$colsField]['name'])){ |
||
143 | $html .= self::getFieldEnumRadioGroupHTML($appListStringsFieldOptions, $lead, $fieldName, $colsField, $fieldRequired); |
||
144 | }else{ |
||
145 | $html .= self::getFieldEnumSelectHTML($fieldName, $leadOptions, $fieldRequired); |
||
146 | } |
||
147 | return $html; |
||
148 | } |
||
149 | |||
150 | private static function getFieldEnumMultiSelectHTML($fieldName, $leadOptions, $fieldRequired) { |
||
151 | $_required = $fieldRequired ? ' required' : ''; |
||
152 | $html = "<select id=\"$fieldName\" multiple=\"true\" name=\"{$fieldName}[]\" tabindex=\"1\"$_required>$leadOptions</select>"; |
||
153 | return $html; |
||
154 | } |
||
155 | |||
156 | private static function getFieldEnumRadioGroupHTML($appListStringsFieldOptions, $lead, $fieldName, $colsField, $fieldRequired) { |
||
157 | $_required = $fieldRequired ? ' required' : ''; |
||
158 | $html = ''; |
||
159 | foreach($appListStringsFieldOptions as $field_option_key => $field_option){ |
||
160 | if($field_option != null){ |
||
161 | if(!empty($lead->$fieldName) && in_array($field_option_key,unencodeMultienum($lead->$fieldName))) { |
||
162 | $_checked = ' checked'; |
||
163 | } |
||
164 | else { |
||
165 | $_checked = ''; |
||
166 | } |
||
167 | $html .="<input id=\"{$colsField}_$field_option_key\" name=\"$colsField\" value=\"$field_option_key\" type=\"radio\"$_checked$_required>"; |
||
168 | // todo ??? --> |
||
169 | $html .="<span ='document.getElementById('".$lead->field_defs[$colsField]."_$field_option_key').checked =true style='cursor:default'; onmousedown='return false;'>$field_option</span><br>"; |
||
170 | } |
||
171 | } |
||
172 | return $html; |
||
173 | } |
||
174 | |||
175 | private static function getFieldEnumSelectHTML($fieldName, $leadOptions, $fieldRequired) { |
||
176 | $_required = $fieldRequired ? ' required' : ''; |
||
177 | $html = "<select id=\"$fieldName\" name=\"$fieldName\" tabindex=\"1\"$_required>$leadOptions</select>"; |
||
178 | return $html; |
||
179 | } |
||
180 | |||
181 | // bool |
||
182 | |||
183 | private static function getFieldBoolHTML($fieldName, $fieldRequired, $fieldLabel, $webRequiredSymbol, $fieldRequired) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
184 | $_required = $fieldRequired ? ' required' : ''; |
||
185 | $html = self::getFieldLabelHTML($fieldLabel, $fieldRequired, $webRequiredSymbol); |
||
186 | $html .= "<input type=\"checkbox\" id=\"$fieldName\" name=\"$fieldName\"$_required>"; |
||
187 | return $html; |
||
188 | } |
||
189 | |||
190 | // date |
||
191 | |||
192 | private static function getFieldDateHTML($fieldName, $fieldRequired, $fieldLabel, $webRequiredSymbol) { |
||
193 | $_required = $fieldRequired ? ' required' : ''; |
||
194 | $html = self::getFieldLabelHTML($fieldLabel, $fieldRequired, $webRequiredSymbol); |
||
195 | $html .= "<input type=\"date\" id=\"{$fieldName}\" name=\"{$fieldName}\"$_required/>"; |
||
196 | return $html; |
||
197 | } |
||
198 | |||
199 | // char strings |
||
200 | |||
201 | private static function getFieldCharsHTML($fieldName, $fieldLabel, $fieldRequired, $webRequiredSymbol) { |
||
202 | $isRequired = $fieldName=='last_name' || $fieldRequired; |
||
203 | $_required = $isRequired ? ' required' : ''; |
||
204 | $html = self::getFieldLabelHTML($fieldLabel, $isRequired, $webRequiredSymbol); |
||
205 | $_type = $fieldName=='email1'||$fieldName=='email2' ? 'email' : 'text'; |
||
206 | $html .= "<input id=\"$fieldName\" name=\"$fieldName\" type=\"$_type\"$_required>"; |
||
207 | return $html; |
||
208 | } |
||
209 | |||
210 | // text |
||
211 | |||
212 | private static function getFieldTextHTML($fieldName, $fieldLabel, $fieldRequired, $webRequiredSymbol) { |
||
213 | $_required = $fieldRequired ? ' required' : ''; |
||
214 | $html = self::getFieldLabelHTML($fieldLabel, $fieldRequired, $webRequiredSymbol); |
||
215 | $html .= "<span class='ta_replace'><input id=\"$fieldName\" name=\"$fieldName\" type=\"text\"$_required></span>"; |
||
216 | return $html; |
||
217 | } |
||
218 | |||
219 | // relate |
||
220 | |||
221 | private static function getFieldRelateHTML($fieldName, $fieldLabel, $fieldRequired, $webRequiredSymbol) { |
||
222 | $_required = $fieldRequired ? ' required' : ''; |
||
223 | $html = self::getFieldLabelHTML($fieldLabel, $fieldRequired, $webRequiredSymbol); |
||
224 | $html .= "<span><input id=\"$fieldName\" name=\"$fieldName\" type=\"text\"$_required></span>"; |
||
225 | return $html; |
||
226 | } |
||
227 | |||
228 | |||
229 | |||
230 | private static function getFieldEmailHTML($fieldName, $fieldRequired, $fieldLabel, $webRequiredSymbol) { |
||
231 | $_required = $fieldRequired ? ' required' : ''; |
||
232 | $html = self::getFieldLabelHTML($fieldLabel, $fieldRequired, $webRequiredSymbol); |
||
233 | $html .= "<input id=\"$fieldName\" name=\"$fieldName\" type=\"email\"$_required>"; |
||
234 | return $html; |
||
235 | } |
||
236 | |||
237 | // ---------------- |
||
238 | |||
239 | private static function getFormTwoColumns($request, $formCols) { |
||
240 | $colsFirst = isset($request[$formCols[0]]) ? $request[$formCols[0]] : null; |
||
241 | $colsSecond = isset($request[$formCols[1]]) ? $request[$formCols[1]] : null; |
||
242 | if(!empty($colsFirst) && !empty($colsSecond)){ |
||
243 | if(count($colsFirst) < count($colsSecond)){ |
||
244 | $columns= count($colsSecond); |
||
245 | } |
||
246 | if(count($colsFirst) > count($colsSecond) || count($colsFirst) == count($colsSecond)){ |
||
247 | $columns= count($colsFirst); |
||
248 | } |
||
249 | } |
||
250 | else if(!empty($colsFirst)){ |
||
251 | $columns= count($colsFirst); |
||
252 | } |
||
253 | else if(!empty($colsSecond)){ |
||
254 | $columns= count($colsSecond); |
||
255 | } |
||
256 | return $columns; |
||
257 | } |
||
258 | |||
259 | private static function getBooleanFields($boolFields) { |
||
260 | $boolean_fields=''; |
||
261 | if($boolFields != null ){ |
||
262 | foreach($boolFields as $boo){ |
||
263 | $boolean_fields=$boolean_fields.$boo.';'; |
||
264 | } |
||
265 | } |
||
266 | return $boolean_fields; |
||
267 | } |
||
268 | |||
269 | private static function getArrayOfFieldInfo($lead, $colsField, &$requiredFields) { |
||
270 | $field_vname= preg_replace('/:$/','',translate($lead->field_defs[$colsField]['vname'],'Leads')); |
||
271 | $field_name= $colsField; |
||
272 | $field_label = $field_vname .": "; |
||
273 | if(isset($lead->field_defs[$colsField]['custom_type']) && $lead->field_defs[$colsField]['custom_type'] != null){ |
||
274 | $field_type= $lead->field_defs[$colsField]['custom_type']; |
||
275 | } |
||
276 | else{ |
||
277 | $field_type= $lead->field_defs[$colsField]['type']; |
||
278 | } |
||
279 | |||
280 | //bug: 47574 - make sure, that webtolead_email1 field has same required attribute as email1 field |
||
281 | if($colsField == 'webtolead_email1' && isset($lead->field_defs['email1']) && isset($lead->field_defs['email1']['required'])){ |
||
282 | $lead->field_defs['webtolead_email1']['required'] = $lead->field_defs['email1']['required']; |
||
283 | } |
||
284 | |||
285 | $field_required = ''; |
||
286 | if(isset($lead->field_defs[$colsField]['required']) && $lead->field_defs[$colsField]['required'] != null |
||
287 | && $lead->field_defs[$colsField]['required'] != 0){ |
||
288 | $field_required = $lead->field_defs[$colsField]['required']; |
||
289 | if (! in_array($lead->field_defs[$colsField]['name'], $requiredFields)){ |
||
290 | array_push($requiredFields,$lead->field_defs[$colsField]['name']); |
||
291 | } |
||
292 | } |
||
293 | if($lead->field_defs[$colsField]['name']=='last_name'){ |
||
294 | if (! in_array($lead->field_defs[$colsField]['name'], $requiredFields)){ |
||
295 | array_push($requiredFields,$lead->field_defs[$colsField]['name']); |
||
296 | } |
||
297 | } |
||
298 | $field_options = null; |
||
299 | if($field_type=='multienum' || $field_type=='enum' || $field_type=='radioenum') $field_options= $lead->field_defs[$colsField]['options']; |
||
300 | return array($field_name, $field_label, $field_type, $field_required, $field_options); |
||
301 | } |
||
302 | |||
303 | // --------------- generate form ------------------ |
||
304 | |||
305 | public static function generate($request, |
||
306 | $lead, |
||
307 | $moduleDir, |
||
308 | $siteURL, |
||
309 | $webPostURL, |
||
310 | $webFormHeader, |
||
311 | $webFormDescription, |
||
312 | $appListStrings, |
||
313 | $webRequiredSymbol, |
||
314 | $webFormFooter, |
||
315 | $webFormSubmitLabel, |
||
316 | $webFormCampaign, |
||
317 | $webRedirectURL, |
||
318 | $webAssignedUser, |
||
319 | $webFormRequiredFieldsMsg, |
||
320 | $formCols = array('colsFirst', 'colsSecond') |
||
321 | ) { |
||
322 | |||
323 | $sugarGrp1Js = getJSPath($siteURL.'/cache/include/javascript/sugar_grp1.js'); |
||
0 ignored issues
–
show
Are you sure the assignment to
$sugarGrp1Js is correct as getJSPath($siteURL . '/c...ascript/sugar_grp1.js') (which targets getJSPath() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
324 | |||
325 | $Web_To_Lead_Form_html = self::getFormStartHTML( |
||
326 | $sugarGrp1Js, |
||
327 | $webPostURL, |
||
328 | $webFormHeader, |
||
329 | $webFormDescription |
||
330 | ); |
||
331 | |||
332 | $columns = self::getFormTwoColumns($request, $formCols); |
||
333 | |||
334 | |||
335 | $required_fields = array(); |
||
336 | $bool_fields = array(); |
||
337 | for($i= 0; $i<$columns;$i++){ |
||
338 | |||
339 | $colsFields = array(); |
||
340 | foreach($formCols as $k => $formCol) { |
||
341 | $colsFields[$k] = !empty($request[$formCol][$i]) ? $request[$formCol][$i] : null; |
||
342 | } |
||
343 | |||
344 | if($colsFieldCount = count($formCols)) { |
||
345 | |||
346 | $colHtml = ''; |
||
347 | $foundField = false; |
||
348 | for ($j = 0; $j < $colsFieldCount; $j++) { |
||
349 | |||
350 | $colHtml .= self::getColFieldStartHTML(); |
||
351 | |||
352 | if (isset($lead->field_defs[$colsFields[$j]]) && $lead->field_defs[$colsFields[$j]] != null) { |
||
353 | |||
354 | list($field_name, $field_label, $field_type, $field_required, $field_options) = self::getArrayOfFieldInfo($lead, $colsFields[$j], $required_fields); |
||
355 | |||
356 | if ($field_type == 'multienum' || $field_type == 'enum' || $field_type == 'radioenum') { |
||
357 | $colHtml .= self::getFieldEnumHTML($lead, $field_name, $appListStrings[$field_options], $field_required, $field_label, $webRequiredSymbol, $colsFields[$j]); |
||
358 | $foundField = true; |
||
359 | } |
||
360 | elseif ($field_type == 'bool') { |
||
361 | $colHtml .= self::getFieldBoolHTML($field_name, $field_required, $field_label, $webRequiredSymbol, $field_required); |
||
0 ignored issues
–
show
The call to
WebToLeadFormBuilder::getFieldBoolHTML() has too many arguments starting with $field_required .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
362 | $foundField = true; |
||
363 | if (!in_array($lead->field_defs[$colsFields[$j]]['name'], $bool_fields)) { |
||
364 | array_push($bool_fields, $lead->field_defs[$colsFields[$j]]['name']); |
||
365 | } |
||
366 | } |
||
367 | elseif ($field_type == 'date') { |
||
368 | $colHtml .= self::getFieldDateHTML($field_name, $field_required, $field_label, $webRequiredSymbol); |
||
369 | $foundField = true; |
||
370 | } |
||
371 | elseif ($field_type == 'varchar' || $field_type == 'name' || $field_type == 'phone' || $field_type == 'currency' || $field_type == 'url' || $field_type == 'int') { |
||
372 | $colHtml .= self::getFieldCharsHTML($field_name, $field_label, $field_required, $webRequiredSymbol); |
||
373 | $foundField = true; |
||
374 | } |
||
375 | elseif ($field_type == 'text') { |
||
376 | $colHtml .= self::getFieldTextHTML($field_name, $field_label, $field_required && false, $webRequiredSymbol); |
||
377 | $foundField = true; |
||
378 | } |
||
379 | elseif ($field_type == 'relate' && $field_name == 'account_name') { |
||
380 | $colHtml .= self::getFieldRelateHTML($field_name, $field_label, $field_required && false, $webRequiredSymbol); |
||
381 | $foundField = true; |
||
382 | } |
||
383 | elseif ($field_type == 'email') { |
||
384 | $colHtml .= self::getFieldEmailHTML(); |
||
0 ignored issues
–
show
|
|||
385 | $foundField = true; |
||
386 | } |
||
387 | else { |
||
388 | $colHtml .= self::getFieldEmptyHTML(); |
||
389 | } |
||
390 | |||
391 | } else { |
||
392 | $colHtml .= self::getFieldEmptyHTML(); |
||
393 | } |
||
394 | |||
395 | $colHtml .= self::getColFieldFinishHTML(); |
||
396 | |||
397 | } |
||
398 | |||
399 | if($foundField) { |
||
400 | $Web_To_Lead_Form_html .= self::getRowStartHTML(); |
||
401 | $Web_To_Lead_Form_html .= $colHtml; |
||
402 | $Web_To_Lead_Form_html .= self:: getRowFinishHTML(); |
||
403 | } |
||
404 | |||
405 | } |
||
406 | } |
||
407 | |||
408 | |||
409 | $booleanFields = self::getBooleanFields(isset($bool_fields) ? $bool_fields : null); |
||
410 | |||
411 | $Web_To_Lead_Form_html .= self::getFormFooterHTML( |
||
412 | $webFormFooter, |
||
413 | $webFormSubmitLabel, |
||
414 | $webFormCampaign, |
||
415 | $webRedirectURL, |
||
416 | $webAssignedUser, |
||
417 | $booleanFields, |
||
418 | $moduleDir |
||
419 | ); |
||
420 | |||
421 | $Web_To_Lead_Form_html .= self::getFormFinishHTML($webFormRequiredFieldsMsg); |
||
422 | |||
423 | return $Web_To_Lead_Form_html; |
||
424 | } |
||
425 | |||
426 | } |
||
427 |