habe heute den Code mal etwas umgearbeitet und er sollte so funktionieren.
Einfach den Code der changeuser.php mit dem hier folgenden Code ersetzen.
Code: Alles auswählen
<?php
/***************************************************************************
* Change Poster Mod
* ------------------------
* Version : Version 1.0-fix5 - 26.05.04
* Copyright : (C) 2004 Tuxman
* Besonderer Dank an : andreasOymann von www.phpbb.de
* URL : <noch keine>
* eMail : tuxman@sumpfkuh.de
*
* $Id: changeuser.php,v 1.0f4 2004/05/26 Tuxman Exp $
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
// general starting
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// session stuff
$userdata = session_pagestart($user_ip, PAGE_CHANGEPOSTER);
init_userprefs($userdata);
// checking rights
if ($userdata['user_level'] != ADMIN) {
message_die(GENERAL_MESSAGE, $lang['ChgP_Admin']);
}
// get params
if ( !isset($HTTP_GET_VARS[POST_POST_URL]))
{
message_die(GENERAL_ERROR, $lang['ChgP_WrongID']);
}
else
{
$changeid = intval($HTTP_GET_VARS[POST_POST_URL]);
}
$mode = $HTTP_GET_VARS['mode'];
$newposter = $HTTP_GET_VARS['newposter'];
$newposter = "'".$newposter."'";
// main code
if ($mode == 'start')
{
//--------------------------------------------
// do the SQL ;-)
//----------------------
$sql = "SELECT p.poster_id, u.username, pt.post_text FROM " . POSTS_TABLE . " p
LEFT JOIN ". USERS_TABLE . " u on p.poster_id = u.user_id
LEFT JOIN ". POSTS_TEXT_TABLE . " pt on p.post_id = pt.post_id
WHERE p.post_id =" . $changeid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error reading database!');
}
while( $row = $db->sql_fetchrow($result) )
{
$changeposter_id = $row['poster_id'];
$changeposter = $row['username'];
$changemsg = $row['post_text'];
}
$db->sql_freeresult($result);
$chgpwrote = $changeposter . ' ' . $lang['ChgP_wrote'];
$template->assign_vars(array(
'CHANGEID' => $changeid,
'SUBMIT' => $lang['ChgP_Submit'],
'ACTION' => $PHP_SELF,
'REASSIGN_TEXT' => $changemsg,
'REASSIGN_POSTER' => $chgpwrote,
'REASSIGN_TITLE' => $lang['ChgP_Reassign'],
'REASSIGN_USERNAME' => $lang['ChgP_enterUsername'])
);
}
else if ($mode == 'reassign')
{
//--------------------------------------------
// do the SQL ;-)
//----------------------
//----------------------
// * change poster
//----------------------
$sql = "SELECT * FROM " . USERS_TABLE . " WHERE username = " . $newposter ;
if ( !($result = $db->sql_query($sql)) )
{
}
while( $row = $db->sql_fetchrow($result) )
{
$newposter_id = intval($row['user_id']);
$newuser_posts = intval($row['user_posts']) + 1;
}
if ($newposter_id != 0)
{
$sql = "SELECT p.poster_id, p.topic_id, u.user_id, u.user_posts FROM " . POSTS_TABLE . " p
LEFT JOIN " . USERS_TABLE . " u on p.poster_id = u.user_id
WHERE post_id = " . $changeid ;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['ChgP_NoUser']);
}
while( $row = $db->sql_fetchrow($result) )
{
$oldposter_id = $row['poster_id'];
$olduser_posts = intval($row['user_posts']) - 1;
$topic_id = intval($row['p.topic_id']);
}
$sql = "SELECT topic_first_post_id FROM " . TOPICS_TABLE . "
WHERE topic_id = " . $topic_id ;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Error reading topics table!');
}
while( $row = $db->sql_fetchrow($result) )
{
$topic_first_post_id = intval($row['topic_first_post_id']);
}
$sql = "UPDATE " . POSTS_TABLE . " SET poster_id=" . $newposter_id . " WHERE post_id =" . $changeid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['ChgP_WrongID']);
}
$sql = "UPDATE " . USERS_TABLE . " SET user_posts= " . $newuser_posts ." WHERE user_id =" . $newposter_id;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['ChgP_Error']);
}
$sql = "UPDATE " . USERS_TABLE . " SET user_posts= " . $olduser_posts ." WHERE user_id =" . $oldposter_id;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['ChgP_Error']);
}
$sql = "UPDATE " . TOPICS_TABLE . " SET topic_poster=" . $newposter_id ." WHERE topic_first_post_id =" . $changeid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['ChgP_Error']);
}
//----------------------
// end of SQL
//--------------------------------------------
message_die(GENERAL_MESSAGE, $topic_first_post_id . $change_id . $oldposter_id . $newposter_id . $lang['ChgP_done']);
}
else
{
$newposter_gast_id = "-1";
$sql = "UPDATE " . POSTS_TABLE . " SET post_username =" . $newposter . ", poster_id =" . $newposter_gast_id . " WHERE post_id =" . $changeid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['ChgP_WrongID']);
}
// * change topicstarter if necessary
//----------------------
$sql = "UPDATE " . TOPICS_TABLE . " SET topic_poster=" . $newposter_gast_id . " WHERE topic_first_post_id =" . $changeid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['ChgP_Error']);
}
message_die(GENERAL_MESSAGE, $topic_first_post_id . $change_id . $oldposter_id . $newposter_id . $lang['ChgP_done']);
}
}
//----------------------
// general ending
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'body' => 'changeuser_body.tpl')
);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>
Die Modder können ja nochmal testen
Gruss
Dogidog2001