25.04.2007, 00:29
Eine neue Erweiterung wurde veröffentlicht: Quick Theme
Zitat:Please see the ReadMe.txt in the download for installation instructions
Zitat:Please see the ReadMe.txt in the download for installation instructions
preg_match('#'.preg_quote('<!-- start: footer -->').'#i', $page, $matches);
if($matches[0])
{
$page = str_replace($matches[0], "<br />".$data."\n<!-- start: footer -->", $page);
}
preg_match('#'.preg_quote('<!-- quicktheme -->').'#i', $page, $matches);
if($matches[0])
{
$page = str_replace($matches[0], "<br />".$data."\n<!-- quicktheme -->", $page);
}
<?php
$plugins->add_hook("pre_output_page", "quicktheme_run");
$plugins->add_hook("index_start", "quicktheme_update");
$plugins->add_hook("global_start", "quicktheme_global");
function quicktheme_info()
{
return array(
"name" => "Quick Theme!",
"description" => "A plugin that allows users to quickly change their theme!",
"website" => "http://www.rct3x.net",
"author" => "Tikitiki",
"authorsite" => "http://www.rct3x.net",
"version" => "1.1",
);
}
function quicktheme_activate()
{
}
function quicktheme_deactivate()
{
}
function quicktheme_run($page)
{
global $mybb, $db, $lang;
$lang->load("usercp");
$theme_select = build_theme_select("style\" onchange=\"document.quicktheme.submit();", $mybb->user['style']);
if(strpos($theme_select, '</select>') === false)
{
$theme_select .= '</select>';
}
$normal = "<select name=\"style\" onchange=\"document.quicktheme.submit();\"><option value=\"0\">Standardeinstellung</option>
<option value=\"0\">-----------</option>";
$kurz = "<select name=\"style\" onchange=\"document.quicktheme.submit();\"><option value=\"0\">Standardeinstellung</option>";
$theme_select = str_replace($normal, $kurz, $theme_select);
$data = "\n<form name=\"quicktheme\" method=\"post\" action=\"./index.php?action=quicktheme\">\n";
$data .= "<input type=\"hidden\" name=\"uid\" value=\"{$mybb->user['uid']}\" />\n";
$data .= $theme_select;
$data .= "\n</form>";
preg_match('#'.preg_quote('<!-- quicktheme -->').'#i', $page, $matches);
if($matches[0])
{
$page = str_replace($matches[0], "<br />".$data."\n<!-- quicktheme -->", $page);
}
return $page;
}
function quicktheme_update()
{
global $mybb, $db, $lang;
if($mybb->input['action'] == 'quicktheme')
{
if(isset($mybb->input['style']) && $mybb->request_method == "post")
{
$lang->load('usercp');
if($mybb->user['uid'])
{
$db->update_query(TABLE_PREFIX."users", array('style' => intval($mybb->input['style'])), "uid='{$mybb->user['uid']}'");
}
else
{
if(intval($mybb->input['style']) == 0)
{
my_unsetcookie('quicktheme');
}
else
{
my_setcookie('quicktheme', intval($mybb->input['style']));
}
}
redirect($_SERVER['HTTP_REFERER'], $lang->redirect_optionsupdated);
}
}
}
function quicktheme_global()
{
global $mybb;
if($mybb->user['uid'] == 0 && intval($_COOKIE['quicktheme']) > 0)
{
$mybb->user['style'] = intval($_COOKIE['quicktheme']);
}
}
?>