I downloaded a Holiday Manager app from Sourceforge which looks exactly what I want to manage a small team.
Firstly, I think the app is now longer supported but I think it could be, and secondly, it doesn't work for me.
I have loaded the code onto my server and everything seemed to work fine ( Upoon first login, the login screen asks for Email and Password. If a new user is created (thro the Admin interface), a password is emailed to that user. Once the user logins in using the email address and the emailed password, the code knows this is a first time user and asks the user to change their password. On the change password screen, you are prompted for a new password plus a confirmation. Once this is entered, the login screen is then shown again. And now a user cannot login.
I'm not sure where to start with what I seem to think is a simply script problem.
Here's the login script:
I somehow think that you'll need more than this.
If you want to try to login under a fresh login, let me know and I can create a user and allow you to see the issue.
Many thanks in anticipation ...
Firstly, I think the app is now longer supported but I think it could be, and secondly, it doesn't work for me.
I have loaded the code onto my server and everything seemed to work fine ( Upoon first login, the login screen asks for Email and Password. If a new user is created (thro the Admin interface), a password is emailed to that user. Once the user logins in using the email address and the emailed password, the code knows this is a first time user and asks the user to change their password. On the change password screen, you are prompted for a new password plus a confirmation. Once this is entered, the login screen is then shown again. And now a user cannot login.
I'm not sure where to start with what I seem to think is a simply script problem.
Here's the login script:
Code:
<?php
//USERS inc file! Not admin!
//
// You WILL need to edit the next line to reflect your setup! DO NOT REALLY RUN AS ROOT!
$dbh=mysql_connect("localhost","dbuser","dbpasswd") or die("Oops can't connect to db!"); //open db. change user and pass for your server
mysql_select_db("dbname") or die("Oops can't select db!"); // change this if the db name is different
session_start(); //set cookie session up
if (!$_SESSION["Loginuser"]) { // if no cookie print login form
if ($_POST["email"] AND $_POST["pass"]) { //if both email and pass are posted to the form (ie we're ready to log in)
$Email=$_POST["email"]; //THESE NEED TO BE MADE MORE SECURE!
$Pass=$_POST["pass"]; //We need to escape quotes etc.
$mydb=mysql_query("SELECT ID,active from users WHERE Email='$Email' and Pass=MD5('$Pass') LIMIT 1");//find if these credentials are real.
if ($data=mysql_fetch_array($mydb)) {
if ($data["active"] == "y") { // check this user has activated their account
$_SESSION["Loginuser"]=$data["ID"]; //set cookie if correct
} else {
$_SESSION["Inactive"]=$data["ID"]; // set a session so we can remember them!
header("Location: ./activate.php"); // send them over to the activation page.
exit;
}
}
$me=$_SERVER['REQUEST_URI'];
header("Location: $me"); //redirect us back to ourself once we've logged in
exit; //quit else we'd run this all twice! Obviously if the pass is wrong execution will continue.
}
print <<<EOL
<head>
<link rel="stylesheet" href="./stylesheet.css">
<title>Holiday Booking</title>
</head>
<body>
<table style="text-align: left; width: 100%; height: 100%;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td
style="background-color: rgb(102, 153, 255); text-align: left; width: 12%; vertical-align: top;"> </td>
<td style="background-color: rgb(153, 204, 255); vertical-align: top;">
<span style="font-family: helvetica,arial,sans-serif;">
<h1>Welcome to the holiday booking system!</h1>
<form action=
EOL;
echo $_SERVER["REQUEST_URI"];
print <<<EOL
method=post>
<table border="1">
<tr>
<td>Email</td>
<td><input type="text" name="email" value="$Email"></td>
</tr>
<tr>
<td>Pass</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</table>
</td>
</form>
</table>
</body>
</html>
EOL;
die(); // quit while we're ahead!
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="./stylesheet.css" />
<?php
function dayoftheyeartodate($day,$year) { // turn a day of the year into a real date
$daysinmonth=array(0,31,28,31,30,31,30,31,31,30,31,30,31); // these are the number of days in each month in the year. First value is 0 so we can use real month numbers offset from one.
if ($year % 4 == 0 AND $year % 100 <> 0 OR $year % 400 == 0) {
$daysinmonth[2]=29; // make feb have 29 days in leap years. We've got til 2400 before all the code is needed, but hey!
}
$mymonth=0; $myday=0; $myyear=$year;
$daysleft=$day;//daysleft will drop down til 0, subtracting the number of days in each month. month counts up, daysleft counts down
for ($month=1; $month<13;$month++) {
if ($daysleft <= $daysinmonth[$month]) {
$mymonth=$month;
$myday=$daysleft;
return array($myday,$mymonth,$myyear); //returns an array of the real date
} else {
$daysleft-=$daysinmonth[$month]; // or move to the next month if we have "extraneous" days
}
}
}
function datetodayoftheyear($day,$month,$year) { //does what the other one does, backwards... works by adding days from the daysinmonth array til the relevant month, then the modulus number of days
$daysinmonth=array(0,31,28,31,30,31,30,31,31,30,31,30,31);
if ($year % 4 == 0 AND $year % 100 <> 0 OR $year % 400 == 0) {
$daysinmonth[2]=29;
}
$dayoftheyear=0;
for ($mon=1;$mon<$month;$mon++) {
$dayoftheyear+=$daysinmonth[$mon];
}
$dayoftheyear+=$day;
return $dayoftheyear;
}
?>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type" />
<title>Holiday Bookings</title>
</head>
<body>
<table class="mainTable">
<tbody>
<tr>
<td class="leftwin">
<h4>Menu</h4>
<p><a href="index.php">Summary</a></p>
<p><a href="calendar.php">Calendar</a></p>
<p><a href="changepass.php">Change Password</a></p>
<p><a href="logout.php">Log out</a></p>
<div id="gotobottom">
<b>Staff Holiday Manager</b><br />
<a href="[URL unfurl="true"]http://sourceforge.net/projects/staffhols/"[/URL] target="New_window">Visit me!</a>
</div>
</td>
<td class="rightwin">
I somehow think that you'll need more than this.
If you want to try to login under a fresh login, let me know and I can create a user and allow you to see the issue.
Many thanks in anticipation ...