diff --git a/includes/menu.inc.php b/includes/menu.inc.php index 3ea0cdf..2fa772a 100755 --- a/includes/menu.inc.php +++ b/includes/menu.inc.php @@ -11,6 +11,7 @@
You do not appear to have any punches on record.
"; - $status = "Out"; - } else { - if (!empty($last->outtime)) { $status = "Out"; $statustime = $last->outtime; } else { $status = "In"; $statustime = $last->intime; $punchid = $last->punchid; $notes = $last->notes; } -echo "You have been Punched $status since " . date('g:i a \o\n M jS, Y', strtotime($statustime)) . ".
"; -} -echo "Clicking the button below will immediately enter a new punch for you depending on your current status. Any notes you enter will be attached to the punch for your administrator to review.
"; -echo "You do not appear to have any punches on record.
"; + $status = "Out"; + } //!isset($last->user) + else { + if (!empty($last->outtime)) { + $status = "Out"; + $statustime = $last->outtime; + } //!empty($last->outtime) + else { + $status = "In"; + $statustime = $last->intime; + $punchid = $last->punchid; + $notes = $last->notes; + } + echo "You have been Punched $status since " . date('g:i a \o\n M jS, Y', strtotime($statustime)) . ".
"; + } + echo "Clicking the button below will immediately enter a new punch for you depending on your current status. Any notes you enter will be attached to the punch for your administrator to review.
"; + echo ""; + + + //********** END CONTENT **********// } require_once($yaptc_inc . "footer.inc.php"); ?> diff --git a/users.php b/users.php index 1e5ab11..3f7e7a1 100755 --- a/users.php +++ b/users.php @@ -4,51 +4,10 @@ require_once("config.inc.php"); $yaptc_pagename = "Users"; require_once($yaptc_inc . "header.inc.php"); require_once($yaptc_inc . "menu.inc.php"); -// Is user logged in? If not, they shouldn't be here - kill all variables and redirect to login... -if (!isset($_SESSION['user_id']) || !isset($_SESSION['signature']) || !isset($_SESSION['loggedIn']) || $_SESSION['loggedIn'] != true || $_SESSION['signature'] != md5($_SESSION['user_id'] . $_SERVER['HTTP_USER_AGENT'])) -{ -session_start(); -session_unset(); -session_destroy(); -header ("Refresh:3; url=login.php", true, 303); -echo "Editing to be added, for now, it doesn;t exist
"; -$result = $sql->prepare("SELECT users.id as userid, users.username as username, users.email as email, users.created as created, users.firstname as firstname, users.lastname as lastname, users.usertype as usertypeid, usertypes.typename as usertype -FROM yaptc.users -INNER JOIN usertypes ON users.usertype = usertypes.id -ORDER BY users.lastname ASC;"); -$result->execute(); -echo 'First Name | '; -echo 'Last Name | '; -echo 'Username | '; -echo 'Created | '; -echo 'User Type | '; -echo '|
---|---|---|---|---|---|
" . $row['firstname'] . " | "; -echo "" . $row['lastname'] . " | "; -echo "" . $row['username'] . " | "; -echo "" . $row['email'] . " | "; -echo "" . $row['created'] . " | "; -echo "" . $row['usertype'] . " | "; -echo "
Use the following form to add users to the system. Passwords must be 8+ characters. Email must be filled out, and username must be unique.
"; @@ -58,19 +17,19 @@ if (!empty($_POST)) { if (empty($_POST['username'])) { - echo "Username cannot be empty."; + $errors['username'] = "Username cannot be empty."; } if (preg_match('/[^a-zA-Z0-9 .-_]/', $_POST['username'])) { - echo "Username contains illegal characters."; + $errors['username'] = "Username contains illegal characters."; } if (empty($_POST['password'])) { - echo "Password cannot be empty."; + $errors['password'] = "Password cannot be empty."; } if (strlen($_POST['password']) < 8) { - echo "Password must be at least 8 charcaters."; + $errors['password'] = "Password must be at least 8 charcaters."; } // OPTIONAL // Force passwords to contain at least one number and one special character. @@ -86,16 +45,16 @@ if (!empty($_POST)) */ if (empty($_POST['password_confirm'])) { - echo "Please confirm password."; + $errors['password_confirm'] = "Please confirm password."; } if ($_POST['password'] != $_POST['password_confirm']) { - echo "Passwords do not match."; + $errors['password_confirm'] = "Passwords do not match."; } $email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL); if (!$email) { - echo "Not a valid email address."; + $errors['email'] = "Not a valid email address."; } /** @@ -125,11 +84,11 @@ if (!empty($_POST)) { if ($existing->username == $_POST['username']) { - echo "That username is already in use."; + $errors['username'] = "That username is already in use."; } if ($existing->email == $email) { - echo "That email address is already in use."; + $errors['email'] = "That email address is already in use."; } } } @@ -151,10 +110,12 @@ if (!empty($_POST) && empty($errors)) * prepared statements, be sure to escape your data before passing it to * your query. */ - $query = "INSERT INTO users (username, password, email, created, usertype) - VALUES (:username, :password, :email, NOW(), :usertype)"; + $query = "INSERT INTO users (firstname, lastname, username, password, email, created, usertype) + VALUES (:firstname, :lastname, :username, :password, :email, NOW(), :usertype)"; $stmt = $sql->prepare($query); $success = $stmt->execute(array( + ':firstname' => $_POST['firstname'], + ':lastname' => $_POST['lastname'], ':username' => $_POST['username'], ':password' => $password, ':email' => $_POST['email'], @@ -190,33 +151,34 @@ if (!empty($_POST) && empty($errors)) -