-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
78 lines (67 loc) · 2.9 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
session_start();
/*
$rq = strpos($_SERVER['REQUEST_URI'],'?');
$rq = $rq==FALSE ? $_SERVER['REQUEST_URI'] : substr($_SERVER['REQUEST_URI'],0,$rq);
$rf = strripos($rq,'/');
$rq = dirname(__FILE__).substr($rq,0,$rf).'/index.php';
if (is_file($rq)){
include($rq);
exit(0);
}
print $rq;
*/
include 'core/core.php';
$core = new Core;
// Åñëè çàïðàøèâàþò css ôàéë, òî ñìîòðèì - íåò ëè òàêîãî æå, íî ñ ðàñøèðåíèåì less, êîìïèëèì åãî è âûäàåì
$fpath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$fname = basename($fpath);
$fpath = dirname($fpath);
if (substr($fname,strlen($fname)-4)=='.css'){
$core->run(TRUE);
$lessfile = $core->pathes['SITE_PATH'].$fpath.'/'.str_replace('.css','.less',$fname);
if (is_file($lessfile)){
$less = new lessc;
$ret=$less->compileFile($lessfile);
header('Content-Type: text/css;charset=UTF-8');
print minify($ret);
} else
header('HTTP/1.0 404 Not Found');
exit(0);
}
$core->run();
$call_default=TRUE;
if (is_file($core->pathes['SITE_PATH'].'themes/'.$core->pathes['THEME'].'/index.php'))
if (include($core->pathes['SITE_PATH'].'themes/'.$core->pathes['THEME'].'/index.php'))
$call_default=FALSE;
// Åñëè ôàéë èíèöèàëèçàöèè òåìû ÷òî-âåðíóë - òî ôàéë èíèöèàëèçàöèè òåìû ïî óìîë÷àíèþ íå âûçûâàåì
if ($call_default && is_file($core->pathes['SITE_PATH'].'themes/default/index.php'))
include($core->pathes['SITE_PATH'].'themes/default/index.php');
// Åñëè äëÿ ýòîãî ïóòè íåò ñâîåé ñòðàíèöû
if (!$core->pathes['EXEC_PAGE_FILE'] || !is_file($core->pathes['EXEC_PAGE_FILE'])) {
if (is_file($core->pathes['SITE_PATH'].'themes/'.$core->pathes['THEME'].'/templates/404.php'))
include($core->pathes['SITE_PATH'].'themes/'.$core->pathes['THEME'].'/templates/404.php');
else
if (is_file($core->pathes['SITE_PATH'].'themes/default/templates/404.php'))
include($core->pathes['SITE_PATH'].'themes/default/templates/404.php');
$core->signal('after_process');
$core->signal('last_call');
exit(0);
}
ob_start();
$template = include($core->pathes['EXEC_PAGE_FILE']) ;
$content = ob_get_clean();
// Åñëè èñïîëíÿåìàÿ ñòðàíèöà íå âåðíóëà èìÿ øàáëîíà
if (!$template) $template = 'default';
// Èùåì è âûïîëíÿåì òðåáóåìûé øàáëîí
if (is_file($core->pathes['SITE_PATH'].'themes/'.$core->pathes['THEME'].'/templates/'.$template.'.tpl.php'))
include($core->pathes['SITE_PATH'].'themes/'.$core->pathes['THEME'].'/templates/'.$template.'.tpl.php');
elseif (is_file($core->pathes['SITE_PATH'].'themes/default/templates/'.$template.'.tpl.php'))
include($core->pathes['SITE_PATH'].'themes/default/templates/'.$template.'.tpl.php');
else
include($core->pathes['SITE_PATH'].'themes/default/templates/default.tpl.php');
$testvar = 'testvar';
$core->signal_name = 'last_call';
include $core->pathes['SITE_PATH'].'core/signal.php';
// $core->signal('last_call');
exit(0);