Unique Image String Attached to Uploaded Images
The system now assigns a unique string to uploaded images, ensuring renewed cached images when new ones are uploaded. https://github.com/LinkStackOrg/LinkStack/issues/480
This commit is contained in:
parent
790133025a
commit
37fd33a322
|
@ -274,7 +274,7 @@ public function SendTestMail(Request $request)
|
|||
User::where('id', $id)->update(['name' => $name, 'email' => $email, 'password' => $password, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role]);
|
||||
}
|
||||
if (!empty($profilePhoto)) {
|
||||
$profilePhoto->move(base_path('assets/img'), $id . ".png");
|
||||
$profilePhoto->move(base_path('assets/img'), $id . '_' . time() . ".png");
|
||||
}
|
||||
if (!empty($customBackground)) {
|
||||
$directory = base_path('assets/img/background-img/');
|
||||
|
@ -286,7 +286,7 @@ public function SendTestMail(Request $request)
|
|||
}}
|
||||
if(file_exists(base_path('assets/img/background-img/').$pathinfo)){File::delete(base_path('assets/img/background-img/').$pathinfo);}
|
||||
|
||||
$customBackground->move(base_path('assets/img/background-img/'), $id.".".$request->file('background')->extension());
|
||||
$customBackground->move(base_path('assets/img/background-img/'), $id . '_' . time() . "." . $request->file('background')->extension());
|
||||
}
|
||||
|
||||
return redirect('admin/users/all');
|
||||
|
@ -339,7 +339,7 @@ public function SendTestMail(Request $request)
|
|||
}}
|
||||
if(file_exists(base_path('/assets/linkstack/images/').$pathinfo)){File::delete(base_path('/assets/linkstack/images/').$pathinfo);}
|
||||
|
||||
$logo->move(base_path('/assets/linkstack/images/'), "avatar.".$request->file('image')->extension());
|
||||
$logo->move(base_path('/assets/linkstack/images/'), "avatar" . '_' . time() . "." .$request->file('image')->extension());
|
||||
}
|
||||
|
||||
if (!empty($icon)) {
|
||||
|
@ -353,7 +353,7 @@ public function SendTestMail(Request $request)
|
|||
}}
|
||||
if(file_exists(base_path('/assets/linkstack/images/').$pathinfo)){File::delete(base_path('/assets/linkstack/images/').$pathinfo);}
|
||||
|
||||
$icon->move(base_path('/assets/linkstack/images/'), "favicon.".$request->file('icon')->extension());
|
||||
$icon->move(base_path('/assets/linkstack/images/'), "favicon" . '_' . time() . "." . $request->file('icon')->extension());
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ use Auth;
|
|||
use DB;
|
||||
use ZipArchive;
|
||||
use File;
|
||||
use DOMDocument;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Button;
|
||||
|
@ -721,34 +720,8 @@ class UserController extends Controller
|
|||
|
||||
$profilePhoto = $request->file('image');
|
||||
$pageName = $request->littlelink_name;
|
||||
$pageDescription = $request->pageDescription;
|
||||
|
||||
// Strip HTML tags except for allowed tags
|
||||
$pageDescription = strip_tags($pageDescription, '<a><p><strong><i><ul><ol><li><blockquote><h2><h3><h4>');
|
||||
|
||||
// Sanitize attributes and remove JavaScript code
|
||||
if (!empty($pageDescription)) {
|
||||
$document = new DOMDocument();
|
||||
$document->loadHTML($pageDescription, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||
|
||||
// Find all elements that have attributes
|
||||
$elements = $document->getElementsByTagName('*');
|
||||
foreach ($elements as $element) {
|
||||
// Check each attribute of the element
|
||||
foreach ($element->attributes as $attribute) {
|
||||
$attributeName = $attribute->nodeName;
|
||||
|
||||
// Remove attributes that contain "on" followed by an event name
|
||||
if (strpos($attributeName, 'on') === 0) {
|
||||
$element->removeAttribute($attributeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the sanitized HTML back
|
||||
$pageDescription = $document->saveHTML();
|
||||
}
|
||||
|
||||
$pageDescription = strip_tags($request->pageDescription,'<a><p><strong><i><ul><ol><li><blockquote><h2><h3><h4>');
|
||||
$pageDescription = preg_replace("/<a([^>]*)>/i", "<a $1 rel=\"noopener noreferrer nofollow\">", $pageDescription);
|
||||
$name = $request->name;
|
||||
$checkmark = $request->checkmark;
|
||||
$sharebtn = $request->sharebtn;
|
||||
|
@ -756,7 +729,7 @@ class UserController extends Controller
|
|||
User::where('id', $userId)->update(['littlelink_name' => $pageName, 'littlelink_description' => $pageDescription, 'name' => $name]);
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$profilePhoto->move(base_path('assets/img'), $userId . ".png");
|
||||
$profilePhoto->move(base_path('assets/img'), $userId . '_' . time() . ".png");
|
||||
}
|
||||
|
||||
if($checkmark == "on"){
|
||||
|
@ -793,7 +766,7 @@ class UserController extends Controller
|
|||
}}
|
||||
if(file_exists(base_path('assets/img/background-img/').$pathinfo)){File::delete(base_path('assets/img/background-img/').$pathinfo);}
|
||||
|
||||
$customBackground->move(base_path('assets/img/background-img/'), $userId.".".$request->file('image')->extension());
|
||||
$customBackground->move(base_path('assets/img/background-img/'), $userId . '_' . time() . "." . $request->file('image')->extension());
|
||||
}
|
||||
|
||||
return Redirect('/studio/theme');
|
||||
|
|
Loading…
Reference in New Issue