XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
css.php
1<?php
2
3// The next line is special fix for IE6.
4session_cache_limiter('private_no_expire');
5
6define('_LEGACY_ALLOW_ACCESS_FROM_ANY_ADMINS_', true);
7
8require_once '../../../mainfile.php';
9$root =& XCube_Root::getSingleton();
10unset($root->mContext->mXoopsModule);
11
12//
13// @Todo Why does this file know Legacy_RenderSystem?
14//
15
16function Legacy_modifier_css_theme($string)
17{
18 $infoArr = Legacy_get_override_file($string, null, true);
19
20 // XCL 2.3.x
21 if (!empty($infoArr['theme']) && !empty($infoArr['dirname'])) {
22 return XOOPS_THEME_URL . '/' . $infoArr['theme'] . '/templates/' . $infoArr['dirname'] . '/' . $string;
23 }
24
25 if (!empty($infoArr['theme']) && !empty($infoArr['dirname'])) {
26 return XOOPS_THEME_URL . '/' . $infoArr['theme'] . '/modules/' . $infoArr['dirname'] . '/' . $string;
27 }
28
29 if (!empty($infoArr['theme'])) {
30 return XOOPS_THEME_URL . '/' . $infoArr['theme'] . '/' . $string;
31 }
32
33 if (!empty($infoArr['dirname'])) {
34 return XOOPS_MODULE_URL . '/' . $infoArr['dirname'] . '/admin/templates/' . $string;
35 }
36
37 return LEGACY_ADMIN_RENDER_FALLBACK_URL . '/' . $string;
38}
39
40$theme = isset($_GET['theme']) ? trim($_GET['theme']) : null;
41$dirname = isset($_GET['dirname']) ? trim($_GET['dirname']) : null;
42$_GET['file'] ??= 'style.css'; // XCL @gigamaster use null coalescing operator $_GET['file'] = isset($_GET['file']) ? $_GET['file'] : 'style.css';
43$file = 'stylesheets/' . trim(@$_GET['file']);
44
45// XCl 'strpos($theme, '..') !== false' is used instead to save memory
46if (strpos($theme, '..') !== false || strpos($dirname, '..') !== false || strpos($file, '..') !== false) {
47 exit();
48}
49require_once XOOPS_ROOT_PATH.'/modules/legacyRender/kernel/Legacy_AdminRenderSystem.class.php';
50
51$smarty =new Legacy_AdminSmarty();
52$smarty->register_modifier('theme', 'Legacy_modifier_css_theme');
53$smarty->register_function('stylesheet', 'Legacy_function_stylesheet');
54
55 //
56 // TODO Emergency WORK AROUND for compile cache problem.
57 //
58 $smarty->force_compile = true;
59
60 if (null !== $theme && null !== $dirname) {
61 //$path = XOOPS_THEME_PATH . "/{$theme}/modules/{$dirname}";
63 // XCL path : theme/templates/dirname
64 $path = XOOPS_THEME_PATH . "/{$theme}/templates/{$dirname}";
65 } elseif (null !== $theme) {
66 $path = XOOPS_THEME_PATH . '/' . $theme;
67 } elseif (null !== $dirname) {
68 $path = XOOPS_MODULE_PATH . "/{$dirname}/admin/templates";
69 } else {
70 $path = LEGACY_ADMIN_RENDER_FALLBACK_PATH;
71 }
72
73 $smarty->template_dir = $path;
74 $smarty->setModulePrefix('_css_' . $theme);
75
76 $result = '';
77 if (is_file($path . '/' . $file)) {
78 $result = $smarty->fetch('file:' . $file);
79 }
80
81header('Content-Type:text/css; charset='._CHARSET);
82echo $result;