これをどのように表現すればよいかよくわからないので、さらに説明が必要な場合は、最善を尽くして説明できます。
ここにコードがあります
$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 ループにあるためだと思いますが、それを行う方法がわかりません。ユーザーは管理者/モッドであり、投稿の横に削除/禁止ボタンが配置されている場合は、削除できるようにします。現在のところ、すべての投稿の横に削除ボタンを配置し、その横に削除および禁止ボタンを付けてすべてを複製しています。