|
14 | 14 | use DB;
|
15 | 15 | use ZipArchive;
|
16 | 16 | use File;
|
17 |
| -use DOMDocument; |
18 | 17 |
|
19 | 18 | use App\Models\User;
|
20 | 19 | use App\Models\Button;
|
@@ -721,42 +720,16 @@ public function editPage(request $request)
|
721 | 720 |
|
722 | 721 | $profilePhoto = $request->file('image');
|
723 | 722 | $pageName = $request->littlelink_name;
|
724 |
| - $pageDescription = $request->pageDescription; |
725 |
| - |
726 |
| - // Strip HTML tags except for allowed tags |
727 |
| - $pageDescription = strip_tags($pageDescription, '<a><p><strong><i><ul><ol><li><blockquote><h2><h3><h4>'); |
728 |
| - |
729 |
| - // Sanitize attributes and remove JavaScript code |
730 |
| - if (!empty($pageDescription)) { |
731 |
| - $document = new DOMDocument(); |
732 |
| - $document->loadHTML($pageDescription, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); |
733 |
| - |
734 |
| - // Find all elements that have attributes |
735 |
| - $elements = $document->getElementsByTagName('*'); |
736 |
| - foreach ($elements as $element) { |
737 |
| - // Check each attribute of the element |
738 |
| - foreach ($element->attributes as $attribute) { |
739 |
| - $attributeName = $attribute->nodeName; |
740 |
| - |
741 |
| - // Remove attributes that contain "on" followed by an event name |
742 |
| - if (strpos($attributeName, 'on') === 0) { |
743 |
| - $element->removeAttribute($attributeName); |
744 |
| - } |
745 |
| - } |
746 |
| - } |
747 |
| - |
748 |
| - // Get the sanitized HTML back |
749 |
| - $pageDescription = $document->saveHTML(); |
750 |
| - } |
751 |
| - |
| 723 | + $pageDescription = strip_tags($request->pageDescription,'<a><p><strong><i><ul><ol><li><blockquote><h2><h3><h4>'); |
| 724 | + $pageDescription = preg_replace("/<a([^>]*)>/i", "<a $1 rel=\"noopener noreferrer nofollow\">", $pageDescription); |
752 | 725 | $name = $request->name;
|
753 | 726 | $checkmark = $request->checkmark;
|
754 | 727 | $sharebtn = $request->sharebtn;
|
755 | 728 |
|
756 | 729 | User::where('id', $userId)->update(['littlelink_name' => $pageName, 'littlelink_description' => $pageDescription, 'name' => $name]);
|
757 | 730 |
|
758 | 731 | if ($request->hasFile('image')) {
|
759 |
| - $profilePhoto->move(base_path('assets/img'), $userId . ".png"); |
| 732 | + $profilePhoto->move(base_path('assets/img'), $userId . '_' . time() . ".png"); |
760 | 733 | }
|
761 | 734 |
|
762 | 735 | if($checkmark == "on"){
|
@@ -793,7 +766,7 @@ public function themeBackground(request $request)
|
793 | 766 | }}
|
794 | 767 | if(file_exists(base_path('assets/img/background-img/').$pathinfo)){File::delete(base_path('assets/img/background-img/').$pathinfo);}
|
795 | 768 |
|
796 |
| - $customBackground->move(base_path('assets/img/background-img/'), $userId.".".$request->file('image')->extension()); |
| 769 | + $customBackground->move(base_path('assets/img/background-img/'), $userId . '_' . time() . "." . $request->file('image')->extension()); |
797 | 770 | }
|
798 | 771 |
|
799 | 772 | return Redirect('/studio/theme');
|
|
0 commit comments