<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="style/style.css"/> <title>Finance - Detail</title> </head> <body id="detail"> <div id="wrap"> <?php show_header(); ?> <div id="content"> <?php show_records(); ?> <div class="box"> <div class="box_top"></div> <div class="box_center"> <?php show_add_record_form(); ?> </div> <div class="box_bottom"></div> </div> <!-- End of box --> </div> <!-- End of content --> </div> <!-- End of wrap -->
function show_page($cur_page, $dbc) { switch ($cur_page) { case '/limbo_landing.php': # Store current page as number, to send in GET request for quick link item details, the current page will determine what content to filter and which 'go back' to display $p = 0; # Define query for the homepage records - return the 6 most recent items $query = 'SELECT stuff.id, stuff.create_date, stuff.description, stuff.status, stuff.image_url, locations.name FROM stuff, locations WHERE stuff.location_id = locations.id ORDER BY stuff.update_date DESC LIMIT 6'; # Store the query results in $results $results = mysqli_query($dbc, $query); check_results($results); # Show results # But...wait until we know the query succeed before # rendering the table start. if ($results) { # Display homepage banner echo '<section id="banner"> <header> <h2>Welcome to Limbo</h2> <p>The Ultimate Lost & Found System</p> </header> </section>'; # Diplay intro/info and get started/learn more buttons # Set up the modal dialog for Get Started, along with javascript to enable actions/button events echo '<section id="intro" class="container">'; echo '<div class="row"> <div class="4u 12u(mobile)"> <section class="first"> <i class="icon featured fa-cog"></i> <header> <h2>Find Your Lost Items</h2> </header> <p>Lost something? Let Limbo find your item for you.</p> </section> </div> <div class="4u 12u(mobile)"> <section class="middle"> <i class="icon featured alt fa-flash"></i> <header> <h2>Quick & Easy</h2> </header> <p>Limbo is a lightweight, user-friendly system, so that you can focus on finding or reporting items as quickly as possible.</p> </section> </div> <div class="4u 12u(mobile)"> <section class="last"> <i class="icon featured alt2 fa-star"></i> <header> <h2>Security & Privacy</h2> </header> <p>We incorporate several filters to keep your item details secure, so that you can have a peace of mind.</p> </section> </div> </div> <footer> <ul class="actions"> <li><input class="button big" type="button" id="getstartedbtn" value="Get Started"></li> <li><a href="faq.php" class="button alt big">Learn More</a></li> </ul> <dialog style="width:25%; height:60%;" id="getstartedDialog"> <form action="' . $_SERVER['PHP_SELF'] . '" method="post"> <section class="box"> <section> <p><h3>Did you lose an Item?</h3> <a style="font-size:20px;" href="lost.php">Lost Items</a><br> <a style="font-size:20px;" href="lost-1.php">Report Lost Item</a><p> <br> <p><h3>Did you find an Item?</h3> <a style="font-size:20px;" href="found.php">Found Items</a><br> <a style="font-size:20px;" href="found-1.php">Report found Item</a><p> </section> <menu> <button id="cancelDialogGS" type="reset">Cancel</button> </menu> </section> </form> </dialog> <script> (function() { var Item = document.getElementById(\'getstartedbtn\'); var favDialog = document.getElementById(\'getstartedDialog\'); var cancelButton = document.getElementById(\'cancelDialogGS\'); // Update buttons opens a modal dialog Item.addEventListener(\'click\', function() { favDialog.showModal(); }); // Form cancel button closes the dialog box cancelButton.addEventListener(\'click\', function() { favDialog.close(); }); })(); </script> </footer> </section> </div> </div>'; # Display the main content echo '<div id="main-wrapper">'; echo '<div class="container">'; echo '<div class="row"> <div class="12u"> <!-- Recent Items --> <section> <header class="major"> <h2>Recent Items</h2> </header> </div> </div>'; # Keep track of the iterations, so that it can be determined when a new line is required (after 3 items in a row) $count = 0; echo '<div class="row">'; while ($row = mysqli_fetch_array($results, MYSQLI_ASSOC)) { # If three items are already in a row, add new items to next row if ($count % 3 == 0 && $count != 0) { echo '</div>'; echo '<div class="row">'; } # If there is no image url provided for the item use a default image if (empty($row['image_url'])) { $image_url = 'images/pic01.jpg'; } else { $image_url = $row['image_url']; } # Quick links to the item, clicking on the picture should also have the same result $imglink = '<a href="ql.php?id=' . $row['id'] . '&p=' . $p . '" class="image scaled"><img src="' . $image_url . '" alt="" /></a>'; $alink = '<A HREF=ql.php?id=' . $row['id'] . '&p=' . $p . '>' . $row['description'] . '</A>'; echo '<div class="4u 12u(mobile)"> <section class="box"> <p>' . $imglink . '</p> <header> <h3>' . $alink . '</h3> </header> <p>Date: ' . $row['create_date'] . '</p> <p>Status: ' . $row['status'] . '</p> <p>Location: ' . $row['name'] . '</p> </section> </div>'; $count++; } # Close the row, container and main-wrapper echo '</div> </section> </div></div>'; } break; # See comments for /admins.php for details, same applies here # See comments for /admins.php for details, same applies here case '/found.php': $p = 1; $query = 'SELECT stuff.id, stuff.create_date, stuff.description, stuff.status, locations.name, stuff.image_url FROM stuff, locations WHERE stuff.location_id = locations.id AND status = \'lost\''; $results = mysqli_query($dbc, $query); check_results($results); # Show results if ($results) { # But...wait until we know the query succeed before # rendering the table start. echo '</div></div>'; echo '<div id="main-wrapper">'; echo '<div class="container">'; echo '<div class="row">'; echo '<div class="4u 12u(mobile)">'; echo '<section class="box">'; echo '<H2>Found Something?</H2>'; echo '<p>If you found something, you\'re in luck! This is the place to report it. Search for the item below:</p>'; # Show search box show_form($dbc, 'found_search'); echo '</section>'; echo '</div>'; $count = 0; while ($row = mysqli_fetch_array($results, MYSQLI_ASSOC)) { if ($count % 2 == 0 && $count != 0) { echo '</div>'; echo '<div class="row">'; } if (empty($row['image_url'])) { $image_url = 'images/pic01.jpg'; } else { $image_url = $row['image_url']; } $imglink = '<a href="ql.php?id=' . $row['id'] . '&p=' . $p . '" class="image scaled"><img src="' . $image_url . '" alt="" /></a>'; $alink = '<A HREF=ql.php?id=' . $row['id'] . '&p=' . $p . '>' . $row['description'] . '</A>'; echo '<div class="4u 12u(mobile)"> <section class="box"> <p>' . $imglink . '</p> <header> <h3>' . $alink . '</h3> </header> <p>Date: ' . $row['create_date'] . '</p> <p>Status: ' . $row['status'] . '</p> <p>Location: ' . $row['name'] . '</p> </section> </div>'; $count++; } echo '</div>'; echo '</div></div>'; echo '</div>'; } break; case '/found-1.php': report($dbc, $cur_page); return; case '/lost.php': $p = 2; $query = 'SELECT stuff.id, stuff.create_date, stuff.description, stuff.status, locations.name, stuff.image_url FROM stuff, locations WHERE stuff.location_id = locations.id AND status = \'found\''; #AND ' . strtotime('stuff.update_date') . ' > ' . strtotime($date . ' -14 days' 3); $results = mysqli_query($dbc, $query); check_results($results); # Show results if ($results) { echo '</div></div>'; echo '<div id="main-wrapper">'; echo '<div class="container">'; echo '<div class="row">'; echo '<div class="4u 12u(mobile)">'; echo '<section class="box">'; echo '<H2>Lost Something?</H2>'; echo '<p>If you lost something, you\'re in luck! This is the place to report it. Search for your item below:</p>'; show_form($dbc, 'lost_search'); echo '</section>'; echo '</div>'; $count = 0; while ($row = mysqli_fetch_array($results, MYSQLI_ASSOC)) { # If three items are already in a row, add new items to next row if ($count % 2 == 0 && $count != 0) { echo '</div>'; echo '<div class="row">'; } if (empty($row['image_url'])) { $image_url = 'images/pic01.jpg'; } else { $image_url = $row['image_url']; } $imglink = '<a href="ql.php?id=' . $row['id'] . '&p=' . $p . '" class="image scaled"><img src="' . $image_url . '" alt="" /></a>'; $alink = '<A HREF=ql.php?id=' . $row['id'] . '&p=' . $p . '>' . $row['description'] . '</A>'; echo '<div class="4u 12u(mobile)"> <section class="box"> <p>' . $imglink . '</p> <header> <h3>' . $alink . '</h3> </header> <p>Date: ' . $row['create_date'] . '</p> <p>Status: ' . $row['status'] . '</p> <p>Location: ' . $row['name'] . '</p> </section> </div>'; $count++; } #show_records($results, $p); echo '</div>'; echo '</div></div>'; echo '</div>'; } break; # Lost item reporting page # Lost item reporting page case '/lost-1.php': report($dbc, $cur_page); return; case '/ql.php': echo '<TITLE>Limbo - Quick Link</TITLE>'; echo '</div></div>'; echo '<div id="main-wrapper">'; echo '<div class="container">'; echo '<section>'; return; # Users quick link for admins # Users quick link for admins case '/ql_users.php': echo '<TITLE>Limbo - Users</TITLE>'; echo '</div></div>'; echo '<div id="main-wrapper">'; echo '<div class="container">'; echo '<section>'; return; case '/admins.php': $p = 3; $query = 'SELECT stuff.id, stuff.create_date, stuff.description, stuff.status, locations.name, stuff.image_url FROM stuff, locations WHERE stuff.location_id = locations.id'; $results = mysqli_query($dbc, $query); check_results($results); echo '<TITLE>Limbo - Admins</TITLE>'; echo '</div></div>'; echo '<div id="main-wrapper">'; echo '<div class="container">'; echo '<div class="12u">'; echo '<section>'; echo '<p>Click on an Item or User to View/Edit details</p>'; echo '<header class="major"> <h2>Items</h2> </header> </section>'; if ($results) { show_records($results, $p); } $query = 'SELECT id, user_id, first_name, last_name, email, pass, reg_date FROM users'; $results = mysqli_query($dbc, $query); check_results($results); echo '<section>'; echo '<header class="major"> <h2>Users</h2> </header> </section>'; if ($results) { show_user_records($results); } echo '</div></div>'; echo '</div></div>'; break; case '/faq.php': echo '<section id="banner"> <header> <h2>FAQ</h2> <p>Welcome to the FAQ section!</p> </header> </section>'; echo '</div></div>'; echo '<div id="main-wrapper">'; echo '<div class="container">'; echo '<div class="12u"> <!-- Recent Items --> <section> <header class="major"> <h2>Frequently Asked Questions</h2> </header> </div> <div class="row"> <div class="6u 12u(mobile)"> <section class="box"> <header> <h2>How do I report a lost or found item?</h2> </header> <p>At the home page, you will see a get started button. This will guide you through a series of steps to either report a lost item or claim a found item.</p> </section> </div> <div class="6u 12u(mobile)"> <section class="box"> <header> <h2>How will I know when someone has found my item?</h2> </header> <p>When an item has been found, you will receive an e-mail with instructions on claiming your item.</p> </div> </div> </div></div>'; return; case '/search.php': echo '</div> <div class="main-wrapper"> <div class="container"> <div class="12u"> '; return; } # Free up the results in memory mysqli_free_result($results); }
$cur_page = $_SERVER['PHP_SELF']; show_links($dbc, $cur_page); show_page($cur_page, $dbc); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $likedesc = trim($_POST['desc']); $location = $_POST['location']; $type = $_POST['type']; $query = 'SELECT stuff.id, stuff.create_date, stuff.description, stuff.status, locations.name, stuff.image_url FROM stuff, locations WHERE stuff.location_id = locations.id AND stuff.status="' . $type . '" AND stuff.location_id="' . $location . '" AND stuff.description LIKE "%' . $likedesc . '%"'; $results = mysqli_query($dbc, $query); check_results($results); if ($results) { show_records($results, 99); switch ($type) { case 'found': echo '<a href=lost.php><<< Go Back</a><br>'; echo '<a href=limbo_landing.php><<< Go Back to Home</a>'; break; case 'lost': echo '<a href=found.php><<< Go Back</a><br>'; echo '<a href=limbo_landing.php><<< Go Back to Home</a>'; break; } echo '</div></div></div></div>'; } } # Show the footer show_footer();
<?php # CONNECT TO MySQL DATABASE. require 'connect_db.php'; # Function to create and execute a MySQL query. function show_records($dbcon) { $q = 'SELECT * FROM watches'; $result = mysqli_query($dbcon, $q); $num = mysqli_num_rows($result); if ($num > 0) { echo '<h1>Records in watches table</h1> '; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<br>' . $row['model'] . ' | ' . $row['style'] . ' @ ' . $row['price']; } } else { echo '<p>' . mysqli_error($dbc) . '</p>'; } } # Call the function. show_records($dbcon); # Create and execute another MySQL query. $q = 'UPDATE watches SET style = "Gents" WHERE style = "Ladies" '; $result = mysqli_query($dbcon, $q); # Call the function again if 2 records updated. if (mysqli_affected_rows($dbcon) == 2) { echo '<hr>' . mysqli_affected_rows($dbcon) . ' Records Updated...'; show_records($dbc); } # Close the connection. mysqli_close($dbcon);
show_records($record->domain); break; case 'delete_record': if (!array_key_exists('id', $_POST)) { die('Missing id'); } $record = \DNS\Record::from_id($_POST['id']); $record->delete(); show_add_record($record->domain); show_records($record->domain); break; default: die('Unknown action'); break; } } else { switch ($_GET['action']) { case 'edit': if (!array_key_exists('id', $_GET)) { die('Missing id'); } $domain = new Domain($_GET['id']); show_add_record($domain); show_records($domain); break; } } ?> </body> </html>