Vergleich admin/inc/functions_themes.php - 1.8.6 - 1.8.27

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 19Zeile 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();

if(!is_array($tree) || !is_array($tree['theme']))

	$tree = $parser->get_tree();

if(!is_array($tree) || !is_array($tree['theme']))

Zeile 59Zeile 57
				}
}
$css_120 .= "}\n";

				}
}
$css_120 .= "}\n";

		}
}


		}
}


	if(isset($theme['themebits']) && is_array($theme['themebits']))
{
$themebits = kill_tags($theme['themebits']);

	if(isset($theme['themebits']) && is_array($theme['themebits']))
{
$themebits = kill_tags($theme['themebits']);

Zeile 102Zeile 100
			}

if($property == 'colors' || $property == 'disporder')

			}

if($property == 'colors' || $property == 'disporder')

			{

			{

				$data = my_unserialize($value['value']);

if(!is_array($data))

				$data = my_unserialize($value['value']);

if(!is_array($data))

Zeile 130Zeile 128

$query = $db->simple_select("themes", "tid", "name='".$db->escape_string($name)."'", array("limit" => 1));
$existingtheme = $db->fetch_array($query);


$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'];
}

Zeile 146Zeile 144

// 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 166Zeile 155
			}
}


			}
}


 
		// Security check

		$security_check = false;

		$security_check = false;

		$templatecache = array();

 
		foreach($templates as $template)
{
if(check_template($template['value']))

		foreach($templates as $template)
{
if(check_template($template['value']))

Zeile 175Zeile 164
				$security_check = true;
break;
}

				$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 183Zeile 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)

		}

foreach($templatecache as $template)

Zeile 240Zeile 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 262Zeile 264
		$loop = 1;
foreach($theme['stylesheets']['stylesheet'] as $stylesheet)
{

		$loop = 1;
foreach($theme['stylesheets']['stylesheet'] as $stylesheet)
{

 
			$stylesheet['attributes']['name'] = my_substr($stylesheet['attributes']['name'], 0, 30);


			if(substr($stylesheet['attributes']['name'], -4) != ".css")
{
continue;

			if(substr($stylesheet['attributes']['name'], -4) != ".css")
{
continue;

Zeile 329Zeile 333
		$updated_theme = array(
"stylesheets" => $db->escape_string(my_serialize($theme_stylesheets))
);

		$updated_theme = array(
"stylesheets" => $db->escape_string(my_serialize($theme_stylesheets))
);


if(is_array($properties['disporder']))
{
asort($properties['disporder'], SORT_NUMERIC);

// Because inherited stylesheets can mess this up
$loop = 1;
$orders = array();
foreach($properties['disporder'] as $filename => $order)
{
$orders[$filename] = $loop;
++$loop;
}

$properties['disporder'] = $orders;
$updated_theme['properties'] = $db->escape_string(my_serialize($properties));
}

 

$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);





	// And done?
return $theme_id;
}

/**
* Parse theme variables in a specific string.

	// And done?
return $theme_id;
}

/**
* Parse theme variables in a specific string.

 *

 *

 * @param string $string The string to parse variables for
* @param array $variables Array of variables
* @return string Parsed string with variables replaced

 * @param string $string The string to parse variables for
* @param array $variables Array of variables
* @return string Parsed string with variables replaced

Zeile 385Zeile 372
 * @return string The cache file path.
*/
function cache_stylesheet($tid, $filename, $stylesheet)

 * @return string The cache file path.
*/
function cache_stylesheet($tid, $filename, $stylesheet)

{
global $mybb;

$filename = str_replace('/', '', $filename);

{
global $mybb;

$filename = basename($filename);

	$tid = (int) $tid;
$theme_directory = "cache/themes/theme{$tid}";

	$tid = (int) $tid;
$theme_directory = "cache/themes/theme{$tid}";

 

if(substr($filename, -4) != ".css")
{
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 420Zeile 412
		"theme" => $theme_directory
);
$stylesheet = parse_theme_variables($stylesheet, $theme_vars);

		"theme" => $theme_directory
);
$stylesheet = parse_theme_variables($stylesheet, $theme_vars);

	$stylesheet = preg_replace_callback("#url\((\"|'|)(.*)\\1\)#", create_function('$matches', 'return fix_css_urls($matches[2]);'), $stylesheet);

	$stylesheet = preg_replace_callback("#url\((\"|'|)([^\"'\s]*?)\\1\)#", 'fix_css_urls_callback', $stylesheet);


$fp = @fopen(MYBB_ROOT . "{$theme_directory}/{$filename}", "wb");
if(!$fp)


$fp = @fopen(MYBB_ROOT . "{$theme_directory}/{$filename}", "wb");
if(!$fp)

Zeile 511Zeile 503
}

/**

}

/**

 
 * @deprecated

 * @param string $url
*
* @return string

 * @param string $url
*
* @return string

Zeile 528Zeile 521
}

/**

}

/**

 
 * @param array $matches Matches.
*
* @return string
*/
function fix_css_urls_callback($matches)
{
return fix_css_urls($matches[2]);
}

/**
* @deprecated

 * @param string $url
*
* @return string

 * @param string $url
*
* @return string

Zeile 565Zeile 569
	{
$query = $db->simple_select("themes", "*", "tid='".(int)$parent."'");
$parent_theme = $db->fetch_array($query);

	{
$query = $db->simple_select("themes", "*", "tid='".(int)$parent."'");
$parent_theme = $db->fetch_array($query);

		if(count($properties) == 0 || !is_array($properties))

		if(!is_array($properties) || count($properties) == 0)

		{
$parent_properties = my_unserialize($parent_theme['properties']);
if(!empty($parent_properties))

		{
$parent_properties = my_unserialize($parent_theme['properties']);
if(!empty($parent_properties))

Zeile 628Zeile 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['stylesheets'] = $db->escape_string(my_serialize($stylesheets));

	if(!empty($stylesheets))
{
$updated_theme['stylesheets'] = $db->escape_string(my_serialize($stylesheets));

	}

	}

	$updated_theme['properties'] = $db->escape_string(my_serialize($properties));

	$updated_theme['properties'] = $db->escape_string(my_serialize($properties));





	if(count($updated_theme) > 0)
{
$db->update_query("themes", $updated_theme, "tid='{$tid}'");
}

	if(count($updated_theme) > 0)
{
$db->update_query("themes", $updated_theme, "tid='{$tid}'");
}





	return $tid;

	return $tid;

}

/**

}

/**

 * Generates an array from an incoming CSS file.
*
* @param string $css The incoming CSS

 * Generates an array from an incoming CSS file.
*
* @param string $css The incoming CSS

Zeile 727Zeile 733
			if(!$css_array['name'])
{
$css_array['name'] = $css_array['class_name'];

			if(!$css_array['name'])
{
$css_array['name'] = $css_array['class_name'];

			}

			}


if($selected_item == $id || (!$selected_item && !$selected))
{
$select .= "<option value=\"{$id}\" selected=\"selected\">{$css_array['name']}</option>\n";
$selected = true;


if($selected_item == $id || (!$selected_item && !$selected))
{
$select .= "<option value=\"{$id}\" selected=\"selected\">{$css_array['name']}</option>\n";
$selected = true;

			}

			}

			else
{
$select .= "<option value=\"{$id}\">{$css_array['name']}</option>\n";

			else
{
$select .= "<option value=\"{$id}\">{$css_array['name']}</option>\n";

Zeile 741Zeile 747
		}
}
return $select;

		}
}
return $select;

}

/**

}

/**

 * @param array $a
* @param array $b
*

 * @param array $a
* @param array $b
*

Zeile 754Zeile 760
	if(!$a['name'])
{
$a['name'] = $a['class_name'];

	if(!$a['name'])
{
$a['name'] = $a['class_name'];

	}


	}


	if(!$b['name'])
{
$b['name'] = $b['class_name'];
}
return strcmp($a['name'], $b['name']);

	if(!$b['name'])
{
$b['name'] = $b['class_name'];
}
return strcmp($a['name'], $b['name']);

}

/**

}

/**

 * @param array|string $css
* @param string $id
*

 * @param array|string $css
* @param string $id
*

Zeile 772Zeile 778
function get_css_properties($css, $id)
{
if(!is_array($css))

function get_css_properties($css, $id)
{
if(!is_array($css))

	{

	{

		$css = css_to_array($css);

		$css = css_to_array($css);

	}

	}


if(!isset($css[$id]))
{


if(!isset($css[$id]))
{

Zeile 785Zeile 791

/**
* Parses CSS supported properties and returns them as an array.


/**
* Parses CSS supported properties and returns them as an array.

 *

 *

 * @param string $values Value of CSS properties from within class or selector
* @return array Array of CSS properties
*/
function parse_css_properties($values)
{

 * @param string $values Value of CSS properties from within class or selector
* @return array Array of CSS properties
*/
function parse_css_properties($values)
{

	$css_bits = array();



	$css_bits = array(
'extra' => null,
);


if(!$values)
{


if(!$values)
{

Zeile 852Zeile 860

// Parse out the CSS
if($css)


// Parse out the CSS
if($css)

	{

	{

		$parsed_css = css_to_array($css);

		$parsed_css = css_to_array($css);

	}


	}


	if(!$class_id)
{
$class_id = $parsed_css[$selector]['class_name'];

	if(!$class_id)
{
$class_id = $parsed_css[$selector]['class_name'];

Zeile 863Zeile 871

// The specified class ID cannot be found, add CSS to end of file
if(!$css || !$parsed_css[$selector])


// The specified class ID cannot be found, add CSS to end of file
if(!$css || !$parsed_css[$selector])

	{

	{

		return $css."{$class_id}\n{\n{$generated_css}\n}\n\n";
}
// Valid CSS, swap out old, swap in new

		return $css."{$class_id}\n{\n{$generated_css}\n}\n\n";
}
// Valid CSS, swap out old, swap in new

Zeile 874Zeile 882
		$css = preg_replace("#^(?!@)\s*([a-z0-9a+\\\[\]\-\"=_:>\*\.\#\,\s\(\)\|~\^]+)(\s*)\{(\n*)#isu", "\n$1 {\n", $css);
$css = preg_replace("#\s{1,}\{#", " {", $css);
$existing_block = $parsed_css[$selector];

		$css = preg_replace("#^(?!@)\s*([a-z0-9a+\\\[\]\-\"=_:>\*\.\#\,\s\(\)\|~\^]+)(\s*)\{(\n*)#isu", "\n$1 {\n", $css);
$css = preg_replace("#\s{1,}\{#", " {", $css);
$existing_block = $parsed_css[$selector];





		$break = strrpos($selector, "_");
$actual_occurance = 0;
if($break !== false)

		$break = strrpos($selector, "_");
$actual_occurance = 0;
if($break !== false)

Zeile 918Zeile 926
 * @param int $tid
*
* @return bool|int

 * @param int $tid
*
* @return bool|int

 */

 */

function copy_stylesheet_to_theme($stylesheet, $tid)
{
global $db;

function copy_stylesheet_to_theme($stylesheet, $tid)
{
global $db;

Zeile 975Zeile 983
			}

$stylesheets[$stylesheet['name']] = $stylesheet;

			}

$stylesheets[$stylesheet['name']] = $stylesheet;

		}
}

$theme_stylesheets = array();

		}
}

$theme_stylesheets = array();


foreach($stylesheets as $name => $stylesheet)
{


foreach($stylesheets as $name => $stylesheet)
{

Zeile 987Zeile 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 = rtrim($mybb->settings['cdnpath'], '/\\').'/';
if(file_exists($cdnpath."cache/themes/theme{$theme_id}/{$stylesheet['name']}") && filemtime(

Zeile 1011Zeile 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 1040Zeile 1048
			}

foreach($attached_actions as $action)

			}

foreach($attached_actions as $action)

			{

			{

				$theme_stylesheets[$attached_file][$action][] = $css_url;

if(!empty($stylesheet['inherited']))

				$theme_stylesheets[$attached_file][$action][] = $css_url;

if(!empty($stylesheet['inherited']))

Zeile 1050Zeile 1058
			}
}
}

			}
}
}





	// Now we have our list of built stylesheets, save them
$updated_theme = array(
"stylesheets" => $db->escape_string(my_serialize($theme_stylesheets))

	// Now we have our list of built stylesheets, save them
$updated_theme = array(
"stylesheets" => $db->escape_string(my_serialize($theme_stylesheets))

Zeile 1060Zeile 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 1072Zeile 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 1082Zeile 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 1110Zeile 1118
	$db->update_query("themes", $updated_theme, "tid = '{$tid}'");

// Do we have any children themes that need updating too?

	$db->update_query("themes", $updated_theme, "tid = '{$tid}'");

// Do we have any children themes that need updating too?

	if(count($child_list) > 0)

	if(is_array($child_list) && count($child_list) > 0)

	{
foreach($child_list as $id)
{

	{
foreach($child_list as $id)
{

Zeile 1228Zeile 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 1270Zeile 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'];
}

Zeile 1294Zeile 1303
		unset($themes);
}


		unset($themes);
}


	if(!is_array($theme_cache[$parent]))

	if(!isset($theme_cache[$parent]) || !is_array($theme_cache[$parent]))

	{
return;
}

	{
return;
}

Zeile 1302Zeile 1311
	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&amp;action=edit&amp;tid={$theme['tid']}");

		if($theme['tid'] > 1)
{
$popup->add_item($lang->edit_theme, "index.php?module=style-themes&amp;action=edit&amp;tid={$theme['tid']}");

Zeile 1323Zeile 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&amp;action=force&amp;tid={$theme['tid']}&amp;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&amp;action=force&amp;tid={$theme['tid']}&amp;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&amp;action=export&amp;tid={$theme['tid']}");
$popup->add_item($lang->duplicate_theme, "index.php?module=style-themes&amp;action=duplicate&amp;tid={$theme['tid']}");

		}
$popup->add_item($lang->export_theme, "index.php?module=style-themes&amp;action=export&amp;tid={$theme['tid']}");
$popup->add_item($lang->duplicate_theme, "index.php?module=style-themes&amp;action=duplicate&amp;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 1366Zeile 1377
		unset($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;
}

Zeile 1420Zeile 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 1434Zeile 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 1457Zeile 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);