/** * Install a style on the demo board. * * @param string $phpbb_root_path * @param mixed contrib object */ public function install_demo_style($phpbb_root_path, $contrib) { phpbb::$user->add_lang('acp/styles'); if ($phpbb_root_path[strlen($phpbb_root_path) - 1] != '/') { $phpbb_root_path .= '/'; } if (!is_dir($phpbb_root_path) || !file_exists($phpbb_root_path . 'config.' . PHP_EXT)) { $this->error[] = 'PATH_INVALID'; return false; } include $phpbb_root_path . 'config.' . PHP_EXT; $sql_db = !empty($dbms) ? 'dbal_' . basename($dbms) : 'dbal'; // Is this DBAL loaded? phpbb::_include('db/' . $dbms, false, $sql_db); // Instantiate DBAL class $db = new $sql_db(); // Connect to demo board DB $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport); // We do not need this any longer, unset for safety purposes unset($dbpasswd); if (empty($this->unzip_dir)) { // Extract zip. $this->unzip_dir = titania::$config->contrib_temp_path . basename($this->original_zip, 'zip') . '/'; // Clear out old stuff if there is anything here... $this->rmdir_recursive($this->unzip_dir); // Unzip to our temp directory $this->extract($this->original_zip, $this->unzip_dir); } $package_root = $this->find_root(false, 'style.cfg'); $stylecfg = parse_cfg_file($this->unzip_dir . $package_root . '/style.cfg'); $style_root = $phpbb_root_path . 'styles/' . $contrib->contrib_id . '/'; $this->mvdir_recursive($this->unzip_dir . $package_root, $style_root, false); $this->rmdir_recursive($this->unzip_dir); $variables = array('db', 'phpbb_root_path'); // Let's get lazy. foreach ($variables as $variable) { ${'_' . $variable} = $GLOBALS[$variable]; $GLOBALS[$variable] = ${$variable}; } // Get the acp_styles class. phpbb::_include('acp/acp_styles', false, 'acp_styles'); if (!defined('TEMPLATE_BITFIELD')) { // Hardcoded template bitfield to add for new templates $bitfield = new bitfield(); $bitfield->set(0); $bitfield->set(1); $bitfield->set(2); $bitfield->set(3); $bitfield->set(4); $bitfield->set(8); $bitfield->set(9); $bitfield->set(11); $bitfield->set(12); define('TEMPLATE_BITFIELD', $bitfield->get_base64()); unset($bitfield); } $styles = new acp_styles(); // Fill the configuration variables $styles->style_cfg = $styles->template_cfg = $styles->theme_cfg = $styles->imageset_cfg = ' # # phpBB {MODE} configuration file # # @package phpBB3 # @copyright (c) 2005 phpBB Group # @license http://opensource.org/licenses/gpl-license.php GNU Public License # # # At the left is the name, please do not change this # At the right the value is entered # For on/off options the valid values are on, off, 1, 0, true and false # # Values get trimmed, if you want to add a space in front or at the end of # the value, then enclose the value with single or double quotes. # Single and double quotes do not need to be escaped. # # # General Information about this {MODE} name = {NAME} copyright = {COPYRIGHT} version = {VERSION} '; $styles->theme_cfg .= ' # Some configuration options # # You have to turn this option on if you want to use the # path template variables ({T_IMAGESET_PATH} for example) within # your css file. # This is mostly the case if you want to use language specific # images within your css file. # parse_css_file = {PARSE_CSS_FILE} '; $styles->template_cfg .= ' # Some configuration options # # You can use this function to inherit templates from another template. # The template of the given name has to be installed. # Templates cannot inherit from inheriting templates. #'; $styles->imageset_keys = array('logos' => array('site_logo'), 'buttons' => array('icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply'), 'icons' => array('icon_post_target', 'icon_post_target_unread', 'icon_topic_attach', 'icon_topic_latest', 'icon_topic_newest', 'icon_topic_reported', 'icon_topic_unapproved', 'icon_friend', 'icon_foe'), 'forums' => array('forum_link', 'forum_read', 'forum_read_locked', 'forum_read_subforum', 'forum_unread', 'forum_unread_locked', 'forum_unread_subforum', 'subforum_read', 'subforum_unread'), 'folders' => array('topic_moved', 'topic_read', 'topic_read_mine', 'topic_read_hot', 'topic_read_hot_mine', 'topic_read_locked', 'topic_read_locked_mine', 'topic_unread', 'topic_unread_mine', 'topic_unread_hot', 'topic_unread_hot_mine', 'topic_unread_locked', 'topic_unread_locked_mine', 'sticky_read', 'sticky_read_mine', 'sticky_read_locked', 'sticky_read_locked_mine', 'sticky_unread', 'sticky_unread_mine', 'sticky_unread_locked', 'sticky_unread_locked_mine', 'announce_read', 'announce_read_mine', 'announce_read_locked', 'announce_read_locked_mine', 'announce_unread', 'announce_unread_mine', 'announce_unread_locked', 'announce_unread_locked_mine', 'global_read', 'global_read_mine', 'global_read_locked', 'global_read_locked_mine', 'global_unread', 'global_unread_mine', 'global_unread_locked', 'global_unread_locked_mine', 'pm_read', 'pm_unread'), 'polls' => array('poll_left', 'poll_center', 'poll_right'), 'ui' => array('upload_bar'), 'user' => array('user_icon1', 'user_icon2', 'user_icon3', 'user_icon4', 'user_icon5', 'user_icon6', 'user_icon7', 'user_icon8', 'user_icon9', 'user_icon10')); // Define references. $error = array(); $style_id = 0; $style_row = array('install_name' => $stylecfg['name'], 'install_copyright' => $stylecfg['copyright'], 'template_id' => 0, 'template_name' => $stylecfg['name'], 'template_copyright' => $stylecfg['copyright'], 'theme_id' => 0, 'theme_name' => $stylecfg['name'], 'theme_copyright' => $stylecfg['copyright'], 'imageset_id' => 0, 'imageset_name' => $stylecfg['name'], 'imageset_copyright' => $stylecfg['copyright'], 'store_db' => 0, 'style_active' => 1, 'style_default' => 0); // Install the style. // (&$error, $action, $root_path, &$id, $name, $path, $copyright, $active, $default, &$style_row, $template_root_path = false, $template_path = false, $theme_root_path = false, $theme_path = false, $imageset_root_path = false, $imageset_path = false) if (!$styles->install_style($error, 'install', $style_root, $style_id, $stylecfg['name'], $contrib->contrib_id, $stylecfg['copyright'], true, false, $style_row)) { if ($error != array(phpbb::$user->lang['STYLE_ERR_NAME_EXIST'])) { $this->error = array_merge($this->error, $error); } else { $sql = 'SELECT style_id FROM ' . STYLES_TABLE . "\n\t\t\t\t\tWHERE style_name = '" . $db->sql_escape(basename($stylecfg['name'])) . "'"; $db->sql_query($sql); $style_id = $db->sql_fetchfield('style_id'); $db->sql_freeresult(); } } // Have UMIL refresh the template, theme, imageset phpbb::_include('../umil/umil', false, 'umil'); $umil = new umil(true, $db); $umil->cache_purge('template', $style_id); $umil->cache_purge('theme', $style_id); $umil->cache_purge('imageset', $style_id); foreach ($variables as $variable) { $GLOBALS[$variable] = ${'_' . $variable}; } return $style_id; }
} else { if (is_numeric($unit)) { $mem_limit = floor((int) ($mem_limit . $unit) / 1048576); } } } $mem_limit = max(128, $mem_limit) . 'M'; } else { $mem_limit = '128M'; } @ini_set('memory_limit', $mem_limit); // Init critical repair and run the tools that *must* be ran before initing anything else include STK_ROOT_PATH . 'includes/critical_repair.' . PHP_EXT; $critical_repair = new critical_repair(); $critical_repair->initialise(); $critical_repair->run_tool('bom_sniffer'); $critical_repair->run_tool('config_repair'); require STK_ROOT_PATH . 'common.' . PHP_EXT; // We'll run the rest of the critical repair tools automatically now $critical_repair->autorun_tools(); // At this point things should be runnable // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup('acp/common', $config['default_style']); stk_add_lang('common'); // Purge teh caches $umil = new umil(true); $umil->cache_purge(array('data')); // Let's tell the user all is okay :) $critical_repair->trigger_error($user->lang['ERK_OK'], true);
if (!$umil->config_exists($mod['config'])) { // Lets add a config setting for enabling/disabling the MOD and set it to true $umil->config_add($mod['enable'], true); // We must handle the version number ourselves. $umil->config_add($mod['config'], $mod['version']); $umil->table_column_add('phpbb_groups', 'group_position', array('UINT', '0')); // Select all groups that have no set position $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . ' WHERE group_position = 0'; $result = $db->sql_query($sql); // Set default positions for groups (so that all positions are not set to 0) $group_position = 0; while ($row = $db->sql_fetchrow($result)) { $group_position++; $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_position = ' . $group_position . ' WHERE group_id = ' . $row['group_id']; $db->sql_query($sql); } $db->sql_freeresult($result); // Our final action, we purge the board cache $umil->cache_purge(); } // We are done trigger_error('Done!'); } else { confirm_box(false, 'INSTALL_TEST_MOD'); } // Shouldn't get here. redirect($phpbb_root_path . $user->page['page_name']);
if ($unit == 'g') { $mem_limit *= 1024; } else { if (is_numeric($unit)) { $mem_limit = floor((int) ($mem_limit . $unit) / 1048576); } } } $mem_limit = max(128, $mem_limit) . 'M'; } else { $mem_limit = '128M'; } @ini_set('memory_limit', $mem_limit); // Init critical repair and run the tools that *must* be ran before initing anything else include STK_ROOT_PATH . 'includes/critical_repair.' . PHP_EXT; $critical_repair = new critical_repair(); $critical_repair->run_tool('bom_sniffer'); $critical_repair->run_tool('config_repair'); require STK_ROOT_PATH . 'common.' . PHP_EXT; // We'll run the rest of the critical repair tools automatically now $critical_repair->autorun_tools(); // At this point things should be runnable // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup('acp/common', $config['default_style']); // Purge teh caches $umil = new umil(true); $umil->cache_purge(array('data', 'template', 'theme', 'imageset')); // Let's tell the user all is okay :) $critical_repair->trigger_error("The Emergency Repair Kit hasn't found any critical issues within your phpBB installation.", true);