我不确定如何表达,所以如果您需要更多说明,我可以尽力解释。
这是代码
$file = "shout.txt";
$filed = file_get_contents($file);
preg_match_all('|<div class=\'date\'>(?P<date>.*?) .*<a.*>(?P<user>.*)</a>|i', $filed, $matches);
$shoutlines = file($shout_file);
$aTemp = array();
foreach($matches['user'] as $user) {
$aTemp[] = "'" . mysql_real_escape_string($user) . "'";
}
$user = implode(",", $aTemp);
$getlevel = $db->query("SELECT * FROM accounts WHERE username IN ( ".$user." )");
$isadmin = $db->query("SELECT * FROM accounts WHERE username = '".$_SESSION['username']."'");
$admin = $isadmin->fetch_assoc();
while($status = $getlevel->fetch_assoc()){
//output the html
for($i = 0; $i < (1000); $i++)
{
if(isset($shoutlines[$i]))
{
if ($admin['admin'] == 1 && $status['sblevel'] != Admin && $status['sblevel'] != Banned){
$delete = "<a href='javascript: delete_shoutline({$i});' title='Delete' class='delete' onclick=\"return confirm('Are you sure you want to delete this message?');\">x</a><a href='javascript: ban({$status['id']});' class='ban' onclick=\"return confirm('Are you sure you want to ban this user?');\">o</a>";
}
if ($admin['admin'] == 1 && $status['sblevel'] != Admin && $status['sblevel'] == Banned){
$delete = "<a href='javascript: delete_shoutline({$i});' title='Delete' class='delete' onclick=\"return confirm('Are you sure you want to delete this message?');\">x</a><a href='?index=shout&unban&user=".$shout['username']."' class='ban' onclick=\"return confirm('Are you sure you want to unban this user?');\">ø</a>";
}
if ($admin['admin'] == 1 && $status['sblevel'] == Admin){
$delete = "<a href='javascript: delete_shoutline({$i});' title='Delete' class='delete' onclick=\"return confirm('Are you sure you want to delete this message?');\">x</a>";
}
if ($admin['sblevel'] == Moderator && $status['sblevel'] != Admin && $status['sblevel'] != Moderator){
$delete = "<a href='javascript: delete_shoutline({$i});' title='Delete' class='delete' onclick=\"return confirm('Are you sure you want to delete this message?');\">x</a><a href='?index=shout&ban&user=".$shout['username']."' class='ban' onclick=\"return confirm('Are you sure you want to ban this user?');\">o</a>";
}
if ($status['sblevel'] == Moderator && $status['sblevel'] != Admin){
$delete = "<a href='javascript: delete_shoutline({$i});' title='Delete' class='delete' onclick=\"return confirm('Are you sure you want to delete this message?');\">x</a>";
}
$shoutline = preg_replace('/<\/div>\n/', ' ', $shoutlines[$i], 1);
echo showSmileys($shoutline) . $delete . "</div>";
}
}
}
问题是它为每个发布的用户复制了所有帖子。我假设这是因为它处于一个while循环中,但我不知道该怎么做,因为我需要检查一个用户是管理员/mod,如果他们在帖子旁边放置了一个删除/禁止按钮以允许他们删除。就目前而言,它会在所有帖子旁边放置一个删除按钮,然后使用它们旁边的删除和禁止按钮将它们全部复制。