session_start();
//==========================================
// Login Session is Copyright (c)2007, Scott J. LeCompte
// Web Site: http://www.myphpscripts.net/scripts.php
//
// Login Session V1.0
// By PhpScripts.net
// DD 07/05/07 Works on Unix/Linux hosted sites.
//
// May be used free of charge. There is no copyright. Feel free to edit.
// Need help with installation or customization? Visit:
// http://www.myphpscripts.net
//============================================
// Variables - Edit These
// Self Registration: 1 to enable, 0 to disable.
$registration = 0;
// Name of your user file (Recommended to leave the extension as .inc)
$pwd = 'loginoptka2.inc';
// Do not edit below this line unless you know what you are doing!
// =============================================================
function head() {
?>
Database Organisme Pengganggu Tumbuhan Karantina
::.Basisdata Organisme Pengganggu Tanaman Karantina.::
}
function foot() {
?>
Basisdata Organisme Pengganggu Tanaman Karantina Badan Karantina Pertanian - Kementerian Pertanian Republik Indonesia Ver 1.5.03.12@admin
exit();
}
if (isset($_REQUEST['logout'])) {
head();
$redirect = $_SERVER['HTTP_REFERER'];
echo ' ';
echo 'Logging Out. ';
unset($_SESSION['logged_in']);
foot();
}
else if ($registration == 1 && isset($_REQUEST['register'])) {
head();
$redirect = strtok($_SESSION['redirect'],'?');
if (isset($_REQUEST['register_passwd']) && isset($_REQUEST['register_verify']) && isset($_REQUEST['register_password'])) {
if ($_REQUEST['register_passwd'] == $_REQUEST['register_verify']) {
$handle = @fopen($pwd, "r");
while (!feof($handle)) {
$tmpstr = fgets($handle, 100);
$line[] = ereg_replace("\n", "", $tmpstr);
}
for ($i=0; $i < count($line); $i++) {
$login_hash = strtok($line[$i],'_');
if ($_REQUEST['register_username'] == $login_hash) {
echo ' ';
echo 'Username already exists. ';
$username_exists = 1;
break;
}
}
if ($username_exists != 1 && $_REQUEST['register_passwd'] != "" && $_REQUEST['register_username'] != "") {
$fh = fopen($pwd, 'a+') or die("can't open file");
$stringData = $_REQUEST['register_username'] . '_' . md5($_REQUEST['register_passwd']) . "\n";
fwrite($fh, $stringData);
fclose($fh);
echo ' ';
echo 'User Created. ';
}
else if ($username_exists != 1 && $_REQUEST['register_passwd'] == "") {
echo ' ';
unset($_SESSION['logged_in']);
echo 'Password cannot be blank. ';
}
else if ($username_exists != 1 && $_REQUEST['register_username'] == "") {
echo ' ';
unset($_SESSION['logged_in']);
echo 'Username cannot be blank. ';
}
fclose($handle);
}
else {
echo ' ';
unset($_SESSION['logged_in']);
echo 'Passwords do not match. Please try again. ';
}
}
else {
?>
}
foot();
}
else if (!isset($_SESSION['logged_in'])) {
head();
$redirect = $_SESSION['redirect'];
if (!file_exists($pwd)) {
if (isset($_REQUEST['passwd']) && isset($_REQUEST['passwd_verify']) && isset($_REQUEST['save_password'])) {
if ($_REQUEST['passwd'] == $_REQUEST['passwd_verify']) {
$fh = fopen($pwd, 'a+') or die("can't open file");
$stringData = $_REQUEST['username'] . '_' . md5($_REQUEST['passwd']) . "\n";
fwrite($fh, $stringData);
fclose($fh);
echo ' ';
echo 'User Created. ';
}
else {
echo ' ';
unset($_SESSION['logged_in']);
echo 'Passwords do not match. Please try again. ';
}
}
else {
$_SESSION['redirect'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
?>
}
}
else if (isset($_REQUEST['passwd']) && isset($_REQUEST['login'])) {
$handle = @fopen($pwd, "r");
if ($handle) {
while (!feof($handle)) {
$tmpstr = fgets($handle, 100);
$line[] = ereg_replace("\n", "", $tmpstr);
}
for ($i=0; $i < count($line); $i++) {
$pass_hash = strrev(strtok(strrev($line[$i]),_));
$login_hash = strtok($line[$i],'_');
if (md5($_REQUEST['passwd']) == $pass_hash && $_REQUEST['username'] == $login_hash) {
$_SESSION['logged_in'] = 1;
echo ' ';
echo 'Password Accepted ';
break;
}
else if ($line[$i] == "") {
echo ' ';
unset($_SESSION['logged_in']);
echo 'Invalid Login Credentials. ';
break;
}
}
}
fclose($handle);
}
else {
$_SESSION['redirect'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
?>
Administrator Login Required:
if ($registration == 1) { echo 'Register '; } ?>
}
foot();
}
?>
::.Basisdata Organisme Pengganggu Tanaman Karantina.::
Basisdata Organisme Pengganggu Tanaman Karantina Badan Karantina Pertanian - Kementerian Pertanian Republik Indonesia Ver 1.5.03.12@admin