Jump to content

Multi user system with suspend function NEED HELP !


Recommended Posts

Hi. First of all: THIS IS FLATFILE!

I'm developing a big news system.

There is just a little problem, in my multi-user suspend function.

It won't say "you're suspended", it just log the user in.

 

Here is my code: (If you need more explanation, tell me)

$login_user = $_POST['user'];
$login_pass = $_POST['pass'];
if($_POST['remember'] == "on") set_cookie("ln_username", $login_user, "month");
if($_POST['remember'] == "on") set_cookie("ln_password", $login_pass, "month");
$user_db = file("./data/users.php");
foreach($user_db as $user_db_line)
{
                if(!eregi("<\?",$user_db_line)){
                $col = explode("|",$user_db_line);
                if(strtolower($col[1]) == strtolower($login_user) && $col[2] == $login_pass)
                {
                $file = file($UsersFile);
                $suspended = false;
                foreach($file as $db) {
                    $a2 = explode("|", $db);
                    $now = time();
                    if($a2[5] <= $now) {
                         $file = file($UsersFile);
                         $line = 0;
                         while($file[$line]) {
                              $a = explode("|", $file[$line]);
	                      if ($a[1] == $user) {
		                         $a[5] = "";
		                         $file[$line] = implode($a, "|");
	                      }
                     $line++;
                     }
                     $a = implode($file, "");
                     $fp = fopen($UsersFile, "w");
                     fwrite($fp, $a);
                     fclose($fp);

                         $suspended = false;
                     }
                     else {
                         $suspended = true;
                     }
                }
                if($suspended) {
                    die("suspended");
                    break;
                }
                else {
                $_SESSION['logged_in'] = true;
                $_SESSION['username'] = $col[1];
                $_SESSION['level'] = $col[0];
                header("Location: index.php");
                break;
                }


                }
                else echo("".W_PASS."<br>".BACK."");
                } else echo "ERROR";
         }

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.