<?php
#############################################################
# Top List 0.5 Beta #
#############################################################
# #
# Explora.Pc's Software #
# Copyright (c) 1998 - 2007 #
# by. Benjamin Nehls #
# #
# Website: www.Exp-Soft.de #
# #
# learn from this file but do not change any data on this #
# file write your file / plugin self! #
# #
#############################################################
if(!defined("IN_MYBB")) {
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("index_start","toplist");
function toplist_info()
{
return array(
"name" => "TopList",
"description" => "Zeigt die letzten Beiträge der User an & die besten Poster an.",
"website" => "http://www.Exp-Soft.de",
"author" => "Benjamin Nehls",
"authorsite" => "http://www.Exp-Soft.de",
"version" => "0.5 Beta",
);
}
function toplist_activate()
{
global $db;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", '#{\$forums}(\r?)\n#', "{\$forums}\n{\$toplist}\n");
$templatearray = array(
"tid" => "NULL",
"title" => "index_toplist",
"template" => "<table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\">
<thead>
<tr>
<td class=\"thead\" colspan=\"2\">
<div class=\"expcolimage\"><img src=\"{$theme['imgdir']}/collapse{$collapsedimg['blabla']}.gif\" id=\"blabla_img\" class=\"expander\" alt=\"[-]\" /></div>
<div><strong>{$lang->boardstats} <a href=\"http://www.Exp-Soft.de\" target=\"_blank\">Top List</a></strong></div>
</td>
</tr>
<tbody style=\"{$collapsed['toplist_e']}\" id=\"toplist_e\">
<tr>
<td class=\"tcat\" width=\"40%\"><strong>Top 10 Poster</strong></td>
<td class=\"tcat\"><strong>Neueste Beiträge</strong></td>
</tr>
<tr>
<td class=\"trow1\" valign=\"top\">{$top10}</td>
<td class=\"trow1\" valign=\"top\">{$thrd10}</td>
</tr>
</tbody>
</thead>
</table>
<div> </div>",
"sid" => "-1",
);
$db->insert_query(TABLE_PREFIX."templates", $templatearray);
$toplist_group = array(
"gid" => "NULL",
"name" => "TopList",
"title" => "TopList",
"description" => "Zeigt die letzten Beiträge der User an & die besten Poster an.",
"disporder" => "1",
"isdefault" => "no",
);
$db->insert_query(TABLE_PREFIX."settinggroups", $toplist_group);
$gid = $db->insert_id();
$toplist_1 = array(
"sid" => "NULL",
"name" => "toplist_topposter",
"title" => "Zeige Beste Poster an?",
"description" => "Sollen die besten Poster angezeigt werden?",
"optionscode" => "yesno",
"value" => "yes",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $toplist_1);
$toplist_2 = array(
"sid" => "NULL",
"name" => "toplist_last_post",
"title" => "Zeige die letzten Beiträge an?",
"description" => "Sollen die letzten Beiträge angezeigt werden?",
"optionscode" => "yesno",
"value" => "yes",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $toplist_2);
rebuild_settings();
}
function toplist_deactivate()
{
global $db;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("index", '#{\$toplist}(\r?)\n#', "", 0);
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='index_toplist'");
// Einstellungsgruppen löschen
$query = $db->query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='TopList'");
$g = $db->fetch_array($query);
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid='".$g['gid']."'");
// Einstellungen löschen
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid='".$g['gid']."'");
// Rebuilt settings.php
rebuild_settings();
}
// ###################### Hier werden die Besten Poster ermittelt und ausgegeben #####################################
function top10()
{
global $db;
$top10 .= "<table border=\"0\" width=\"100%\"><tr><td width=\"60%\"><strong>Username</strong></td><td width=\"40%\" align=\"right\"><strong>Beiträge</strong></td></tr>";
$query2 = $db->query ("SELECT username,uid,postnum FROM ".TABLE_PREFIX."users ORDER BY postnum DESC LIMIT 0,10");
while ($topposters = $db->fetch_array($query2))
{
$top10 .= "<tr><td class=\"smalltext\"><a href=\"member.php?action=profile&uid=".$topposters['uid']."\">".$topposters['username']."</a></td><td align=\"right\" class=\"smalltext\"><a href=\"search.php?action=finduser&uid=".$topposters['uid']."\">".$topposters['postnum']."</a></td></tr>";
}
$top10 .= "</table>";
return $top10;
}
// ###################### Hier werden die letzten Beiträge der User ermittelt und ausgegeben #########################
function thrd10()
{
global $db;
$thrd10 .= "<table border=\"0\" width=\"100%\"><tr><td width=\"60%\"><strong>Thread</strong></td><td width=\"20%\" align=\"right\"><Strong>Erstellt von</strong></td><td width=\"20%\" align=\"right\"><Strong>Antowrten</strong></td></tr>";
$query2 = $db->query ("SELECT * FROM ".TABLE_PREFIX."threads ORDER BY lastpost DESC LIMIT 0,10")or die ("error");
while ($threadsdb = $db->fetch_array($query2))
{
$query3 = $db->query ("SELECT uid,pid,tid FROM ".TABLE_PREFIX."posts WHERE tid=".$threadsdb['tid']."");
$threadsdb2 = $db->fetch_array($query3);
$thrd10 .= "<tr><td width=\"60%\" class=\"smalltext\"><a href=\"showthread.php?tid=".$threadsdb['tid']."&pid=".$threadsdb2['pid']."#pid".$threadsdb2['pid']."\">".substr(mysql_real_escape_string($threadsdb['subject']),0,50)."</a></td><td width=\"20%\" align=\"right\" class=\"smalltext\">".$threadsdb['lastposter']."</td><td width=\"20%\" align=\"right\" class=\"smalltext\">".$threadsdb['replies']."</td></tr>";
}
$thrd10 .= "</table>";
return $thrd10;
}
function toplist() {
// Gobale Variablen
global $db, $mybb, $cache, $templates, $lang, $toplist;
$top10 = top10();
$thrd10 = thrd10();
eval("\$toplist = \"".$templates->get("index_toplist")."\";");
}
// ###################### Einstellungen erneuern #########################
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);
}
}
?>