Skip to content

Commit

Permalink
WIP: md5 secured passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRannou committed Dec 1, 2011
1 parent 688aceb commit 5acb545
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 72 deletions.
14 changes: 7 additions & 7 deletions admin/createDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
$sql="CREATE TABLE users(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name VARCHAR(30),
email VARCHAR(30),
password VARCHAR(30))";
name VARCHAR(100),
email VARCHAR(100),
password VARCHAR(100))";

if (mysql_query($sql, $con))
{
Expand All @@ -42,10 +42,10 @@
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
owner INT,
name VARCHAR(30),
modified VARCHAR(30),
type VARCHAR(30),
date VARCHAR(30))";
name VARCHAR(100),
modified VARCHAR(100),
type VARCHAR(100),
date VARCHAR(100))";

if (mysql_query($sql, $con))
{
Expand Down
2 changes: 1 addition & 1 deletion body.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<body>
<form id='login' action='login.php' method='post' accept-charset='UTF-8'>
<form id='login' action='login.php?action=login' method='post' accept-charset='UTF-8'>
<label for='username' >Email:</label>
<input type='text' name='email' id='email' maxlength="50" /> <br />
<label for='password' >Password:</label>
Expand Down
10 changes: 10 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<?
session_name("MyLogin");
session_start();
session_destroy();

if($_GET['login'] == "failed") {
print $_GET['cause'];
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
Expand Down
18 changes: 15 additions & 3 deletions login.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
session_name("MyLogin");
session_start();

if($_GET['action'] == "login") {
// parse file to get password
$cnf = parse_ini_file("admin/.my.cnf");

Expand All @@ -21,6 +25,7 @@
$myemail = stripslashes($myemail);
$mypassword = mysql_real_escape_string($mypassword);
$myemail = mysql_real_escape_string($myemail);
$mypassword = md5($mypassword);

$sql="SELECT * FROM $tbl_name WHERE email='$myemail' and password='$mypassword'";
$result=mysql_query($sql);
Expand All @@ -30,13 +35,20 @@
// If result matched $myemail and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and $myemail and redirect to file "login_success.php"
session_register("myemail");
session_register("myusername");
session_register("mypassword");
header("location:registeredarea.html");
header("location:registeredarea.php");
exit;
}
else {
echo "Wrong Username or Password";
echo "<meta http-equiv='refresh' content='3;url=index.php'>";
exit;
}
}

// if the session is not registered
if(session_is_registered("myusername") == false) {
echo "Session is not registered, please log in";
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
}
?>
2 changes: 2 additions & 0 deletions register.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
$mypassword = mysql_real_escape_string($mypassword);
$myemail = mysql_real_escape_string($myemail);

$mypassword = md5($mypassword);

//
$sql="select COUNT(*) from users where name='$myusername'";
$result = mysql_query($sql, $con);
Expand Down
71 changes: 12 additions & 59 deletions registeredarea.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,29 @@
<?
session_start();
if(!session_is_registered(myusername)){
echo "Wrong Username or Password";
echo "<meta http-equiv='refresh' content='3;url=index.php'>";
}
?>

<html>
<head>
<title>jQuery Dock from Queness WebBlog</title>
<script type="text/javascript" src="libs/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="libs/js/jquery.easing.1.3.js"></script>
<script src="libs/jqueryFileTree.js" type="text/javascript"></script>
<link href="libs/jqueryFileTree.css" rel="stylesheet" type="text/css" media="screen" />

<script>

$(document).ready(function() {

var top = '-' + $('#slidedown_content .content').css('height');
var easing = 'easeOutBounce';

$('#slidedown_top').mouseover(function() {
$('#slidedown_content').animate({'top' : 0}, {queue:false, duration:1000, easing: easing});
});

$('#slidedown_bottom').mouseover(function() {
$('#slidedown_content').animate({'top' : top}, {queue:false, duration:500, easing: easing});
});

});

</script>

<script type="text/javascript">
<script type="text/javascript">

$(document).ready( function() {
$(document).ready( function() {

$('#fileTreeDemo_1').fileTree({ root: '../../bank/', script: 'libs/connectors/jqueryFileTree.php' }, function(file) {
$('#fileTreeDemo_1').fileTree({ root: '../../bank/', script: 'libs/connectors/jqueryFileTree.php' }, function(file) {
alert(file);
});

});
</script>
</script>

<style>
body {
Expand Down Expand Up @@ -115,42 +104,6 @@
</head>
<body>


<div id="slidedown_top"></div> <!-- slidedown_top -->
<div id="slidedown_content">

<div class="content">
<div class="block">
<img src="libs/footerAuthor.gif"/><br/>
<p>A passionate web designer, developer who keens to contribute to web development industry.</p>
<p>Feel free to say hi to me, or follow me on twitter. </p>
</div>
<div class="block">
<img src="libs/footerTwitter.gif"/><br/>
<ul>
<li>I have a new inspiration using easing method, stay tuned!</li>
<li>Dock menu with jQuery! pretty cool huh...</li>
</ul>
</div>
<div class="block">
<img src="libs/footerPartner.gif"/><br/>
<ul>
<li>Smashing Magazine</li>
<li>Vandelay Design</li>
<li>Sixrevision</li>
<li>CSS Mania</li>
<li>Web Designer Depot</li>
<li>Queness</li>
</ul>
</div>
<div class="clear"></div>
</div> <!-- content -->

<div class="footer">
</div> <!-- footer -->

</div> <!-- slidedown_content -->

<div id="slidedown_bottom">
<div class="example">
<h2>Default options</h2>
Expand Down
120 changes: 118 additions & 2 deletions registeredarea.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,119 @@
<?php
echo "Welcome in the registered area";
<?
require("login.php");
?>
<?
session_start();
if(!session_is_registered(myusername)){
echo "Wrong Username or Password";
echo "<meta http-equiv='refresh' content='3;url=index.php'>";
}
?>

<html>
<head>
<title>jQuery Dock from Queness WebBlog</title>
<script type="text/javascript" src="libs/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="libs/js/jquery.easing.1.3.js"></script>
<script src="libs/jqueryFileTree.js" type="text/javascript"></script>
<link href="libs/jqueryFileTree.css" rel="stylesheet" type="text/css" media="screen" />

<script type="text/javascript">

$(document).ready( function() {

$('#fileTreeDemo_1').fileTree({ root: '../../bank/', script: 'libs/connectors/jqueryFileTree.php' }, function(file) {
alert(file);
});

});
</script>

<style>
body {
margin:0;
padding:0
}

#slidedown_top {
height: 70px;
background-color:#666;
}

#slidedown_bottom {
position: absolute;
width: 100%;
height:100%;
background-color:#666;
}

#slidedown_content {
position: absolute;
width: 100%;
height: 250px;
top: -205px;
text-align:center;
background:url(libs/bg.gif) repeat-x 0 bottom;
z-index:999;
}

#slidedown_content .content {
margin:0 auto;
width:830px;
height:205px;
}

/* Styles for content */

#slidedown_content .content .block {
float:left;
width:250px;
padding:0 4px 0 4px;
margin: 0 4px 0 4px;

text-align:left;
font-family:georgia;
font-size:11px;
color:#ccc;
}

#slidedown_content .footer {
height:40px;
}

#slidedown_content .content li {
padding:0;
margin:4px 0
}

.clear {clear:both}

.example {
float: left;
margin: 15px;
}

.demo {
width: 200px;
height: 400px;
border-top: solid 1px #BBB;
border-left: solid 1px #BBB;
border-bottom: solid 1px #FFF;
border-right: solid 1px #FFF;
background: #FFF;
overflow: scroll;
padding: 5px;
}
</style>
</head>
<body>

<div id="slidedown_bottom">
<div class="example">
<h2>Default options</h2>
<div id="fileTreeDemo_1" class="demo"></div>
</div>
</div>

</body>
</head>
</html>

0 comments on commit 5acb545

Please sign in to comment.