Konfiguration im Quelltext
Änderungen:
1 neue Datei (prefix.php)
2 Dateien zu ändern (viewforum.php, templates/*/viewforum_body.tpl) [3 Änderungen]
prefix.php:
[Based on: Vorlage für in phpBB eingebundene Seiten http://www.phpbb.de/doku/kb/artikel.php ... hpbb_seite und dem Standardhandling von POST & GET von phpBB]
Code: Alles auswählen
<?php
//
// very simple prefix by luna + seimon
//
//Benötigte Dateien und Variablen von phpBB
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//Session auslesen und Benutzer-Informationen laden
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
if ( !( $userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD ))
{
message_die(GENERAL_ERROR, $lang['Not_Authorised']);
}
//get parameters
$topic_id = '';
if ( isset($HTTP_POST_VARS['topic_id']) || isset($HTTP_GET_VARS['topic_id']) )
{
$topic_id = ( isset($HTTP_POST_VARS['topic_id']) ) ? intval(htmlspecialchars($HTTP_POST_VARS['topic_id'])) : intval(htmlspecialchars($HTTP_GET_VARS['topic_id']));
}
$redirect_id = '';
if ( isset($HTTP_POST_VARS['redirect_id']) || isset($HTTP_GET_VARS['redirect_id']) )
{
$redirect_id = ( isset($HTTP_POST_VARS['redirect_id']) ) ? intval(htmlspecialchars($HTTP_POST_VARS['redirect_id'])) : intval(htmlspecialchars($HTTP_GET_VARS['redirect_id']));
}
$text = '';
if ( isset($HTTP_POST_VARS['text']) || isset($HTTP_GET_VARS['text']) )
{
$text = ( isset($HTTP_POST_VARS['text']) ) ? htmlspecialchars($HTTP_POST_VARS['text']) : htmlspecialchars($HTTP_GET_VARS['text']);
}
//check if we have all we need
if ((!$topic_id) || (!$redirect_id) || (!$text))
{
message_die(GENERAL_ERROR, 'Not enough parameters', '', __LINE__, __FILE__);
}
//get topic title
$sql = "SELECT topic_title FROM " . $table_prefix . "topics WHERE topic_id = $topic_id;";
$result;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Cannot find topic title', '', __LINE__, __FILE__, $sql);
}
$title_old = '';
if ( $db->sql_numrows($result) > 0)
{
$row = mysql_fetch_array($result);
$title_old = $row['topic_title'];
}
//set new title
$title_new = $title_old;
if ($title_old)
{
//add done only if it not exists
if (!(preg_match("/\[$text\]/", $title_old)))
{
$title_new = "[$text] ".$title_old;
}
} else
{
message_die(GENERAL_ERROR, 'Cannot get topic title', '', __LINE__, __FILE__, $sql);
}
//update title for this thread in database
$sql = "UPDATE " . $table_prefix . "topics SET topic_title = '$title_new' WHERE topic_id = $topic_id;";
$result = mysql_query($sql);
//redirect to desired forum
$redirect_url = 'viewforum.php?f='.$redirect_id;
header("Location: $redirect_url");
exit;
?>
MOD:
Code: Alles auswählen
#
#-----[ COPY ]------------------------------------------------
#
copy prefix.php to prefix.php
#
#-----[ OPEN ]------------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------------
#
$template->assign_block_vars('topicrow', array(
#
#-----[ BEFORE, ADD ]-----------------------------------------
# Hier kann konfiguriert werden
# Für die Unterschiedlichen "Prefix Pakete" gibt es jeweils ein if
# In der Bedingung stehen die Userberechtigungen und in welchem Forum es die Buttons gibt
# Die Variable $luna_done bestimmt das Prefix und das Aussehen der Buttons
// very simple prefix by luna + seimon start
$luna_done = '';
if ( ( $userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD ) AND $forum_id == 37 )
{
$luna_done = ' <a href="prefix.php?topic_id=' . $topic_id . '&redirect_id='. $forum_id . '&text=done"> <img src="images/hakerl.gif" alt="Beitrag als done markieren" title="Beitrag als done markieren" border="0" /></a>';
}
if ( ( $userdata['user_level'] == ADMIN || $userdata['user_id'] == 4525 || $userdata['user_id'] == 6143 ) AND $forum_id == 27 )
{
$luna_done = ' <a href="prefix.php?topic_id=' . $topic_id . '&redirect_id='. $forum_id . '&text=verwarnt"> <img src="images/icon_ycard.gif" alt="User wurde verwarnt" title="User wurde verwarnt" border="0" /></a>';
$luna_done .= ' <a href="prefix.php?topic_id=' . $topic_id . '&redirect_id='. $forum_id . '&text=deleted"> <img src="images/icon_rcard.gif" alt="User wurde gelöscht" title="User wurde gelöscht" border="0" /></a>';
$luna_done .= ' <a href="prefix.php?topic_id=' . $topic_id . '&redirect_id='. $forum_id . '&text=done"> <img src="images/hakerl.gif" alt="Beitrag als done markieren" title="Beitrag als done markieren" border="0" /></a>';
}
// very simple prefix by luna + seimon end
#
#-----[ FIND ]------------------------------------------------
#
'TOPIC_TITLE' => $topic_title,
#
#-----[ AFTER, ADD ]------------------------------------------
#
// very simple prefix by luna + seimon start
'LUNA_DONE' => $luna_done,
// very simple prefix by luna + seimon end
#
#-----[ OPEN ]------------------------------------------------
#
templates/*/viewforum_body.tpl
#
#-----[ FIND ]------------------------------------------------
#
<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a></span>
#
#-----[ AFTER, ADD ]------------------------------------------
#
{topicrow.LUNA_DONE}
mfg Seimon
/edit: achja wär nett, wenn mir wer sagen könnte, ob es da sicherheitslücken gibt, die ich übersehen hab
