Skip to content

Commit

Permalink
goddamn
Browse files Browse the repository at this point in the history
still working on preliminary shit
  • Loading branch information
paleomedia committed Apr 5, 2015
1 parent 2cd20ce commit 4b9b2e2
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 25 deletions.
3 changes: 0 additions & 3 deletions about.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
$thisPage="About";
include 'top.php'; ?>


<!-- <title>About - IDLEG - Idaho Legislative Information Portal, Bills, Lawmakers & Data</title> -->

<div class="maincontainer">

<?php include 'dash.php'; ?>
Expand Down
5 changes: 2 additions & 3 deletions bills.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php
$thisPage="Bills";
include 'top.php'; ?>


<!-- <title>Bills - IDLEG - Idaho Legislative Information Portal, Bills, Lawmakers & Data</title> -->

<div class="maincontainer">

<?php include 'dash.php'; ?>



<?php include 'footer.php'; ?>
12 changes: 9 additions & 3 deletions dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
<input type="search" name="search" placeholder="Search bills, legislators, etc...." autocomplete="on">
</div>
</form>
</div>
</div>

<div class="dashhead" id="login">Login</div>
<div class="loginbox">
<form action="login.php" method="post">
<!-- <?php
if (isset($_SESSION["status"])) {
echo "<div id=\"status\">" . $_SESSION["status"] . "</div>";
unset($_SESSION["status"]);
}
?> -->
<form action="login.php" method="POST">
<div class="loginbox">
<input type="text" name="name" id="username" placeholder="User name" />
<input type="text" name="username" id="username" placeholder="User name" />
</div>
<input type="submit" value="Go">
<div>
Expand Down
14 changes: 14 additions & 0 deletions granted.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

session_start();

if (isset($_SESSION["access_granted"]) && !$_SESSION["access_granted"] ||
!isset($_SESSION["access_granted"])) {
$_SESSION["status"] = "You need to log in first";
header("Location:index.php");
}
else {
echo "ACCESS GRANTED"; }
?>

<a href="logout.php">Logout</a>
6 changes: 4 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php $thisPage="Home"; ?>
<?php include 'top.php'; ?>
<?php
include 'session_start.php';
$thisPage="Home";
include 'top.php'; ?>

<body>

Expand Down
15 changes: 12 additions & 3 deletions lawmakers.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<?php
$thisPage="Lawmakers";
include 'top.php'; ?>


<!-- <title>Lawmakers - IDLEG - Idaho Legislative Information Portal, Bills, Lawmakers & Data</title> -->

<div class="maincontainer">

<?php include 'dash.php'; ?>

<div class="billmain">

<?php

$host = "localhost";
$user = "root";
$dbpassword = "root";
$database = "idleg_test";
$dbport = 8889;

$db = new PDO("mysql:host=$host;dbname=$database;port=$dbport", $user, $dbpassword);

<?php include 'footer.php'; ?>
18 changes: 18 additions & 0 deletions login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

session_start();
include 'users.php';

if (check_login($_POST["username"], $_POST["password"])) {
$_SESSION["access_granted"] = true;
header("Location:granted.php");

} else {
$status = "Invalid username or password";
$_SESSION["status"] = $status;
$_SESSION["user_preset"] = $_POST["user"];
$_SESSION["access_granted"] = false;

header("Location:index.php");
}
?>
22 changes: 22 additions & 0 deletions login_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
include('top.php');
include('users.php');

$name = $_POST["name"];
$password = $_POST["password"];

if (check_login($name, $password) {
session_start();
$_SESSION["name"] = $name;
?>

<p>Login successful! Welcome back, <?= $name ?>.</p>
<?php
}
else {
?>
<p>Sorry, incorrect user name or password.</p>
<?php
}
include('bottom.php');
?>
5 changes: 5 additions & 0 deletions logout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
session_start();
session_destroy();
header("Location:index.php");
?>
24 changes: 24 additions & 0 deletions session_start.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

if (!isset($_SESSION)) {
session_start();
}

if (isset($_SESSION["flash"])) {
?>
<div id="flash"> <?= $_SESSION["flash"] ?> </div>
<?php
unset($_SESSION["flash"]);
}



/* if (isset($_SESSION["access_granted"]) && $_SESSION["access_granted"]) {
header("Location:granted.php");
}
$user = "";
if (isset($_SESSION["user_preset"])) {
$user = $_SESSION["user_preset"];
} */
?>
7 changes: 1 addition & 6 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<<<<<<< HEAD




.tops {
width: 100%;
height: 145px;
Expand Down Expand Up @@ -88,7 +83,7 @@ div#logo {
padding: .5em;
margin: 10;
}
=======
body {
font-family: 'Source Sans Pro', Helvetica, sans-serif;
font-size: 12px;
Expand Down
5 changes: 3 additions & 2 deletions top.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700' rel='stylesheet' type='text/css'>

<title>IDLEG - Idaho Legislative Information Portal, Bills, Lawmakers & Data</title>
<title><?php if ($thisPage!="")
echo "$thisPage"; ?> - Idaho Legislative Information Portal, Bills, Lawmakers & Data</title>
<meta charset="utf-8" />
<meta name="description" content="idleg: Idaho legislative bill information portal" />
<meta name="keywords" content="Idaho, legislature, bills, laws, legislation" />
<meta name="author" content="Nathaniel Hoffman" /> <!-- Note: Make dynamic based on page author -->

<?php include 'functions.php'; ?>
<meta name="revised" content="<?php filemtime(index.html); ?>" /> <!-- last mod of index.html -->
<meta name="revised" content="<?php filemtime('index.php'); ?>" /> <!-- last mod of index.html -->
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="styles.css" type="text/scc" rel="stylesheet" />
Expand Down
3 changes: 0 additions & 3 deletions topics.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
$thisPage="Topics";
include 'top.php'; ?>


<!-- <title>Topics - IDLEG - Idaho Legislative Information Portal, Bills, Lawmakers & Data</title> -->

<div class="maincontainer">

<?php include 'dash.php'; ?>
Expand Down
38 changes: 38 additions & 0 deletions users.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

if (!isset($_SESSION)) { session_start(); }

# Returns TRUE if PW correct

ini_set('display_errors',1);
error_reporting(E_ALL);

/* $host = "localhost";
$user = "root";
$dbpassword = "root";
$database = "idleg_test";
$dbport = 8889; */

function check_login($name, $password) {
$db = new PDO("mysql:host=127.0.0.1;port=8889;dbname=idleg_test", "root", "root");
var_dump($db);
$name = $db->quote($name);
$rows = $db->query("SELECT password FROM users WHERE username = $name");
if ($rows) {
foreach ($rows as $row) { #only one row should match
if ($password === $row["password"]) {
return TRUE;
}
}
}
return FALSE;
}

function ensure_logged_in() {
if (!isset($_SESSION[$name])) {
redirect("user.php", "You must login first");
}
}

function redirect
?>

0 comments on commit 4b9b2e2

Please sign in to comment.