Which page would you like to view the highlighted source code of?
login.php | project.php | header.php | gpl | none
login.php:
<?php
/*
----------------------------------------------------------------
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 the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
----------------------------------------------------------------
*/
session_start();
if ($_SESSION['oba_auth']) {
header("Location: ./project.php");
}
$page_title = "login";
include ("header.php");
echo " <p><b>system message:</b>\n";
/* Include the DataBase Credentials page. This is so you don't have to put you MySQL connect
information directly in this file. */
include "./admin/dbc.php"; // Removed For Security Reasons
/* Used to "get" the value of 'm' passed in the URI */
$mode = $_GET['m'];
/* Check to see if a value for 'm' was actually passed in the URI; if so, make sure that it
equals "l". This is to prevent any SQL injection. */
if (isset($mode)) {
if ($mode == "l") {
if ($_SESSION['oba_auth'] != true) {
die("<b class=\"errormsg\">You don't seem to be logged in, therefore you can't log out.</b><br /><br />");
}
/* Grab all the session variables... */
$_SESSION = array();
/* ... and destroy them. */
session_destroy();
die("<span class=\"success\"><b>You have been logged out of the system successfully.</b></span>");
}
else {
die("<b class=\"errormsg\">The mode you have specified doesn't seem to exist.</b><br /><br />");
}
}
/* Do the following only if the 'submit' button was pressed. */
if ($_POST['submit']) {
/* Connect to the SQL server */
mysql_connect($dbhname, $dbuname, $dbpword);
mysql_select_db($dbname);
$un = $_REQUEST['un'];
$pw = $_REQUEST['pw'];
if ((preg_match('/^(?:[a-zA-Z0-9]+ *)+$/', $un)) && (preg_match('/^(?:[a-zA-Z0-9]+ *)+$/', $un)) && (strlen(trim($un)) != 0) && (strlen(trim($pw)) != 0)) {
$pw = md5($pw);
$request = mysql_query("SELECT * FROM users WHERE name='".$un."' AND password='".$pw."'");
if (mysql_num_rows($request)) {
$_SESSION['oba_auth'] = true;
$_SESSION['oba_un'] = $un;
echo "<span class=\"success\"><b>success, you will be <a href=\"project.php\">redirected</a></b></span>";
echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"1; url=project.php\" />";
}
else {
echo "<span class=\"errormsg\"><b>this username and password combination was not found</b></span>";
}
}
else {
if ((strlen(trim($un)) == 0)) {
echo "<span class=\"errormsg\"><b>you didn't enter a username</b></span>";
}
else if ((strlen(trim($pw)) == 0)) {
echo "<span class=\"errormsg\"><b>you didn't enter a password</b></span>";
}
else if (!preg_match('/^(?:[a-zA-Z0-9]+ *)+$/', $un)) {
echo "<span class=\"errormsg\"><b>the username that you supplied contains illegal characters</b></span>";
}
else if (!preg_match('/^(?:[a-zA-Z0-9]+ *)+$/', $pn)) {
echo "<span class=\"errormsg\"><b>the password that you supplied contains illegal characters</b></span>";
}
}
}
else {
echo "<b>none</b>";
}
echo " </p>\n";
echo " <form action=\"login.php\" method=\"post\">\n";
echo " <table border=\"0\">\n";
echo " <tr>\n";
echo " <td>\n";
echo " uname:\n";
echo " </td>\n";
echo " <td>\n";
echo " <input type=\"text\" name=\"un\" size=\"20\" />\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>\n";
echo " pword:\n";
echo " </td>\n";
echo " <td>\n";
echo " <input type=\"password\" name=\"pw\" size=\"20\" />\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>\n";
echo " \n";
echo " </td>\n";
echo " <td>\n";
echo " <input type=\"submit\" name=\"submit\" value=\"submit\" />\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " </form>\n";
echo " </body>\n";
echo "</html>\n";
?>