Added:
/trunk/BookGet/book.php
/trunk/BookGet/userpage.php
Modified:
/trunk/BookGet/Include/SearchEngine.php
/trunk/BookGet/Include/category_bar.php
/trunk/BookGet/Include/header_bar.php
/trunk/BookGet/login.php
/trunk/BookGet/search.php
=======================================
--- /dev/null
+++ /trunk/BookGet/book.php Fri Dec 3 09:15:04 2010
@@ -0,0 +1,73 @@
+<?php require_once("Include/SearchEngine.php");
+
+$db = SearchEngine::getInstance();
+if ($_GET["bookid"] != "") {
+ $res = $db->Search_Phrase($_GET["bookid"], "BookID");
+} else {
+ header("index.php");
+ exit;
+}
+?>
+<?php include "Include/mimetype.php" ?>
+ <head>
+ <title>BookGet.com</title>
+ <link rel="stylesheet" href="style/layout.css" type="text/css" />
+ </head>
+ <body>
+ <div id="headerbar">
+ </div>
+ <div id="headerwrapper">
+ <div id="pageheader">
+ <div id="logodiv">
+ <span id="book">book</span><span id="get">get</span>
+ </div>
+ <div id="headercontent" class="clearboth">
+ <form method="get" action="search.php">
+ <div id="searchdiv" class="searchbar">
+ <input id="searchbox" type="text" name="query"
size="40" class="search" />
+ <button id="searchbutton" type="submit"
class="search"></button>
+ </div>
+ </form>
+
+ <div id="accountsettings">
+ <a href="settings.php">Settings</a>
+ <a href="account.php">Account</a>
+ <a href="login.php">Login</a>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div id="pagewrapper">
+ <div id="leftcol">
+ <?php include("Include/category_bar.php"); ?>
+ </div>
+ <div id="pagecontent">
+ <div id="rightcol" >
+ <?php include("Include/account_settings.php"); ?>
+ </div>
+ <div id="content">
+ <h1><?php echo $res[0]["title"]; ?></h1>
+ <div id="bookwrapper">
+ <div id="picture">
+ Image Here
+ <?php // get right image ?>
+ </div>
+ <div id="basic_info">
+ <?php // generate info from GET ?>
+ </div>
+ <div id="description">
+ <?php //fetch from DB ?>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!--div id="footer">
+ <div id="foot_center">
+ <a href="http://validator.w3.org/check?uri=referer">Valid
XHTML 1.1</a>,
+ <a
href="http://jigsaw.w3.org/css-validator/check/referer">Valid CSS</a>
+ </div>
+ </div-->
+ </body>
+</html>
=======================================
--- /dev/null
+++ /trunk/BookGet/userpage.php Fri Dec 3 09:15:04 2010
@@ -0,0 +1,91 @@
+<?php
+require_once("Include/AccountDB.php");
+session_start();
+ if (!array_key_exists("user", $_SESSION)) {
+ header('Location: login.php');
+ exit;
+ }
+
+
+include "Include/mimetype.php" ?>
+<head>
+ <title>BookGet.com</title>
+ <link rel="stylesheet" href="style/layout.css" type="text/css" />
+ <link rel="stylesheet" href="style/registration.css" type="text/css" />
+</head>
+<body>
+ <div id="headerbar">
+ </div>
+ <div id="headerwrapper">
+ <div id="pageheader">
+ <div id="logodiv">
+ <span id="book">book</span><span id="get">get</span>
+ </div>
+ <div id="headercontent" class="clearboth">
+ <form method="get" action="search.php">
+ <div id="searchdiv" class="searchbar">
+ <input id="searchbox" type="text" name="query"
size="40" class="search" />
+ <button id="searchbutton" type="submit"
class="search"></button>
+ </div>
+ </form>
+
+ <div id="accountsettings">
+ <a href="settings.php">Settings</a>
+ <a href="account.php">Account</a>
+ <a href="logout.php">Logout</a>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div id="pagewrapper">
+ <div id="leftcol">
+ <?php include("Include/category_bar.php"); ?>
+ </div>
+ <div id="pagecontent">
+ <div id="rightcol" >
+ <?php include("Include/account_settings.php"); ?>
+ </div>
+ <div id="content">
+ <table id="registrationbox">
+ <th id="registrationtitle"> Account </th>
+ <tr>
+ <td rowspan="2"><p> </p>
+ <?php echo "<b>Welcome Back, </b>" . $_SESSION["user"]; ?>
+
+ <p> </p>
+ <ul>
+ <p><a href="">Personal Information</a></p>
+ <p> </p>
+ <p><a href="">Change Name
</a> </p>
+ <p> </p>
+ <p><a href="">Change Password</a></p>
+ <p> </p>
+ <p><a href="">Change E-mail Adress
</a> </p>
+ </ul>
+ <p> </p>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </div>
+
+
+
+ <script type="text/javascript">
+
+ function reset_fields() {
+ var email=document.getElementsByName("email")[0];
+ var user=document.getElementsByName("user")[0];
+ var pwd1=document.getElementsByName("password")[0];
+ var pwd2=document.getElementsByName("password2")[0];
+ var fname=document.getElementsByName("firstname")[0];
+ var lname=document.getElementsByName("lastname")[0];
+ var school=document.getElementsByName("schopol")[0];
+
+ email.value = user.value = pwd1.value = pwd2.value = fname.value
= " ";
+ lname.value = school.value = fname.value;
+ }
+ </script>
+</body>
+</html>
=======================================
--- /trunk/BookGet/Include/SearchEngine.php Tue Nov 30 15:56:57 2010
+++ /trunk/BookGet/Include/SearchEngine.php Fri Dec 3 09:15:04 2010
@@ -43,11 +43,6 @@
while($row = mysql_fetch_array($tmp)) {
$book_table[] = $row; // Append the row to the table
}
-
- /** DEBUG
- print count($book_table)."<br/>";
- print count($word_array)."<br/>";
- */
// If we have more than one result, we gotta use the other words to
// narrow it down.
@@ -56,8 +51,6 @@
for($k=0; $k < count($word_array); $k++) {
for($i=0;$i< count($book_table);$i++)
{
- /** DEBUG print $word_array[$k]."<br/>"; */
-
/* If the book entry matches the word, add it to the
results
* array if it isnt already in there. */
if (preg_match('/'.$word_array[$k].'/',
$book_table[$i][$field])) {
@@ -72,12 +65,57 @@
if (count($results) == 0)
$results = $book_table;
- /** DEBUG print count($results)."<br/>";*/
return $results;
}
-
+ public function omnisearch($query) {
+ $db = $this;
+ $res = array();
+ $ret = array();
+
+ /* Search through each field */
+ $res[] = $db->Search_Phrase($query, "title");
+ $res[] = $db->Search_Phrase($query, "title");
+ $res[] = $db->Search_Phrase($query, "author");
+ $res[] = $db->Search_Phrase($query, "author_one");
+ $res[] = $db->Search_Phrase($query, "Description");
+ $res[] = $db->Search_Phrase($query, "ISBN");
+ $res[] = $db->Search_Phrase($query, "School");
+
+ /* Add the arrays together, removing duplicates */
+ foreach ($res as $row) {
+ foreach ($row as $item) {
+ if (!in_array($item,$ret)) {
+ $ret[] = $item;
+ }
+ }
+ }
+
+ return $ret;
+ }
+
+ function catsearch($category, $query) {
+ $db = $this;
+
+ /* Get all the items in the category */
+ $catsearch = $db->Search_Phrase($category, "Department");
+
+ /* Search through everything */
+ $omnisearch = $this->omnisearch($query);
+
+ $result = array();
+
+ /* Only return the ones that are in both */
+ foreach ($catsearch as $item) {
+ foreach ($omnisearch as $candidate)
+ if (in_array($candidate, $catsearch) &&
(!in_array($candidate, $result))) {
+ $result[] = $candidate;
+ }
+ }
+
+ return $result;
+ }
private function strip_common_words($phrase) {
if (strpos($phrase, " ")) {
=======================================
--- /trunk/BookGet/Include/category_bar.php Thu Dec 2 23:26:16 2010
+++ /trunk/BookGet/Include/category_bar.php Fri Dec 3 09:15:04 2010
@@ -1,18 +1,21 @@
<?php
-print("<span><br /><h3><b>Categories</b></h3><br />
+{
+ $buffer = <<<EOF
+<span><br /><h3><b>Categories</b></h3><br />
+
<b>Department</b><br />
- <a href='search.php?query=Literature'>Literature</a><br />
- <a href='search.php?query=Math'>Math</a><br />
- <a href='search.php?query=Science'>Science</a><br />
- <a href='search.php?query=History'>History</a><br />
- <a href='search.php?query=Art'>Art</a><br />
- <a href='search.php?query=Economics'>Economics</a><br />
- <a href='search.php?query=Foreign Language'>Foreign Language</a><br />
- <a href='search.php?query=Social Studies'>Social Studies</a><br />
- <a href='search.php?query=Computer Science'>Computer Science</a><br />
- <a href='search.php?query=Engineering'>Engineering</a><br />
- <a href='search.php?query=Business'>Business</a><br />
+ <a href='search.php?cat=Literature%q%'>Literature</a><br />
+ <a href='search.php?cat=Math%q%'>Math</a><br />
+ <a href='search.php?cat=Science%q%'>Science</a><br />
+ <a href='search.php?cat=History%q%'>History</a><br />
+ <a href='search.php?cat=Art%q%'>Art</a><br />
+ <a href='search.php?cat=conomics%q%'>Economics</a><br />
+ <a href='search.php?cat=Foreign%20Language%q%'>Foreign
Language</a><br />
+ <a href='search.php?cat=Social%20Studies%q%'>Social Studies</a><br />
+ <a href='search.php?cat=Computer%20Science%q%'>Computer
Science</a><br />
+ <a href='search.php?cat=Engineering%q%'>Engineering</a><br />
+ <a href='search.php?cat=Business%q%'>Business</a><br />
<br /><b>Price</b><br />
@@ -28,8 +31,16 @@
<a href=''>Bad</a><br />
<br /><b>Schools</b><br />
- <a href='search.php?query=FAU'>FAU</a><br />
- <a href='search.php?query=SFSU'>SFSU</a><br />
-
-</span>");
+ <a href='search.php?cat=FAU'>FAU</a><br />
+ <a href='search.php?cat=SFSU'>SFSU</a><br />
+
+</span>
+EOF;
+
+ if ($query) {
+ print(str_replace("%q%", "?query=".$query, $buffer));
+ } else {
+ print(str_replace("%q%", "", $buffer));
+ }
+}
?>
=======================================
--- /trunk/BookGet/Include/header_bar.php Thu Dec 2 23:26:16 2010
+++ /trunk/BookGet/Include/header_bar.php Fri Dec 3 09:15:04 2010
@@ -5,7 +5,7 @@
<div id="headerwrapper">
<div id="pageheader">
<div id="logodiv">
- <span id="book">book</span><span id="get">get</span>
+ <a href="index.php"><span id="book">book</span><span
id="get">get</span></a>
</div>
<div id="headercontent" class="clearboth">
<form method="get" action="search.php">
=======================================
--- /trunk/BookGet/login.php Thu Dec 2 23:26:16 2010
+++ /trunk/BookGet/login.php Fri Dec 3 09:15:04 2010
@@ -34,7 +34,7 @@
if ($db->verify_credentials($_POST["user"], $_POST["userpassword"])) {
session_start();
$_SESSION["user"] = $_POST["user"];
- header('Location: account.php');
+ header('Location: userpage.php');
exit;
} else {
$logonSuccess = false;
@@ -61,7 +61,7 @@
</div>
<div id="pagecontent">
<div id="rightcol" >
- <?php include("Include/account_settings.php"); ?>
+ <?php include("Include/category_bar.php"); ?>
</div>
<div id="content">
=======================================
--- /trunk/BookGet/search.php Thu Dec 2 23:26:16 2010
+++ /trunk/BookGet/search.php Fri Dec 3 09:15:04 2010
@@ -1,45 +1,30 @@
<?php
require_once("Include/SearchEngine.php");
-// Search box function
-function omnisearch($query) {
- $db = SearchEngine::getInstance();
- $res = array();
- $ret = array();
-
- $res[] = $db->Search_Phrase($query, "title");
- $res[] = $db->Search_Phrase($query, "title");
- $res[] = $db->Search_Phrase($query, "author");
- $res[] = $db->Search_Phrase($query, "author_one");
- $res[] = $db->Search_Phrase($query, "Description");
- $res[] = $db->Search_Phrase($query, "ISBN");
- $res[] = $db->Search_Phrase($query, "Department");
- $res[] = $db->Search_Phrase($query, "School");
-
- foreach ($res as $row) {
- foreach ($row as $item) {
- if (!in_array($item,$ret)) {
- $ret[] = $item;
- }
+$db = SearchEngine::GetInstance();
+
+$termsIsEmpty = true;
+$query = $_GET["query"];
+$cat = $_GET["cat"];
+
+$noResults = true;
+$searchresults = array();
+
+if ($cat != "") {
+ $searchresults = $db->catsearch($cat, $query);
+ if (count(searchresults) > 1) {
+ $noresults = false;
+ }
+} else {
+ if ($query != "") {
+ $searchresults = $db->omnisearch($query);
+ if (count(searchresults) > 1) {
+ $noresults = false;
}
}
-
- return $ret;
}
-$termsIsEmpty = true;
-if ($_GET["query"] != "") {
- $termsIsEmpty = false;
-
- $searchresults = omnisearch($_GET["query"]);
- if (count($searchresults) < 1) {
- $termsIsEmpty = true;
- $noResults = true;
- }
-} else {
- header("index.php");
- exit;
-}
+
?>
<?php include("Include/mimetype.php");
include "Include/header_bar.php"; ?>
@@ -63,13 +48,14 @@
<?php print $header; ?>
<div id="pagewrapper">
<div id="leftcol">
- <?php include("Include/category_bar.php"); ?>
+ <?php include("Include/category_bar.php"); ?>
</div>
<div id="pagecontent">
<div id="rightcol" >
<?php include("Include/account_settings.php"); ?>
</div>
<div id="content">
+ <?php if ($noResults) { ?>
<table id="results">
<tr>
<th scope="col" class="label">Cover</th>
@@ -113,6 +99,9 @@
}
?>
</table>
+ <?php } else { ?>
+ <h1 class="label">Found no results</h1>
+ <?php } ?>
</div>
</div>
</div>