<?php
/**
* Copyright © 2005 k776, All Rights Reserved
*/
if(!defined("IN_MYBB"))
{
die("This file cannot be accessed directly.");
}
$plugins->add_hook("index_start", "welcome_panel");
function welcome_info()
{
return array(
"name" => "Willkommens-Panel [Index]",
"description" => "Fügt ein Willkommens-Panel auf der Hauptseite ein.",
"website" => "",
"author" => "k776",
"authorsite" => "",
"version" => "1.0",
);
}
function welcome_activate()
{
global $db;
// Insert all Varibles needed for the Welcome Panel
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", '#\$header(\r?)\n#', "\$header\n\$welcomepanel\n");
// Insert all Templates needed for the Welcome Panel
$templatearray = array(
"tid" => "NULL",
"title" => "index_welcomepanel",
"template" => "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"tborder\">
<tr>
<td class=\"thead\" colspan=\"4\"><i>»</i> <b>\$lang->panel_welcome \$username</b></td>
</tr>
<tr>
\$avatarbox
\$yourstatsheader
\$boardstatsheader
\$spotlightheader
</tr>
<tr>
\$yourstatsbox
\$boardstatsbox
\$spotlightbox
</tr>
\$latestbox
</table>
<br />",
"sid" => "-1",
);
$db->insert_query(TABLE_PREFIX."templates", $templatearray);
// Insert all Setting Groups needed for the Welcome Panel
$welcomepanel_group = array(
"gid" => "NULL",
"name" => "Willkommens-Panel",
"description" => "",
"disporder" => "1",
"isdefault" => "no",
);
$db->insert_query(TABLE_PREFIX."settinggroups", $welcomepanel_group);
$gid = $db->insert_id();
// Insert all Settings needed for the Welcome Panel
$welcomepanel_1 = array(
"sid" => "NULL",
"name" => "showavatarbox",
"title" => "Ein- oder Ausschalten der \'Avatar\' Box",
"description" => "Soll die \'Avatar\' Box im Panel angezeigt werden?",
"optionscode" => "yesno",
"value" => "yes",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $welcomepanel_1);
$welcomepanel_2 = array(
"sid" => "NULL",
"name" => "showyourstatsbox",
"title" => "Ein- oder Ausschalten der \'Statistik\' Box",
"description" => "Soll die \'Statistik\' Box im Panel angezeigt werden?",
"optionscode" => "yesno",
"value" => "yes",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $welcomepanel_2);
$welcomepanel_3 = array(
"sid" => "NULL",
"name" => "showboardstatsbox",
"title" => "Ein- oder Ausschalten der \'Forenstatistik\' Box",
"description" => "Soll die \'Forenstatistik\' Box im Panel angezeigt werden?",
"optionscode" => "yesno",
"value" => "yes",
"disporder" => "3",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $welcomepanel_3);
$welcomepanel_4 = array(
"sid" => "NULL",
"name" => "showspotlightbox",
"title" => "Ein- oder Ausschalten der \'Spotlight\' Box",
"description" => "Soll die \'Spotlight\' Box im Panel angezeigt werden?",
"optionscode" => "yesno",
"value" => "yes",
"disporder" => "4",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $welcomepanel_4);
$welcomepanel_5 = array(
"sid" => "NULL",
"name" => "showlatestbox",
"title" => "Ein- oder Ausschalten der \'Spotlight\' Box",
"description" => "Soll die \'Letze...\' Box im Panel angezeigt werden?",
"optionscode" => "yesno",
"value" => "yes",
"disporder" => "5",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $welcomepanel_5);
// Rebuilt settings.php
rebuild_settings();
}
function welcome_deactivate()
{
global $db;
// Delete all Varibles needed in the Welcome Panel
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", '#\$welcomepanel(\r?)\n#', "", 0);
// Delete all Templates needed in the Welcome Panel
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='index_welcomepanel'");
// Delete all Setting Groups needed in the Welcome Panel
$query = $db->query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='Welcome Panel'");
$g = $db->fetch_array($query);
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid='".$g['gid']."'");
// Delete all Settings needed in the Welcome Panel
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid='".$g['gid']."'");
// Rebuilt settings.php
rebuild_settings();
}
function welcome_panel()
{
global $db, $mybb, $cache, $templates, $lang, $welcomepanel;
$lang->panel_welcome = "Willkommen";
$lang->panel_yourinfo = "Deine Informationen";
$lang->panel_boardinfo = "Foreninformation";
$lang->panel_spotlight = "Mitglieder Spotlight";
$lang->panel_userid = "Benutzer-ID:";
$lang->panel_posts = "Beiträge:";
$lang->panel_title = "Benutzertitel:";
$lang->panel_regemail = "Email:";
$lang->panel_tmembers = "Mitglieder:";
$lang->panel_tthreads = "Themen:";
$lang->panel_tposts = "Beiträge:";
$lang->panel_newmem = "Neuestes Mitglied:";
$lang->panel_spotuser = "Benutzername:";
$lang->panel_spottitle = "Benutzertitel:";
$lang->panel_spotpost = "Beiträge:";
$lang->panel_lthread = "Letztes Thema:";
$lang->panel_lpost = "Letzter Beitrag:";
$lang->panel_lpoll = "Letzte Umfrage:";
$lang->panel_nothread = "Noch keine Themen!";
$lang->panel_nopost = "Noch keine Beiträge!";
$lang->panel_nopoll = "Noch keine Umfragen!";
$lang->panel_email = "Email schicken";
$lang->panel_pm = "PN schicken";
$lang->panel_guser = "Besucher";
$lang->panel_gtitle = "Nicht registriert / Nicht angemeldet";
require MYBB_ROOT."/inc/functions_user.php";
if($mybb->settings['showyourstatsbox'] != "no" && $mybb->settings['showboardstatsbox'] != "no" && $mybb->settings['showspotlightbox'] != "no")
{
$width = " width=\"33%\"";
}
else
{
$width = "";
}
if($mybb->user['uid'] == 0)
{
$username = $lang->panel_guser;
}
else
{
$username = $mybb->user['username'];
}
if($mybb->settings['showavatarbox'] != "no")
{
if($mybb->user['uid'] != 0 && $mybb->user['avatar'])
{
$avatar = "<img src=\"".$mybb->user['avatar']."\">";
}
$avatarbox = "<td class=\"trow1\" valign=\"center\" align=\"center\" rowspan=\"3\"><table border=\"0\" cellpadding=\"10\"><tr><td>$avatar</td></tr></table></td>";
}
if($mybb->settings['showyourstatsbox'] != "no")
{
if($mybb->user['uid'] != 0)
{
$title = get_usertitle($mybb->user['uid']);
if($mybb->user['email'])
{
$email = "$lang->panel_regemail</td><td><a href=\"mailto:".$mybb->user['email']."\">". $mybb->user['email'] ."</a>";
}
}
else
{
$mybb->user['uid'] = "0";
$mybb->user['postnum'] = "0";
$title = $lang->panel_gtitle;
}
$yourstatsheader = "<td class=\"tcat\"$width><b><u>$lang->panel_yourinfo</u></b></td>";
$yourstatsbox = "<td class=\"trow2\" valign=\"top\"$width><table width=\"100%\" cellpadding=\"1\" cellspacing=\"1\"><tr><td>$lang->panel_userid</td><td>".$mybb->user['uid']."</td></tr><tr><td>$lang->panel_posts</td><td>".$mybb->user['postnum']."</td></tr><tr><td>$lang->panel_title</td><td>$title</td></tr><tr><td>$email</td></tr></table></td>";
}
if($mybb->settings['showboardstatsbox'] != "no")
{
$stats = $cache->read("stats");
$boardstatsheader = "<td class=\"tcat\"$width><b><u>$lang->panel_boardinfo</u></b></td>";
$boardstatsbox = "<td class=\"trow1\" valign=\"top\"$width><table width=\"100%\" cellpadding=\"1\" cellspacing=\"1\"><tr><td>$lang->panel_tmembers</td><td>$stats[numusers]</td></tr><tr><td>$lang->panel_tthreads</td><td>$stats[numthreads]</td></tr><tr><td>$lang->panel_tposts</td><td>$stats[numposts]</td></tr><tr><td>$lang->panel_newmem</td><td><a href=\"member.php?action=profile&uid=$stats[lastuid]\">$stats[lastusername]</a></td></tr></table></td>";
}
if($mybb->settings['showspotlightbox'] != "no")
{
$query = $db->query("SELECT uid,username,postnum FROM ".TABLE_PREFIX."users ORDER BY rand() LIMIT 0,1");
$spotlight = $db->fetch_array($query);
if($mybb->user['uid'] != 0)
{
$spotlight_options = "<td colspan=\"2\"><br><center><a href=\"member.php?action=emailuser&uid=$spotlight[uid]\">$lang->panel_email</a> | <a href=\"private.php?action=send&uid=$spotlight[uid]\">$lang->panel_pm</a></center></td>";
}
$title = get_usertitle($spotlight['uid']);
$spotlightheader = "<td class=\"tcat\"$width><b><u>$lang->panel_spotlight</u></b></td>";
$spotlightbox = "<td class=\"trow2\" valign=\"top\"$width><table width=\"100%\" cellpadding=\"1\" cellspacing=\"1\"><tr><td>$lang->panel_spotuser</td><td><a href=\"member.php?action=profile&uid=$spotlight[uid]\">$spotlight[username]</a></td></tr><tr><td>$lang->panel_spottitle</td><td>$title</td></tr><tr><td>$lang->panel_spotpost</td><td>$spotlight[postnum]</td></tr><tr>$spotlight_options</tr></table></td>";
}
if($mybb->settings['showlatestbox'] != "no")
{
$query1 = $db->query("SELECT tid,subject FROM ".TABLE_PREFIX."threads ORDER BY tid DESC LIMIT 0,1");
$t1 = $db->num_rows($query1);
if($t1 != "0")
{
$thread = $db->fetch_array($query1);
$thread = "<td align=\"left\">$lang->panel_lthread <a href=\"showthread.php?tid=$thread[tid]\">$thread[subject]</a></td>";
}
else
{
$thread = "<td align=\"left\">$lang->panel_nothread</td>";
}
$query2 = $db->query("SELECT tid,pid,subject FROM ".TABLE_PREFIX."posts ORDER BY pid DESC LIMIT 0,1");
$p1 = $db->num_rows($query2);
if($p1 != "0")
{
$post = $db->fetch_array($query2);
$post = "<td align=\"center\">$lang->panel_lpost <a href=\"showthread.php?tid=$post[tid]&pid=$post[pid]#pid$post[pid]\">$post[subject]</a></td>";
}
else
{
$post = "<td align=\"center\">$lang->panel_nopost</a>";
}
$query3 = $db->query("SELECT tid,question FROM ".TABLE_PREFIX."polls ORDER BY pid DESC LIMIT 0,1");
$p2 = $db->num_rows($query3);
if($p2 != "0")
{
$poll = $db->fetch_array($query3);
$poll = "<td align=\"right\">$lang->panel_lpoll <a href=\"showthread.php?tid=$poll[tid]\">$poll[question]</a></td>";
}
else
{
$poll = "<td align=\"right\">$lang->panel_nopoll</td>";
}
$latestbox = "<tr><td colspan=\"3\" class=\"trow1\"><table width=\"90%\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\"><tr>$thread$post$poll</tr></table></td></tr>";
}
eval("\$welcomepanel = \"".$templates->get("index_welcomepanel")."\";");
}
if(!function_exists("rebuild_settings"))
{
function rebuild_settings()
{
global $db;
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."settings ORDER BY title ASC");
while($setting = $db->fetch_array($query))
{
$setting['value'] = addslashes($setting['value']);
$settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";
}
$settings = "<?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?>";
$file = fopen(MYBB_ROOT."/inc/settings.php", "w");
fwrite($file, $settings);
fclose($file);
}
}
?>