sorry! didnt see that one, silly me! :rolleyes: this is the code i found:
<?php
function login_connect($username,$password) {
$content = join('',file("logged.txt"));
if(ereg($username.":".$password." | ",$content)) {
$fp=fopen("logged.txt","a+");
$readr = fread($fp,filesize("logged.txt"));
$readr = str_replace("$username $password | ","$username $password loggedin | ",$readr);
fwrite($fp,$readr);
fclose($fp);
return true;
} else {
return false;
}
}
function login_isconnected($thelogin,$username,$password) {
$fileF = file("logged.txt");
$content = join('',$fileF);
if(ereg("$username $password loggedin | ",$content)) {
return true;
} else {
return false;
}
}
function login_register($username,$password) {
$fp=fopen("logged.txt","a+") or return false; // Is the file registered/At Writable?
if(fwrite($fp,"$username $password | ")) {
return true;
}
fclose($fp);
}
function login_unregister($username,$password) {
$fp=fopen("logged.txt","a+");
$readed = fread($fp,filesize("logged.txt"));
$readed = str_replace("$username $password | ","",$readed);
fwrite($fp,$readed);
fclose($fp);
}
function login_quit($username,$password) {
$fp=fopen("logged.txt","a+");
$re = fread($fp,filesize("logged.txt"));
$re = str_replace("$username $password loggedin | ","$username $password | ",$re);
fwrite($fp,$re);
fclose($fp);
}
// -------------------- Example --------------------------
login_register("lentin64","test"); // Let it put in to the 2nd file
$logged = login_connect("lentin64","test")
if(login_isconnected("lentin64","test")) {
echo "Logged in";
} else {
echo "Not Logged in";
}
login_quit("lentin64","test"); // Logout
login_unregister("lentin64","test"); // Get rid of him
?>
can you tell me if that uses MD5 encryption, if not can some one re-wright it so it is lol, and can some one put comments next to some of the lines to explain what they are, im bit mew to PHP.
how do i logout?
can it be re-written to use sessions to store the logon data, so they can be restricted from pages if they just type the address in.
thanks very much
Matt