Changes adopted from version 0.5
This commit is contained in:
87
login.php
87
login.php
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
IP Reg, a PHP/MySQL IPAM tool
|
||||
Copyright (C) 2008 Wietse Warendorff
|
||||
Copyright (C) 2007-2009 Wietse Warendorff
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -20,53 +20,60 @@
|
||||
or contact me at wietsew@users.sourceforge.net
|
||||
*****************************************************************************/
|
||||
|
||||
// start session with default language
|
||||
session_start();
|
||||
include('lang/en.php');
|
||||
// session
|
||||
// start session
|
||||
session_start();
|
||||
|
||||
// headers
|
||||
// raw http headers
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
// includes
|
||||
include("config.php");
|
||||
include("dbconnect.php");
|
||||
include("functions.php");
|
||||
include("yapter.php");
|
||||
// includes
|
||||
include("config.php");
|
||||
include("dbconnect.php");
|
||||
|
||||
// load lib
|
||||
include("lib.php");
|
||||
|
||||
// include language file
|
||||
include('lang/en.php');
|
||||
|
||||
// check for submit
|
||||
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
|
||||
if(isset($_POST['user_name']) && isset($_POST['user_pass']) && trim($_POST['user_name']) <> "" && trim($_POST['user_pass']) <> "") {
|
||||
$user_name = $_POST['user_name'];
|
||||
$result = mysql_query("SELECT user_id, user_pass, user_level, user_displayname, user_mac, user_lang FROM user WHERE user_name='$user_name'") or die(mysql_error());
|
||||
// try login?
|
||||
// check for submit
|
||||
if ($_SERVER['REQUEST_METHOD']=="POST" ) {
|
||||
/// get post info
|
||||
$user_name = sanitize($_POST['user_name']);
|
||||
$user_pass = sanitize($_POST['user_pass']);
|
||||
|
||||
if(mysql_num_rows($result) > 0) {
|
||||
if(!strcmp(md5($_POST['user_pass']), mysql_result($result, 0, "user_pass"))) {
|
||||
// all ok, user logged in
|
||||
$_SESSION['suser_id'] = mysql_result($result, 0, "user_id");
|
||||
$_SESSION['suser_level'] = mysql_result($result, 0, "user_level");
|
||||
$_SESSION['suser_displayname'] = mysql_result($result, 0, "user_displayname");
|
||||
$_SESSION['suser_mac'] = mysql_result($result, 0, "user_mac");
|
||||
$_SESSION['suser_lang'] = mysql_result($result, 0, "user_lang");
|
||||
|
||||
header_location("index.php");
|
||||
} else {
|
||||
// login
|
||||
$login = $user->user_login($user_name, $user_pass);
|
||||
|
||||
if($login==TRUE) {
|
||||
// redirect
|
||||
header_location("index.php");
|
||||
} else {
|
||||
// not ok, break session
|
||||
$_SESSION = array();
|
||||
session_destroy();
|
||||
}
|
||||
// clear mysql-result
|
||||
mysql_free_result($result);
|
||||
$_SESSION = array();
|
||||
session_destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// start output
|
||||
// set template
|
||||
$tp = new Template("tpl/login.tpl");
|
||||
// set template
|
||||
$tp = new Template("tpl/login.tpl", $config_yapter_error);
|
||||
|
||||
// get version for the footer-stamp
|
||||
$tp->set("config_version", $config_version);
|
||||
|
||||
// set language variables
|
||||
$tp->setvars($lang);
|
||||
|
||||
// set language variables
|
||||
$tp->setvars($lang);
|
||||
|
||||
// output
|
||||
$tp->parse();
|
||||
$tp->spit();
|
||||
|
||||
include("footer.php");
|
||||
// end page
|
||||
// output
|
||||
$tp->parse();
|
||||
$tp->spit();
|
||||
|
||||
// end output
|
||||
include("footer.php");
|
||||
?>
|
||||
Reference in New Issue
Block a user