|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* View app controller |
|
5
|
|
|
* |
|
6
|
|
|
* @author Alexey Krupskiy <[email protected]> |
|
7
|
|
|
* @link http://inji.ru/ |
|
8
|
|
|
* @copyright 2015 Alexey Krupskiy |
|
9
|
|
|
* @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @property View $module |
|
14
|
|
|
*/ |
|
15
|
|
|
class ViewController extends Controller { |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
public function editorcssAction() { |
|
18
|
|
|
if (file_exists($this->view->template->path . '/css/editor.css')) { |
|
19
|
|
|
\Inji\Tools::redirect('/static/templates/' . $this->view->template->name . '/css/editor.css'); |
|
20
|
|
|
} else { |
|
21
|
|
|
header("Content-type: text/css"); |
|
22
|
|
|
exit(); |
|
|
|
|
|
|
23
|
|
|
} |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function checkStaticUpdatesAction($hash = '', $timeHash = '') { |
|
27
|
|
|
if (is_string($hash) && !empty($_GET['files'])) { |
|
28
|
|
|
$hashFiles = json_encode($_GET['files']); |
|
29
|
|
|
if (!empty($this->module->template->config['staticUpdaterSalt'])) { |
|
30
|
|
|
$hashFiles .= $this->module->template->config['staticUpdaterSalt']; |
|
31
|
|
|
} |
|
32
|
|
|
$hashFiles = md5($hashFiles); |
|
33
|
|
|
if ($hash !== $hashFiles) { |
|
34
|
|
|
exit(); |
|
|
|
|
|
|
35
|
|
|
} |
|
36
|
|
|
$timeStr = ''; |
|
37
|
|
|
$urls = []; |
|
38
|
|
|
foreach ($_GET['files'] as $href) { |
|
39
|
|
|
$path = App::$cur->staticLoader->parsePath($href); |
|
40
|
|
|
if (file_exists($path)) { |
|
41
|
|
|
$urls[$href] = $path; |
|
42
|
|
|
$timeStr .= filemtime($path); |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
$timeMd5 = md5($timeStr); |
|
47
|
|
|
if ($timeHash === $timeMd5) { |
|
48
|
|
|
exit(); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
$cacheDir = Cache::getDir('static'); |
|
|
|
|
|
|
51
|
|
|
$cssAll = ''; |
|
52
|
|
|
if (!file_exists($cacheDir . 'all' . $timeMd5 . '.css')) { |
|
53
|
|
|
foreach ($urls as $primaryUrl => $url) { |
|
54
|
|
|
$source = file_get_contents($url); |
|
55
|
|
|
$rootPath = substr($primaryUrl, 0, strrpos($primaryUrl, '/')); |
|
56
|
|
|
$levelUpPath = substr($rootPath, 0, strrpos($rootPath, '/')); |
|
57
|
|
|
$source = preg_replace('!url\((\'?"?)[\.]{2}!isU', 'url($1' . $levelUpPath, $source); |
|
58
|
|
|
$source = preg_replace('!url\((\'?"?)[\.]{1}!isU', 'url($1' . $rootPath, $source); |
|
59
|
|
|
$source = preg_replace('#url\(([\'"]){1}(?!http|https|/|data\:)([^/])#isU', 'url($1' . $rootPath . '/$2', $source); |
|
60
|
|
|
$source = preg_replace('#url\((?!http|https|/|data\:|\'|")([^/])#isU', 'url(' . $rootPath . '/$1$2', $source); |
|
61
|
|
|
$cssAll .= $source . "\n"; |
|
62
|
|
|
} |
|
63
|
|
|
file_put_contents($cacheDir . 'all' . $timeMd5 . '.css', $cssAll); |
|
64
|
|
|
} |
|
65
|
|
|
echo json_encode(['path' => '/' . $cacheDir . 'all' . $timeMd5 . '.css', 'timeHash' => $timeMd5]); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function templateProgramAction() { |
|
71
|
|
|
$args = func_get_args(); |
|
72
|
|
|
if ($args) { |
|
|
|
|
|
|
73
|
|
|
$moduleName = ucfirst($args[0]); |
|
74
|
|
|
$params = array_slice($args, 1); |
|
75
|
|
|
if (file_exists($this->view->template->path . '/program/modules/' . $moduleName . '/' . $moduleName . '.php')) { |
|
76
|
|
|
include_once $this->view->template->path . '/program/modules/' . $moduleName . '/' . $moduleName . '.php'; |
|
77
|
|
|
$module = new $moduleName($this->module->app); |
|
78
|
|
|
$cotroller = $module->findController(); |
|
79
|
|
|
$cotroller->params = $params; |
|
80
|
|
|
$cotroller->run(); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths