Zeile 19 | Zeile 19 |
---|
{ global $mybb, $db;
|
{ global $mybb, $db;
|
require_once MYBB_ROOT."inc/class_xml.php";
$parser = new XMLParser($xml);
| $parser = create_xml_parser($xml);
|
$tree = $parser->get_tree();
|
$tree = $parser->get_tree();
|
|
|
if(!is_array($tree) || !is_array($tree['theme'])) { return -1;
| if(!is_array($tree) || !is_array($tree['theme'])) { return -1;
|
Zeile 44 | Zeile 42 |
---|
foreach($values as $property => $value) { if(is_array($value))
|
foreach($values as $property => $value) { if(is_array($value))
|
{
| {
|
$property = str_replace('_', ':', $property);
$css_120 .= "}\n{$name} {$property} {\n";
| $property = str_replace('_', ':', $property);
$css_120 .= "}\n{$name} {$property} {\n";
|
Zeile 110 | Zeile 108 |
---|
// Bad data? continue; }
|
// Bad data? continue; }
|
|
|
$value['value'] = $data; }
| $value['value'] = $data; }
|
Zeile 123 | Zeile 121 |
---|
$name = $theme['attributes']['name']; } else
|
$name = $theme['attributes']['name']; } else
|
{
| {
|
$name = $mybb->input['name']; } $version = $theme['attributes']['version'];
$query = $db->simple_select("themes", "tid", "name='".$db->escape_string($name)."'", array("limit" => 1)); $existingtheme = $db->fetch_array($query);
|
$name = $mybb->input['name']; } $version = $theme['attributes']['version'];
$query = $db->simple_select("themes", "tid", "name='".$db->escape_string($name)."'", array("limit" => 1)); $existingtheme = $db->fetch_array($query);
|
if(!empty($options['force_name_check']) && $existingtheme['tid'])
| if(!empty($options['force_name_check']) && !empty($existingtheme['tid']))
|
{ return -3;
|
{ return -3;
|
} else if($existingtheme['tid'])
| } else if(!empty($existingtheme['tid']))
|
{ $options['tid'] = $existingtheme['tid'];
|
{ $options['tid'] = $existingtheme['tid'];
|
}
| }
|
if($mybb->version_code != $version && $options['version_compat'] != 1)
|
if($mybb->version_code != $version && $options['version_compat'] != 1)
|
{
| {
|
return -2; }
|
return -2; }
|
|
|
// Do we have any templates to insert? if(!empty($theme['templates']['template']) && empty($options['no_templates']))
|
// Do we have any templates to insert? if(!empty($theme['templates']['template']) && empty($options['no_templates']))
|
{ if($options['templateset']) { $sid = $options['templateset']; } else { $sid = $db->insert_query("templatesets", array('title' => $db->escape_string($name)." Templates")); }
| {
|
$templates = $theme['templates']['template']; if(is_array($templates)) {
| $templates = $theme['templates']['template']; if(is_array($templates)) {
|
Zeile 166 | Zeile 155 |
---|
} }
|
} }
|
| // Security check
|
$security_check = false;
|
$security_check = false;
|
$templatecache = array();
| |
foreach($templates as $template)
|
foreach($templates as $template)
|
{
| {
|
if(check_template($template['value'])) { $security_check = true; break;
|
if(check_template($template['value'])) { $security_check = true; break;
|
}
| } }
if($security_check == true) { return -4; }
if(!empty($options['templateset'])) { $sid = (int)$options['templateset']; } else { $sid = $db->insert_query("templatesets", array('title' => $db->escape_string($name)." Templates")); }
$templatecache = array(); foreach($templates as $template) {
|
$templatecache[] = array( "title" => $db->escape_string($template['attributes']['name']), "template" => $db->escape_string($template['value']),
| $templatecache[] = array( "title" => $db->escape_string($template['attributes']['name']), "template" => $db->escape_string($template['value']),
|
Zeile 183 | Zeile 190 |
---|
"version" => $db->escape_string($template['attributes']['version']), "dateline" => TIME_NOW );
|
"version" => $db->escape_string($template['attributes']['version']), "dateline" => TIME_NOW );
|
}
if($security_check == true) { return -4; }
| }
|
foreach($templatecache as $template) { // PostgreSQL causes apache to stop sending content sometimes and
| foreach($templatecache as $template) { // PostgreSQL causes apache to stop sending content sometimes and
|
Zeile 201 | Zeile 203 |
---|
}
$db->insert_query("templates", $template);
|
}
$db->insert_query("templates", $template);
|
}
| }
|
$properties['templateset'] = $sid; }
| $properties['templateset'] = $sid; }
|
Zeile 222 | Zeile 224 |
---|
$db->delete_query("themestylesheets", "tid='{$options['tid']}'"); $db->update_query("themes", array("properties" => $db->escape_string(my_serialize($properties))), "tid='{$options['tid']}'"); $theme_id = $options['tid'];
|
$db->delete_query("themestylesheets", "tid='{$options['tid']}'"); $db->update_query("themes", array("properties" => $db->escape_string(my_serialize($properties))), "tid='{$options['tid']}'"); $theme_id = $options['tid'];
|
}
| }
|
// If we have any stylesheets, process them if(!empty($theme['stylesheets']['stylesheet']) && empty($options['no_stylesheets']))
| // If we have any stylesheets, process them if(!empty($theme['stylesheets']['stylesheet']) && empty($options['no_stylesheets']))
|
Zeile 240 | Zeile 242 |
---|
{ $inherited_stylesheets = my_unserialize($db->fetch_field($query, "stylesheets"));
|
{ $inherited_stylesheets = my_unserialize($db->fetch_field($query, "stylesheets"));
|
if(is_array($inherited_stylesheets['inherited']))
| if(isset($inherited_stylesheets['inherited']) && is_array($inherited_stylesheets['inherited']))
|
{ $loop = 1; foreach($inherited_stylesheets['inherited'] as $action => $stylesheets)
| { $loop = 1; foreach($inherited_stylesheets['inherited'] as $action => $stylesheets)
|
Zeile 267 | Zeile 269 |
---|
if(substr($stylesheet['attributes']['name'], -4) != ".css") { continue;
|
if(substr($stylesheet['attributes']['name'], -4) != ".css") { continue;
|
}
| }
|
if(empty($stylesheet['attributes']['lastmodified'])) {
| if(empty($stylesheet['attributes']['lastmodified'])) {
|
Zeile 333 | Zeile 335 |
---|
);
$db->update_query("themes", $updated_theme, "tid='{$theme_id}'");
|
);
$db->update_query("themes", $updated_theme, "tid='{$theme_id}'");
|
}
| }
|
update_theme_stylesheet_list($theme_id);
| update_theme_stylesheet_list($theme_id);
|
Zeile 378 | Zeile 380 |
---|
$theme_directory = "cache/themes/theme{$tid}";
if(substr($filename, -4) != ".css")
|
$theme_directory = "cache/themes/theme{$tid}";
if(substr($filename, -4) != ".css")
|
{ return false; }
| { return false; }
|
// If we're in safe mode save to the main theme folder by default if($mybb->safemode) {
| // If we're in safe mode save to the main theme folder by default if($mybb->safemode) {
|
Zeile 630 | Zeile 632 |
---|
); $properties['logo'] = parse_theme_variables($properties['logo'], $theme_vars); }
|
); $properties['logo'] = parse_theme_variables($properties['logo'], $theme_vars); }
|
|
|
$updated_theme = array(); if(!empty($stylesheets)) {
| $updated_theme = array(); if(!empty($stylesheets)) {
|
Zeile 656 | Zeile 658 |
---|
{ // Normalise line breaks $css = str_replace(array("\r\n", "\n", "\r"), "\n", $css);
|
{ // Normalise line breaks $css = str_replace(array("\r\n", "\n", "\r"), "\n", $css);
|
|
|
/** * Play with the css a little - just to ensure we can parse it *
| /** * Play with the css a little - just to ensure we can parse it *
|
Zeile 664 | Zeile 666 |
---|
* so it's parsed correctly below */ $stripped_css = preg_replace('#(?<!\\")\}#', "\n}\n", $css);
|
* so it's parsed correctly below */ $stripped_css = preg_replace('#(?<!\\")\}#', "\n}\n", $css);
|
|
|
// Fetch out classes and comments preg_match_all('#(\/\*(.|[\r\n])*?\*\/)?([a-z0-9a+\\\[\]\-\"=_:>\*\.\#\,\s\(\)\|~|@\^]+)(\s*)\{(.*?)\}\n#msi', $stripped_css, $matches, PREG_PATTERN_ORDER); $total = count($matches[1]);
|
// Fetch out classes and comments preg_match_all('#(\/\*(.|[\r\n])*?\*\/)?([a-z0-9a+\\\[\]\-\"=_:>\*\.\#\,\s\(\)\|~|@\^]+)(\s*)\{(.*?)\}\n#msi', $stripped_css, $matches, PREG_PATTERN_ORDER); $total = count($matches[1]);
|
|
|
$parsed_css = array();
|
$parsed_css = array();
|
|
|
for($i=0; $i < $total; $i++) { $name = $description = '';
| for($i=0; $i < $total; $i++) { $name = $description = '';
|
Zeile 737 | Zeile 739 |
---|
{ $select .= "<option value=\"{$id}\" selected=\"selected\">{$css_array['name']}</option>\n"; $selected = true;
|
{ $select .= "<option value=\"{$id}\" selected=\"selected\">{$css_array['name']}</option>\n"; $selected = true;
|
} else
| } else
|
{ $select .= "<option value=\"{$id}\">{$css_array['name']}</option>\n"; }
| { $select .= "<option value=\"{$id}\">{$css_array['name']}</option>\n"; }
|
Zeile 761 | Zeile 763 |
---|
}
if(!$b['name'])
|
}
if(!$b['name'])
|
{
| {
|
$b['name'] = $b['class_name']; } return strcmp($a['name'], $b['name']);
| $b['name'] = $b['class_name']; } return strcmp($a['name'], $b['name']);
|
Zeile 783 | Zeile 785 |
---|
if(!isset($css[$id])) { return false;
|
if(!isset($css[$id])) { return false;
|
}
| }
|
return parse_css_properties($css[$id]['values']); }
| return parse_css_properties($css[$id]['values']); }
|
Zeile 795 | Zeile 797 |
---|
*/ function parse_css_properties($values) {
|
*/ function parse_css_properties($values) {
|
$css_bits = array();
| $css_bits = array( 'extra' => null, );
|
if(!$values) {
| if(!$values) {
|
Zeile 828 | Zeile 832 |
---|
} return $css_bits; }
|
} return $css_bits; }
|
|
|
/** * Inserts an incoming string of CSS in to an already defined document. If the class ID is not found, the CSS is appended to the file. *
| /** * Inserts an incoming string of CSS in to an already defined document. If the class ID is not found, the CSS is appended to the file. *
|
Zeile 844 | Zeile 848 |
---|
$new_css = str_replace(array("\r\n", "\n", "\r"), "\n", $new_css);
$generated_css = '';
|
$new_css = str_replace(array("\r\n", "\n", "\r"), "\n", $new_css);
$generated_css = '';
|
|
|
// Build the new CSS properties list $new_css = explode("\n", $new_css); foreach($new_css as $css_line) { $generated_css .= "\t".trim($css_line)."\n";
|
// Build the new CSS properties list $new_css = explode("\n", $new_css); foreach($new_css as $css_line) { $generated_css .= "\t".trim($css_line)."\n";
|
}
| }
|
$parsed_css = array();
// Parse out the CSS
| $parsed_css = array();
// Parse out the CSS
|
Zeile 915 | Zeile 919 |
---|
$css = preg_replace("#{\n*#s", "{\n", $css); $css = preg_replace("#\s*\}\s*#", "\n}\n\n", $css); return $css;
|
$css = preg_replace("#{\n*#s", "{\n", $css); $css = preg_replace("#\s*\}\s*#", "\n}\n\n", $css); return $css;
|
}
/**
| }
/**
|
* @param array $stylesheet * @param int $tid *
| * @param array $stylesheet * @param int $tid *
|
Zeile 936 | Zeile 940 |
---|
if(!is_numeric($key)) { $new_stylesheet[$db->escape_string($key)] = $db->escape_string($value);
|
if(!is_numeric($key)) { $new_stylesheet[$db->escape_string($key)] = $db->escape_string($value);
|
} }
| } }
|
$sid = $db->insert_query("themestylesheets", $new_stylesheet);
return $sid;
| $sid = $db->insert_query("themestylesheets", $new_stylesheet);
return $sid;
|
Zeile 954 | Zeile 958 |
---|
function update_theme_stylesheet_list($tid, $theme = false, $update_disporders = true) { global $mybb, $db, $cache, $plugins;
|
function update_theme_stylesheet_list($tid, $theme = false, $update_disporders = true) { global $mybb, $db, $cache, $plugins;
|
|
|
$stylesheets = array();
$child_list = make_child_theme_list($tid); $parent_list = make_parent_theme_list($tid);
|
$stylesheets = array();
$child_list = make_child_theme_list($tid); $parent_list = make_parent_theme_list($tid);
|
|
|
if(!is_array($parent_list)) { return false; }
|
if(!is_array($parent_list)) { return false; }
|
|
|
$tid_list = implode(',', $parent_list);
// Get our list of stylesheets
| $tid_list = implode(',', $parent_list);
// Get our list of stylesheets
|
Zeile 979 | Zeile 983 |
---|
}
$stylesheets[$stylesheet['name']] = $stylesheet;
|
}
$stylesheets[$stylesheet['name']] = $stylesheet;
|
}
| }
|
}
$theme_stylesheets = array();
| }
$theme_stylesheets = array();
|
Zeile 991 | Zeile 995 |
---|
foreach($parent_list as $theme_id) {
|
foreach($parent_list as $theme_id) {
|
if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath']))
| if(!empty($mybb->settings['usecdn']) && !empty($mybb->settings['cdnpath']))
|
{ $cdnpath = rtrim($mybb->settings['cdnpath'], '/\\').'/'; if(file_exists($cdnpath."cache/themes/theme{$theme_id}/{$stylesheet['name']}") && filemtime( $cdnpath."cache/themes/theme{$theme_id}/{$stylesheet['name']}"
|
{ $cdnpath = rtrim($mybb->settings['cdnpath'], '/\\').'/'; if(file_exists($cdnpath."cache/themes/theme{$theme_id}/{$stylesheet['name']}") && filemtime( $cdnpath."cache/themes/theme{$theme_id}/{$stylesheet['name']}"
|
) >= $stylesheet['lastmodified'] ) { $css_url = "cache/themes/theme{$theme_id}/{$stylesheet['name']}"; break; }
| ) >= $stylesheet['lastmodified'] ) { $css_url = "cache/themes/theme{$theme_id}/{$stylesheet['name']}"; break; }
|
} else {
| } else {
|
Zeile 1015 | Zeile 1019 |
---|
} } }
|
} } }
|
|
|
if(is_object($plugins)) { $plugins->run_hooks('update_theme_stylesheet_list_set_css_url', $css_url);
| if(is_object($plugins)) { $plugins->run_hooks('update_theme_stylesheet_list_set_css_url', $css_url);
|
Zeile 1023 | Zeile 1027 |
---|
$attachedto = $stylesheet['attachedto']; if(!$attachedto)
|
$attachedto = $stylesheet['attachedto']; if(!$attachedto)
|
{
| {
|
$attachedto = "global"; } // private.php?compose,folders|usercp.php,global|global
| $attachedto = "global"; } // private.php?compose,folders|usercp.php,global|global
|
Zeile 1064 | Zeile 1068 |
---|
if($update_disporders) { if(!is_array($theme) || !$theme)
|
if($update_disporders) { if(!is_array($theme) || !$theme)
|
{
| {
|
$theme_cache = cache_themes(); $theme = $theme_cache[$tid];
|
$theme_cache = cache_themes(); $theme = $theme_cache[$tid];
|
}
| }
|
$orders = $orphaned_stylesheets = array(); $properties = $theme['properties'];
| $orders = $orphaned_stylesheets = array(); $properties = $theme['properties'];
|
Zeile 1076 | Zeile 1080 |
---|
{ $properties = my_unserialize($theme['properties']); }
|
{ $properties = my_unserialize($theme['properties']); }
|
$max_disporder = 0;
| $max_disporder = 0;
|
foreach($stylesheets as $stylesheet) {
| foreach($stylesheets as $stylesheet) {
|
Zeile 1086 | Zeile 1090 |
---|
$orphaned_stylesheets[] = $stylesheet['name']; continue; }
|
$orphaned_stylesheets[] = $stylesheet['name']; continue; }
|
|
|
if($properties['disporder'][$stylesheet['name']] > $max_disporder) { $max_disporder = $properties['disporder'][$stylesheet['name']];
| if($properties['disporder'][$stylesheet['name']] > $max_disporder) { $max_disporder = $properties['disporder'][$stylesheet['name']];
|
Zeile 1232 | Zeile 1236 |
---|
$query = $db->simple_select("themes", "*", "", array('order_by' => "pid, name")); while($theme = $db->fetch_array($query)) {
|
$query = $db->simple_select("themes", "*", "", array('order_by' => "pid, name")); while($theme = $db->fetch_array($query)) {
|
| $theme['users'] = 0;
|
$theme['properties'] = my_unserialize($theme['properties']); $theme['stylesheets'] = my_unserialize($theme['stylesheets']); $theme_cache[$theme['tid']] = $theme;
| $theme['properties'] = my_unserialize($theme['properties']); $theme['stylesheets'] = my_unserialize($theme['stylesheets']); $theme_cache[$theme['tid']] = $theme;
|
Zeile 1274 | Zeile 1279 |
---|
$user_themes['style'] = $themes['default']; }
|
$user_themes['style'] = $themes['default']; }
|
if($themes[$user_themes['style']]['users'] > 0)
| if(isset($themes[$user_themes['style']]['users']) && $themes[$user_themes['style']]['users'] > 0)
|
{ $themes[$user_themes['style']]['users'] += (int)$user_themes['users'];
|
{ $themes[$user_themes['style']]['users'] += (int)$user_themes['users'];
|
} else {
| } else {
|
$themes[$user_themes['style']]['users'] = (int)$user_themes['users'];
|
$themes[$user_themes['style']]['users'] = (int)$user_themes['users'];
|
}
| }
|
}
// Restrucure the theme array to something we can "loop-de-loop" with
| }
// Restrucure the theme array to something we can "loop-de-loop" with
|
Zeile 1291 | Zeile 1296 |
---|
{ continue; }
|
{ continue; }
|
|
|
$theme_cache[$theme['pid']][$theme['tid']] = $theme; } $theme_cache['num_themes'] = count($themes); unset($themes);
|
$theme_cache[$theme['pid']][$theme['tid']] = $theme; } $theme_cache['num_themes'] = count($themes); unset($themes);
|
}
if(!is_array($theme_cache[$parent])) { return; }
| }
if(!isset($theme_cache[$parent]) || !is_array($theme_cache[$parent])) { return; }
|
foreach($theme_cache[$parent] as $theme) { $popup = new PopupMenu("theme_{$theme['tid']}", $lang->options);
|
foreach($theme_cache[$parent] as $theme) { $popup = new PopupMenu("theme_{$theme['tid']}", $lang->options);
|
| $set_default = '';
|
if($theme['tid'] > 1) { $popup->add_item($lang->edit_theme, "index.php?module=style-themes&action=edit&tid={$theme['tid']}");
| if($theme['tid'] > 1) { $popup->add_item($lang->edit_theme, "index.php?module=style-themes&action=edit&tid={$theme['tid']}");
|
Zeile 1327 | Zeile 1333 |
---|
$set_default = "<img src=\"styles/{$page->style}/images/icons/default.png\" alt=\"{$lang->default_theme}\" style=\"vertical-align: middle;\" title=\"{$lang->default_theme}\" />"; } $popup->add_item($lang->force_on_users, "index.php?module=style-themes&action=force&tid={$theme['tid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_forced}')");
|
$set_default = "<img src=\"styles/{$page->style}/images/icons/default.png\" alt=\"{$lang->default_theme}\" style=\"vertical-align: middle;\" title=\"{$lang->default_theme}\" />"; } $popup->add_item($lang->force_on_users, "index.php?module=style-themes&action=force&tid={$theme['tid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_forced}')");
|
| $set_default = "<div class=\"float_right\">{$set_default}</div>";
|
} $popup->add_item($lang->export_theme, "index.php?module=style-themes&action=export&tid={$theme['tid']}"); $popup->add_item($lang->duplicate_theme, "index.php?module=style-themes&action=duplicate&tid={$theme['tid']}");
|
} $popup->add_item($lang->export_theme, "index.php?module=style-themes&action=export&tid={$theme['tid']}"); $popup->add_item($lang->duplicate_theme, "index.php?module=style-themes&action=duplicate&tid={$theme['tid']}");
|
$table->construct_cell("<div class=\"float_right\">{$set_default}</div><div style=\"margin-left: {$padding}px;\"><strong>{$theme['name']}</strong></div>");
| $table->construct_cell("{$set_default}<div style=\"margin-left: {$padding}px;\"><strong>{$theme['name']}</strong></div>");
|
$table->construct_cell(my_number_format($theme['users']), array("class" => "align_center")); $table->construct_cell($popup->fetch(), array("class" => "align_center")); $table->construct_row();
| $table->construct_cell(my_number_format($theme['users']), array("class" => "align_center")); $table->construct_cell($popup->fetch(), array("class" => "align_center")); $table->construct_row();
|
Zeile 1368 | Zeile 1375 |
---|
$theme_cache[$theme['pid']][$theme['tid']] = $theme; } unset($theme);
|
$theme_cache[$theme['pid']][$theme['tid']] = $theme; } unset($theme);
|
}
if(!is_array($theme_cache[$parent]) || $ignoretid === $parent) {
| }
if(!isset($theme_cache[$parent]) || !is_array($theme_cache[$parent]) || $ignoretid === $parent) {
|
return null;
|
return null;
|
}
| }
|
foreach($theme_cache[$parent] as $theme)
|
foreach($theme_cache[$parent] as $theme)
|
{
| {
|
if($ignoretid === $theme['tid']) { continue;
| if($ignoretid === $theme['tid']) { continue;
|
Zeile 1390 | Zeile 1397 |
---|
if(!$parent) { return $list;
|
if(!$parent) { return $list;
|
} }
| } }
|
/** * @param array $theme *
| /** * @param array $theme *
|
Zeile 1424 | Zeile 1431 |
---|
foreach($style as $stylesheet2) { $stylesheets[$stylesheet2]['applied_to'][$file][] = $action;
|
foreach($style as $stylesheet2) { $stylesheets[$stylesheet2]['applied_to'][$file][] = $action;
|
if(is_array($file_stylesheets['inherited'][$file."_".$action]) && in_array($stylesheet2, array_keys($file_stylesheets['inherited'][$file."_".$action])))
| if(isset($file_stylesheets['inherited'][$file."_".$action]) && is_array($file_stylesheets['inherited'][$file."_".$action]) && in_array($stylesheet2, array_keys($file_stylesheets['inherited'][$file."_".$action])))
|
{ $stylesheets[$stylesheet2]['inherited'] = $file_stylesheets['inherited'][$file."_".$action]; foreach($file_stylesheets['inherited'][$file."_".$action] as $value)
| { $stylesheets[$stylesheet2]['inherited'] = $file_stylesheets['inherited'][$file."_".$action]; foreach($file_stylesheets['inherited'][$file."_".$action] as $value)
|
Zeile 1438 | Zeile 1445 |
---|
foreach($stylesheets as $file => $stylesheet2) {
|
foreach($stylesheets as $file => $stylesheet2) {
|
if(is_array($stylesheet2['inherited']))
| if(isset($stylesheet2['inherited']) && is_array($stylesheet2['inherited']))
|
{ foreach($stylesheet2['inherited'] as $inherited_file => $tid) {
| { foreach($stylesheet2['inherited'] as $inherited_file => $tid) {
|
Zeile 1461 | Zeile 1468 |
---|
*/ function upgrade_css_120_to_140($css) {
|
*/ function upgrade_css_120_to_140($css) {
|
| global $mybb;
|
// Update our CSS to the new stuff in 1.4 $parsed_css = css_to_array($css);
| // Update our CSS to the new stuff in 1.4 $parsed_css = css_to_array($css);
|