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 | namespace MeestorHok\Blue; |
||
4 | |||
5 | use Artesaos\SEOTools\Facades\SEOTools as SEOTools; |
||
6 | use Request; |
||
7 | use File; |
||
8 | use MeestorHok\Blue\Site; |
||
9 | |||
10 | class SEOGenerator |
||
11 | { |
||
12 | public $defaults; |
||
13 | |||
14 | public function __construct () { |
||
15 | $this->defaults = [ |
||
16 | 'title' => 'Home', |
||
17 | 'title-spacer' => ' – ', |
||
18 | 'title-description' => 'Laravel Blue', |
||
19 | 'keywords' => array_collapse([['home'], ['laravel', 'blue', 'cms', 'meestorhok']]), |
||
20 | 'description' => 'This amazing site was created by Laravel Blue!', |
||
21 | 'images' => [], |
||
22 | 'twitter' => '@BlueCMS', |
||
23 | 'copyright' => '© 2016 Laravel Blue', |
||
24 | 'robots' => 'index,follow', |
||
25 | 'colors' => [ |
||
26 | 'safari_pinned' => '#151e4f', |
||
27 | 'ms_tile' => '#ffffff', |
||
28 | 'theme' => '#151e4f' |
||
29 | ] |
||
30 | ]; |
||
31 | } |
||
32 | |||
33 | public function generateSEO (array $page) |
||
34 | { |
||
35 | SEOTools::metatags() |
||
36 | ->setTitleDefault($page['title-description']) |
||
37 | ->setTitleSeparator($page['title-spacer']) |
||
38 | ->setTitle($page['title']) |
||
39 | ->setDescription($page['description']) |
||
40 | ->setCanonical(Request::url()) |
||
41 | ->addMeta('copyright', $page['copyright']) |
||
42 | ->addMeta('robots', $page['robots']) |
||
43 | ->addMeta('HandheldFriendly', 'True') |
||
44 | ->addMeta('MobileOptimized', '320') |
||
45 | ->addMeta('X-UA-Compatible', 'IE=edge', 'http-equiv') |
||
46 | ->addMeta('viewport', 'width=device-width, initial-scale=1, shrink-to-fit=no'); |
||
47 | SEOTools::opengraph() |
||
48 | ->setTitle($page['title'].$page['title-spacer'].$page['title-description']) |
||
49 | ->setDescription($page['description']) |
||
50 | ->setUrl(Request::url()) |
||
51 | ->addProperty('locale', 'en_US') |
||
52 | ->addProperty('type', 'website'); |
||
53 | SEOTools::twitter() |
||
54 | ->setSite($page['twitter']) |
||
55 | ->setTitle($page['title'].$page['title-spacer'].$page['title-description']) |
||
56 | ->setDescription($page['description']) |
||
57 | ->setType('summary') |
||
58 | ->setUrl(Request::url()); |
||
59 | foreach ($page['images'] as $image) { |
||
60 | SEOTools::opengraph()->addImage(asset($image['uri'])); |
||
61 | SEOTools::twitter()->addImage(asset($image['uri'])); |
||
62 | } |
||
63 | foreach ($page['keywords'] as $keyword) { |
||
64 | SEOTools::metatags()->addKeyword($keyword); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | public function make (array $details, $view = null) |
||
69 | { |
||
70 | $this->defaults = array_replace($this->defaults, $details); |
||
71 | |||
72 | $this->generateSEO($this->defaults); |
||
73 | |||
74 | if (!is_null($view)) { |
||
75 | return view($view); |
||
76 | } |
||
77 | } |
||
78 | |||
79 | public function get () |
||
80 | { |
||
81 | return (Site::first()->is_public_site) ? str_replace(PHP_EOL, '', SEOTools::generate()) . $this->getFavicons() : '<meta name="robots" content="noindex,nofollow">'.$this->getFavicons(); |
||
82 | } |
||
83 | |||
84 | public function generateFavicons ($dir = '') |
||
85 | { |
||
86 | $colors = $this->defaults['colors']; |
||
87 | return |
||
88 | View Code Duplication | insert_if_exists (['60x60', '72x72', '114x114', '120x120', '152x152', '180x180'], function ($insert) use ($dir) { |
|
0 ignored issues
–
show
|
|||
89 | return '<link rel="apple-touch-icon" sizes="' . $insert . '" href="' . asset($dir . '/apple-touch-icon-' . $insert . '.png').'">'; |
||
90 | }, function ($insert) use ($dir) { |
||
91 | return File::exists(public_path($dir.'/apple-touch-icon-'.$insert.'.png')); |
||
92 | }) . |
||
93 | View Code Duplication | insert_if_exists (['16x16', '32x32', '96x96', '194x194'], function ($insert) use ($dir) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
94 | return '<link rel="icon" type="image/png" href="' . asset($dir . '/favicon-' . $insert . '.png').'" sizes="'.$insert.'">'; |
||
95 | }, function ($insert) use ($dir) { |
||
96 | return File::exists(public_path($dir.'/favicon-'.$insert.'.png')); |
||
97 | }) . |
||
98 | View Code Duplication | insert_if_exists (['192x192'], function ($insert) use ($dir) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
99 | return '<link rel="icon" type="image/png" href="' . asset($dir . '/android-chrome-' . $insert . '.png').'" sizes="'.$insert.'">'; |
||
100 | }, function ($insert) use ($dir) { |
||
101 | return File::exists(public_path($dir.'/android-chrome-'.$insert.'.png')); |
||
102 | }) . |
||
103 | insert_if_exists ($dir.'/manifest.json', function ($insert) { |
||
104 | return '<link rel="manifest" href="' . asset($insert) . '">'; |
||
105 | }, function ($insert) { |
||
106 | return File::exists(public_path($insert)); |
||
107 | }) . |
||
108 | insert_if_exists ($dir.'/safari-pinned-tab.svg', function ($insert) use ($colors) { |
||
109 | return '<link rel="mask-icon" href="'.asset($insert).'" color="' . insert_if_exists($colors['safari_pinned']) . '">'; |
||
110 | }, function ($insert) { |
||
111 | return File::exists(public_path($insert)); |
||
112 | }) . |
||
113 | insert_if_exists ($dir.'/favicon.ico', function ($insert) { |
||
114 | return '<link rel="shortcut icon" href="'.asset($insert).'">'; |
||
115 | }, function ($insert) { |
||
116 | return File::exists(public_path($insert)); |
||
117 | }) . |
||
118 | insert_if_exists ($dir.'/mstile-144x144.png', function ($insert) { |
||
119 | return '<meta name="msapplication-TileImage" content="'.asset($insert).'">'; |
||
120 | }, function ($insert) { |
||
121 | return File::exists(public_path($insert)); |
||
122 | }) . |
||
123 | insert_if_exists ($dir.'/browserconfig.xml', function ($insert) { |
||
124 | return '<meta name="msapplication-config" content="'.asset($insert).'">'; |
||
125 | }, function ($insert) { |
||
126 | return File::exists(public_path($insert)); |
||
127 | }) . |
||
128 | insert_if_exists ($colors['ms_tile'], function ($insert) { |
||
129 | return '<meta name="msapplication-TileColor" content="'.$insert.'">'; |
||
130 | }) . |
||
131 | insert_if_exists ($colors['theme'], function ($insert) { |
||
132 | return '<meta name="theme-color" content="'.$insert.'">'; |
||
133 | }); |
||
134 | } |
||
135 | |||
136 | public function getFavicons () |
||
137 | { |
||
138 | $site = Site::first(); |
||
139 | if (is_null($site)) { |
||
140 | return $this->generateFavicons('/blue/img/icons'); |
||
141 | } |
||
142 | return $site->favicons; |
||
143 | } |
||
144 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.