@@ -116,6 +116,12 @@ private function loadEditorData() {
116
116
return $ data ;
117
117
}
118
118
119
+ /*
120
+ Load theme sections, components and inputs
121
+ */
122
+ private function loadEditorAssets () {
123
+ }
124
+
119
125
/*
120
126
Load theme sections, components and inputs
121
127
*/
@@ -169,14 +175,14 @@ function index() {
169
175
$ posts = [];
170
176
171
177
foreach ($ results ['post ' ] as $ post ) {
172
- $ slug = $ post ['slug ' ];
178
+ $ slug = htmlspecialchars ( $ post ['slug ' ]) ;
173
179
$ url = url ('content/page/index ' ,['slug ' => $ slug , 'post_id ' => $ post ['post_id ' ]]);
174
180
175
- $ posts [$ slug ] = [
176
- 'name ' => $ slug ,
181
+ $ posts [" $ slug-page " ] = [
182
+ 'name ' => " $ slug-page " ,
177
183
'file ' => $ post ['template ' ] ? $ post ['template ' ] : 'content/page.html ' ,
178
184
'url ' => $ url . ($ theme ? '?theme= ' . $ theme : '' ),
179
- 'title ' => $ post ['name ' ],
185
+ 'title ' => htmlspecialchars ( $ post ['name ' ]) ,
180
186
'post_id ' => $ post ['post_id ' ],
181
187
'folder ' => '' ,
182
188
'className ' => 'page ' ,
@@ -197,18 +203,75 @@ function index() {
197
203
$ className = 'url ' ;
198
204
$ current_page = [];
199
205
206
+ //check if url and template is relative
207
+ if (strpos ($ url , '// ' ) !== false && strpos ($ template , '.. ' ) !== false ) {
208
+ $ this ->notFound ();
209
+
210
+ exit ();
211
+ }
212
+
213
+ //check if the url has extension and is a html file and exists in the theme folder
214
+ if (strpos ($ url , '. ' ) !== false ) {
215
+ if (substr_compare ($ url , '.html ' , -5 ,5 ) === 0 ) {
216
+ if (! file_exists (DIR_THEMES . $ theme . DS . $ url )) {
217
+ $ this ->notFound ();
218
+
219
+ exit ();
220
+ }
221
+ } else {
222
+ $ this ->notFound ();
223
+
224
+ exit ();
225
+ }
226
+ }
227
+
228
+ //check if template belongs to theme and is a html file
229
+ if (substr_compare ($ template , '.html ' , -5 ,5 ) === 0 ) {
230
+ if (! file_exists (DIR_THEMES . $ theme . DS . $ template )) {
231
+ $ this ->notFound ();
232
+
233
+ exit ();
234
+ }
235
+ } else {
236
+ $ this ->notFound ();
237
+
238
+ exit ();
239
+ }
240
+
200
241
if ($ route && isset ($ route ['module ' ])) {
201
242
switch ($ route ['module ' ]) {
202
243
case 'product/product/index ' :
203
244
$ className = 'product ' ;
204
- $ current_page ['product_id ' ] = $ route ['product_id ' ];
245
+
246
+ if (isset ($ route ['product_id ' ])) {
247
+ $ current_page ['product_id ' ] = $ route ['product_id ' ];
248
+ } else {
249
+ if (isset ($ this ->request ->get ['product_id ' ])) {
250
+ $ current_page ['product_id ' ] = $ this ->request ->get ['product_id ' ];
251
+ } else {
252
+ if (isset ($ route ['slug ' ])) {
253
+ $ current_page ['slug ' ] = htmlspecialchars ($ route ['slug ' ]);
254
+ }
255
+ }
256
+ }
205
257
206
258
break ;
207
259
208
260
case 'content/post/index ' :
209
261
case 'content/page/index ' :
210
262
$ className = 'page ' ;
211
- $ current_page ['post_id ' ] = $ route ['post_id ' ];
263
+
264
+ if (isset ($ route ['post_id ' ])) {
265
+ $ current_page ['post_id ' ] = $ route ['post_id ' ];
266
+ } else {
267
+ if (isset ($ this ->request ->get ['post_id ' ])) {
268
+ $ current_page ['post_id ' ] = $ this ->request ->get ['post_id ' ];
269
+ } else {
270
+ if (isset ($ route ['slug ' ])) {
271
+ $ current_page ['slug ' ] = htmlspecialchars ($ route ['slug ' ]);
272
+ }
273
+ }
274
+ }
212
275
213
276
break ;
214
277
}
@@ -561,14 +624,15 @@ function save() {
561
624
'template ' => $ file ,
562
625
'type ' => $ type ,
563
626
'image ' => 'posts/2.jpg ' , //'placeholder.svg'
564
- 'post_content ' => [[
565
- 'slug ' => $ slug ,
566
- 'name ' => $ name ,
567
- 'content ' => $ content ,
568
- 'language_id ' => $ this ->global ['language_id ' ],
569
- ]],
570
627
] + $ this ->global ,
571
- 'site_id ' => [$ this ->global ['site_id ' ]], ] + $ this ->global );
628
+ 'post_content ' => [[
629
+ 'slug ' => $ slug ,
630
+ 'name ' => $ name ,
631
+ 'content ' => $ content ,
632
+ 'language_id ' => $ this ->global ['language_id ' ],
633
+ ]],
634
+ 'site_id ' => [$ this ->global ['site_id ' ]],
635
+ ] + $ this ->global );
572
636
573
637
if ($ result ['post ' ]) {
574
638
$ post_id = $ result ['post ' ];
@@ -591,14 +655,14 @@ function save() {
591
655
'status ' => 1 , //active
592
656
'template ' => $ file ,
593
657
'price ' => $ price ,
594
- 'product_content ' => [[
595
- 'slug ' => $ slug ,
596
- 'name ' => $ name ,
597
- 'name ' => $ name ,
598
- 'content ' => $ content ,
599
- 'language_id ' => $ this ->global ['language_id ' ],
600
- ]],
601
658
] + $ this ->global ,
659
+ 'product_content ' => [[
660
+ 'slug ' => $ slug ,
661
+ 'name ' => $ name ,
662
+ 'name ' => $ name ,
663
+ 'content ' => $ content ,
664
+ 'language_id ' => $ this ->global ['language_id ' ],
665
+ ]],
602
666
'site_id ' => [$ this ->global ['site_id ' ]], ] + $ this ->global );
603
667
604
668
if ($ result ['product ' ]) {
0 commit comments