Passed
Push — main ( debb02...cc6a11 )
by Julian
04:30
created
app/Http/Controllers/UserController.php 1 patch
Braces   +33 added lines, -29 removed lines patch added patch discarded remove patch
@@ -212,8 +212,9 @@  discard block
 block discarded – undo
212 212
         $customParams = [];
213 213
         foreach ($request->all() as $key => $param) {
214 214
             //echo $key . " = " . $param . "<br />";
215
-            if (str_starts_with($key, "_") ||  in_array($key, ['linktype_id', 'linktype_title', 'link_text', 'link_url']))
216
-                continue;
215
+            if (str_starts_with($key, "_") ||  in_array($key, ['linktype_id', 'linktype_title', 'link_text', 'link_url'])) {
216
+                            continue;
217
+            }
217 218
 
218 219
             $customParams[$key] = $param;
219 220
         }
@@ -221,8 +222,9 @@  discard block
 block discarded – undo
221 222
         $userId = Auth::user()->id;
222 223
         $button = Button::where('name', $request->button)->first();
223 224
 
224
-        if ($button && empty($LinkTitle))
225
-            $LinkTitle = $button->alt;
225
+        if ($button && empty($LinkTitle)) {
226
+                    $LinkTitle = $button->alt;
227
+        }
226 228
 
227 229
         if ($linkType->typename == 'video' && empty($LinkTitle)) {
228 230
             $embed = OEmbed::get($LinkURL);
@@ -245,25 +247,25 @@  discard block
 block discarded – undo
245 247
                         'title' => $LinkTitle,
246 248
                         'button_id' => "2",
247 249
                     ]);
248
-                }elseif($linkType->typename == "link"){
250
+                } elseif($linkType->typename == "link"){
249 251
                     $OrigLink->update([
250 252
                         'link' => $LinkURL,
251 253
                         'title' => $LinkTitle,
252 254
                         'button_id' => "1",
253 255
                     ]);
254
-                }elseif($linkType->typename == "spacer"){
256
+                } elseif($linkType->typename == "spacer"){
255 257
                     $OrigLink->update([
256 258
                         'link' => $LinkURL,
257 259
                         'title' => $customParams['height'] ?? null,
258 260
                         'button_id' => "43",
259 261
                     ]);
260
-                }elseif($linkType->typename == "heading"){
262
+                } elseif($linkType->typename == "heading"){
261 263
                     $OrigLink->update([
262 264
                         'link' => $LinkURL,
263 265
                         'title' => $LinkTitle,
264 266
                         'button_id' => "42",
265 267
                     ]);
266
-                }elseif($linkType->typename == "text"){
268
+                } elseif($linkType->typename == "text"){
267 269
                     $sanitizedText = $request->text;
268 270
                     $sanitizedText = strip_tags($sanitizedText, '<a><p><strong><i><ul><ol><li><blockquote><h2><h3><h4>');
269 271
                     $sanitizedText = preg_replace("/<a([^>]*)>/i", "<a $1 rel=\"noopener noreferrer nofollow\">", $sanitizedText);
@@ -272,21 +274,21 @@  discard block
 block discarded – undo
272 274
                         'button_id' => "93",
273 275
                         'title' => $sanitizedText,
274 276
                     ]);
275
-                }elseif($linkType->typename == "email"){
277
+                } elseif($linkType->typename == "email"){
276 278
                     $LinkURL = "mailto:".$LinkURL;
277 279
                     $OrigLink->update([
278 280
                         'link' => $LinkURL,
279 281
                         'button_id' => $button?->id,
280 282
                         'title' => $LinkTitle,
281 283
                     ]);
282
-                }elseif($linkType->typename == "telephone"){
284
+                } elseif($linkType->typename == "telephone"){
283 285
                     $LinkURL = "tel:".$LinkURL;
284 286
                     $OrigLink->update([
285 287
                         'link' => $LinkURL,
286 288
                         'button_id' => $button?->id,
287 289
                         'title' => $LinkTitle,
288 290
                     ]);
289
-                }elseif($linkType->typename == "vcard"){
291
+                } elseif($linkType->typename == "vcard"){
290 292
 
291 293
                     $prefix = $request->input('prefix');
292 294
                     $firstName = $request->input('first_name');
@@ -358,7 +360,7 @@  discard block
 block discarded – undo
358 360
                         'button_id' => 96,
359 361
                         'title' => $LinkTitle,
360 362
                     ]);
361
-                }else{
363
+                } else{
362 364
                     $OrigLink->update([
363 365
                         'link' => $LinkURL,
364 366
                         'title' => $LinkTitle,
@@ -379,31 +381,31 @@  discard block
 block discarded – undo
379 381
             $links->user_id = $userId;
380 382
             if($linkType->typename == "spacer"){
381 383
             $links->title = $SpacerHeight;
382
-            }else{
384
+            } else{
383 385
             $links->title = $LinkTitle;
384 386
             }
385 387
             if($linkType->typename == "link" and $isCustomWebsite == "1"){
386 388
                 $links->button_id = "2";
387
-            }elseif($linkType->typename == "link"){
389
+            } elseif($linkType->typename == "link"){
388 390
                 $links->button_id = "1";
389
-            }elseif($linkType->typename == "spacer"){
391
+            } elseif($linkType->typename == "spacer"){
390 392
                 $links->button_id = "43";
391
-            }elseif($linkType->typename == "heading"){
393
+            } elseif($linkType->typename == "heading"){
392 394
                 $links->button_id = "42";
393
-            }elseif($linkType->typename == "text"){
395
+            } elseif($linkType->typename == "text"){
394 396
                 $sanitizedText = $request->text;
395 397
                 $sanitizedText = strip_tags($sanitizedText, '<a><p><strong><i><ul><ol><li><blockquote><h2><h3><h4>');
396 398
                 $sanitizedText = preg_replace("/<a([^>]*)>/i", "<a $1 rel=\"noopener noreferrer nofollow\">", $sanitizedText);
397 399
                 $sanitizedText = strip_tags_except_allowed_protocols($sanitizedText);
398 400
                 $links->button_id = "93";
399 401
                 $links->title = $sanitizedText;
400
-            }elseif($linkType->typename == "email"){
402
+            } elseif($linkType->typename == "email"){
401 403
                 $links->link = "mailto:".$links->link;
402 404
                 $links->button_id = $button?->id;
403
-            }elseif($linkType->typename == "telephone"){
405
+            } elseif($linkType->typename == "telephone"){
404 406
                 $links->link = "tel:".$links->link;
405 407
                 $links->button_id = $button?->id;
406
-            }elseif($linkType->typename == "vcard"){
408
+            } elseif($linkType->typename == "vcard"){
407 409
 
408 410
                 $prefix = $request->input('prefix');
409 411
                 $firstName = $request->input('first_name');
@@ -471,7 +473,7 @@  discard block
 block discarded – undo
471 473
                 $links->link = $json ? $json : null;               
472 474
 
473 475
                 $links->button_id = 96;
474
-            }else{
476
+            } else{
475 477
                 $links->button_id = $button?->id;
476 478
             }
477 479
 
@@ -720,14 +722,16 @@  discard block
 block discarded – undo
720 722
             'button' => 'required',
721 723
         ]);
722 724
 
723
-        if (stringStartsWith($request->link, 'http://') == 'true' or stringStartsWith($request->link, 'https://') == 'true' or stringStartsWith($request->link, 'mailto:') == 'true')
724
-            $link1 = $request->link;
725
-        else
726
-            $link1 = 'https://' . $request->link;
727
-        if (stringEndsWith($request->link, '/') == 'true')
728
-            $link = rtrim($link1, "/ ");
729
-        else
730
-        $link = $link1;
725
+        if (stringStartsWith($request->link, 'http://') == 'true' or stringStartsWith($request->link, 'https://') == 'true' or stringStartsWith($request->link, 'mailto:') == 'true') {
726
+                    $link1 = $request->link;
727
+        } else {
728
+                    $link1 = 'https://' . $request->link;
729
+        }
730
+        if (stringEndsWith($request->link, '/') == 'true') {
731
+                    $link = rtrim($link1, "/ ");
732
+        } else {
733
+                $link = $link1;
734
+        }
731 735
         $title = $request->title;
732 736
         $order = $request->order;
733 737
         $button = $request->button;
Please login to merge, or discard this patch.