forked from mybb/mybb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
css.php
78 lines (62 loc) · 1.44 KB
/
css.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
/**
* MyBB 1.8
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/about/license
*
*/
define("IN_MYBB", 1);
define("NO_ONLINE", 1);
define('THIS_SCRIPT', 'css.php');
require_once "./inc/init.php";
require_once MYBB_ROOT . $config['admin_dir'] . '/inc/functions_themes.php';
$stylesheets = $mybb->get_input('stylesheet', MyBB::INPUT_ARRAY);
if(!empty($stylesheets))
{
$stylesheet_list = implode(', ', array_map('intval', $stylesheets));
$content = '';
$prefix = TABLE_PREFIX;
switch($db->type)
{
case 'pgsql':
case 'sqlite':
$sql = <<<SQL
SELECT stylesheet FROM {$prefix}themestylesheets
WHERE sid IN ({$stylesheet_list})
ORDER BY CASE sid
SQL;
$i = 0;
foreach($stylesheets as $sid)
{
$sid = (int) $sid;
$sql .= "WHEN {$sid} THEN {$i}\n";
$i++;
}
$sql .= 'END;';
break;
default:
$sql = <<<SQL
SELECT stylesheet FROM {$prefix}themestylesheets
WHERE sid IN ({$stylesheet_list})
ORDER BY FIELD(sid, {$stylesheet_list});
SQL;
break;
}
$query = $db->query($sql);
while($row = $db->fetch_array($query))
{
$stylesheet = $row['stylesheet'];
$plugins->run_hooks('css_start', $stylesheet);
if(!empty($mybb->settings['minifycss']))
{
$stylesheet = minify_stylesheet($stylesheet);
}
$plugins->run_hooks('css_end', $stylesheet);
$content .= $stylesheet;
}
header('Content-type: text/css');
echo $content;
}
exit;