function latestposts_install() { global $db, $lang; $lang->load("latestposts"); $new_setting_group = array("name" => "latestposts", "title" => $lang->settings_name, "disporder" => 1, "isdefault" => 0); $gid = $db->insert_query("settinggroups", $new_setting_group); $settings[] = array("name" => "latestposts_threadcount", "title" => $lang->num_posts_to_show, "optionscode" => "text", "disporder" => 1, "value" => 15, "gid" => $gid); $settings[] = array("name" => "latestposts_forumskip", "title" => $lang->forums_to_skip, "description" => $lang->forums_to_skip_desc, "optionscode" => "text", "disporder" => 2, "gid" => $gid); $settings[] = array("name" => "latestposts_showtime", "title" => $lang->latestposts_showtime, "optionscode" => "yesno", "disporder" => 3, "value" => 1, "gid" => $gid); $settings[] = array("name" => "latestposts_rightorleft", "title" => $lang->rightorleft, "optionscode" => "select\r\nright=" . $lang->latestposts_right . "\r\nleft=" . $lang->latestposts_left, "disporder" => 4, "value" => "right", "gid" => $gid); foreach ($settings as $array => $content) { $db->insert_query("settings", $content); } rebuild_settings(); require_once MYBB_ROOT . "admin/inc/functions_themes.php"; // Add stylesheet to the master template so it becomes inherited. $stylesheet = <<<code \t.latestpost { \t\tpadding: 2px 10px; \t} code; $css = array('sid' => NULL, 'name' => 'latestposts.css', 'tid' => '1', 'stylesheet' => $db->escape_string($stylesheet), 'cachefile' => 'latestposts.css', 'lastmodified' => TIME_NOW); $db->insert_query('themestylesheets', $css); cache_stylesheet(1, "latestposts.css", $stylesheet); update_theme_stylesheet_list(1, false, true); }
private function insertCSS() { global $db; require_once MYBB_ADMIN_DIR . "inc/functions_themes.php"; // Add stylesheet to the master template so it becomes inherited. $stylesheet = @file_get_contents(MYBB_ROOT . 'inc/plugins/wiki/templates/stylesheets/wiki.css'); $wiki_stylesheet = array('name' => 'wiki.css', 'tid' => '1', 'stylesheet' => $db->escape_string($stylesheet), 'cachefile' => 'wiki.css', 'lastmodified' => TIME_NOW, 'attachedto' => 'wiki.php'); $db->insert_query('themestylesheets', $wiki_stylesheet); cache_stylesheet(1, "wiki.css", $stylesheet); update_theme_stylesheet_list("1"); }
function portal_news_preview_install() { global $db; require_once MYBB_ROOT . "admin/inc/functions_themes.php"; $stylesheet = ".readmore, .readmore:visited {\n\tbackground-color: #237;\n\tcolor: #fff;\n\tfloat: left;\n\tpadding: 10px;\n\tmargin: 20px;\n\ttransition: box-shadow linear 0.25s, background linear 0.25s;\n}\n\n\n.readmore:hover {\n\tbackground-color: #06b !important;\n\tbox-shadow: 0px 1px 9px 2px #555;\n\tcolor: #fff;\n\ttransition: box-shadow linear 0.2s, background linear 0.2s;\n\ttext-decoration: none;\n}\n\n.readmore:active {\n\tbackground-color: #0066a6 !important;\n\tcolor: #fff;\n\ttext-decoration: none;\t\n\toutline: none;\n}"; $portal_news_preview_stylesheet = array('sid' => NULL, 'name' => 'readmore.css', 'tid' => '1', 'stylesheet' => $db->escape_string($stylesheet), 'cachefile' => 'readmore.css', 'lastmodified' => TIME_NOW); cache_stylesheet(1, "readmore.css", $stylesheet); $sid = $db->insert_query("themestylesheets", $portal_news_preview_stylesheet); $db->update_query("themestylesheets", array("cachefile" => "css.php?stylesheet=" . $sid), "sid = '" . $sid . "'", 1); $tids = $db->simple_select("themes", "tid"); while ($theme = $db->fetch_array($tids)) { update_theme_stylesheet_list($theme['tid']); } }
/** * MyBB 1.8 * Copyright 2014 MyBB Group, All Rights Reserved * * Website: http://www.mybb.com * License: http://www.mybb.com/about/license * */ function task_recachestylesheets($task) { global $mybb, $db, $lang; if (file_exists(MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php")) { require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php"; } else { if (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) { require_once MYBB_ROOT . "admin/inc/functions_themes.php"; } } $query = $db->simple_select('themestylesheets', '*'); $num_recached = 0; while ($stylesheet = $db->fetch_array($query)) { if (cache_stylesheet($stylesheet['tid'], $stylesheet['name'], $stylesheet['stylesheet'])) { $db->update_query("themestylesheets", array('cachefile' => $db->escape_string($stylesheet['name'])), "sid='{$stylesheet['sid']}'", 1); ++$num_recached; } } add_task_log($task, $lang->sprintf($lang->task_recachestylesheets_ran, $num_recached)); }
/** * 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'); }
<?php define("IN_MYBB", 1); define("NO_ONLINE", 1); define('THIS_SCRIPT', 'updatecss.php'); require_once "./inc/init.php"; require_once "./admin/inc/functions_themes.php"; $stylesheet = $mybb->input['stylesheet']; $tid = intval($mybb->input['tid']); $name = $mybb->input['name']; if (empty($tid) || empty($name) || empty($stylesheet)) { exit; } $updated_stylesheet = array("stylesheet" => $db->escape_string(unfix_css_urls($stylesheet)), "lastmodified" => TIME_NOW); if ($db->update_query("themestylesheets", $updated_stylesheet, "tid='{$tid}' AND name='{$db->escape_string($name)}'")) { cache_stylesheet($tid, $name, $stylesheet); }
$attached[] = $attached_to; } } } else { if ($mybb->input['attach'] == 2) { if (!is_array($mybb->input['color'])) { $errors[] = $lang->error_no_color_picked; } else { $attached = $mybb->input['color']; } } } // Add Stylesheet $insert_array = array('name' => $db->escape_string($mybb->input['name']), 'tid' => $mybb->get_input('tid', MyBB::INPUT_INT), 'attachedto' => implode('|', array_map(array($db, "escape_string"), $attached)), 'stylesheet' => $db->escape_string($stylesheet), 'cachefile' => $db->escape_string(str_replace('/', '', $mybb->input['name'])), 'lastmodified' => TIME_NOW); $sid = $db->insert_query("themestylesheets", $insert_array); if (!cache_stylesheet($theme['tid'], str_replace('/', '', $mybb->input['name']), $stylesheet)) { $db->update_query("themestylesheets", array('cachefile' => "css.php?stylesheet={$sid}"), "sid='{$sid}'", 1); } // Update the CSS file list for this theme update_theme_stylesheet_list($theme['tid'], $theme, true); $plugins->run_hooks("admin_style_themes_add_stylesheet_commit"); // Log admin action log_admin_action($sid, $mybb->input['name'], $theme['tid'], htmlspecialchars_uni($theme['name'])); flash_message($lang->success_stylesheet_added, 'success'); admin_redirect("index.php?module=style-themes&action=edit_stylesheet&tid={$mybb->input['tid']}&sid={$sid}&file=" . urlencode($mybb->input['name'])); } } if ($admin_options['codepress'] != 0) { $page->extra_header .= ' <link href="./jscripts/codemirror/lib/codemirror.css" rel="stylesheet"> <link href="./jscripts/codemirror/theme/mybb.css?ver=1804" rel="stylesheet">
function upgrade12_redothemes() { global $db, $output, $config, $mybb; $output->print_header("Converting themes"); if (!@is_dir(MYBB_ROOT . 'cache/')) { @mkdir(MYBB_ROOT . 'cache/', 077); // Add in empty index.html! $fp = @fopen(MYBB_ROOT . "cache/index.html", "w"); @fwrite($fp, ""); @fclose($fp); } $cachewritable = @fopen(MYBB_ROOT . 'cache/test.write', 'w'); if (!$cachewritable) { $not_writable = true; @fclose($cachewritable); } else { @fclose($cachewritable); @my_chmod(MYBB_ROOT . 'cache', '0777'); @my_chmod(MYBB_ROOT . 'cache/test.write', '0777'); @unlink(MYBB_ROOT . 'cache/test.write'); } if ($not_writable) { echo "<p><span style=\"color: red; font-weight: bold;\">Unable to write to the cache/ directory.</span><br />Before the upgrade process can continue you need to make sure this directory exists and is writable (chmod 777)</p>"; $output->print_footer("12_redothemes"); exit; } $not_writable = false; if (!@is_dir(MYBB_ROOT . 'cache/themes/')) { @mkdir(MYBB_ROOT . 'cache/themes/', 077); // Add in empty index.html! $fp = @fopen(MYBB_ROOT . "cache/themes/index.html", "w"); @fwrite($fp, ""); @fclose($fp); } $themewritable = @fopen(MYBB_ROOT . 'cache/themes/test.write', 'w'); if (!$themewritable) { $not_writable = true; @fclose($themewritable); } else { @fclose($themewritable); @my_chmod(MYBB_ROOT . 'cache/themes', '0777'); @my_chmod(MYBB_ROOT . 'cache/themes/test.write', '0777'); @unlink(MYBB_ROOT . 'cache/themes/test.write'); } if ($not_writable) { echo "<p><span style=\"color: red; font-weight: bold;\">Unable to write to the cache/themes/ directory.</span><br />Before the upgrade process can continue you need to make sure this directory exists and is writable (chmod 777)</p>"; $output->print_footer("12_redothemes"); exit; } if ($db->field_exists('themebits', "themes") && !$db->field_exists('properties', "themes")) { $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes CHANGE themebits properties text NOT NULL"); } if ($db->field_exists('cssbits', "themes")) { $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes DROP cssbits"); } if ($db->field_exists('csscached', "themes")) { $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes DROP csscached"); } if ($db->field_exists('stylesheets', "themes")) { $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes DROP stylesheets"); } $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes ADD stylesheets text NOT NULL AFTER properties"); if ($db->table_exists("themestylesheets")) { $db->drop_table("themestylesheets"); } $db->write_query("CREATE TABLE " . TABLE_PREFIX . "themestylesheets(\n\t\tsid int unsigned NOT NULL auto_increment,\n\t\tname varchar(30) NOT NULL default '',\n\t\ttid int unsigned NOT NULL default '0',\n\t\tattachedto text NOT NULL,\n\t\tstylesheet text NOT NULL,\n\t\tcachefile varchar(100) NOT NULL default '',\n\t\tlastmodified bigint(30) NOT NULL default '0',\n\t\tPRIMARY KEY(sid)\n\t) ENGINE=MyISAM{$collation};"); // Define our default stylesheets - MyBB 1.4 contains additional stylesheets that our converted themes will also need $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_themes.php"; } else { if (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) { require_once MYBB_ROOT . "admin/inc/functions_themes.php"; } else { $output->print_error("Please make sure your admin directory is uploaded correctly."); } } // Import master theme if (import_theme_xml($contents, array("tid" => 1, "no_templates" => 1, "version_compat" => 1)) === -1) { $output->print_error("Please make sure your install/resources/mybb_theme.xml file is uploaded correctly."); } // Fetch out default stylesheets from master $query = $db->simple_select("themes", "*", "tid=1"); $master_theme = $db->fetch_array($query); $master_stylesheets = unserialize($master_theme['stylesheets']); if (is_array($master_stylesheets)) { // Note: 1.4 only ships with one global|global stylesheet foreach ($master_stylesheets as $location => $sheets) { foreach ($sheets as $action => $sheets) { foreach ($sheets as $stylesheet) { if ($location == "global" && $action == "global") { continue; // Skip global } $default_stylesheets[$location][$action][] = $stylesheet; $default_stylesheets['inherited']["{$location}_{$action}"][$stylesheet] = 1; // This stylesheet is inherited from the master } } } } $query = $db->simple_select("themes"); while ($theme = $db->fetch_array($query)) { if (!$theme['css']) { continue; } $theme['css'] .= "\n\n" . $theme['extracss']; $theme['css'] = upgrade_css_120_to_140($theme['css']); // Create stylesheets $cache_file = cache_stylesheet($theme['tid'], "global.css", $theme['css']); $new_stylesheet = array("tid" => $theme['tid'], "name" => "global.css", "attachedto" => "", "stylesheet" => $db->escape_string($theme['css']), "cachefile" => "global.css", "lastmodified" => TIME_NOW); $sid = $db->insert_query("themestylesheets", $new_stylesheet); $css_url = "css.php?stylesheet={$sid}"; if ($cache_file) { $css_url = $cache_file; } // Now we go and update the stylesheets column for this theme $stylesheets = $default_stylesheets; // Add in our local for this theme $stylesheets['global']['global'][] = $css_url; // Update the theme $db->update_query("themes", array("stylesheets" => $db->escape_string(serialize($stylesheets))), "tid='{$theme['tid']}'"); } if ($db->field_exists('css', "themes")) { $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes DROP css"); } if ($db->field_exists('extracss', "themes")) { $db->write_query("ALTER TABLE " . TABLE_PREFIX . "themes DROP extracss"); } // We need to replace this for our themes css to show up // <link rel="stylesheet" type="text/css" href="{$theme['css_url']}" /> must be present in the old template (it usually is) $query = $db->simple_select("templates", "tid,template", "title='headerinclude'"); while ($template = $db->fetch_array($query)) { $template['template'] = str_replace('<link rel="stylesheet" type="text/css" href="{$theme[\'css_url\']}" />', '{$stylesheets}', $template['template']); $db->update_query("templates", array('template' => $db->escape_string($template['template'])), "tid='{$template['tid']}'"); } echo "<p>Your themes have successfully been converted to the new theme system.</p>"; echo "<p>Click next to continue with the upgrade process.</p>"; global $footer_extra; //$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatically Redirecting...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>"; $output->print_footer("12_done"); }
/** * Re-cache the existing stylesheets so that they get minified. * * @return int The number of re-cached stylesheets. */ function recache_existing_styles() { global $db; $query = $db->simple_select('themestylesheets', '*'); $num_updated = 0; while ($stylesheet = $db->fetch_array($query)) { if (cache_stylesheet((int) $stylesheet['tid'], $stylesheet['name'], $stylesheet['stylesheet'])) { ++$num_updated; } } return $num_updated; }
/** * Update stylesheet metadata. * */ function _update_themes_stylesheets($stylesheet = false) { global $mybb; $tid = 1; // MyBB Master Style require_once MYBB_ROOT . $mybb->config['admin_dir'] . '/inc/functions_themes.php'; if ($stylesheet) { cache_stylesheet($stylesheet['tid'], $stylesheet['cachefile'], $stylesheet['stylesheet']); } update_theme_stylesheet_list($tid); // includes all children }
function upgrade17_updatecss() { global $db, $output, $orig_config, $mybb; if (file_exists(MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php")) { require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php"; } else { if (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) { require_once MYBB_ROOT . "admin/inc/functions_themes.php"; } else { $output->print_error("Please make sure your admin directory is uploaded correctly."); } } $output->print_header("Updating CSS"); $query = $db->simple_select("themestylesheets", "*", "name='global.css' OR name='usercp.css'"); while ($theme = $db->fetch_array($query)) { resync_stylesheet($theme); } $query = $db->simple_select("themestylesheets", "*", "name='global.css' OR name='usercp.css'"); while ($theme = $db->fetch_array($query)) { $theme['stylesheet'] = upgrade_css_140_to_160($theme['name'], $theme['stylesheet']); // Create stylesheets cache_stylesheet($theme['tid'], $theme['cachefile'], $theme['stylesheet']); $update_stylesheet = array("stylesheet" => $db->escape_string($theme['stylesheet']), "lastmodified" => TIME_NOW); $db->update_query("themestylesheets", $update_stylesheet, "sid='{$theme['sid']}'"); } echo "<p>The CSS has been successfully updated.</p>"; echo "<p>Click next to continue with the upgrade process.</p>"; global $footer_extra; //$footer_extra = "<script type=\"text/javascript\">$(document).ready(function() { var button = $('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>"; $output->print_footer("17_done"); }
function upgrade17_updatecss() { global $db, $output, $orig_config, $mybb; if (file_exists(MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php")) { require_once MYBB_ROOT . $mybb->config['admin_dir'] . "/inc/functions_themes.php"; } else { if (file_exists(MYBB_ROOT . "admin/inc/functions_themes.php")) { require_once MYBB_ROOT . "admin/inc/functions_themes.php"; } else { $output->print_error("Upewnij się, że katalog /admin został poprawnie załadowany na serwer."); } } $output->print_header("Aktualizowanie arkuszy stylów CSS"); $query = $db->simple_select("themestylesheets", "*", "name='global.css' OR name='usercp.css'"); while ($theme = $db->fetch_array($query)) { resync_stylesheet($theme); } $query = $db->simple_select("themestylesheets", "*", "name='global.css' OR name='usercp.css'"); while ($theme = $db->fetch_array($query)) { $theme['stylesheet'] = upgrade_css_140_to_160($theme['name'], $theme['stylesheet']); // Create stylesheets cache_stylesheet($theme['tid'], $theme['cachefile'], $theme['stylesheet']); $update_stylesheet = array("stylesheet" => $db->escape_string($theme['stylesheet']), "lastmodified" => TIME_NOW); $db->update_query("themestylesheets", $update_stylesheet, "sid='{$theme['sid']}'"); } echo "<p>Arkusze stylów CSS zostały zaktualizowane.</p>"; echo "<p>Naciśnij przycisk Dalej, aby kontynuować proces aktualizacji.</p>"; global $footer_extra; //$footer_extra = "<script type=\"text/javascript\">window.onload = function() { var button = $$('.submit_button'); if(button[0]) { button[0].value = 'Automatyczne przekierowanie...'; button[0].disabled = true; button[0].style.color = '#aaa'; button[0].style.borderColor = '#aaa'; document.forms[0].submit(); }}</script>"; $output->print_footer("17_done"); }
function resync_stylesheet($stylesheet) { global $db; // Try and fix any missing cache file names if (!$stylesheet['cachefile'] && $stylesheet['name']) { $stylesheet['cachefile'] = $stylesheet['name']; $db->update_query("themestylesheets", array('cachefile' => $db->escape_string($stylesheet['name'])), "sid='{$stylesheet['sid']}'"); } // Still don't have the cache file name or is it not a flat file? Return false if (!$stylesheet['cachefile'] || strpos($stylesheet['cachefile'], 'css.php') !== false) { return false; } if (!file_exists(MYBB_ROOT . "cache/themes/theme{$stylesheet['tid']}/{$stylesheet['name']}") && !file_exists(MYBB_ROOT . "cache/themes/{$stylesheet['tid']}_{$stylesheet['name']}")) { if (cache_stylesheet($stylesheet['tid'], $stylesheet['cachefile'], $stylesheet['stylesheet']) !== false) { $db->update_query("themestylesheets", array('cachefile' => $db->escape_string($stylesheet['name'])), "sid='{$stylesheet['sid']}'"); update_theme_stylesheet_list($stylesheet['tid']); if ($stylesheet['sid'] != 1) { $db->update_query("themestylesheets", array('lastmodified' => TIME_NOW), "sid='{$stylesheet['sid']}'"); } } return true; } else { if ($stylesheet['sid'] != 1 && @filemtime(MYBB_ROOT . "cache/themes/theme{$stylesheet['tid']}/{$stylesheet['name']}") > $stylesheet['lastmodified']) { $contents = unfix_css_urls(file_get_contents(MYBB_ROOT . "cache/themes/theme{$stylesheet['tid']}/{$stylesheet['name']}")); $db->update_query("themestylesheets", array('stylesheet' => $db->escape_string($contents), 'lastmodified' => TIME_NOW), "sid='{$stylesheet['sid']}'", 1); return true; } } return false; }
function mysteam_install() { global $db, $lang; if (!$lang->mysteam) { $lang->load('mysteam'); } // Add Steam ID database field $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users ADD steamid varchar(30) NOT NULL"); // If Advanced Sidebox is installed, install ASB module and disable plugin's list functionality by default. if (file_exists(MYBB_ROOT . 'inc/plugins/asb.php')) { @copy(MYBB_ROOT . 'inc/plugins/mysteam/mysteamlist.php', MYBB_ROOT . 'inc/plugins/asb/modules/mysteamlist.php'); $list_enable_value = 'no'; } else { $list_enable_value = 'yes'; } // Add non-Advanced Sidebox status list settings group, then settings. $group = array('gid' => 'NULL', 'title' => $lang->mysteam_list_group_title, 'name' => 'mysteam_list_group', 'description' => $lang->mysteam_list_group_desc, 'disporder' => '222', 'isdefault' => '0'); $db->insert_query('settinggroups', $group); $gid = $db->insert_id(); $group_gid = (int) $gid; $setting = array('sid' => 'NULL', 'name' => 'mysteam_index', 'title' => $lang->mysteam_index_title, 'description' => $lang->mysteam_index_desc, 'optionscode' => 'yesno', 'value' => 'yes', 'disporder' => '1', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_portal', 'title' => $lang->mysteam_portal_title, 'description' => $lang->mysteam_portal_desc, 'optionscode' => 'yesno', 'value' => 'yes', 'disporder' => '2', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_list_width', 'title' => $lang->mysteam_list_width_title, 'description' => $lang->mysteam_list_width_desc, 'optionscode' => 'text', 'value' => '200', 'disporder' => '3', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_list_number', 'title' => $lang->mysteam_list_number_title, 'description' => $lang->mysteam_list_number_desc, 'optionscode' => 'text', 'value' => '0', 'disporder' => '4', 'gid' => $group_gid); $db->insert_query('settings', $setting); // Generate link to status list settings. if ($group_gid) { $mysteam_list_enable_desc = $lang->mysteam_list_enable_desc . ' (<a href="index.php?module=config-settings&action=change&gid=' . $group_gid . '">' . $lang->mysteam_list_settings . '</a>)'; } else { $mysteam_list_enable_desc = $lang->mysteam_list_enable_desc; } // Add main settings group, then settings. $group = array('gid' => 'NULL', 'title' => $lang->mysteam_title, 'name' => 'mysteam_main_group', 'description' => $lang->mysteam_main_group_desc, 'disporder' => '221', 'isdefault' => '0'); $db->insert_query('settinggroups', $group); $gid = $db->insert_id(); $group_gid = (int) $gid; $setting = array('sid' => 'NULL', 'name' => 'mysteam_list_enable', 'title' => $lang->mysteam_list_enable_title, 'description' => $mysteam_list_enable_desc, 'optionscode' => 'yesno', 'value' => $list_enable_value, 'disporder' => '1', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_apikey', 'title' => $lang->mysteam_apikey_title, 'description' => $lang->mysteam_apikey_desc, 'optionscode' => 'text', 'value' => '', 'disporder' => '2', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_limitbygroup', 'title' => $lang->mysteam_limitbygroup_title, 'description' => $lang->mysteam_limitbygroup_desc, 'optionscode' => 'text', 'value' => '', 'disporder' => '3', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_cache', 'title' => $lang->mysteam_cache_title, 'description' => $lang->mysteam_cache_desc, 'optionscode' => 'text', 'value' => '10', 'disporder' => '4', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_displayname', 'title' => $lang->mysteam_displayname_title, 'description' => $lang->mysteam_displayname_desc, 'optionscode' => 'radio steam=' . $lang->mysteam_displayname_steam . ' forum=' . $lang->mysteam_displayname_forum . ' both=' . $lang->mysteam_displayname_both, 'value' => 'forum', 'disporder' => '5', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_profile', 'title' => $lang->mysteam_profile_title, 'description' => $lang->mysteam_profile_desc, 'optionscode' => 'yesno', 'value' => 'yes', 'disporder' => '6', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_postbit', 'title' => $lang->mysteam_postbit_title, 'description' => $lang->mysteam_postbit_desc, 'optionscode' => 'radio img=' . $lang->mysteam_postbit_img . ' text=' . $lang->mysteam_postbit_text . ' no=' . $lang->mysteam_postbit_no, 'value' => 'img', 'disporder' => '7', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_hover', 'title' => $lang->mysteam_hover_title, 'description' => $lang->mysteam_hover_desc, 'optionscode' => 'yesno', 'value' => 'yes', 'disporder' => '8', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_prune', 'title' => $lang->mysteam_prune_title, 'description' => $lang->mysteam_prune_desc, 'optionscode' => 'text', 'value' => '0', 'disporder' => '9', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_usercp', 'title' => $lang->mysteam_usercp_title, 'description' => $lang->mysteam_usercp_desc, 'optionscode' => 'yesno', 'value' => 'yes', 'disporder' => '10', 'gid' => $group_gid); $db->insert_query('settings', $setting); $setting = array('sid' => 'NULL', 'name' => 'mysteam_modcp', 'title' => $lang->mysteam_modcp_title, 'description' => $lang->mysteam_modcp_desc, 'optionscode' => 'yesno', 'value' => 'yes', 'disporder' => '11', 'gid' => $group_gid); $db->insert_query('settings', $setting); rebuild_settings(); // Insert template group. $tgroup = array('prefix' => 'mysteam', 'title' => $lang->mysteam_template_group); $db->insert_query('templategroups', $tgroup); // Add CSS stylesheet. require_once MYBB_ADMIN_DIR . 'inc/functions_themes.php'; $stylesheet = @file_get_contents(MYBB_ROOT . 'inc/plugins/mysteam/mysteam.css'); $stylesheet_array = array('sid' => NULL, 'name' => 'mysteam.css', 'tid' => '1', 'stylesheet' => $db->escape_string($stylesheet), 'cachefile' => 'mysteam.css', 'lastmodified' => TIME_NOW); $db->insert_query('themestylesheets', $stylesheet_array); cache_stylesheet(1, 'mysteam.css', $stylesheet); update_theme_stylesheet_list(1); }
function avatarep_activate() { //Variables que vamos a utilizar global $mybb, $cache, $db, $lang, $templates; $lang->load("avatarep", false, true); // Crear el grupo de opciones $query = $db->simple_select("settinggroups", "COUNT(*) as rows"); $rows = $db->fetch_field($query, "rows"); $avatarep_groupconfig = array('name' => 'avatarep', 'title' => $db->escape_string($lang->avatarep_title), 'description' => $db->escape_string($lang->avatarep_title_descrip), 'disporder' => $rows + 1, 'isdefault' => 0); $group['gid'] = $db->insert_query("settinggroups", $avatarep_groupconfig); // Crear las opciones del plugin a utilizar $avatarep_config = array(); $avatarep_config[] = array('name' => 'avatarep_active', 'title' => $db->escape_string($lang->avatarep_power), 'description' => $db->escape_string($lang->avatarep_power_descrip), 'optionscode' => 'yesno', 'value' => '1', 'disporder' => 10, 'gid' => $group['gid']); $avatarep_config[] = array('name' => 'avatarep_foros', 'title' => $db->escape_string($lang->avatarep_forum), 'description' => $db->escape_string($lang->avatarep_forum_descrip), 'optionscode' => 'yesno', 'value' => '1', 'disporder' => 20, 'gid' => $group['gid']); $avatarep_config[] = array('name' => 'avatarep_temas', 'title' => $db->escape_string($lang->avatarep_thread_owner), 'description' => $db->escape_string($lang->avatarep_thread_owner_descrip), 'optionscode' => 'yesno', 'value' => '1', 'disporder' => 30, 'gid' => $group['gid']); $avatarep_config[] = array('name' => 'avatarep_temas2', 'title' => $db->escape_string($lang->avatarep_thread_lastposter), 'description' => $db->escape_string($lang->avatarep_thread_lastposter_descrip), 'optionscode' => 'yesno', 'value' => '1', 'disporder' => 40, 'gid' => $group['gid']); $avatarep_config[] = array('name' => 'avatarep_anuncios', 'title' => $db->escape_string($lang->avatarep_thread_announcements), 'description' => $db->escape_string($lang->avatarep_thread_announcements_descrip), 'optionscode' => 'yesno', 'value' => '1', 'disporder' => 50, 'gid' => $group['gid']); $avatarep_config[] = array('name' => 'avatarep_busqueda', 'title' => $db->escape_string($lang->avatarep_search), 'description' => $db->escape_string($lang->avatarep_search_descrip), 'optionscode' => 'yesno', 'value' => '1', 'disporder' => 60, 'gid' => $group['gid']); $avatarep_config[] = array('name' => 'avatarep_menu', 'title' => $db->escape_string($lang->avatarep_menu), 'description' => $db->escape_string($lang->avatarep_menu_descrip), 'optionscode' => 'yesno', 'value' => '1', 'disporder' => 70, 'gid' => $group['gid']); $avatarep_config[] = array('name' => 'avatarep_menu_width', 'title' => $db->escape_string($lang->avatarep_width), 'description' => $db->escape_string($lang->avatarep_width_descrip), 'optionscode' => 'textarea', 'value' => '350', 'disporder' => 80, 'gid' => $group['gid']); $avatarep_config[] = array('name' => 'avatarep_menu_heigh', 'title' => $db->escape_string($lang->avatarep_height), 'description' => $db->escape_string($lang->avatarep_height_descrip), 'optionscode' => 'textarea', 'value' => '120', 'disporder' => 90, 'gid' => $group['gid']); $avatarep_config[] = array('name' => 'avatarep_version', 'title' => "Version", 'description' => "Plugin version of last poster avatar on threadlist and forumlist", 'optionscode' => 'text', 'value' => 281, 'disporder' => 100, 'gid' => 0); foreach ($avatarep_config as $array => $content) { $db->insert_query("settings", $content); } // Creamos la cache de datos para nuestros avatares $query = $db->simple_select('announcements', 'uid'); $query = $db->query("\n\t\tSELECT DISTINCT(a.uid) as uid, u.username, u.username AS userusername, u.avatar, u.usergroup, u.displaygroup\n\t\tFROM " . TABLE_PREFIX . "announcements a\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON u.uid = a.uid\t\n\t"); if ($db->num_rows($query)) { $inline_avatars = array(); while ($user = $db->fetch_array($query)) { $inline_avatars[$user['uid']] = format_avatar($user); } $cache->update('anno_cache', $inline_avatars); } //Reconstruimos las opciones del archivo settings rebuild_settings(); //Adding new templates $templatearray = array('title' => 'avatarep_popup', 'template' => $db->escape_string('<table> <tr> <td id="tvatar"> <span><img src="{$memprofile[\'avatar\']}" alt="" /></span> </td> <td class="trow_profile"> <div class="trow_uprofile"> <a href="member.php?action=profile&uid={$uid}"> <span id="trow_uname">{$formattedname}</span> </a> <br /> <span id="trow_memprofile">{$usertitle}<br /> <a href="member.php?action=profile&uid={$uid}">{$lang->avatarep_user_profile}</a> <a href="private.php?action=send&uid={$memprofile[\'uid\']}">{$lang->avatarep_user_sendpm}</a> </span> <hr> <span id="trow_status"> {$lang->postbit_status} {$online_status}<br /> {$lang->registration_date} {$memregdate}<br /> {$lang->reputation} {$memprofile[\'reputation\']}<br /> {$lang->total_posts} {$memprofile[\'postnum\']}<br /> {$lang->lastvisit} {$memlastvisitdate} {$memlastvisittime}<br /> {$lang->warning_level} <a href="{$warning_link}">{$warning_level} %</a><br /><hr> (<a href="search.php?action=finduserthreads&uid={$uid}">{$lang->find_threads}</a> — <a href="search.php?action=finduser&uid={$uid}">{$lang->find_posts}</a>) </span> </div> </td> </tr> </table>'), 'sid' => '-1'); $db->insert_query("templates", $templatearray); // Añadir el css para la tipsy $avatarep_css = '/* POPUP MENU*/ .tbox { position:absolute; display:none; padding:14px 17px; z-index:900; text-align:left } .tinner { padding:15px; border-radius:5px; background:url(images/avatarep/loader.gif) no-repeat 50% 50% #FFFFFF; border-right:1px solid #F0F0F0; border-bottom:1px solid #F0F0F0; opacity: 0.8; } .tmask { position:absolute; display:none; top:0px; left:0px; height:100%; width:100%; background-color:#000000; z-index:800; opacity:0.8 !important; } .tclose { position:absolute; top:0px; right:0px; width:30px; height:30px; cursor:pointer; background:url(images/avatarep/close.png) no-repeat; } .tclose:hover { background-position:0 -30px; } #error { background:#e09c09; color:#424242; text-shadow:1px 1px #cf5454; border-right:1px solid #000; border-bottom:1px solid #000; padding:0; } #error .tcontent { padding:10px 14px 11px; border:1px solid #ffb8b8; border-radius:5px; } #success { background:#FFFFFF; color:#424242; text-shadow:1px 1px #1b6116; border-right:1px solid #000; border-bottom:1px solid #000; padding:10; border-radius:2px; } #bluemask { background:#4195aa; } #frameless { padding:0; } #frameless .tclose { left:6px; } #tvatar img { max-height: 135px; max-width: 135px; padding: 4px; border: 1px solid #0d4705; box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.1); } #tvatar img:hover { border-color: #e09c09; } hr { background-color:#989898; } .trow_profile{ vertical-align: top; padding-left: 9px; width:340px; color:#424242; } .trow_profile a{ color: #051517; } .trow_profile a:hover{ color: #e09c09; } .trow_uprofile{ min-height:175px; line-height:1.2; } #trow_uname{ font-size:15px; } #trow_memprofile{ font-size:11px; font-weight:bold; } #trow_status{ font-size: 11px; } .avatarep_img{ padding: 3px; border: 1px solid #D8DFEA; width: 30px; height: 30px; border-radius: 3px; opacity: 0.9; } .avatarep_fs{ margin-top: 13px; margin-left: 5px; position: absolute; font-size: 11px; } .avatarep_fd{ float: left; }'; $stylesheet = array("name" => "avatarep.css", "tid" => 1, "attachedto" => '', "stylesheet" => $db->escape_string($avatarep_css), "cachefile" => "avatarep.css", "lastmodified" => TIME_NOW); $sid = $db->insert_query("themestylesheets", $stylesheet); //Archivo requerido para cambios en estilos y plantillas. require_once MYBB_ADMIN_DIR . '/inc/functions_themes.php'; cache_stylesheet($stylesheet['tid'], $stylesheet['cachefile'], $avatarep_css); update_theme_stylesheet_list(1, false, true); /* Variables de imágen válidas, las normales son las que traen ya todo el código preformateado con la imágen y todo incluido... Anuncios: $anno_avatar['avatar'] - Ruta de la imagen $anno_avatar['avatarep'] - Código preformateado Temas: $avatarep_avatar['avatar'] - creador del tema (Ruta de la imagen) $avatarep_lastpost['avatar'] - ultimo envío (Ruta de la imagen) $avatarep_avatar['avatar'] - creador del tema (Código preformateado) $avatarep_lastpost['avatar'] - ultimo envío (Código preformateado) Foros: $forum['avatarep_lastpost']['avatar'] - Ruta de la imagen $forum['avatarep_lastpost']['avatarep'] - Código preformateado Ventana desplegable (Menú al dar clic en el avatar): $memprofile['avatar'] - Ruta de la imagen $memprofile['avatarep'] - Código preformateado Mostrar Tema: $avatarep['avatar'] - plugin SEO */ //Archivo requerido para reemplazo de templates require MYBB_ROOT . 'inc/adminfunctions_templates.php'; // Reemplazos que vamos a hacer en las plantillas 1.- Platilla 2.- Contenido a Reemplazar 3.- Contenido que reemplaza lo anterior find_replace_templatesets("headerinclude", '#' . preg_quote('{$stylesheets}') . '#', '{$stylesheets} <script type="text/javascript" src="{$mybb->settings[\'bburl\']}/images/avatarep/avatarep.js"></script>'); find_replace_templatesets("forumdisplay_thread", '#^(.*)$#s', '<tr class="inline_row"> <td align="center" class="{$bgcolor}{$thread_type_class}" width="2%"><span class="thread_status {$folder}" title="{$folder_label}"> </span>{$icon}</td> <td align="center" class="{$bgcolor}{$thread_type_class}" width="2%">{$avatarep_avatar[\'avatarep\']}</td> <td class="{$bgcolor}{$thread_type_class}"> {$attachment_count} <div> <span>{$prefix} {$gotounread}{$thread[\'threadprefix\']}<span class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}"><a href="{$thread[\'threadlink\']}">{$thread[\'subject\']}</a></span>{$thread[\'multipage\']}</span> <div class="author smalltext">{$thread[\'profilelink\']}</div> </div> </td> <td align="center" class="{$bgcolor}{$thread_type_class}"><a href="javascript:MyBB.whoPosted({$thread[\'tid\']});">{$thread[\'replies\']}</a>{$unapproved_posts}</td> <td align="center" class="{$bgcolor}{$thread_type_class}">{$thread[\'views\']}</td> {$rating} <td class="{$bgcolor}{$thread_type_class}" style="white-space: nowrap; text-align: left;"> <table border="0"> <tr> <td>{$avatarep_lastpost[\'avatarep\']}</td> <td> <span class="lastpost smalltext">{$lastpostdate} {$lastposttime}<br /> <a href="{$thread[\'lastpostlink\']}">{$lang->lastpost}</a>: {$lastposterlink}</span> </td> </tr> </table> </td> {$modbit} </tr>'); find_replace_templatesets("forumbit_depth2_forum_lastpost", '#^(.*)$#s', '<table border="0"> <tr> <td width="2%">{$lastpost_profilelink}</td> <td align="left" valign="top"> <span class="smalltext"> <a href="{$lastpost_link}" title="{$full_lastpost_subject}"><strong>{$lastpost_subject}</strong></a> <br />{$lastpost_date} {$lastpost_time}</span> </td> </tr> </table>'); find_replace_templatesets("forumdisplay_announcements_announcement", '#^(.*)$#s', '<tr> <td align="center" class="{$bgcolor}" width="2%"><span class="thread_status {$folder}"> </span></td> <td align="center" class="{$bgcolor}" width="2%">{$anno_avatar[\'avatarep\']}</td> <td class="{$bgcolor} forumdisplay_announcement"> <a href="{$announcement[\'announcementlink\']}"{$new_class}>{$announcement[\'subject\']}</a> <div class="author smalltext">{$announcement[\'profilelink\']}</div> </td> <td align="center" class="{$bgcolor} forumdisplay_announcement">-</td> <td align="center" class="{$bgcolor} forumdisplay_announcement">-</td> {$rating} <td class="{$bgcolor} forumdisplay_announcement" style="white-space: nowrap; text-align: right"><span class="smalltext">{$postdate}</span></td> {$modann} </tr>'); find_replace_templatesets("search_results_posts_post", '#^(.*)$#s', '<tr class="inline_row"> <td align="center" class="{$bgcolor}" width="2%"><span class="thread_status {$folder}"> </span>{$icon} </td> <td align="center" class="{$bgcolor}" width="2%">{$avatarep_avatar[\'avatarep\']}</td> <td class="{$bgcolor}"> <span class="smalltext"> {$lang->post_thread} <a href="{$thread_url}{$highlight}">{$post[\'thread_subject\']}</a><br /> {$lang->post_subject} <a href="{$post_url}{$highlight}#pid{$post[\'pid\']}">{$post[\'subject\']}</a> </span><br /> <table width="100%"><tr><td><span class="smalltext"><em>{$prev}</em></span></td></tr></table> </td> <td align="center" class="{$bgcolor}">{$post[\'profilelink\']}</td> <td class="{$bgcolor}" >{$post[\'forumlink\']}</td> <td align="center" class="{$bgcolor}"><a href="javascript:MyBB.whoPosted({$post[\'tid\']});">{$post[\'thread_replies\']}</a></td> <td align="center" class="{$bgcolor}">{$post[\'thread_views\']}</td> <td class="{$bgcolor}" style="white-space: nowrap; text-align: center;"><span class="smalltext">{$posted}</span></td> {$inline_mod_checkbox} </tr>'); find_replace_templatesets("search_results_threads_thread", '#^(.*)$#s', '<tr class="inline_row"> <td align="center" class="{$bgcolor}" width="2%"><span class="thread_status {$folder}" title="{$folder_label}"> </span>{$icon} </td> <td align="center" class="{$bgcolor}" width="2%">{$avatarep_avatar[\'avatarep\']}</td> <td class="{$bgcolor}"> {$attachment_count} <div> <span>{$prefix} {$gotounread}{$thread[\'threadprefix\']}<a href="{$thread_link}{$highlight}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread[\'subject\']}</a>{$thread[\'multipage\']}</span> <div class="author smalltext">{$thread[\'profilelink\']}</div> </div> </td> <td class="{$bgcolor}">{$thread[\'forumlink\']}</td> <td align="center" class="{$bgcolor}"><a href="javascript:MyBB.whoPosted({$thread[\'tid\']});">{$thread[\'replies\']}</a></td> <td align="center" class="{$bgcolor}">{$thread[\'views\']}</td> <td class="{$bgcolor}" style="white-space: nowrap"> <table border"0"> <tr> <td width="2%"> {$avatarep_lastpost[\'avatarep\']} </td> <td> <span class="smalltext"> {$lastpostdate}<br /> <a href="{$thread[\'lastpostlink\']}">{$lang->lastpost}</a>: {$lastposterlink} </span> </td> </tr> </table> </td> {$inline_mod_checkbox} </tr>'); //Se actualiza la info de las plantillas $cache->update_forums(); return true; }