Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0a183d43d5
Fetching contributors…

Cannot retrieve contributors at this time

file 86 lines (76 sloc) 2.509 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
<?php

require_once('init.php');
$loginmsg = "";

$error = array();
if(!empty($_POST))
  {
    $user = new user($dbpdo);
    if($user->verify_credentials($_POST['username'], $_POST['password']))
      {
try
{
$user->get_attribute_value('banned');
}
catch (ObjectAttributeNotFoundException $e)
{
$error[] = 'that account has been banned';
}

login($user);
@setcookie("ureddit_sessid", session_id(),time()+(60*60*24*365*5));
$dbpdo->query("INSERT INTO `sessions` (`object_id`,`session_id`) VALUES (?, ?)",
array(
$user->id,
session_id()
));

$dbpdo->query("INSERT INTO `logins` (`object_id`,`datetime`) VALUES (?, ?)",
array(
$user->id,
$user->timestamp()
));
      }
    else
      {
$error[] = "the username or password you entered is incorrect";
      }
  }

if(logged_in())
  send_user_to("/user/" . $_SESSION['username'],"ureddit.com");

$params['title'] .= ' : Log In';
require('header2.php');

?>
<div id="login">
<div class="content">
<h1>Log In</h1>
<form method="post" action="<?=PREFIX ?>/login">
<p>
Username:<br />
<input type="text" name="username" id="username" /><br /><br />

Password:<br />
<input type="password" name="password" id="password" /><br /><br />

<input type="submit" />
</form><br />
<?php
    if(!empty($_POST) && count($error) > 0)
      foreach($error as $err)
echo '<span style="color: red;">' . $err . '</span><br />';
?>
<p>
<strong>Forgot your password?</strong> <a href="<?=PREFIX ?>/recover_password"><br>Reset my password</a></p>
</p>
</div>
</div>
<div id="whyregister">
<div class="content">
<p>
<strong>Don't have an account?</strong> <a href="<?=PREFIX ?>/register"><br>Register</a>!
</p>

<p>
<strong>Why should you register?</strong><br>
By registering an account, you will be able to add classes to your personal schedule and thereby use your account as an organizational tool. Furthermore, teachers often send out mass messages to users that have added their class with class updates, new material, and so on, so you'll be automatically kept up to date.
</p>
<p>
You'll also get an @ureddit.com email address you can check from webmail, your mail client, Gmail account, or smartphone in order to always be up to date!
</p>
</div>
</div>
<?php require_once('footer2.php'); ?>
Something went wrong with that request. Please try again.