Hi, I got this login script from zubrag.com . It's really goot but wanted to make my own login form as theres sucks a little.
I keep recieving errormessages. I cannot edit the current login.php because all the protected pages imports infomation from it.
So I just nicked the form. Then noticed the form cannot work without the PHP from the original PHP form. Was wondering of you could look at the script for me and see how I can edit it down for my own use. (make sence
)
Here is the code from zubrag.com [ login.php ]
This script imports its own form if you are not logged in see lines 40 - 43. Here is the form from line 42
I just want to be able to use the code in my own php document without have to edit the form provided. so strip down the login.php form from its other functions and use its login functions for my own form....
Maka sence???
Here is my attempt but no luck
Please help
Advanced thanks Dan.
I keep recieving errormessages. I cannot edit the current login.php because all the protected pages imports infomation from it.
So I just nicked the form. Then noticed the form cannot work without the PHP from the original PHP form. Was wondering of you could look at the script for me and see how I can edit it down for my own use. (make sence
Here is the code from zubrag.com [ login.php ]
| Code: |
| <?php
// load settings include_once('settings.php'); // list of users $users = @file('/home/relentle/domains/mydomain.com/public_html/mydirectory/' . USERS_LIST_FILE); if (!$users) die('Cannot find users list! Please report problem to an administrator, Sorry for trouble. Dan.'); // remove php "die" statement (hackers protection) unset($users[0]); // prepare users list and redirects $LOGIN_INFORMATION = array(); $REDIRECTS = array(); foreach ($users as $user) { $u = explode(',',$user); if (USE_USERNAME) { $LOGIN_INFORMATION[trim($u[0])] = trim($u[1]); $REDIRECTS[trim($u[0])] = isset($u[3]) ? trim($u[3]) : ''; } else { $LOGIN_INFORMATION[] = trim($u[0]); } } // timeout in seconds $timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES * 300); // logout? if(isset($_GET['logout'])) { setcookie("verify", '', $timeout, '/'); // clear password; header('Location: ' . LOGOUT_URL); exit(); } if(!function_exists('showLoginPasswordProtect')) { // show login form function showLoginPasswordProtect($error_msg) { include('login_header.php'); include('login_form.php'); include('login_footer.php'); // stop at this point die(); } } // user provided password if (isset($_POST['access_password'])) { $login = isset($_POST['access_login']) ? $_POST['access_login'] : ''; $pass = $_POST['access_password']; if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION) || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) ) ) { showLoginPasswordProtect("Incorrect password."); } else { // set cookie if password was validated setcookie("verify", md5($login.'%'.$pass), $timeout, '/'); // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed // So need to clear password protector variables unset($_POST['access_login']); unset($_POST['access_password']); unset($_POST['Submit']); // need to be redirected? if (isset($REDIRECTS[$login]) && !empty($REDIRECTS[$login])) { header('Location: ' . ((REDIRECT_PREFIX != '') && (strpos($REDIRECTS[$login], 'http') !== false) ? '' : REDIRECT_PREFIX) . $REDIRECTS[$login]); exit(); } } } else { // check if password cookie is set if (!isset($_COOKIE['verify'])) { showLoginPasswordProtect(""); } // check if cookie is good $found = false; foreach($LOGIN_INFORMATION as $key=>$val) { $lp = (USE_USERNAME ? $key : '') .'%'.$val; if ($_COOKIE['verify'] == md5($lp)) { $found = true; // prolong timeout if (TIMEOUT_CHECK_ACTIVITY) { setcookie("verify", md5($lp), $timeout, '/'); } break; } } if (!$found) { showLoginPasswordProtect(""); } } ?> |
This script imports its own form if you are not logged in see lines 40 - 43. Here is the form from line 42
| Code: |
| <form method="post">
<h3>Please enter password to access this page</h3> <font color="red"><?php echo $error_msg; ?></font><br /> <?php if (USE_USERNAME) echo 'Login:<br /><input type="input" name="access_login" /><br />Password:<br />'; ?> <input type="password" name="access_password" /><p></p><input type="submit" name="Submit" value="Submit" /> </form> |
I just want to be able to use the code in my own php document without have to edit the form provided. so strip down the login.php form from its other functions and use its login functions for my own form....
Maka sence???
Here is my attempt but no luck
| Code: |
| <?php
include_once('settings.php'); if (isset($_POST['access_password'])) { $login = isset($_POST['access_login']) ? $_POST['access_login'] : ''; $pass = $_POST['access_password']; if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) else { setcookie("verify", md5($login.'%'.$pass), $timeout, '/'); unset($_POST['access_login']); unset($_POST['access_password']); unset($_POST['Submit']); if (isset($REDIRECTS[$login]) && !empty($REDIRECTS[$login])) { header('Location: ' . ((REDIRECT_PREFIX != '') && (strpos($REDIRECTS[$login], 'http') !== false) ? '' : REDIRECT_PREFIX) . $REDIRECTS[$login]); exit(); } } } ?> |
Please help
Advanced thanks Dan.
