diff --git a/app/Functions/functions.php b/app/Functions/functions.php
index a5cdc7c..6e6350f 100644
--- a/app/Functions/functions.php
+++ b/app/Functions/functions.php
@@ -150,4 +150,46 @@ function strip_tags_except_allowed_protocols($str) {
}
return $str;
+}
+
+if(!function_exists('setBlockAssetContext')) {
+ function setBlockAssetContext($type = null) {
+ static $currentType = null;
+ if ($type !== null) {
+ $currentType = $type;
+ }
+ return $currentType;
+ }
+}
+
+// Get custom block assets
+if(!function_exists('block_asset')) {
+ function block_asset($file) {
+ $type = setBlockAssetContext(); // Retrieve the current type context
+ return url("block-asset/$type?asset=$file");
+ }
+}
+
+if(!function_exists('get_block_file_contents')) {
+ function get_block_file_contents($file) {
+ $type = setBlockAssetContext(); // Retrieve the current type context
+ return file_get_contents(base_path("blocks/$type/$file"));
+ }
+}
+
+function block_text_translation_check($text) {
+ if (empty($text)) {
+ return false;
+ }
+ $translate = __("messages.$text");
+ return $translate === "messages.$text" ? true : false;
+}
+
+function block_text($text) {
+ $translate = __("messages.$text");
+ return $translate === "messages.$text" ? $text : $translate;
+}
+
+function bt($text) {
+ return block_text($text);
}
\ No newline at end of file
diff --git a/app/Http/Controllers/LinkTypeViewController.php b/app/Http/Controllers/LinkTypeViewController.php
index b182ccc..994c0de 100644
--- a/app/Http/Controllers/LinkTypeViewController.php
+++ b/app/Http/Controllers/LinkTypeViewController.php
@@ -12,17 +12,16 @@ class LinkTypeViewController extends Controller
public function getParamForm($typename, $linkId = 0)
{
$data = [
- 'link_title' => '',
- 'link_url' => '',
+ 'title' => '',
+ 'link' => '',
'button_id' => 0,
'buttons' => [],
];
if ($linkId) {
$link = Link::find($linkId);
- $typename = $link->type ?? 'predefined';
- $data['link_title'] = $link->title;
- $data['link_url'] = $link->link;
+ $data['title'] = $link->title;
+ $data['link'] = $link->link;
if (Route::currentRouteName() != 'showButtons') {
$data['button_id'] = $link->button_id;
}
@@ -52,4 +51,32 @@ class LinkTypeViewController extends Controller
return view($typename . '.form', $data);
}
+
+ public function blockAsset(Request $request, $type)
+ {
+ $asset = $request->query('asset');
+
+ // Prevent directory traversal in $type
+ if (preg_match('/\.\.|\/|\\\\/', $type)) {
+ abort(403, 'Unauthorized action.');
+ }
+
+ // Define allowed file extensions
+ $allowedExtensions = ['js', 'css', 'img', 'svg', 'gif', 'jpg', 'jpeg', 'png', 'mp4', 'mp3'];
+
+ $extension = strtolower(pathinfo($asset, PATHINFO_EXTENSION));
+ if (!in_array($extension, $allowedExtensions)) {
+ return response('File type not allowed', Response::HTTP_FORBIDDEN);
+ }
+
+ $basePath = realpath(base_path("blocks/$type"));
+
+ $fullPath = realpath(base_path("blocks/$type/$asset"));
+
+ if (!$fullPath || !file_exists($fullPath) || strpos($fullPath, $basePath) !== 0) {
+ return response('File not found', Response::HTTP_NOT_FOUND);
+ }
+
+ return response()->file($fullPath);
+ }
}
\ No newline at end of file
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index e1745c6..009bd78 100755
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -176,7 +176,7 @@ class UserController extends Controller
'title' => "Predefined Site",
];
- $data['typename'] = $link->type ?? 'predefined';
+ $data['typename'] = $linkData->type ?? 'predefined';
return view('studio/edit-link', $data);
}
@@ -209,6 +209,7 @@ class UserController extends Controller
if (file_exists($linkTypePath)) {
include $linkTypePath;
$linkData = handleLinkType($request, $linkType);
+ $linkData['button_id'] = $linkData['button_id'] ?? 1; // Set 'button_id' unless overwritten by handleLinkType
$linkData['type'] = $linkType->typename; // Ensure 'type' is included in $linkData
} else {
abort(404, "Link type logic not found.");
@@ -384,7 +385,7 @@ class UserController extends Controller
$userId = Auth::user()->id;
$data['pagePage'] = 10;
- $data['links'] = Link::select('id', 'link', 'title', 'order', 'click_number', 'up_link', 'links.button_id')->where('user_id', $userId)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->paginate(99999);
+ $data['links'] = Link::select()->where('user_id', $userId)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->paginate(99999);
return view('studio/links', $data);
}
diff --git a/blocks/email/config.yml b/blocks/email/config.yml
index c1ba023..3e6a04d 100644
--- a/blocks/email/config.yml
+++ b/blocks/email/config.yml
@@ -1,5 +1,4 @@
id: 6
typename: email
-title: "Custom Link"
icon: "bi bi-envelope-fill"
custom_html: false
\ No newline at end of file
diff --git a/blocks/email/form.blade.php b/blocks/email/form.blade.php
index 6a5c8ba..ee0b1a7 100644
--- a/blocks/email/form.blade.php
+++ b/blocks/email/form.blade.php
@@ -3,11 +3,11 @@
-
+
{{__('messages.Leave blank for default title')}}
-
+
{{__('messages.Enter your E-Mail')}}