get basic login functionality going, some minor code cleanup, more to follow
This commit is contained in:
Родитель
58737ea5eb
Коммит
e07906cf53
|
@ -35,85 +35,44 @@
|
|||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
require_once("../../config.inc.php");
|
||||
require_once('DB.php');
|
||||
require_once($config['app_path'].'/includes/iolib.inc.php');
|
||||
require_once($config['app_path'].'/includes/security.inc.php');
|
||||
|
||||
// Start Session
|
||||
require_once('../../config.inc.php');
|
||||
require_once($config['base_path'].'/includes/iolib.inc.php');
|
||||
require_once($config['base_path'].'/includes/db.inc.php');
|
||||
require_once($config['base_path'].'/includes/contrib/smarty/libs/Smarty.class.php');
|
||||
require_once($config['base_path'].'/includes/security.inc.php');
|
||||
|
||||
// start the session
|
||||
session_name('reportSessID');
|
||||
session_start();
|
||||
header("Cache-control: private"); //IE 6 Fix
|
||||
printheaders();
|
||||
|
||||
include($config['app_path'].'/includes/header.inc.php');
|
||||
include($config['app_path'].'/includes/message.inc.php');
|
||||
|
||||
if (isset($_POST['redirect'])){
|
||||
$redirect = $_POST['redirect'];
|
||||
}
|
||||
else if (isset($_GET['redirect'])){
|
||||
$redirect = $_GET['redirect'];
|
||||
}
|
||||
else {
|
||||
$redirect = $config['app_url'];
|
||||
}
|
||||
|
||||
|
||||
if ($_SESSION['login'] != true){
|
||||
// submit form?
|
||||
if (isset($_POST['submit_login'])){
|
||||
if(isset($_POST['do_login'])){
|
||||
$login = false;
|
||||
|
||||
// Open DB
|
||||
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleErrors');
|
||||
$db =& DB::connect($config['db_dsn']);
|
||||
$db = NewDBConnection($config['db_dsn']);
|
||||
$db->SetFetchMode(ADODB_FETCH_ASSOC);
|
||||
|
||||
$loginCheck = false;
|
||||
$loginCheck = $userlib->login($_POST['username'], $_POST['password']);
|
||||
$login = $securitylib->login($_POST['username'], $_POST['password']);
|
||||
|
||||
// disconnect database
|
||||
$db->disconnect();
|
||||
$db->Close();
|
||||
|
||||
if ($loginCheck[0] == true){
|
||||
header("Location: ".$redirect);
|
||||
exit;
|
||||
} else {
|
||||
$error = true;
|
||||
?>Login Failed<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<fieldset>
|
||||
<legend>Login</legend>
|
||||
<form method="post" action ="<?php print $config['app_url']; ?>/login/" ID="login">
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="username">Username: </label></td>
|
||||
<td><input type="text" id="username" name="username" <?php if ($error == true){ print 'value="'.$_POST['username'].'" ';}?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="password">Password: </label></td>
|
||||
<td><input type="password" id="password" name="password" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" id="redirect" name="redirect" value="<?php print $redirect; ?>" />
|
||||
<input type="submit" id="submit_login" name="submit_login" value="Login" />
|
||||
</form>
|
||||
</fieldset>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<h5>Administrator Login</h5>
|
||||
<p>Contact <a href="http://robert.accettura.com/contact/?subject=Reporter%20Access%20Request">Robert Accettura</a> if you need an admin account. This is for special circumstances only.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?
|
||||
if($login === true){
|
||||
header('Location: '.$config['base_url']);
|
||||
exit;
|
||||
}
|
||||
$content = initializeTemplate();
|
||||
$content->assign('error', 'Incorrect Username or Password');
|
||||
}
|
||||
|
||||
if(!isset($content)){
|
||||
$content = initializeTemplate();
|
||||
}
|
||||
displayPage($content, 'login', 'login.tpl');
|
||||
exit;
|
||||
} else {
|
||||
header("Location: ".$redirect);
|
||||
header('Location: '.$config['base_url']);
|
||||
}
|
||||
include($config['app_path'].'/includes/footer.inc.php');
|
||||
?>
|
||||
?>
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Reporter (r.m.o).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Robert Accettura <robert@accettura.com>.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
require_once('../../config.inc.php');
|
||||
require_once($config['app_path'].'/includes/iolib.inc.php');
|
||||
|
||||
// start the session
|
||||
session_name('reportSessID');
|
||||
session_start();
|
||||
header("Cache-control: private"); //IE 6 Fix
|
||||
printheaders();
|
||||
|
||||
$_SESSION = array();
|
||||
session_destroy();
|
||||
|
||||
if (isset($_GET['redirect'])){
|
||||
$redirect = $_GET['redirect'];
|
||||
} else {
|
||||
$redirect = $config['app_url'];
|
||||
}
|
||||
|
||||
if($_SESSION['username']){
|
||||
// not sure if this could ever happen, but just incase.
|
||||
echo 'Failed to logout';
|
||||
} else {
|
||||
header("Location: ".$redirect);
|
||||
}
|
||||
?>
|
|
@ -1,140 +1,139 @@
|
|||
body {
|
||||
margin: 0 30px 2em 30px;
|
||||
color: #333;
|
||||
background: #fff url("img/body_back.gif") repeat-x;
|
||||
font-size: 100%;
|
||||
margin: 0 30px 2em 30px;
|
||||
color: #333;
|
||||
background: #fff url("img/body_back.gif") repeat-x;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
body, td, th, h3, input, pre { /* redundant rules for bad browsers */
|
||||
font-family: verdana, sans-serif;
|
||||
voice-family: "\"}\"";
|
||||
voice-family: inherit;
|
||||
font-family: verdana, sans-serif;
|
||||
voice-family: "\"}\"";
|
||||
voice-family: inherit;
|
||||
}
|
||||
|
||||
#container {
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#page {
|
||||
padding: 15px 0 0 0;
|
||||
padding: 15px 0 0 0;
|
||||
}
|
||||
|
||||
#content {
|
||||
background: url("img/page-background.gif") repeat-x top left;
|
||||
font-size: 0.8em;
|
||||
background: url("img/page-background.gif") repeat-x top left;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
#mozilla-org {
|
||||
position: relative;
|
||||
height: 25px;
|
||||
position: relative;
|
||||
height: 25px;
|
||||
}
|
||||
|
||||
#mozilla-org a {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
display: block;
|
||||
width: 110px;
|
||||
height: 25px;
|
||||
background: url("img/mozilla-org.gif") no-repeat;
|
||||
text-decoration: none;
|
||||
text-indent: -5000em;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
display: block;
|
||||
width: 110px;
|
||||
height: 25px;
|
||||
background: url("img/mozilla-org.gif") no-repeat;
|
||||
text-decoration: none;
|
||||
text-indent: -5000em;
|
||||
}
|
||||
|
||||
.skipLink {
|
||||
display: none;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
#reporterSearch label {
|
||||
font-weight: bold;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#reporterSearch .label {
|
||||
text-align: right;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#reporterQuery {
|
||||
font-size: 0.9em;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
#reporterQuery .header {
|
||||
background-color: #ddd;
|
||||
color: #666;
|
||||
text-align: left;
|
||||
background-color: #ddd;
|
||||
color: #666;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#reporterQuery .header a {
|
||||
color: #666;
|
||||
text-decoration: none;
|
||||
color: #666;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#reporterQuery td {
|
||||
border-bottom: 1px solid #eee;
|
||||
padding: 1px 0 1px 0;
|
||||
font-size: 0.9em;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding: 1px 0 1px 0;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
#reporterReport .header{
|
||||
background-color: #eee;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
padding: 4px 0 4px 0;
|
||||
background-color: #eee;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
padding: 4px 0 4px 0;
|
||||
}
|
||||
|
||||
#reporterReport div {
|
||||
margin-bottom: 3px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
#reporterReport .title {
|
||||
float: left;
|
||||
width: 9em;
|
||||
padding: 0 .5em;
|
||||
text-align: right;
|
||||
font-weight: bold;
|
||||
float: left;
|
||||
width: 9em;
|
||||
padding: 0 .5em;
|
||||
text-align: right;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#reporterReport .data {
|
||||
overflow: auto;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#header{
|
||||
margin: 20px 0 16px 0;
|
||||
bottom: 1px solid #eee;
|
||||
}
|
||||
#header h1 {
|
||||
display: inline;
|
||||
font-size: 2.2em;
|
||||
}
|
||||
#header{
|
||||
margin: 20px 0 16px 0;
|
||||
bottom: 1px solid #eee;
|
||||
}
|
||||
#header h1 {
|
||||
display: inline;
|
||||
font-size: 2.2em;
|
||||
}
|
||||
#header #logo {
|
||||
margin: 0;
|
||||
float: left;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#header #logo {
|
||||
margin: 0;
|
||||
float: left;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#header #logo a {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
}
|
||||
#header #logo a {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#header a img {
|
||||
border: 0;
|
||||
}
|
||||
#header #navbox {
|
||||
float: right;
|
||||
margin-top: 8px;
|
||||
margin-right: 15px;
|
||||
#header a img {
|
||||
border: 0;
|
||||
}
|
||||
#header #navbox {
|
||||
float: right;
|
||||
margin-top: 8px;
|
||||
margin-right: 15px;
|
||||
background-color: #eee;
|
||||
border: 1px solid #333;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
}
|
||||
|
||||
#navbox ul {
|
||||
padding: 0 0 0 8px;
|
||||
}
|
||||
#navbox li {
|
||||
#navbox ul {
|
||||
padding: 0 0 0 8px;
|
||||
}
|
||||
#navbox li {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
padding: 0 8px 0 0;
|
||||
|
@ -143,24 +142,46 @@ body, td, th, h3, input, pre { /* redundant rules for bad browsers */
|
|||
}
|
||||
|
||||
.navigation {
|
||||
text-align: center;
|
||||
margin: 12px auto 5px auto;
|
||||
text-align: center;
|
||||
margin: 12px auto 5px auto;
|
||||
}
|
||||
|
||||
.navigation .currentPage {
|
||||
font-weight: bold;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.navigation a {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
}
|
||||
.navigation a:hover {
|
||||
border-bottom: 2px solid #000;
|
||||
border-bottom: 2px solid #000;
|
||||
}
|
||||
|
||||
#login_form label{
|
||||
float: left;
|
||||
width: 9em;
|
||||
padding: 0 .5em;
|
||||
text-align: right;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#login_leftcol{
|
||||
float: left;
|
||||
width: 45%;
|
||||
padding: 2px 9px 5px 9px;
|
||||
|
||||
}
|
||||
|
||||
#login_rightcol {
|
||||
float: right;
|
||||
width: 45%;
|
||||
padding: 2px 9px 5px 9px;
|
||||
}
|
||||
/*
|
||||
|
||||
|
||||
|
||||
#reporter_note {
|
||||
border: 1px solid #ccc;
|
||||
background: #eee;
|
||||
|
|
|
@ -61,12 +61,12 @@ function initializeTemplate(){
|
|||
|
||||
|
||||
function templateStandardVars($object){
|
||||
global $config, $userlib;
|
||||
global $config, $securitylib;
|
||||
|
||||
$object->assign('base_url', $config['base_url']);
|
||||
$object->assign('app_url', $config['base_url'].'/app');
|
||||
$object->assign('charset', 'utf-8');
|
||||
$object->assign('is_admin', $userlib->isLoggedIn());
|
||||
$object->assign('is_admin', $securitylib->isLoggedIn());
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ function strMiddleReduceWordSensitive($string, $max = 50, $rep = '[...]') {
|
|||
}
|
||||
return $return;
|
||||
return substr($string, 0, $start) . $rep . substr($string, - $end);
|
||||
}
|
||||
}
|
||||
|
||||
function resolveProblemTypes($q){
|
||||
global $problemTypes;
|
||||
|
|
|
@ -36,32 +36,38 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class userlib {
|
||||
class securitylib {
|
||||
|
||||
function login($username, $password){
|
||||
global $db;
|
||||
function login($username, $password){
|
||||
global $db;
|
||||
|
||||
$data =& $db->getRow("SELECT user.user_id, user.user_username, user.user_password, user.user_realname, user.user_status
|
||||
FROM user
|
||||
WHERE user.user_username = ".$db->quote($username)." AND user.user_password = md5(".$db->quote($password).")", DB_FETCHMODE_ASSOC);
|
||||
if ($data['user_status'] == 1){
|
||||
$_SESSION['user_id'] = $data['user_id'];
|
||||
$_SESSION['user_realname'] = $data['user_realname'];
|
||||
$_SESSION['user_username'] = $data['user_username'];
|
||||
$_SESSION['login'] = true;
|
||||
return array(true, '');
|
||||
$data = $db->Execute("SELECT user.user_id, user.user_username, user.user_password, user.user_realname, user.user_status
|
||||
FROM user
|
||||
WHERE user.user_username = ".$db->quote($username)."
|
||||
AND user.user_password = PASSWORD(".$db->quote($password).")
|
||||
AND user.user_status = 1");
|
||||
if(!$data || $data->EOF){
|
||||
return false;
|
||||
}
|
||||
if ($data->fields['user_status'] == 1){
|
||||
$_SESSION['user_id'] = $data->fields['user_id'];
|
||||
$_SESSION['user_realname'] = $data->fields['user_realname'];
|
||||
$_SESSION['user_username'] = $data->fields['user_username'];
|
||||
$_SESSION['login'] = true;
|
||||
session_regenerate_id();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return array(false, 'Bad Status');
|
||||
}
|
||||
|
||||
function isLoggedIn(){
|
||||
if ($_SESSION['user_username'] && $_SESSION['login'] == true){
|
||||
return true;
|
||||
function isLoggedIn(){
|
||||
if ($_SESSION['user_username'] && $_SESSION['login'] == true){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// End Class
|
||||
}
|
||||
$userlib = new userlib;
|
||||
?>
|
||||
$securitylib = new securitylib;
|
||||
?>
|
|
@ -23,7 +23,13 @@
|
|||
</div>
|
||||
<div id="navbox">
|
||||
<ul>
|
||||
<li id="login"><a href="{$base_url}/app/login" title="Admin Login">Login</a></li>
|
||||
<li id="login">{strip}
|
||||
{if $is_admin == true}
|
||||
<a href="{$base_url}/app/logout" title="Admin Logout">Logout</a>
|
||||
{else}
|
||||
<a href="{$base_url}/app/login" title="Admin Login">Login</a>
|
||||
{/if}
|
||||
{/strip}</li>
|
||||
<li id="stats"><a href="{$base_url}/app/stats/" title="View Statistics">Stats</a></li>
|
||||
<li id="top_25"><a href="{$base_url}/app/query/?show=25&count=on&&submit_query=Search" title="Top 25 Hosts">Top 25</a></li>
|
||||
<li id="query"><a href="{$base_url}/app" title="Create a new Query">Query</a></li>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<div id="login_leftcol">
|
||||
<form method="post" action="{$base_url}/app/login/" id="login_form">
|
||||
<fieldset>
|
||||
<legend>Login</legend>
|
||||
{if $error != ''}
|
||||
<p>{$error}</p>
|
||||
{/if}
|
||||
<div>
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" name="username" id="username" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" name="password" id="password" />
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" name="do_login" id="do_login" value="Login" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div id="login_rightcol">
|
||||
<p>If you need access to this system, contact <a href="http://robert.accettura.com/contact">Robert Accettura</a>.</p>
|
||||
<p>Login Access is only given in special circumstances.</p>
|
||||
</div>
|
||||
<br style="clear: both;" />
|
|
@ -53,11 +53,11 @@
|
|||
{if $is_admin == true}
|
||||
<div>
|
||||
<div class="title">Email:</div>
|
||||
<div class="data">{$report_email}</div>
|
||||
<div class="data">{$report_email} {*this space at the end fixes some formatting issues with no text in this optional field *}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="title">IP Address:</div>
|
||||
<div class="data"><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput={$report_ip}" rel="external" target="_blank" title="Lookup IP: {$report_ip}">{$report_ip}</a></div>
|
||||
<div class="data"><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput={$report_ip}" rel="external" target="_blank" title="Lookup IP: {$report_ip}">{$report_ip}</a> {*this space at the end fixes some formatting issues with no text in this optional field *}</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div>
|
||||
|
|
Загрузка…
Ссылка в новой задаче