| @ -1,39 +1,37 @@ | |||
| <?php | |||
| //11-24-16 | |||
| require('includes/header.php'); | |||
| if($admin) | |||
| { | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| //users | |||
| include('user/users.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| //edit user | |||
| include('user/editUser.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| //new user | |||
| include('user/newUser.php'); | |||
| echo '</div></div>'; | |||
| } | |||
| else | |||
| { | |||
| include('includes/profile.php'); | |||
| } | |||
| require('includes/footer.php'); | |||
| ?> | |||
| //11-24-16 | |||
| require('includes/header.php'); | |||
| if($admin) | |||
| { | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| //users | |||
| include('user/users.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| //edit user | |||
| include('user/editUser.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| //new user | |||
| include('user/newUser.php'); | |||
| echo '</div></div>'; | |||
| } | |||
| else | |||
| { | |||
| include('includes/profile.php'); | |||
| } | |||
| require('includes/footer.php'); | |||
| @ -1,114 +1,114 @@ | |||
| <?php | |||
| //11-24-16 | |||
| $loggedIn = false; | |||
| $admin = false; | |||
| session_start(); | |||
| ob_start(); | |||
| require_once("../quotes_connect.php"); | |||
| if((md5($_SERVER['HTTP_USERAGENT'] . 'salt')) == ($_SESSION['agent']) && $_SESSION['use'] == true) | |||
| //11-24-16 | |||
| $loggedIn = false; | |||
| $admin = false; | |||
| session_start(); | |||
| ob_start(); | |||
| require_once("../quotes_connect.php"); | |||
| if((md5($_SERVER['HTTP_USERAGENT'] . 'salt')) == | |||
| ($_SESSION['agent']) && $_SESSION['use'] == true) | |||
| { | |||
| $loggedIn = true; | |||
| //checks to see if user is an admin | |||
| $q = "select admin from users where user_name='" . | |||
| $_SESSION['username'] . "'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| if(@mysqli_num_rows($r) == 1) | |||
| { | |||
| $loggedIn = true; | |||
| //checks to see if user is an admin | |||
| $q = "select admin from users where user_name='" . $_SESSION['username'] . "'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| if(@mysqli_num_rows($r) == 1) | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $checka = $row['admin']; | |||
| } | |||
| if($checka) | |||
| { | |||
| $admin = true; | |||
| } | |||
| $checka = $row['admin']; | |||
| } | |||
| if($checka) | |||
| { | |||
| $admin = true; | |||
| } | |||
| } | |||
| if($admin) | |||
| { | |||
| echo '<!DOCTYPE html> | |||
| <html> | |||
| <title>Panda Quotes</title> | |||
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" > </script> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <link rel="stylesheet" href="includes/w3.css"> | |||
| <link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-black.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"> | |||
| <body> | |||
| <!-- Header --> | |||
| <header class="w3-container w3-theme w3-padding" id="myHeader"> | |||
| <div class="w3-center"> | |||
| <h1 class="w3-xxxlarge w3-animate-bottom">Panda Quotes</h1> | |||
| <ul class="w3-navbar w3-theme"> | |||
| <li><a class="w3-dark-grey w3-padding-16" href="index.php">Home</a></li> | |||
| <li><a class="w3-padding-16" href="quotes.php">Add Quote</a></li> | |||
| <li><a class="w3-padding-16" href="admin.php">Admin</a></li> | |||
| </ul> | |||
| </div> | |||
| </header>'; | |||
| } | |||
| elseif($loggedIn) | |||
| { | |||
| echo '<!DOCTYPE html> | |||
| <html> | |||
| <title>Panda Quotes</title> | |||
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" > </script> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <link rel="stylesheet" href="includes/w3.css"> | |||
| <link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-black.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"> | |||
| <body> | |||
| <!-- Header --> | |||
| <header class="w3-container w3-theme w3-padding" id="myHeader"> | |||
| <div class="w3-center"> | |||
| <h1 class="w3-xxxlarge w3-animate-bottom">Panda Quotes</h1> | |||
| <ul class="w3-navbar w3-theme"> | |||
| <li><a class="w3-dark-grey w3-padding-16" href="index.php">Home</a></li> | |||
| <li><a class="w3-padding-16" href="quotes.php">Add Quote</a></li> | |||
| </ul> | |||
| </div> | |||
| </header>'; | |||
| } | |||
| else | |||
| { | |||
| echo '<!DOCTYPE html> | |||
| <html> | |||
| <title>Panda Quotes</title> | |||
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" > </script> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <link rel="stylesheet" href="includes/w3.css"> | |||
| <link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-black.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"> | |||
| <body> | |||
| <!-- Header --> | |||
| <header class="w3-container w3-theme w3-padding" id="myHeader"> | |||
| <div class="w3-center"> | |||
| <h1 class="w3-xxxlarge w3-animate-bottom">Panda Quotes</h1> | |||
| <ul class="w3-navbar w3-theme"> | |||
| <li><a class="w3-dark-grey w3-padding-16" href="index.php">Home</a></li> | |||
| </ul> | |||
| </div> | |||
| </header>'; | |||
| } | |||
| } | |||
| if($admin) | |||
| { | |||
| echo '<!DOCTYPE html> | |||
| <html> | |||
| <title>Panda Quotes</title> | |||
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" > </script> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <link rel="stylesheet" href="includes/w3.css"> | |||
| <link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-black.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"> | |||
| <body> | |||
| <!-- Header --> | |||
| <header class="w3-container w3-theme w3-padding" id="myHeader"> | |||
| <div class="w3-center"> | |||
| <h1 class="w3-xxxlarge w3-animate-bottom">Panda Quotes</h1> | |||
| <ul class="w3-navbar w3-theme"> | |||
| <li><a class="w3-dark-grey w3-padding-16" href="index.php">Home</a></li> | |||
| <li><a class="w3-padding-16" href="quotes.php">Add Quote</a></li> | |||
| <li><a class="w3-padding-16" href="admin.php">Admin</a></li> | |||
| </ul> | |||
| </div> | |||
| </header>'; | |||
| } | |||
| elseif($loggedIn) | |||
| { | |||
| echo '<!DOCTYPE html> | |||
| <html> | |||
| <title>Panda Quotes</title> | |||
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" > </script> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <link rel="stylesheet" href="includes/w3.css"> | |||
| <link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-black.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"> | |||
| <body> | |||
| <!-- Header --> | |||
| <header class="w3-container w3-theme w3-padding" id="myHeader"> | |||
| <div class="w3-center"> | |||
| <h1 class="w3-xxxlarge w3-animate-bottom">Panda Quotes</h1> | |||
| <ul class="w3-navbar w3-theme"> | |||
| <li><a class="w3-dark-grey w3-padding-16" href="index.php">Home</a></li> | |||
| <li><a class="w3-padding-16" href="quotes.php">Add Quote</a></li> | |||
| </ul> | |||
| </div> | |||
| </header>'; | |||
| } | |||
| else | |||
| { | |||
| echo '<!DOCTYPE html> | |||
| <html> | |||
| <title>Panda Quotes</title> | |||
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" > </script> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <link rel="stylesheet" href="includes/w3.css"> | |||
| <link rel="stylesheet" href="http://www.w3schools.com/lib/w3-theme-black.css"> | |||
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"> | |||
| <body> | |||
| <!-- Header --> | |||
| <header class="w3-container w3-theme w3-padding" id="myHeader"> | |||
| <div class="w3-center"> | |||
| ?> | |||
| <h1 class="w3-xxxlarge w3-animate-bottom">Panda Quotes</h1> | |||
| <ul class="w3-navbar w3-theme"> | |||
| <li><a class="w3-dark-grey w3-padding-16" href="index.php">Home</a></li> | |||
| </ul> | |||
| </div> | |||
| </header>'; | |||
| } | |||
| @ -1,40 +1,32 @@ | |||
| <?php | |||
| //11-24-16 | |||
| include('includes/header.php'); | |||
| //first row | |||
| include 'quotes/panda.php'; | |||
| include('quotes/public.php'); | |||
| include('quotes/private.php'); | |||
| //4-row | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container"><div style=\'position: relative; width: 100%; height: 0px; padding-bottom: 60%;\'">'; | |||
| echo '<iframe src="https://www.youtube.com/embed/bxydoU2R7F4" frameborder="0" allowfullscreen style=\'position: absolute; left: 0px; top: 0px; width: 100%; height: 100%\'"></iframe>'; | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-half w3-container"><div id="repo1">'; | |||
| echo '<script src="RepoJS/repo.js"></script> | |||
| <script> | |||
| $(\'#repo1\').repo({ user: \'jrtechs\', name: \'Panda-Quotes\' }); | |||
| </script>'; | |||
| echo '</div></div>'; | |||
| echo '</div>'; | |||
| include('includes/footer.php'); | |||
| ?> | |||
| include('includes/header.php'); | |||
| //first row | |||
| include 'quotes/panda.php'; | |||
| include('quotes/public.php'); | |||
| include('quotes/private.php'); | |||
| //4-row | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container"><div style=\'position: relative; width: 100%; height: 0px; padding-bottom: 60%;\'">'; | |||
| echo '<iframe src="https://www.youtube.com/embed/bxydoU2R7F4" frameborder="0" allowfullscreen style=\'position: absolute; left: 0px; top: 0px; width: 100%; height: 100%\'"></iframe>'; | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-half w3-container"><div id="repo1">'; | |||
| echo '<script src="RepoJS/repo.js"></script> | |||
| <script> | |||
| $(\'#repo1\').repo({ user: \'jrtechs\', name: \'Panda-Quotes\' }); | |||
| </script>'; | |||
| echo '</div></div>'; | |||
| echo '</div>'; | |||
| include('includes/footer.php'); | |||
| @ -1,50 +1,41 @@ | |||
| <?php | |||
| include('includes/header.php'); | |||
| include('includes/header.php'); | |||
| if($loggedIn) | |||
| { | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| //add quote | |||
| include('quotes/newQuote.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| //people | |||
| include('quotes/people.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| //add person | |||
| include('quotes/newPerson.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| //people | |||
| include('quotes/allQuotes.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| echo '</div></div>'; | |||
| } | |||
| else | |||
| { | |||
| include('includes/profile.php'); | |||
| } | |||
| include('includes/footer.php'); | |||
| ?> | |||
| if($loggedIn) | |||
| { | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| include('quotes/newQuote.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| include('user/profile.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| include('quotes/people.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| include('quotes/newPerson.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| include('quotes/allQuotes.php'); | |||
| echo '</div><div class="w3-third w3-container"></div></div>'; | |||
| } | |||
| else | |||
| { | |||
| include('includes/profile.php'); | |||
| } | |||
| include('includes/footer.php'); | |||
| @ -1,87 +1,81 @@ | |||
| <?php | |||
| require_once 'includes/carbon.php'; | |||
| use Carbon\Carbon; | |||
| if($loggedIn) | |||
| require_once 'includes/carbon.php'; | |||
| use Carbon\Carbon; | |||
| if($loggedIn) | |||
| { | |||
| if(isset($_POST['del_quote_id'])) | |||
| { | |||
| if(isset($_POST['del_quote_id'])) | |||
| $del_id = mysqli_real_escape_string($dbc, | |||
| trim($_POST['del_quote_id'])); | |||
| $q = "delete from quote where quote_id='$del_id' limit 1"; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: quotes.php"); | |||
| } | |||
| echo '<h1 class="w3-text-teal w3-center">Quotes</h1>'; | |||
| $q = "select * from quote"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"> | |||
| <table class="w3-table w3-striped w3-bordered"> | |||
| <thead> | |||
| <tr class="w3-theme w3-center"> | |||
| <td>Quote</td> | |||
| <td>Person</td> | |||
| <td>Created By</td> | |||
| <td>Date</td> | |||
| <td>Delete</td> | |||
| </tr> | |||
| </thead> | |||
| <tbody>'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<tr>'; | |||
| //quote | |||
| echo "<td>" . $row['quote'] . "</td>"; | |||
| //person | |||
| $q2 = "select name from people where person_id='" | |||
| . $row['person_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| $del_id = mysqli_real_escape_string($dbc, trim($_POST['del_quote_id'])); | |||
| $q = "delete from quote where quote_id='$del_id' limit 1"; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: quotes.php"); | |||
| echo "<td>" . $row2['name'] . "</td>"; | |||
| } | |||
| echo '<h1 class="w3-text-teal w3-center">Quotes</h1>'; | |||
| $q = "select * from quote"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"> | |||
| <table class="w3-table w3-striped w3-bordered"> | |||
| <thead> | |||
| <tr class="w3-theme w3-center"> | |||
| <td>Quote</td> | |||
| <td>Person</td> | |||
| <td>Created By</td> | |||
| <td>Date</td> | |||
| <td>Delete</td> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| '; | |||
| while($row = mysqli_fetch_array($r)) | |||
| //created by | |||
| $q2 = "select user_name from users where user_id='" | |||
| . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| echo '<tr>'; | |||
| //quote | |||
| echo "<td>" . $row['quote'] . "</td>"; | |||
| //person | |||
| $q2 = "select name from people where person_id='" . $row['person_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| echo "<td>" . $row2['name'] . "</td>"; | |||
| } | |||
| //created by | |||
| $q2 = "select user_name from users where user_id='" . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| echo "<td>" . $row2['user_name'] . "</td>"; | |||
| } | |||
| //date | |||
| $c = Carbon::createFromTimestampUTC(strtotime($row['creation_date'] . ' UTC')); | |||
| echo '<td>' . $c->format('l jS \of F Y') . '</td>'; | |||
| //del | |||
| echo '<td>'; | |||
| echo '<form action = "quotes.php" method = "post"> | |||
| <input type = "submit" name="Delete" value="Delete" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/> | |||
| <input type="hidden" name="delPerson" value="TRUE"> | |||
| <input type="hidden" name="del_quote_id" value=' . $row['quote_id'] . '> | |||
| </form>'; | |||
| echo '</td>'; | |||
| echo '</tr>'; | |||
| echo "<td>" . $row2['user_name'] . "</td>"; | |||
| } | |||
| echo '</tbody> | |||
| </table> | |||
| </div>'; | |||
| } | |||
| //date | |||
| $c = Carbon::createFromTimestampUTC(strtotime( | |||
| $row['creation_date'] . ' UTC')); | |||
| echo '<td>' . $c->format('l jS \of F Y') . '</td>'; | |||
| ?> | |||
| //del | |||
| echo '<td>'; | |||
| echo '<form action = "quotes.php" method = "post"> | |||
| <input type = "submit" name="Delete" value="Delete" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/> | |||
| <input type="hidden" name="delPerson" value="TRUE"> | |||
| <input type="hidden" name="del_quote_id" value=' . $row['quote_id'] . '> | |||
| </form>'; | |||
| echo '</td>'; | |||
| echo '</tr>'; | |||
| } | |||
| echo '</tbody></table></div>'; | |||
| } | |||
| @ -1,44 +1,46 @@ | |||
| <?php | |||
| if($loggedIn) | |||
| if($loggedIn) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['newPerson'])) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['newPerson'])) | |||
| { | |||
| $i_first = mysqli_real_escape_string($dbc, trim($_POST['person_first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, trim($_POST['person_last'])); | |||
| $q = "insert into people (name, creation_date) values ('" . $i_first . " " . $i_last . "' , now())"; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: quotes.php"); | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>New Person</center></h1>'; | |||
| echo '<form action="quotes.php" method ="post" class="w3-container w3-card-4"> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="person_first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="person_last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <p><input type="submit" name="Submit" value="Add Person" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="newPerson" value="TRUE" /> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| { | |||
| echo " - $msg<br />"; | |||
| } | |||
| $i_first = mysqli_real_escape_string($dbc, | |||
| trim($_POST['person_first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, | |||
| trim($_POST['person_last'])); | |||
| $q = "insert into people (name, creation_date) values ('" | |||
| . $i_first . " " . $i_last . "' , now())"; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: quotes.php"); | |||
| } | |||
| ?> | |||
| echo '<h1 class="w3-text-teal"><center>New Person</center></h1>'; | |||
| echo '<form action="quotes.php" method ="post" class="w3-container | |||
| w3-card-4"> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="person_first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="person_last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <p><input type="submit" name="Submit" value="Add Person" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="newPerson" value="TRUE" /> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| echo " - $msg<br />"; | |||
| } | |||
| @ -1,80 +1,84 @@ | |||
| <?php | |||
| if($loggedIn) | |||
| if($loggedIn) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['new_quote'])) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['new_quote'])) | |||
| $i_name = mysqli_real_escape_string($dbc, | |||
| trim($_POST['add_quote_name'])); | |||
| $i_quote = mysqli_real_escape_string($dbc, | |||
| trim($_POST['add_quote_quote'])); | |||
| $q = "select * from people where name ='$i_name'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| if(@mysqli_num_rows($r) == 1) | |||
| { | |||
| $i_name = mysqli_real_escape_string($dbc, trim($_POST['add_quote_name'])); | |||
| $i_quote = mysqli_real_escape_string($dbc, trim($_POST['add_quote_quote'])); | |||
| $q = "select * from people where name ='$i_name'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| if(@mysqli_num_rows($r) == 1) | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $person_id = $row['person_id']; | |||
| } | |||
| if($_POST['add_quote_visibility']) | |||
| { | |||
| $q_create = "insert into quote (user_id, creation_date, person_id, quote, visibility) values ('" . $_SESSION['user_id'] . "', now(), '$person_id', '$i_quote', true)"; | |||
| } | |||
| else | |||
| { | |||
| $q_create = "insert into quote (user_id, creation_date, person_id, quote, visibility) values ('" . $_SESSION['user_id'] . "', now(), '$person_id', '$i_quote', false)"; | |||
| } | |||
| //echo $q_create; | |||
| mysqli_query($dbc, $q_create); | |||
| header("Location: quotes.php"); | |||
| $person_id = $row['person_id']; | |||
| } | |||
| if($_POST['add_quote_visibility']) | |||
| { | |||
| $q_create = "insert into quote (user_id, creation_date, | |||
| person_id, quote, visibility) values ('" . $_SESSION['user_id'] . "', | |||
| now(), '$person_id', '$i_quote', true)"; | |||
| } | |||
| else | |||
| { | |||
| $q_create = "insert into quote (user_id, creation_date, | |||
| person_id, quote, visibility) values ('" . $_SESSION['user_id'] . "', | |||
| now(), '$person_id', '$i_quote', false)"; | |||
| } | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>New Quote</center></h1>'; | |||
| echo '<form action="quotes.php" method ="post" class="w3-container w3-card-4">'; | |||
| $q = "select name from people order by name asc"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<select class="w3-select" name ="add_quote_name">'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<option value="' . $row['name'] . '">'; | |||
| echo $row['name'] . '</option>'; | |||
| } | |||
| echo '</select>'; | |||
| echo '<div class="w3-group"> | |||
| <input class="w3-input" type="text" name="add_quote_quote" required> | |||
| <label class="w3-label w3-validate">Quote</label> | |||
| </div> | |||
| <input class="w3-check" type="checkbox" name="add_quote_visibility" checked> | |||
| <label class="w3-validate">Public<label> | |||
| //echo $q_create; | |||
| mysqli_query($dbc, $q_create); | |||
| <p><input type="submit" name="Submit" value="Create Quote" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="new_quote" value="TRUE" /> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| { | |||
| echo " - $msg<br />"; | |||
| header("Location: quotes.php"); | |||
| } | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>New Quote</center></h1>'; | |||
| echo '<form action="quotes.php" method ="post" class="w3-container | |||
| w3-card-4">'; | |||
| $q = "select name from people order by name asc"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<select class="w3-select" name ="add_quote_name">'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<option value="' . $row['name'] . '">'; | |||
| echo $row['name'] . '</option>'; | |||
| } | |||
| echo '</select>'; | |||
| echo '<div class="w3-group"> | |||
| <input class="w3-input" type="text" name="add_quote_quote" required> | |||
| <label class="w3-label w3-validate">Quote</label> | |||
| </div> | |||
| <input class="w3-check" type="checkbox" name="add_quote_visibility" checked> | |||
| <label class="w3-validate">Public<label> | |||
| <p><input type="submit" name="Submit" value="Create Quote" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /> | |||
| </p> | |||
| <input type="hidden" name="new_quote" value="TRUE" /> | |||
| ?> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| echo " - $msg<br />"; | |||
| } | |||
| @ -1,198 +1,187 @@ | |||
| <?php | |||
| function wordWrapAnnotation(&$image, &$draw, $text, $maxWidth) | |||
| function wordWrapAnnotation(&$image, &$draw, $text, $maxWidth) | |||
| { | |||
| $words = explode(" ", $text); | |||
| $lines = array(); | |||
| $i = 0; | |||
| $lineHeight = 0; | |||
| while($i < count($words) ) | |||
| { | |||
| $words = explode(" ", $text); | |||
| $lines = array(); | |||
| $i = 0; | |||
| $lineHeight = 0; | |||
| while($i < count($words) ) | |||
| $currentLine = $words[$i]; | |||
| if($i+1 >= count($words)) | |||
| { | |||
| $lines[] = $currentLine; | |||
| break; | |||
| } | |||
| //Check to see if we can add another word to this line | |||
| $metrics = $image->queryFontMetrics($draw, $currentLine . ' ' | |||
| . $words[$i+1]); | |||
| while($metrics['textWidth'] <= $maxWidth) | |||
| { | |||
| $currentLine = $words[$i]; | |||
| //If so, do it and keep doing it! | |||
| $currentLine .= ' ' . $words[++$i]; | |||
| if($i+1 >= count($words)) | |||
| { | |||
| $lines[] = $currentLine; | |||
| break; | |||
| } | |||
| //Check to see if we can add another word to this line | |||
| $metrics = $image->queryFontMetrics($draw, $currentLine . ' ' . $words[$i+1]); | |||
| while($metrics['textWidth'] <= $maxWidth) | |||
| { | |||
| //If so, do it and keep doing it! | |||
| $currentLine .= ' ' . $words[++$i]; | |||
| if($i+1 >= count($words)) | |||
| break; | |||
| $metrics = $image->queryFontMetrics($draw, $currentLine . ' ' . $words[$i+1]); | |||
| } | |||
| //We can't add the next word to this line, so loop to the next line | |||
| $lines[] = $currentLine; | |||
| $i++; | |||
| //Finally, update line height | |||
| if($metrics['textHeight'] > $lineHeight) | |||
| $lineHeight = $metrics['textHeight']; | |||
| $metrics = $image->queryFontMetrics($draw, $currentLine . ' ' | |||
| . $words[$i+1]); | |||
| } | |||
| return array($lines, $lineHeight); | |||
| //We can't add the next word to this line, so loop to the next line | |||
| $lines[] = $currentLine; | |||
| $i++; | |||
| //Finally, update line height | |||
| if($metrics['textHeight'] > $lineHeight) | |||
| $lineHeight = $metrics['textHeight']; | |||
| } | |||
| function displayImage($quote, $person, $imageLoc) | |||
| { | |||
| $draw = new ImagickDraw(); | |||
| return array($lines, $lineHeight); | |||
| } | |||
| function displayImage($quote, $person, $imageLoc) | |||
| { | |||
| $draw = new ImagickDraw(); | |||
| $image = new Imagick(); | |||
| $image->readImage($imageLoc); | |||
| $image = new Imagick(); | |||
| $image->readImage($imageLoc); | |||
| //grayscale | |||
| /* Green text */ | |||
| $draw->setFillColor("rgb(0,255,0)"); | |||
| //$image->modulateImage(100, 0, 100); | |||
| /* Font properties */ | |||
| $draw->setFont('Bookman-DemiItalic'); | |||
| /* Green text */ | |||
| $draw->setFillColor("rgb(0,255,0)"); | |||
| $fontsize = 0.05 * $image->getimagewidth(); | |||
| /* Font properties */ | |||
| $draw->setFont('Bookman-DemiItalic'); | |||
| $fontsize = 0.05 * $image->getimagewidth(); | |||
| $draw->setFontSize( "$fontsize" ); | |||
| //width = 1180 font is 50 | |||
| //width = 300 font is 15 | |||
| //font = slope of diff(width) + x intercept | |||
| $draw->setFontSize( "$fontsize" ); | |||
| $xpos = $image->getimagewidth()/4; | |||
| $ypos = $image->getimageheight()/4; | |||
| $xpos = $image->getimagewidth()/4; | |||
| $ypos = $image->getimageheight()/4; | |||
| $msg = '"' . $quote . '"' . " - $person"; | |||
| list($lines, $lineHeight) = wordWrapAnnotation($image, $draw, $msg, $image->getimagewidth() /2); | |||
| for($i = 0; $i < count($lines); $i++) | |||
| { | |||
| $msg = '"' . $quote . '"' . " - $person"; | |||
| $image->annotateImage($draw, $xpos, $ypos + $i*$lineHeight, 0, $lines[$i]); | |||
| list($lines, $lineHeight) = wordWrapAnnotation($image, | |||
| $draw, $msg, $image->getimagewidth() /2); | |||
| for($i = 0; $i < count($lines); $i++) | |||
| $image->annotateImage($draw, $xpos, $ypos + $i*$lineHeight, | |||
| 0, $lines[$i]); | |||
| /* Give image a format */ | |||
| $image->setImageFormat('png'); | |||
| echo '<img src="data:image/jpg;base64,'.base64_encode( | |||
| $image->getImageBlob()).'" alt="" width="100%"/>'; | |||
| } | |||
| function printHalf($query) | |||
| { | |||
| $r = mysqli_query ($dbc, $query); | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $q2 = "select name from people where person_id='" . | |||
| $row['person_id'] . "' limit 1"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| $images = glob('../img/*'); | |||
| displayImage($row['quote'], $row2['name'], | |||
| $images[rand(0, count($images) - 1)]); | |||
| } | |||
| } | |||
| echo '</div>'; | |||
| } | |||
| echo '<div class="w3-row-padding w3-center w3-margin-top">'; | |||
| /* Give image a format */ | |||
| $image->setImageFormat('png'); | |||
| echo '<div class="w3-half">'; | |||
| echo '<h1 class="w3-text-teal w3-center">Random Quote</h1>'; | |||
| $q ="select * from quote where visibility=true order by rand() limit 1"; | |||
| $r = mysqli_query ($dbc, $q); | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $q2 = "select name from people where person_id='" . $row['person_id'] | |||
| . "' limit 1"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| echo '<img src="data:image/jpg;base64,'.base64_encode($image->getImageBlob()).'" alt="" width="100%"/>'; | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| $images = glob('../img/*'); | |||
| displayImage($row['quote'], $row2['name'], | |||
| $images[rand(0, count($images) - 1)]); | |||
| } | |||
| function printHalf($query) | |||
| } | |||
| echo '</div>'; | |||
| echo '<div class="w3-half">'; | |||
| echo '<h1 class="w3-text-teal w3-center">Most Recent</h1>'; | |||
| $q ="select * from quote where visibility=true order by creation_date | |||
| desc limit 1"; | |||
| $r = mysqli_query ($dbc, $q); | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $q2 = "select name from people where person_id='" . $row['person_id'] | |||
| . "' limit 1"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| //random | |||
| $images = glob('../img/*'); | |||
| displayImage($row['quote'], $row2['name'], | |||
| $images[rand(0, count($images) - 1)]); | |||
| } | |||
| } | |||
| $r = mysqli_query ($dbc, $query); | |||
| echo '</div>'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $q2 = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; | |||
| echo '</div>'; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| echo '<div class="w3-row-padding w3-center w3-margin-top">'; | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| $images = glob('../img/*'); | |||
| displayImage($row['quote'], $row2['name'], $images[rand(0, count($images) - 1)]); | |||
| } | |||
| } | |||
| echo '<div class="w3-half row-center">'; | |||
| echo '</div>'; | |||
| } | |||
| echo '<div class="w3-row-padding w3-center w3-margin-top">'; | |||
| echo '<div class="w3-half">'; | |||
| echo '<h1 class="w3-text-teal w3-center">Random Quote</h1>'; | |||
| $q ="select * from quote where visibility=true order by rand() limit 1"; | |||
| $r = mysqli_query ($dbc, $q); | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $q2 = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; | |||
| if(isset($_POST['panda'])) | |||
| { | |||
| displayImage($_POST['panda_quote'], $_POST['panda_name'], | |||
| $images[rand(0, count($images) - 1)]); | |||
| } | |||
| echo '<h1 class="w3-text-teal w3-center">Create a panda quote!</h1>'; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| $images = glob('../img/*'); | |||
| displayImage($row['quote'], $row2['name'], $images[rand(0, count($images) - 1)]); | |||
| } | |||
| } | |||
| echo '</div>'; | |||
| echo '<div class="w3-half">'; | |||
| echo '<h1 class="w3-text-teal w3-center">Most Recent</h1>'; | |||
| $q ="select * from quote where visibility=true order by creation_date desc limit 1"; | |||
| $r = mysqli_query ($dbc, $q); | |||
| echo '<form action="index.php" method ="post" class="w3-container w3-card-4"> | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $q2 = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="panda_quote" required> | |||
| <label class="w3-label w3-validate">Quote</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="panda_name" required> | |||
| <label class="w3-label w3-validate">Person\'s Name</label> | |||
| </div> | |||
| <p><input type="submit" name="Submit" value="Create Panda Quote" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="panda" value="TRUE" /> | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| $images = glob('../img/*'); | |||
| displayImage($row['quote'], $row2['name'], $images[rand(0, count($images) - 1)]); | |||
| } | |||
| } | |||
| </form>'; | |||
| echo '</div>'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div>'; | |||
| echo '</div>'; | |||
| echo '</div>'; | |||
| echo '</div>'; | |||
| echo '<div class="w3-row-padding w3-center w3-margin-top">'; | |||
| echo '<div class="w3-half row-center">'; | |||
| if(isset($_POST['panda'])) | |||
| { | |||
| displayImage($_POST['panda_quote'], $_POST['panda_name'], $images[rand(0, count($images) - 1)]); | |||
| } | |||
| echo '<h1 class="w3-text-teal w3-center">Create a panda quote!</h1>'; | |||
| echo '<form action="index.php" method ="post" class="w3-container w3-card-4"> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="panda_quote" required> | |||
| <label class="w3-label w3-validate">Quote</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="panda_name" required> | |||
| <label class="w3-label w3-validate">Person\'s Name</label> | |||
| </div> | |||
| <p><input type="submit" name="Submit" value="Create Panda Quote" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="panda" value="TRUE" /> | |||
| </form>'; | |||
| echo '</div>'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div>'; | |||
| echo '</div>'; | |||
| ?> | |||
| @ -1,60 +1,58 @@ | |||
| <?php | |||
| if($loggedIn) | |||
| if($loggedIn) | |||
| { | |||
| if(isset($_POST['delPerson'])) | |||
| { | |||
| if(isset($_POST['delPerson'])) | |||
| { | |||
| $delete_id = mysqli_real_escape_string($dbc, trim($_POST['del_person_id'])); | |||
| $q = "delete from people where person_id='$delete_id' limit 1"; | |||
| mysqli_query($dbc, $q); | |||
| $q = "delete from quote where person_id='$delete_id'"; | |||
| mysqli_query($dbc, $q); | |||
| } | |||
| echo '<h1 class="w3-text-teal w3-center">People</h1>'; | |||
| $q = "select * from people"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"> | |||
| <table class="w3-table w3-striped w3-bordered"> | |||
| <thead> | |||
| <tr class="w3-theme w3-center"> | |||
| <td>Name</td> | |||
| <td>Delete</td> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| '; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<tr>'; | |||
| //display name | |||
| echo "<td>" . $row['name'] . "</td>"; | |||
| //del | |||
| echo '<td>'; | |||
| echo '<form action = "quotes.php" method = "post"> | |||
| <input type = "submit" name="Delete" value="Delete" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/> | |||
| <input type="hidden" name="delPerson" value="TRUE"> | |||
| <input type="hidden" name="del_person_id" value=' . $row['person_id'] . '> | |||
| </form>'; | |||
| echo '</td>'; | |||
| echo '</tr>'; | |||
| } | |||
| echo '</tbody> | |||
| </table> | |||
| </div>'; | |||
| $delete_id = mysqli_real_escape_string($dbc, | |||
| trim($_POST['del_person_id'])); | |||
| $q = "delete from people where person_id='$delete_id' limit 1"; | |||
| mysqli_query($dbc, $q); | |||
| $q = "delete from quote where person_id='$delete_id'"; | |||
| mysqli_query($dbc, $q); | |||
| } | |||
| ?> | |||
| echo '<h1 class="w3-text-teal w3-center">People</h1>'; | |||
| $q = "select * from people"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"> | |||
| <table class="w3-table w3-striped w3-bordered"> | |||
| <thead> | |||
| <tr class="w3-theme w3-center"> | |||
| <td>Name</td> | |||
| <td>Delete</td> | |||
| </tr> | |||
| </thead> | |||
| <tbody>'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<tr>'; | |||
| //display name | |||
| echo "<td>" . $row['name'] . "</td>"; | |||
| //del | |||
| echo '<td>'; | |||
| echo '<form action = "quotes.php" method = "post"> | |||
| <input type = "submit" name="Delete" value="Delete" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/> | |||
| <input type="hidden" name="delPerson" value="TRUE"> | |||
| <input type="hidden" name="del_person_id" value=' | |||
| . $row['person_id'] . '> | |||
| </form>'; | |||
| echo '</td>'; | |||
| echo '</tr>'; | |||
| } | |||
| echo '</tbody> | |||
| </table> | |||
| </div>'; | |||
| } | |||
| @ -1,124 +1,91 @@ | |||
| <?php | |||
| if($loggedIn) | |||
| { | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<h1 class="w3-text-teal w3-center">Private Quotes</h1>'; | |||
| if($loggedIn) | |||
| { | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<h1 class="w3-text-teal w3-center">Private Quotes</h1>'; | |||
| $q_people = "select * from people order by name asc"; | |||
| $q_people = "select * from people order by name asc"; | |||
| $r_people = mysqli_query($dbc, $q_people); | |||
| $i = 1; | |||
| $row_count = $r_people->num_rows; | |||
| //echo $row_count; | |||
| $r_people = mysqli_query($dbc, $q_people); | |||
| $i = 1; | |||
| $row_count = $r_people->num_rows; | |||
| //$people_array = mysqli_fetch_array($r_people); | |||
| echo '<div class="w3-half w3-container">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| while($row = mysqli_fetch_array($r_people)) | |||
| { | |||
| while($row = mysqli_fetch_array($r_people)) | |||
| if($i <= $row_count/2) | |||
| { | |||
| $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=false"; | |||
| if($i <= $row_count/2) | |||
| { | |||
| //printPerson($row['person_id']); | |||
| //echo $row['name']; | |||
| $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=false"; | |||
| //echo $q_quotes; | |||
| $r = mysqli_query($dbc, $q_quotes); | |||
| $r = mysqli_query($dbc, $q_quotes); | |||
| if($r->num_rows == 0) | |||
| { | |||
| //echo 'nada'; | |||
| } | |||
| else | |||
| { | |||
| echo '<div class="w3-pannel w3-leftbar w3-light-grey">'; | |||
| echo '<p class="w3-xlarge w3-serif">'; | |||
| while($row_quote = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<i>"' . $row_quote['quote'] . '"</i><br>'; | |||
| } | |||
| echo '</p>'; | |||
| if($r->num_rows != 0) | |||
| { | |||
| echo '<div class="w3-pannel w3-leftbar w3-light-grey">'; | |||
| $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; | |||
| //echo $q_name; | |||
| echo '<p class="w3-xlarge w3-serif">'; | |||
| while($row_quote = mysqli_fetch_array($r)) | |||
| echo '<i>"' . $row_quote['quote'] . '"</i><br>'; | |||
| $r_name = mysqli_query($dbc, $q_name); | |||
| echo '</p>'; | |||
| while($row_name = mysqli_fetch_array($r_name)) | |||
| { | |||
| echo '<p>' . $row_name['name'] . '</p>'; | |||
| } | |||
| $q_name = "select name from people where person_id='" . | |||
| $row['person_id'] . "' limit 1"; | |||
| $r_name = mysqli_query($dbc, $q_name); | |||
| echo '</div>'; | |||
| while($row_name = mysqli_fetch_array($r_name)) | |||
| { | |||
| echo '<p>' . $row_name['name'] . '</p>'; | |||
| } | |||
| echo '</div>'; | |||
| } | |||
| $i++; | |||
| } | |||
| $i++; | |||
| } | |||
| echo '</div>'; | |||
| echo '</div>'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| $i = 1; | |||
| $r_people = mysqli_query($dbc, $q_people); | |||
| while($row = mysqli_fetch_array($r_people)) | |||
| $i = 1; | |||
| $r_people = mysqli_query($dbc, $q_people); | |||
| while($row = mysqli_fetch_array($r_people)) | |||
| { | |||
| if($i <= $row_count && $i > $row_count/2) | |||
| { | |||
| if($i <= $row_count && $i > $row_count/2) | |||
| $q_quotes = "select * from quote where person_id='" . | |||
| $row['person_id'] . "' and visibility=false"; | |||
| $r = mysqli_query($dbc, $q_quotes); | |||
| if($r->num_rows != 0) | |||
| { | |||
| //printPerson($row['person_id']); | |||
| //echo $row['name']; | |||
| $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=false"; | |||
| //echo $q_quotes; | |||
| $r = mysqli_query($dbc, $q_quotes); | |||
| echo '<div class="w3-pannel w3-leftbar w3-light-grey">'; | |||
| if($r->num_rows == 0) | |||
| { | |||
| echo '<p class="w3-xlarge w3-serif">'; | |||
| while($row_quote = mysqli_fetch_array($r)) | |||
| echo '<i>"' . $row_quote['quote'] . '"</i><br>'; | |||
| //echo 'nada'; | |||
| } | |||
| else | |||
| { | |||
| echo '<div class="w3-pannel w3-leftbar w3-light-grey">'; | |||
| echo '<p class="w3-xlarge w3-serif">'; | |||
| while($row_quote = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<i>"' . $row_quote['quote'] . '"</i><br>'; | |||
| } | |||
| echo '</p>'; | |||
| echo '</p>'; | |||
| $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; | |||
| //echo $q_name; | |||
| $q_name = "select name from people where person_id='" . | |||
| $row['person_id'] . "' limit 1"; | |||
| $r_name = mysqli_query($dbc, $q_name); | |||
| $r_name = mysqli_query($dbc, $q_name); | |||
| while($row_name = mysqli_fetch_array($r_name)) | |||
| { | |||
| echo '<p>' . $row_name['name'] . '</p>'; | |||
| } | |||
| while($row_name = mysqli_fetch_array($r_name)) | |||
| echo '<p>' . $row_name['name'] . '</p>'; | |||
| echo '</div>'; | |||
| } | |||
| echo '</div>'; | |||
| } | |||
| $i ++; | |||
| } | |||
| echo '</div>'; | |||
| echo '</div>'; | |||
| $i ++; | |||
| } | |||
| ?> | |||
| echo '</div></div>'; | |||
| } | |||
| @ -1,120 +1,98 @@ | |||
| <?php | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<h1 class="w3-text-teal w3-center">Quotes</h1>'; | |||
| $q_people = "select * from people order by name asc"; | |||
| $r_people = mysqli_query($dbc, $q_people); | |||
| $i = 1; | |||
| $row_count = $r_people->num_rows; | |||
| //echo $row_count; | |||
| //$people_array = mysqli_fetch_array($r_people); | |||
| echo '<div class="w3-half w3-container">'; | |||
| while($row = mysqli_fetch_array($r_people)) | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<h1 class="w3-text-teal w3-center">Quotes</h1>'; | |||
| $q_people = "select * from people order by name asc"; | |||
| $r_people = mysqli_query($dbc, $q_people); | |||
| $i = 1; | |||
| $row_count = $r_people->num_rows; | |||
| echo '<div class="w3-half w3-container">'; | |||
| while($row = mysqli_fetch_array($r_people)) | |||
| { | |||
| if($i <= $row_count/2) | |||
| { | |||
| if($i <= $row_count/2) | |||
| $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=true"; | |||
| $r = mysqli_query($dbc, $q_quotes); | |||
| if($r->num_rows != 0) | |||
| { | |||
| //printPerson($row['person_id']); | |||
| //echo $row['name']; | |||
| $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=true"; | |||
| //echo $q_quotes; | |||
| $r = mysqli_query($dbc, $q_quotes); | |||
| echo '<div class="w3-pannel w3-leftbar w3-light-grey">'; | |||
| if($r->num_rows == 0) | |||
| echo '<p class="w3-xlarge w3-serif">'; | |||
| while($row_quote = mysqli_fetch_array($r)) | |||
| { | |||
| //echo 'nada'; | |||
| echo '<i>"' . $row_quote['quote'] . '"</i><br>'; | |||
| } | |||
| else | |||
| { | |||
| echo '<div class="w3-pannel w3-leftbar w3-light-grey">'; | |||
| echo '<p class="w3-xlarge w3-serif">'; | |||
| while($row_quote = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<i>"' . $row_quote['quote'] . '"</i><br>'; | |||
| } | |||
| echo '</p>'; | |||
| echo '</p>'; | |||
| $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; | |||
| //echo $q_name; | |||
| $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; | |||
| //echo $q_name; | |||
| $r_name = mysqli_query($dbc, $q_name); | |||
| $r_name = mysqli_query($dbc, $q_name); | |||
| while($row_name = mysqli_fetch_array($r_name)) | |||
| { | |||
| echo '<p>' . $row_name['name'] . '</p>'; | |||
| } | |||
| echo '</div>'; | |||
| while($row_name = mysqli_fetch_array($r_name)) | |||
| { | |||
| echo '<p>' . $row_name['name'] . '</p>'; | |||
| } | |||
| echo '</div>'; | |||
| } | |||
| $i++; | |||
| } | |||
| echo '</div>'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| $i = 1; | |||
| $r_people = mysqli_query($dbc, $q_people); | |||
| while($row = mysqli_fetch_array($r_people)) | |||
| $i++; | |||
| } | |||
| echo '</div>'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| $i = 1; | |||
| $r_people = mysqli_query($dbc, $q_people); | |||
| while($row = mysqli_fetch_array($r_people)) | |||
| { | |||
| if($i <= $row_count && $i > $row_count/2) | |||
| { | |||
| if($i <= $row_count && $i > $row_count/2) | |||
| //printPerson($row['person_id']); | |||
| //echo $row['name']; | |||
| $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=true"; | |||
| //echo $q_quotes; | |||
| $r = mysqli_query($dbc, $q_quotes); | |||
| if($r->num_rows != 0) | |||
| { | |||
| //printPerson($row['person_id']); | |||
| //echo $row['name']; | |||
| $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=true"; | |||
| //echo $q_quotes; | |||
| $r = mysqli_query($dbc, $q_quotes); | |||
| echo '<div class="w3-pannel w3-leftbar w3-light-grey">'; | |||
| if($r->num_rows == 0) | |||
| echo '<p class="w3-xlarge w3-serif">'; | |||
| while($row_quote = mysqli_fetch_array($r)) | |||
| { | |||
| //echo 'nada'; | |||
| echo '<i>"' . $row_quote['quote'] . '"</i><br>'; | |||
| } | |||
| else | |||
| { | |||
| echo '<div class="w3-pannel w3-leftbar w3-light-grey">'; | |||
| echo '<p class="w3-xlarge w3-serif">'; | |||
| while($row_quote = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<i>"' . $row_quote['quote'] . '"</i><br>'; | |||
| } | |||
| echo '</p>'; | |||
| $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; | |||
| //echo $q_name; | |||
| echo '</p>'; | |||
| $r_name = mysqli_query($dbc, $q_name); | |||
| $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1"; | |||
| //echo $q_name; | |||
| while($row_name = mysqli_fetch_array($r_name)) | |||
| { | |||
| echo '<p>' . $row_name['name'] . '</p>'; | |||
| } | |||
| $r_name = mysqli_query($dbc, $q_name); | |||
| echo '</div>'; | |||
| while($row_name = mysqli_fetch_array($r_name)) | |||
| { | |||
| echo '<p>' . $row_name['name'] . '</p>'; | |||
| } | |||
| echo '</div>'; | |||
| } | |||
| $i ++; | |||
| } | |||
| echo '</div>'; | |||
| $i ++; | |||
| } | |||
| echo '</div></div>'; | |||
| echo '</div>'; | |||
| ?> | |||
| @ -1,9 +1,9 @@ | |||
| <?php | |||
| try | |||
| { | |||
| $dbc = mysqli_connect("127.0.0.1", "quote_user", 'supersecretpassword', "quotes"); | |||
| } catch (Exception $ex) { | |||
| echo 'Bad things just happened'; | |||
| } | |||
| ?> | |||
| try | |||
| { | |||
| $dbc = mysqli_connect("127.0.0.1", "quote_user", | |||
| 'supersecretpassword', "quotes"); | |||
| } catch (Exception $ex) { | |||
| echo 'Bad things just happened'; | |||
| } | |||
| @ -1,102 +1,111 @@ | |||
| <?php | |||
| if($admin) | |||
| if($admin) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['edit_user'])) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['edit_user'])) | |||
| $i_username = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_username'])); | |||
| $i_first = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_last'])); | |||
| $i_password = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_pass'])); | |||
| $i_admin = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_admin'])); | |||
| $passcom = $i_password . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if($i_admin) | |||
| { | |||
| $i_username = mysqli_real_escape_string($dbc, trim($_POST['edit_user_username'])); | |||
| $i_first = mysqli_real_escape_string($dbc, trim($_POST['edit_user_first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, trim($_POST['edit_user_last'])); | |||
| $i_password = mysqli_real_escape_string($dbc, trim($_POST['edit_user_pass'])); | |||
| $i_admin = mysqli_real_escape_string($dbc, trim($_POST['edit_user_admin'])); | |||
| $passcom = $i_password . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if($i_admin) | |||
| { | |||
| $admin_temp = "true"; | |||
| } | |||
| else | |||
| { | |||
| $admin_temp = "false"; | |||
| } | |||
| $q = "select user_id from users where user_name ='$i_username'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $q = "update users set first_name ='$i_first' where user_id='" . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| $q = "update users set last_name ='$i_last' where user_id='" . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| $q = "update users set pass ='$passcom' where user_id='" . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| //echo $q; | |||
| $q = "update users set admin =$admin_temp where user_id='" . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| //echo $q; | |||
| } | |||
| header("Location: admin.php"); | |||
| $admin_temp = "true"; | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Edit User</center></h1>'; | |||
| echo '<form action="admin.php" method ="post" class="w3-container w3-card-4">'; | |||
| $q = "select user_name from users"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<select class="w3-select" name ="edit_user_username">'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| else | |||
| { | |||
| echo '<option value="' . $row['user_name'] . '">'; | |||
| echo $row['user_name'] . '</option>'; | |||
| $admin_temp = "false"; | |||
| } | |||
| echo '</select>'; | |||
| echo '<div class="w3-group"> | |||
| <input class="w3-input" type="text" name="edit_user_first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="edit_user_last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="edit_user_pass" maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| <input class="w3-check" type="checkbox" name="edit_user_admin"> | |||
| <label class="w3-validate">Admin<label> | |||
| <p><input type="submit" name="Submit" value="Edit User" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="edit_user" value="TRUE" /> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| $q = "select user_id from users where user_name ='$i_username'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo " - $msg<br />"; | |||
| $q = "update users set first_name ='$i_first' where user_id='" | |||
| . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| $q = "update users set last_name ='$i_last' where user_id='" | |||
| . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| $q = "update users set pass ='$passcom' where user_id='" | |||
| . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| //echo $q; | |||
| $q = "update users set admin =$admin_temp where user_id='" | |||
| . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| //echo $q; | |||
| } | |||
| header("Location: admin.php"); | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Edit User</center></h1>'; | |||
| echo '<form action="admin.php" method ="post" class="w3-container | |||
| w3-card-4">'; | |||
| $q = "select user_name from users"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<select class="w3-select" name ="edit_user_username">'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<option value="' . $row['user_name'] . '">'; | |||
| echo $row['user_name'] . '</option>'; | |||
| } | |||
| ?> | |||
| echo '</select>'; | |||
| echo '<div class="w3-group"> | |||
| <input class="w3-input" type="text" name="edit_user_first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="edit_user_last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="edit_user_pass" | |||
| maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| <input class="w3-check" type="checkbox" name="edit_user_admin"> | |||
| <label class="w3-validate">Admin<label> | |||
| <p><input type="submit" name="Submit" value="Edit User" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /> | |||
| </p> | |||
| <input type="hidden" name="edit_user" value="TRUE" /> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| echo " - $msg<br />"; | |||
| } | |||
| @ -1,93 +1,90 @@ | |||
| <?php | |||
| if($admin) | |||
| if($admin) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['newUser'])) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['newUser'])) | |||
| $i_first = mysqli_real_escape_string($dbc, trim($_POST['first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, trim($_POST['last'])); | |||
| $i_pass = mysqli_real_escape_string($dbc, trim($_POST['pass'])); | |||
| $i_user = mysqli_real_escape_string($dbc, trim($_POST['user_name'])); | |||
| if($i_first && $i_last && $i_pass && $i_user) | |||
| { | |||
| // echo '**********'; | |||
| $i_first = mysqli_real_escape_string($dbc, trim($_POST['first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, trim($_POST['last'])); | |||
| $i_pass = mysqli_real_escape_string($dbc, trim($_POST['pass'])); | |||
| $i_user = mysqli_real_escape_string($dbc, trim($_POST['user_name'])); | |||
| if($i_first && $i_last && $i_pass && $i_user) | |||
| $q = "select user_id from users where user_name='$i_user'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| if(@mysqli_num_rows($r) == 1) | |||
| { | |||
| $q = "select user_id from users where user_name='$i_user'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| if(@mysqli_num_rows($r) == 1) | |||
| { | |||
| $errors['name'] = "That user name is already in use."; | |||
| } | |||
| $errors['name'] = "That user name is already in use."; | |||
| } | |||
| else | |||
| } | |||
| else | |||
| { | |||
| $errors['input'] = "Please fill in all fields!"; | |||
| } | |||
| if(empty($errors)) | |||
| { | |||
| $passcom = $i_pass . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if(isset($_POST['admin'])) | |||
| { | |||
| $errors['input'] = "Please fill in all fields!"; | |||
| $adminn = "true"; | |||
| } | |||
| if(empty($errors)) | |||
| else | |||
| { | |||
| $passcom = $i_pass . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if(isset($_POST['admin'])) | |||
| { | |||
| $adminn = "true"; | |||
| } | |||
| else | |||
| { | |||
| $adminn = "false"; | |||
| } | |||
| $q = "insert into users(first_name, last_name, user_name, pass, registration_date, admin) values ('$i_first', '$i_last' , '$i_user', '$passcom', now(), $adminn)"; | |||
| //echo $q; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: admin.php"); | |||
| $adminn = "false"; | |||
| } | |||
| $q = "insert into users(first_name, last_name, user_name, | |||
| pass, registration_date, admin) values ('$i_first', '$i_last' , '$i_user', | |||
| '$passcom', now(), $adminn)"; | |||
| //echo $q; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: admin.php"); | |||
| } | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Add User</center></h1>'; | |||
| echo '<form action="admin.php" method ="post" class="w3-container | |||
| w3-card-4"> | |||
| echo '<h1 class="w3-text-teal"><center>Add User</center></h1>'; | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="user_name" required> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="pass" | |||
| maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| echo '<form action="admin.php" method ="post" class="w3-container w3-card-4"> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="user_name" required> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="pass" maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| <input class="w3-check" type="checkbox" name="admin"> | |||
| <label class="w3-validate">Admin<label> | |||
| <p><input type="submit" name="Submit" value="Add User" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="newUser" value="TRUE" /> | |||
| <input class="w3-check" type="checkbox" name="admin"> | |||
| <label class="w3-validate">Admin<label> | |||
| </form>'; | |||
| <p><input type="submit" name="Submit" value="Add User" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="newUser" value="TRUE" /> | |||
| foreach($errors as $msg) | |||
| { | |||
| echo " - $msg<br />"; | |||
| } | |||
| } | |||
| ?> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| echo " - $msg<br />"; | |||
| } | |||
| @ -1,145 +1,146 @@ | |||
| <?php | |||
| //ini_set('display_errors', 1); | |||
| $errors = array(); | |||
| if(isset($_POST['logout'])) | |||
| //ini_set('display_errors', 1); | |||
| $errors = array(); | |||
| if(isset($_POST['logout'])) | |||
| { | |||
| $_SESSION = array(); | |||
| echo '<h3>You are now logged out</h3>'; | |||
| echo("<meta http-equiv='refresh' content='1'>"); | |||
| } | |||
| if(isset($_POST['log_in'])) | |||
| { | |||
| //echo 'Login procces'; | |||
| if(isset($_POST['user_name'])) | |||
| { | |||
| $_SESSION = array(); | |||
| echo '<h3>You are now logged out</h3>'; | |||
| echo("<meta http-equiv='refresh' content='1'>"); | |||
| $i_username = @mysqli_real_escape_string($dbc, | |||
| trim($_POST['user_name'])); | |||
| } | |||
| else | |||
| { | |||
| $errors['User Name'] = 'You need to enter a user name!'; | |||
| } | |||
| if(isset($_POST['log_in'])) | |||
| if(isset($_POST['password'])) | |||
| { | |||
| //echo 'Login procces'; | |||
| if(isset($_POST['user_name'])) | |||
| { | |||
| $i_username = @mysqli_real_escape_string($dbc, trim($_POST['user_name'])); | |||
| } | |||
| else | |||
| { | |||
| $errors['User Name'] = 'You need to enter a user name!'; | |||
| } | |||
| if(isset($_POST['password'])) | |||
| { | |||
| $i_password = @mysqli_real_escape_string($dbc, trim($_POST['password'])); | |||
| } | |||
| else | |||
| { | |||
| $errors['password'] = "You need to enter a password!"; | |||
| } | |||
| if($i_password && $i_username) | |||
| $i_password = @mysqli_real_escape_string($dbc, | |||
| trim($_POST['password'])); | |||
| } | |||
| else | |||
| { | |||
| $errors['password'] = "You need to enter a password!"; | |||
| } | |||
| if($i_password && $i_username) | |||
| { | |||
| //valid username | |||
| $q3 = "select * from users where user_name='$i_username'"; | |||
| //echo $q3; | |||
| $r3 = mysqli_query($dbc, $q3); | |||
| if(@mysqli_num_rows($r3) == 1) | |||
| { | |||
| //valid username | |||
| $q3 = "select * from users where user_name='$i_username'"; | |||
| //echo $q3; | |||
| $r3 = mysqli_query($dbc, $q3); | |||
| if(@mysqli_num_rows($r3) == 1) | |||
| //echo 'das good'; | |||
| $firstName = ""; | |||
| while($row = mysqli_fetch_array($r3)) | |||
| { | |||
| //echo 'das good'; | |||
| $firstName = ""; | |||
| while($row = mysqli_fetch_array($r3)) | |||
| { | |||
| $firstName = $row['first_name']; | |||
| } | |||
| $q2 = "select * from users where user_name = '$i_username' and pass ='" . SHA1($i_password . $firstName) . "'"; | |||
| //echo $q2; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| //30 minutes of error seaching to realize if frogot the s in mysqli | |||
| if(@mysqli_num_rows($r2) == 1) | |||
| { | |||
| while($row = mysqli_fetch_array($r2)) | |||
| { | |||
| $_SESSION['use'] = true; | |||
| $_SESSION['fname'] = $firstName; | |||
| $_SESSION['user_id'] = $row['user_id']; | |||
| $_SESSION['username'] = $row['user_name']; | |||
| $_SESSION['agent'] = md5($_SERVER['HTTP_USERAGENT'] . 'salt'); | |||
| header("Location: index.php"); | |||
| } | |||
| } | |||
| else | |||
| $firstName = $row['first_name']; | |||
| } | |||
| $q2 = "select * from users where user_name = | |||
| '$i_username' and pass ='" . SHA1($i_password . $firstName) . "'"; | |||
| //echo $q2; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| //30 minutes of error seaching to realize if frogot the s in mysqli | |||
| if(@mysqli_num_rows($r2) == 1) | |||
| { | |||
| while($row = mysqli_fetch_array($r2)) | |||
| { | |||
| $errors['password'] = "You entered an invalid password"; | |||
| $_SESSION['use'] = true; | |||
| $_SESSION['fname'] = $firstName; | |||
| $_SESSION['user_id'] = $row['user_id']; | |||
| $_SESSION['username'] = $row['user_name']; | |||
| $_SESSION['agent'] = | |||
| md5($_SERVER['HTTP_USERAGENT'] . 'salt'); | |||
| header("Location: index.php"); | |||
| } | |||
| } | |||
| else | |||
| { | |||
| $errors['user'] = "You entered an invalid user name!"; | |||
| $errors['password'] = "You entered an invalid password"; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| $errors['user'] = "You entered an invalid user name!"; | |||
| } | |||
| } | |||
| } | |||
| echo '<h1 class="w3-text-teal">'; | |||
| echo '<center>'; | |||
| if($loggedIn) | |||
| echo 'Profile'; | |||
| else | |||
| echo 'Log In'; | |||
| echo '</center></h1>'; | |||
| echo '<div class ="w3-card-4 w3-container w3-padding-16">'; | |||
| if($loggedIn) | |||
| { | |||
| echo '<h3 class="w3-center">Welcome ' . $_SESSION['fname'] . '</h3>'; | |||
| echo '<form action="index.php" method ="post"> | |||
| <input class="w3-padding-16 w3-hover-dark-grey | |||
| w3-btn-block w3-center-align" type="submit" name ="logout" | |||
| value="logout" /> | |||
| <input type="hidden" name="logout" value="TRUE" /> | |||
| </form>'; | |||
| } | |||
| else | |||
| { | |||
| //prints login form | |||
| echo '<form action ="index.php" method ="post"> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" value="" name="user_name" | |||
| class="w3-container w3-card-4" required/> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| echo '<h1 class="w3-text-teal">'; | |||
| echo '<center>'; | |||
| if($loggedIn) | |||
| { | |||
| echo 'Profile'; | |||
| } | |||
| else | |||
| { | |||
| echo 'Log In'; | |||
| } | |||
| echo '</center></h1>'; | |||
| echo '<div class ="w3-card-4 w3-container w3-padding-16">'; | |||
| if($loggedIn) | |||
| { | |||
| echo '<h3 class="w3-center">Welcome ' . $_SESSION['fname'] . '</h3>'; | |||
| echo '<form action="index.php" method ="post"> | |||
| <input class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" type="submit" name ="logout" value="logout" /> | |||
| <input type="hidden" name="logout" value="TRUE" /> | |||
| </form>'; | |||
| } | |||
| else | |||
| { | |||
| //prints login form | |||
| echo '<form action ="index.php" method ="post"> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" value="" name="user_name" class="w3-container w3-card-4" required/> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" value="" name="password" class="w3-container w3-card-4" required/> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| <input type="submit" name="login" value="login" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/> | |||
| <input type="hidden" name="log_in" value="TRUE"/> | |||
| </form>'; | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" value="" name="password" | |||
| class="w3-container w3-card-4" required/> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| } | |||
| foreach($errors as $msg) | |||
| { | |||
| echo " - $msg<br />"; | |||
| } | |||
| echo '</div>'; | |||
| <input type="submit" name="login" value="login" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block | |||
| w3-center-align"/> | |||
| <input type="hidden" name="log_in" value="TRUE"/> | |||
| </form>'; | |||
| } | |||
| foreach($errors as $msg) | |||
| echo " - $msg<br />"; | |||
| ?> | |||
| echo '</div>'; | |||
| @ -1,71 +1,68 @@ | |||
| <?php | |||
| //11-24-16 | |||
| if($admin) | |||
| //11-24-16 | |||
| if($admin) | |||
| { | |||
| if(isset($_POST['delUser'])) | |||
| { | |||
| if(isset($_POST['delUser'])) | |||
| { | |||
| $i_id = mysqli_real_escape_string($dbc, trim($_POST['del_user_id'])); | |||
| $q = "delete from users where user_id='$i_id'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: admin.php"); | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Users</center></h1>'; | |||
| $q = "select * from users order by first_name asc"; | |||
| $i_id = mysqli_real_escape_string($dbc, trim($_POST['del_user_id'])); | |||
| $q = "delete from users where user_id='$i_id'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"><table class="w3-table w3-striped w3-bordered"><thead>'; | |||
| echo '<tr class="w3-theme"> | |||
| <td>First Name</td> | |||
| <td>Last Name</td> | |||
| <td>User Name</td> | |||
| <td>Admin</td> | |||
| <td><center>Delete User<center></td> | |||
| </tr></thead><tbody>'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<tr>'; | |||
| //first name | |||
| echo '<td>' . $row['first_name'] . '</td>'; | |||
| //last name | |||
| echo '<td>' . $row['last_name'] . '</td>'; | |||
| //username | |||
| echo '<td>' . $row['user_name'] . '</td>'; | |||
| //admin | |||
| if($row['admin']) | |||
| { | |||
| echo '<td>True</td>'; | |||
| } | |||
| else | |||
| { | |||
| echo '<td>False</td>'; | |||
| } | |||
| //del | |||
| echo '<td>'; | |||
| echo '<form action = "admin.php" method = "post"> | |||
| <input type = "submit" name="Delete" value="Delete" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/> | |||
| <input type="hidden" name="delUser" value="TRUE"> | |||
| <input type="hidden" name="del_user_id" value=' . $row['user_id'] . '> | |||
| </form>'; | |||
| echo '</td>'; | |||
| echo '</tr>'; | |||
| } | |||
| echo '</tbody></table></div>'; | |||
| header("Location: admin.php"); | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Users</center></h1>'; | |||
| $q = "select * from users order by first_name asc"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"><table | |||
| class="w3-table w3-striped w3-bordered"><thead>'; | |||
| echo '<tr class="w3-theme"> | |||
| <td>First Name</td> | |||
| <td>Last Name</td> | |||
| <td>User Name</td> | |||
| <td>Admin</td> | |||
| <td><center>Delete User<center></td> | |||
| </tr></thead><tbody>'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<tr>'; | |||
| //first name | |||
| echo '<td>' . $row['first_name'] . '</td>'; | |||
| //last name | |||
| echo '<td>' . $row['last_name'] . '</td>'; | |||
| //username | |||
| echo '<td>' . $row['user_name'] . '</td>'; | |||
| //admin | |||
| if($row['admin']) | |||
| echo '<td>True</td>'; | |||
| else | |||
| echo '<td>False</td>'; | |||
| //del | |||
| echo '<td>'; | |||
| echo '<form action = "admin.php" method = "post"> | |||
| <input type = "submit" name="Delete" value="Delete" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block | |||
| w3-center-align"/> | |||
| <input type="hidden" name="delUser" value="TRUE"> | |||
| <input type="hidden" name="del_user_id" value=' . $row['user_id'] | |||
| . '> | |||
| </form>'; | |||
| echo '</td>'; | |||
| echo '</tr>'; | |||
| } | |||
| ?> | |||
| echo '</tbody></table></div>'; | |||
| } | |||