/** * Install our theme */ function insert_templates() { global $mybb, $output, $cache, $db, $lang; require MYBB_ROOT . 'inc/config.php'; $db = db_connection($config); require_once MYBB_ROOT . 'inc/class_datacache.php'; $cache = new datacache(); $output->print_header($lang->theme_installation, 'theme'); echo $lang->theme_step_importing; $db->delete_query("themes"); $db->delete_query("templates"); $db->delete_query("themestylesheets"); my_rmdir_recursive(MYBB_ROOT . "cache/themes", array(MYBB_ROOT . "cache/themes/index.html")); $insert_array = array('title' => 'Default Templates'); $templateset = $db->insert_query("templatesets", $insert_array); $contents = @file_get_contents(INSTALL_ROOT . 'resources/mybb_theme.xml'); if (!empty($mybb->config['admin_dir']) && file_exists(MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php")) { require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions.php"; require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php"; } elseif (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) { require_once MYBB_ROOT . "admin/inc/functions.php"; require_once MYBB_ROOT . "admin/inc/functions_themes.php"; } else { $output->print_error("Please make sure your admin directory is uploaded correctly."); } $theme_id = import_theme_xml($contents, array("templateset" => -2, "version_compat" => 1)); $tid = build_new_theme("Default", null, $theme_id); // Update our properties template set to the correct one $query = $db->simple_select("themes", "stylesheets, properties", "tid='{$tid}'", array('limit' => 1)); $theme = $db->fetch_array($query); $properties = my_unserialize($theme['properties']); $stylesheets = my_unserialize($theme['stylesheets']); $properties['templateset'] = $templateset; unset($properties['inherited']['templateset']); // 1.8: Stylesheet Colors $contents = @file_get_contents(INSTALL_ROOT . 'resources/mybb_theme_colors.xml'); require_once MYBB_ROOT . "inc/class_xml.php"; $parser = new XMLParser($contents); $tree = $parser->get_tree(); if (is_array($tree) && is_array($tree['colors'])) { if (is_array($tree['colors']['scheme'])) { foreach ($tree['colors']['scheme'] as $tag => $value) { $exp = explode("=", $value['value']); $properties['colors'][$exp[0]] = $exp[1]; } } if (is_array($tree['colors']['stylesheets'])) { $count = count($properties['disporder']) + 1; foreach ($tree['colors']['stylesheets']['stylesheet'] as $stylesheet) { $new_stylesheet = array("name" => $db->escape_string($stylesheet['attributes']['name']), "tid" => $tid, "attachedto" => $db->escape_string($stylesheet['attributes']['attachedto']), "stylesheet" => $db->escape_string($stylesheet['value']), "lastmodified" => TIME_NOW, "cachefile" => $db->escape_string($stylesheet['attributes']['name'])); $sid = $db->insert_query("themestylesheets", $new_stylesheet); $css_url = "css.php?stylesheet={$sid}"; $cached = cache_stylesheet($tid, $stylesheet['attributes']['name'], $stylesheet['value']); if ($cached) { $css_url = $cached; } // Add to display and stylesheet list $properties['disporder'][$stylesheet['attributes']['name']] = $count; $stylesheets[$stylesheet['attributes']['attachedto']]['global'][] = $css_url; ++$count; } } } $db->update_query("themes", array("def" => 1, "properties" => $db->escape_string(my_serialize($properties)), "stylesheets" => $db->escape_string(my_serialize($stylesheets))), "tid = '{$tid}'"); echo $lang->theme_step_imported; $output->print_footer('configuration'); }
/** * Custom rmdir function to loop through an entire directory and delete all files/folders within * * @param string The path to the directory * @param array Any files you wish to ignore (optional) */ function my_rmdir_recursive($path, $ignore = array()) { global $orig_dir; if (!isset($orig_dir)) { $orig_dir = $path; } if (@is_dir($path) && !@is_link($path)) { if ($dh = @opendir($path)) { while (($file = @readdir($dh)) !== false) { if ($file == '.' || $file == '..' || $file == '.svn' || in_array($path . '/' . $file, $ignore) || !my_rmdir_recursive($path . '/' . $file)) { continue; } } @closedir($dh); } // Are we done? Don't delete the main folder too and return true if ($path == $orig_dir) { return true; } return @rmdir($path); } return @unlink($path); }
function insert_templates() { global $output, $cache, $db, $lang; require MYBB_ROOT . 'inc/config.php'; $db = db_connection($config); require_once MYBB_ROOT . 'inc/class_datacache.php'; $cache = new datacache(); $output->print_header($lang->theme_installation, 'theme'); echo $lang->theme_step_importing; $db->delete_query("themes"); $db->delete_query("templates"); $db->delete_query("themestylesheets"); my_rmdir_recursive(MYBB_ROOT . "cache/themes", array(MYBB_ROOT . "cache/themes/index.html")); $insert_array = array('title' => 'Default Templates'); $templateset = $db->insert_query("templatesets", $insert_array); $contents = @file_get_contents(INSTALL_ROOT . 'resources/mybb_theme.xml'); if (file_exists(MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php")) { require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions.php"; require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php"; } elseif (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) { require_once MYBB_ROOT . "admin/inc/functions.php"; require_once MYBB_ROOT . "admin/inc/functions_themes.php"; } else { $output->print_error("Please make sure your admin directory is uploaded correctly."); } $theme_id = import_theme_xml($contents, array("templateset" => -2, "version_compat" => 1)); $tid = build_new_theme("Default", null, $theme_id); // Update our properties template set to the correct one $query = $db->simple_select("themes", "properties", "tid='{$tid}'", array('limit' => 1)); $properties = unserialize($db->fetch_field($query, "properties")); $properties['templateset'] = $templateset; unset($properties['inherited']['templateset']); $db->update_query("themes", array("def" => 1, "properties" => $db->escape_string(serialize($properties))), "tid='{$tid}'"); echo $lang->theme_step_imported; $output->print_footer('configuration'); }
<?php /* * Plugin Name: Advanced Sidebox for MyBB 1.6.x * Copyright 2014 WildcardSearch * http://www.rantcentralforums.com * * this file removes any existing files from ASB 1.0 */ define('IN_MYBB', 1); require_once '../../../global.php'; global $config; $removed_files = array('inc/languages/english/adv_sidebox.lang.php', 'inc/plugins/adv_sidebox.php', 'jscripts/adv_sidebox.js', "{$config['admin_dir']}/jscripts/adv_sidebox_acp.js", "{$config['admin_dir']}/styles/adv_sidebox_acp.css", 'inc/plugins/asb/cleanup.php'); $removed_folders = array('inc/plugins/adv_sidebox'); // delete the old adv_sidebox_xxx files and folders foreach ($removed_files as $filename) { $fullpath = MYBB_ROOT . $filename; if (file_exists($fullpath) && !is_dir($fullpath)) { @unlink($fullpath); } } foreach ($removed_folders as $folder) { $fullpath = MYBB_ROOT . $folder; if (is_dir($fullpath)) { @my_rmdir_recursive($fullpath); @rmdir($fullpath); } } require_once MYBB_ROOT . $config['admin_dir'] . '/inc/functions.php'; flash_message('All components of previous installation deleted', 'success'); admin_redirect("{$mybb->settings['bburl']}/{$config['admin_dir']}/index.php?module=config-plugins");