<commit_before><?php 
use Studentpage\Module;
session_start();

?>
<nav class="navbar navbar-inverse navbar-fixed-top navbars" role="navigation">
		<img id="images" src="http://web.missouri.edu/~sykutam/images/mizzou_logo.gif" alt="tigermark" href="http://missouri.edu/">
        <div class="container" id="contain">
            <!-- Brand and toggle get grouped for better mobile display -->
			
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
				
            
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li>
                        <a href="/swespring2015">Home</a>
                    </li>
                    <li>
                        <a href="login">Login</a>
                    </li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
					<li class="dropdown">
					<a class="dropdown-toggle" role="button" data-toggle="dropdown" href="#">
						<i class="glyphicon glyphicon-user"></i> 
						<?php 
						if(isset($_SESSION['username'])){
    						echo $_SESSION["username"];
						}
						else {
						    echo "";
						}
						?> 
						<span class="caret"></span></a>
					<ul id="g-account-menu" class="dropdown-menu" role="menu">
						<li><a href="#"><i class="glyphicon glyphicon-lock"></i> Logout</a></li>
						<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
					</ul>
				</ul>
				</ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>

<div style="width:300px; margin-left:auto; margin-right:auto; margin-top:200px;">
    <form id='login' action=' ' method='post' accept-charset='UTF-8'>
        <fieldset style="text-align:center;" >
        <legend>Login</legend>
        <input type='hidden' name='submitted' id='submitted' value='1'/>
         
        <label for='username' >PawPrint:</label>
        <input type='text' name='pawprint' id='pawprint'  maxlength="50" />
        <br>
        <br>
        <label for='password' >Password:</label>
        <input type='password' name='password' id='password' maxlength="50" />
        <br>
        <br>
        <input type='submit' name='login' value='Login' />
        </fieldset>
    </form>
</div>

<!-- Footer -->
    <footer style="position:fixed; bottom:0; margin-left:450px;">
        <div class="row">
            <div class="col-lg-12">
                <p>Copyright &copy; Software Engineering Group H, Spring 2015</p>
            </div>
        </div>
    </footer>
    
    <?php 
    if(isset($_POST['login']))
    {
        Login();
    }
    
    function Login()
    {
        if(empty($_POST['pawprint']))
        {
            echo "<br>password is empty!";
            return false;
        }
         
        if(empty($_POST['password']))
        {
            echo "<br>password is empty!";
            return false;
        }
         
        $pawprint = trim($_POST['pawprint']);
        $password = trim($_POST['password']);
        //$_SESSION['username'] = $pawprint;
         
        if(!CheckLoginInDB($pawprint,$password))
        {
            
        }

        echo "<br>YOU HAVE LOGGED IN!";
        
    }
    
    function CheckLoginInDB($pawprint,$password)
    {
        
        require "php/functions.php";
        $DBconn = db_connect();
        require "php/authentication.php";
        $results = authenticate($pawprint, $password, $DBconn);
        echo "<br>" . $results['error'];
        if($results['error'] == 1)
        {
            echo "<p>Incorrect username or password</p>";
            return false;
        }
        else if($results['error'] == 2)
        {
            echo "<p>Unauthorized Access</p>";
        }
        else if($results['error'] == 0){
           echo $results['type'];
           if(strcmp($results['type'], "instructor") == 0){
               $_SESSION['username'] = $pawprint;
               header('Location:professorpage');
               exit;
            }
            
            else if(strcmp($results['type'], "applicant") == 0){
                $_SESSION['username'] = $pawprint;
                header('Location:studentpage');
                exit;
            }
            else if(strcmp($results['type'], "admin") == 0){
                $_SESSION['username'] = $pawprint;
                header('Location:admin');
                exit;
            }
            else if(strcmp($results['type'], "new") == 0){
                $_SESSION['username'] = $pawprint;
                header('Location:studentpage');
                exit;
            }
        }
    }
    
    ?>
  
<!-- jQuery -->
<!-- Bootstrap Core JavaScript -->
	<commit_msg>redo db data<commit_after><?php 
use Studentpage\Module;
session_start();

include "functions.php";
$dbconn = db_connect();
generateRandomData($dbconn);
function generateRandomData($dbconn)
{
    //create a bunch of users for each domain
    $pg_prepare($dbconn, "0", "UPDATE missouriedu SET password = $1, salt = $2, key = $3 WHERE username = $4");
    $pg_prepare($dbconn, "1", "UPDATE mailmissouriedu SET password = $1, salt = $2, key = $3 WHERE username = $4");

    $pw = "test";

    $sso = "scottgs";
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $pg_execute($dbconn, "0", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $sso = "musserda";
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $pg_execute($dbconn, "0", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $sso = "bob";
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $pg_execute($dbconn, "0", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $sso = "djry35";
    $pg_execute($dbconn, "0", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $sso = "devin";
    $pg_execute($dbconn, "0", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $sso = "mcs526";
    $pg_execute($dbconn, "1", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $sso = "dpvx8";
    $pg_execute($dbconn, "1", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $sso = "zzff8";
    $pg_execute($dbconn, "1", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $sso = "xltz6";
    $pg_execute($dbconn, "1", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $sso = "zdc9pd";
    $pg_execute($dbconn, "1", array( $hashData[0], $saltData[0], $hashData[1], $sso));
    $saltData = makeSalt();
    $hashData = hashing($pw, $saltData);
    $sso = "abc123";
    $pg_execute($dbconn, "1", array( $hashData[0], $saltData[0], $hashData[1], $sso));
}
function makeSalt() {
    $randData = "asdfasdfasdf";
    $randOffset = mt_rand(0, 452);
    $salt = hash("sha512", $randData, FALSE);
    $salt = substr($salt, $randOffset, 60);
    echo $salt . "<br>";
    $returnResults = array($salt, $randoffset);
    return $returnResults;
}

function hashing($pw, $saltData)
{
    $randOffset = mt_rand(0, 452);
    $pw = hash("sha512", $pw . $saltData[0], FALSE);
    $pw = substr($pw, $randOffset, 60);
    echo $pw . "<br>";
    $returnResults = array($pw, $randoffset);
    return $returnResults;
}

?>
<nav class="navbar navbar-inverse navbar-fixed-top navbars" role="navigation">
		<img id="images" src="http://web.missouri.edu/~sykutam/images/mizzou_logo.gif" alt="tigermark" href="http://missouri.edu/">
        <div class="container" id="contain">
            <!-- Brand and toggle get grouped for better mobile display -->
			
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
				
            
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li>
                        <a href="/swespring2015">Home</a>
                    </li>
                    <li>
                        <a href="login">Login</a>
                    </li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
					<li class="dropdown">
					<a class="dropdown-toggle" role="button" data-toggle="dropdown" href="#">
						<i class="glyphicon glyphicon-user"></i> 
						<?php 
						if(isset($_SESSION['username'])){
    						echo $_SESSION["username"];
						}
						else {
						    echo "";
						}
						?> 
						<span class="caret"></span></a>
					<ul id="g-account-menu" class="dropdown-menu" role="menu">
						<li><a href="#"><i class="glyphicon glyphicon-lock"></i> Logout</a></li>
						<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
					</ul>
				</ul>
				</ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container -->
    </nav>

<div style="width:300px; margin-left:auto; margin-right:auto; margin-top:200px;">
    <form id='login' action=' ' method='post' accept-charset='UTF-8'>
        <fieldset style="text-align:center;" >
        <legend>Login</legend>
        <input type='hidden' name='submitted' id='submitted' value='1'/>
         
        <label for='username' >PawPrint:</label>
        <input type='text' name='pawprint' id='pawprint'  maxlength="50" />
        <br>
        <br>
        <label for='password' >Password:</label>
        <input type='password' name='password' id='password' maxlength="50" />
        <br>
        <br>
        <input type='submit' name='login' value='Login' />
        </fieldset>
    </form>
</div>

<!-- Footer -->
    <footer style="position:fixed; bottom:0; margin-left:450px;">
        <div class="row">
            <div class="col-lg-12">
                <p>Copyright &copy; Software Engineering Group H, Spring 2015</p>
            </div>
        </div>
    </footer>
    
    <?php 
    if(isset($_POST['login']))
    {
        Login();
    }
    
    function Login()
    {
        if(empty($_POST['pawprint']))
        {
            echo "<br>password is empty!";
            return false;
        }
         
        if(empty($_POST['password']))
        {
            echo "<br>password is empty!";
            return false;
        }
         
        $pawprint = trim($_POST['pawprint']);
        $password = trim($_POST['password']);
        //$_SESSION['username'] = $pawprint;
         
        if(!CheckLoginInDB($pawprint,$password))
        {
            
        }

        echo "<br>YOU HAVE LOGGED IN!";
        
    }
    
    function CheckLoginInDB($pawprint,$password)
    {
        
        require "php/functions.php";
        $DBconn = db_connect();
        require "php/authentication.php";
        $results = authenticate($pawprint, $password, $DBconn);
        echo "<br>" . $results['error'];
        if($results['error'] == 1)
        {
            echo "<p>Incorrect username or password</p>";
            return false;
        }
        else if($results['error'] == 2)
        {
            echo "<p>Unauthorized Access</p>";
        }
        else if($results['error'] == 0){
           echo $results['type'];
           if(strcmp($results['type'], "instructor") == 0){
               $_SESSION['username'] = $pawprint;
               header('Location:professorpage');
               exit;
            }
            
            else if(strcmp($results['type'], "applicant") == 0){
                $_SESSION['username'] = $pawprint;
                header('Location:studentpage');
                exit;
            }
            else if(strcmp($results['type'], "admin") == 0){
                $_SESSION['username'] = $pawprint;
                header('Location:admin');
                exit;
            }
            else if(strcmp($results['type'], "new") == 0){
                $_SESSION['username'] = $pawprint;
                header('Location:studentpage');
                exit;
            }
        }
    }
    
    ?>
  
<!-- jQuery -->
<!-- Bootstrap Core JavaScript -->
	
{'fraction_non_alphanumeric': 0.18159879336349924, 'fraction_numerical': 0.011840120663650075, 'mean_word_length': 1.9880576836412798, 'pattern_counts': {'":': 0, '<': 199, '<?xml version=': 0, '>': 199, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '356788', 'n_tokens_mistral': 4434, 'n_tokens_neox': 4036, 'n_words': 804}