Jump to content

Multi user system with suspend function NEED HELP !


cordoprod

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";
         }

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.