Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8972553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:14:37+00:00 2026-06-15T18:14:37+00:00

I am not really sure how to word this so if you need more

  • 0

I am not really sure how to word this so if you need more clarification I can try my best to explain.

Here is the code

$file = "shout.txt";
$filed = file_get_contents($file);
preg_match_all('|<div class=\'date\'>(?P<date>.*?)&nbsp;.*<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?');\">&oslash;</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>";
        }
    }
}

The problem is that it duplicates all of the posts for every user that posted.. I am assuming this is because it is in a while loop, but I don’t know how else to go about doing it because I need to check if a user is an admin/mod and if they are put a delete/ban button next to the posts to allow them to delete. As it stands now it puts an delete button next to all posts and then duplicates them all with a delete and ban button next to them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:14:39+00:00Added an answer on June 15, 2026 at 6:14 pm

    Here’s the simplest modification to avoid repeating messages. You have to supply a function author() that takes a line from the shout_file and returns the author ID.

    while($status = $getlevel->fetch_assoc()){
        //output the html
        for($i = 0; $i < (1000); $i++)
        {
            if(isset($shoutlines[$i]))
            {
                if (author($shoutlines[$i]) != $status['id']) {
                    continue;
                }
                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?');\">&oslash;</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>";
                unset($shoutlines[$i]);
            }
        }
    }
    

    This probably isn’t the best way to do it, since it repeats the “Ban this user” for each messages from the author. It would be better to put the ban/unban options once at the beginning of each user, then “delete” on each line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm really not sure how to word this question, but here goes... I have
I'm not really sure how to word this exactly, so hopefully someone can make
Ok, not really sure how to word, but will try my best. I have
I am not really sure how to word this question, so I did the
Not really too sure how to word this question, therefore if you don't particularly
I am not sure how to really word this, but I have a game
I'm not really sure how to ask this question, but I'll do my best.
Sorry, I'm not sure how to really word my question. Here it goes. If
I am not really too sure how to word this into google, so I
Hopefully this isn't a redundant question--I'm not really sure how to word it. Let's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.