07.07.2006, 21:32
OK
Hier zunächst mal der komplette Code:
<?php
require './global.php';
require './inc/functions_post.php';
/* Currently, only logged in users can access the shoutbox.
This will change in version 2.0 so as administrators may set which groups can
access the shoutbox. */
if($mybb->user['uid'] == 0)
{
// Sorry mate, you're not coming in!
sb_error('Nur angemeldete Benutzer können die Shoutbox sehen.');
}
/* Function: sb_error()
Display the specified error message to the user and kill the script. */
function sb_error($message)
{
global $header, $footer, $css, $theme, $headerinclude, $templates, $mybb;
// Adios Amigos!
eval("\$error = \"".$templates->get('shoutbox_error')."\";");
outputpage($error);
exit;
}
// Lets do this thang!
switch($mybb->input['action'])
{
case 'do_add':
// Flood checking.
/* Currently, users can only make five consecutive shouts in the shoutbox before
they recieve a flood warning. This will change in version 2.0 so as administrators
may specify the maximum number of consecutive shouts users can make in the shoutbox. */
if($mybb->user['usergroup'] != 4 && $mybb->user['usergroup'] != 3)
{
$query = $db->query("SELECT COUNT(sid) AS shouts FROM ".TABLE_PREFIX."shouts");
$shoutcount = $db->result($query, 0);
}
else
{
$shoutcount = 0;
}
if($shoutcount > 4)
{
$start = $shoutcount - 5;
$floodcheck = 0;
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."shouts ORDER BY dateline LIMIT $start, 5");
while($shout = $db->fetch_array($query))
{
if($shout['username'] == $mybb->user['username'])
{
$check++;
}
}
if($check > 4)
{
sb_error('Bevor Sie einen weiteren Beitrag schreiben können, muss erst ein anderer Benutzer etwas schreiben.');
}
}
$newshout = array(
'sid' => NULL,
'uid' => intval($mybb->user['uid']),
'username' => addslashes($mybb->user['username']),
'message' => addslashes($mybb->input['message']),
'dateline' => time(),
'ipaddress' => getip(),
);
$db->insert_query(TABLE_PREFIX."shouts", $newshout);
redirect('shoutbox.php', 'Beitrag gespeichert', $mybb->settings['bbname']);
break;
case 'do_delete':
if(!intval($mybb->input['sid']))
{
sb_error('Der Beitrag, den Sie bearbeiten wollen, scheint ungültig zu sein.');
}
else
{
$sid = $mybb->input['sid'];
}
// Delete the shout already!
$db->query("DELETE FROM ".TABLE_PREFIX."shouts WHERE sid='$sid'");
redirect('shoutbox.php', 'Beitrag gelöscht', $mybb->settings['bbname']);
break;
case 'do_edit':
if(!intval($mybb->input['sid']))
{
sb_error('Der Beitrag, den Sie löschen wollen, scheint ungültig zu sein.');
}
else
{
$sid = $mybb->input['sid'];
}
// Prepare the updated shout
$updatedshout = array(
'message' => addslashes($mybb->input['message']),
'ipaddress' => getip(),
);
// Update the shout already!
$db->update_query(TABLE_PREFIX."shouts", $updatedshout, "sid='$sid'");
redirect('shoutbox.php', 'Beitrag aktualisiert', $mybb->settings['bbname']);
break;
case 'delete':
if(!intval($mybb->input['sid']))
{
sb_error('Der Beitrag, den Sie löschen wollen, scheint ungültig zu sein.');
}
else
{
$sid = $mybb->input['sid'];
}
// We have a valid shout ID, get the shout from the database.
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."shouts WHERE sid='$sid'");
$shout = $db->fetch_array($query);
// Can this user delete the shout?
/* Better control over who can delete shouts at various times is due to be implemented in version 2.0. */
if($mybb->user['usergroup'] != 4 && $mybb->user['usergroup'] != 3 && $mybb->user['uid'] != $shout['uid'])
{
sb_error('Sie scheinen nicht die Berechtigung zu haben, diesen Beitrag zu löschen.');
}
// Yes, this user can, so let's allow them to.
eval("\$deleteshout = \"".$templates->get('shoutbox_delete')."\";");
outputpage($deleteshout);
break;
case 'edit':
if(!intval($mybb->input['sid']))
{
sb_error('Der Beitrag, den Sie bearbeiten wollen, scheint ungültig zu sein.');
}
else
{
$sid = $mybb->input['sid'];
}
// We have a valid shout ID, get the shout from the database.
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."shouts WHERE sid='$sid'");
$shout = $db->fetch_array($query);
// Can this user modify the shout?
/* Better control over who can edit shouts at various times is due to be implemented in version 2.0. */
if($mybb->user['usergroup'] != 4 && $mybb->user['usergroup'] != 3 && $mybb->user['uid'] != $shout['uid'])
{
sb_error('Sie scheinen nicht die Berechtigung zu haben, diesen Beitrag zu bearbeiten.');
}
// This should stop the edit page breaking.
$shout['message'] = str_replace('"', '"', $shout['message']);
// Yes, this user can, so let's allow them to.
eval("\$editshout = \"".$templates->get('shoutbox_edit')."\";");
outputpage($editshout);
break;
default:
// First things first, pagination. Woohoo!
$query = $db->query("SELECT COUNT(sid) AS shouts FROM ".TABLE_PREFIX."shouts");
$shoutcount = $db->result($query, 0);
// If there are currently no shouts in the database, prompt the user to make one.
if($shoutcount < 1)
{
eval("\$shouts = \"".$templates->get('shoutbox_error_noshouts')."\";");
}
else
{
/* Currently, a maximum of 25 shouts are shown on any one page of the shoutbox.
This will change in version 2.0 so as administrators may set the maximum
number of shouts to be shown per page. */
$perpage = 25;
$pages = ceil($shoutcount / $perpage);
if(!intval($mybb->input['page']))
{
$page = 1;
}
else
{
$page = intval($mybb->input['page']);
}
if($page == $pages)
{
$start = 0;
$limit = $shoutcount - $perpage;
if($limit < 0)
{
$limit = $shoutcount;
}
}
else
{
$start = $shoutcount - $perpage;
$limit = $perpage;
}
$multipage = multipage($shoutcount, $perpage, $page, 'shoutbox.php?');
// Start getting shouts!
$query = $db->query("SELECT s.*, s.username AS shoutusername, u.username, u.usergroup, u.displaygroup FROM ".TABLE_PREFIX."shouts s LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=s.uid) ORDER BY dateline DESC LIMIT $start, $limit");
while($shout = $db->fetch_array($query))
{
$shout['message'] = postify($shout['message']);
$shout['time'] = mydate($mybb->settings['dateformat'], $shout['dateline']).' '.mydate($mybb->settings['timeformat'], $shout['dateline']);
// Check for /me tag in shout.
$mecheck = explode(' ', $shout['message']);
if($mecheck[0] == '/me' || $mecheck[0] == '/slap')
{
$shout['message'] = domecode($shout['message'], $shout['username']);
$shout['username'] = '';
}
else
{
$shout['username'] = formatname($shout['username'], $shout['usergroup'], $shout['displaygroup']);
$shout['username'] = $shout['time'].''.'<<a href="member.php?action=profile&uid='.intval($shout['uid']).'">'.$shout['username'].'</a>>';
}
$title = 'title="Posted: '.$shout['time'];
if($mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 3)
{
$title .= ', IP: '.$shout['ipaddress'];
}
$title .= '"';
if($mybb->user['uid'] == $shout['uid'] || $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 3)
{
eval("\$options = \"".$templates->get('shoutbox_options')."\";");
}
else
{
$options = '';
}
if($bgcolor == 'trow1')
{
$bgcolor = 'trow2';
}
else
{
$bgcolor = 'trow1';
}
eval("\$shouts .= \"".$templates->get('shoutbox_shout')."\";");
}
}
$refresh = "<meta http-equiv=\"refresh\" content=\"60;URL=shoutbox.php\">";
eval("\$addshout = \"".$templates->get('shoutbox_add')."\";");
eval("\$shoutbox = \"".$templates->get('shoutbox')."\";");
outputpage($shoutbox);
break;
}
?>
Und Lenkradschloss tippt mir aus der Seele:
Denn er beschreibt genau auch meine Probleme.
z.B. verschwinden alle Einträge nach dem Löschen eines einzelnen Eintrags.
Wer weiß Rat ?
Hier zunächst mal der komplette Code:
<?php
require './global.php';
require './inc/functions_post.php';
/* Currently, only logged in users can access the shoutbox.
This will change in version 2.0 so as administrators may set which groups can
access the shoutbox. */
if($mybb->user['uid'] == 0)
{
// Sorry mate, you're not coming in!
sb_error('Nur angemeldete Benutzer können die Shoutbox sehen.');
}
/* Function: sb_error()
Display the specified error message to the user and kill the script. */
function sb_error($message)
{
global $header, $footer, $css, $theme, $headerinclude, $templates, $mybb;
// Adios Amigos!
eval("\$error = \"".$templates->get('shoutbox_error')."\";");
outputpage($error);
exit;
}
// Lets do this thang!
switch($mybb->input['action'])
{
case 'do_add':
// Flood checking.
/* Currently, users can only make five consecutive shouts in the shoutbox before
they recieve a flood warning. This will change in version 2.0 so as administrators
may specify the maximum number of consecutive shouts users can make in the shoutbox. */
if($mybb->user['usergroup'] != 4 && $mybb->user['usergroup'] != 3)
{
$query = $db->query("SELECT COUNT(sid) AS shouts FROM ".TABLE_PREFIX."shouts");
$shoutcount = $db->result($query, 0);
}
else
{
$shoutcount = 0;
}
if($shoutcount > 4)
{
$start = $shoutcount - 5;
$floodcheck = 0;
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."shouts ORDER BY dateline LIMIT $start, 5");
while($shout = $db->fetch_array($query))
{
if($shout['username'] == $mybb->user['username'])
{
$check++;
}
}
if($check > 4)
{
sb_error('Bevor Sie einen weiteren Beitrag schreiben können, muss erst ein anderer Benutzer etwas schreiben.');
}
}
$newshout = array(
'sid' => NULL,
'uid' => intval($mybb->user['uid']),
'username' => addslashes($mybb->user['username']),
'message' => addslashes($mybb->input['message']),
'dateline' => time(),
'ipaddress' => getip(),
);
$db->insert_query(TABLE_PREFIX."shouts", $newshout);
redirect('shoutbox.php', 'Beitrag gespeichert', $mybb->settings['bbname']);
break;
case 'do_delete':
if(!intval($mybb->input['sid']))
{
sb_error('Der Beitrag, den Sie bearbeiten wollen, scheint ungültig zu sein.');
}
else
{
$sid = $mybb->input['sid'];
}
// Delete the shout already!
$db->query("DELETE FROM ".TABLE_PREFIX."shouts WHERE sid='$sid'");
redirect('shoutbox.php', 'Beitrag gelöscht', $mybb->settings['bbname']);
break;
case 'do_edit':
if(!intval($mybb->input['sid']))
{
sb_error('Der Beitrag, den Sie löschen wollen, scheint ungültig zu sein.');
}
else
{
$sid = $mybb->input['sid'];
}
// Prepare the updated shout
$updatedshout = array(
'message' => addslashes($mybb->input['message']),
'ipaddress' => getip(),
);
// Update the shout already!
$db->update_query(TABLE_PREFIX."shouts", $updatedshout, "sid='$sid'");
redirect('shoutbox.php', 'Beitrag aktualisiert', $mybb->settings['bbname']);
break;
case 'delete':
if(!intval($mybb->input['sid']))
{
sb_error('Der Beitrag, den Sie löschen wollen, scheint ungültig zu sein.');
}
else
{
$sid = $mybb->input['sid'];
}
// We have a valid shout ID, get the shout from the database.
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."shouts WHERE sid='$sid'");
$shout = $db->fetch_array($query);
// Can this user delete the shout?
/* Better control over who can delete shouts at various times is due to be implemented in version 2.0. */
if($mybb->user['usergroup'] != 4 && $mybb->user['usergroup'] != 3 && $mybb->user['uid'] != $shout['uid'])
{
sb_error('Sie scheinen nicht die Berechtigung zu haben, diesen Beitrag zu löschen.');
}
// Yes, this user can, so let's allow them to.
eval("\$deleteshout = \"".$templates->get('shoutbox_delete')."\";");
outputpage($deleteshout);
break;
case 'edit':
if(!intval($mybb->input['sid']))
{
sb_error('Der Beitrag, den Sie bearbeiten wollen, scheint ungültig zu sein.');
}
else
{
$sid = $mybb->input['sid'];
}
// We have a valid shout ID, get the shout from the database.
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."shouts WHERE sid='$sid'");
$shout = $db->fetch_array($query);
// Can this user modify the shout?
/* Better control over who can edit shouts at various times is due to be implemented in version 2.0. */
if($mybb->user['usergroup'] != 4 && $mybb->user['usergroup'] != 3 && $mybb->user['uid'] != $shout['uid'])
{
sb_error('Sie scheinen nicht die Berechtigung zu haben, diesen Beitrag zu bearbeiten.');
}
// This should stop the edit page breaking.
$shout['message'] = str_replace('"', '"', $shout['message']);
// Yes, this user can, so let's allow them to.
eval("\$editshout = \"".$templates->get('shoutbox_edit')."\";");
outputpage($editshout);
break;
default:
// First things first, pagination. Woohoo!
$query = $db->query("SELECT COUNT(sid) AS shouts FROM ".TABLE_PREFIX."shouts");
$shoutcount = $db->result($query, 0);
// If there are currently no shouts in the database, prompt the user to make one.
if($shoutcount < 1)
{
eval("\$shouts = \"".$templates->get('shoutbox_error_noshouts')."\";");
}
else
{
/* Currently, a maximum of 25 shouts are shown on any one page of the shoutbox.
This will change in version 2.0 so as administrators may set the maximum
number of shouts to be shown per page. */
$perpage = 25;
$pages = ceil($shoutcount / $perpage);
if(!intval($mybb->input['page']))
{
$page = 1;
}
else
{
$page = intval($mybb->input['page']);
}
if($page == $pages)
{
$start = 0;
$limit = $shoutcount - $perpage;
if($limit < 0)
{
$limit = $shoutcount;
}
}
else
{
$start = $shoutcount - $perpage;
$limit = $perpage;
}
$multipage = multipage($shoutcount, $perpage, $page, 'shoutbox.php?');
// Start getting shouts!
$query = $db->query("SELECT s.*, s.username AS shoutusername, u.username, u.usergroup, u.displaygroup FROM ".TABLE_PREFIX."shouts s LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=s.uid) ORDER BY dateline DESC LIMIT $start, $limit");
while($shout = $db->fetch_array($query))
{
$shout['message'] = postify($shout['message']);
$shout['time'] = mydate($mybb->settings['dateformat'], $shout['dateline']).' '.mydate($mybb->settings['timeformat'], $shout['dateline']);
// Check for /me tag in shout.
$mecheck = explode(' ', $shout['message']);
if($mecheck[0] == '/me' || $mecheck[0] == '/slap')
{
$shout['message'] = domecode($shout['message'], $shout['username']);
$shout['username'] = '';
}
else
{
$shout['username'] = formatname($shout['username'], $shout['usergroup'], $shout['displaygroup']);
$shout['username'] = $shout['time'].''.'<<a href="member.php?action=profile&uid='.intval($shout['uid']).'">'.$shout['username'].'</a>>';
}
$title = 'title="Posted: '.$shout['time'];
if($mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 3)
{
$title .= ', IP: '.$shout['ipaddress'];
}
$title .= '"';
if($mybb->user['uid'] == $shout['uid'] || $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 3)
{
eval("\$options = \"".$templates->get('shoutbox_options')."\";");
}
else
{
$options = '';
}
if($bgcolor == 'trow1')
{
$bgcolor = 'trow2';
}
else
{
$bgcolor = 'trow1';
}
eval("\$shouts .= \"".$templates->get('shoutbox_shout')."\";");
}
}
$refresh = "<meta http-equiv=\"refresh\" content=\"60;URL=shoutbox.php\">";
eval("\$addshout = \"".$templates->get('shoutbox_add')."\";");
eval("\$shoutbox = \"".$templates->get('shoutbox')."\";");
outputpage($shoutbox);
break;
}
?>
Und Lenkradschloss tippt mir aus der Seele:
Denn er beschreibt genau auch meine Probleme.
z.B. verschwinden alle Einträge nach dem Löschen eines einzelnen Eintrags.
Wer weiß Rat ?