-
Notifications
You must be signed in to change notification settings - Fork 0
/
projectNewSearch.php
137 lines (108 loc) · 3.41 KB
/
projectNewSearch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
require_once('includes/globals.inc');
emitTop('Peanut Butter -> New Keyword Search', $_SERVER['PHP_SELF']);
if($userType == VISITOR)
{
print('<h3>Sorry, you must be registered to make searches.</h3>');
emitBottom();
die();
}
if(isset($_POST['savesearch']))
{
mysqlSetup();
if(!isset($_POST['keywords']) || !isset($_POST['keyname']) ||
$_POST['keywords'] == '' || $_POST['keyname'] == '')
{
print('<h3>Missing information.</h3>');
}
else
{
$mKeywords = mysql_escape_string($_POST['keywords']);
$mKeyname = mysql_escape_string($_POST['keyname']);
$mUsername = mysql_escape_string($userName);
mysqlSetup();
$sqlquery = "INSERT INTO `pb_searches` (`name`,`owner`,`terms`,`lastused`) "
. "VALUES ('$mKeyname','$mUsername','$mKeywords',NOW())";
$result = mysql_query($sqlquery) or die('Invalid query: ' . mysql_error());
print('<h3>Search has been saved.</h3>');
print('<a href="projectOverview.php">Back to Project Overview</a>');
emitBottom();
die();
}
}
?>
<h3>Enter keywords, separated by commas:</h3>
<form name="newkeywords" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table>
<tr>
<?php
if(isset($_POST['keywords']))
{
$keywords = $_POST['keywords'];
print("\t<th>Name:</th>\n");
print("\t<td><input type=\"text\" name=\"keyname\" size=\"80\" /></td>\n");
print("</tr><tr>\n");
print("\t<th>Keywords:</th>\n");
print("\t<td><input type=\"text\" name=\"keywords\" value=\"$keywords\" size=\"100\"/></td>\n");
print("</tr>\n</table>\n");
print("<input type=\"submit\" name=\"newsearch\" value=\"Try Search\" />");
print("<input type=\"submit\" name=\"savesearch\" value=\"Save Search\" />");
print("</form>\n");
if($keywords != '')
{
$mKeywords = mysql_escape_string($keywords);
mysqlSetup();
$matchColl = new MatchCollection("AND");
$words = explode(',',$keywords);
foreach($words as $word)
$matchColl->addMatch(new Match('Keywords','%'.mysql_escape_string($word).'%','LIKE'));
$whereSQL = $matchColl->toSQL();
$sqlquery = "SELECT `name`, LEFT(`description`,100),`status`,`progress`,`priority`,`owner`,`id` FROM "
. "`pb_projects` WHERE $whereSQL ORDER BY `priority` DESC";
$result = mysql_query($sqlquery) or die('Invalid query: ' . mysql_error());
?>
<table id="projectlist" class="list">
<tr>
<th>Project Name</th>
<th>Owner</th>
<th>Status</th>
<th>Progress</th>
<th>Priority</th>
<th>Description</th>
</tr>
<?php
$rownum = 0;
while($row = mysql_fetch_row($result))
{
$urlname = urlencode($row[0]);
$urlid = urlencode($row[6]);
$style = '';
if($rownum++ % 2 == 0)
$style = ' class="greyed"';
?>
<tr>
<td<?php echo $style;?>><a href="projectInfo.php?projid=<?php echo $urlid;?>"><?php echo $row[0]?></a></td>
<td<?php echo $style;?>><?php echo $row[5]?></td>
<td<?php echo $style;?>><?php echo $row[2]?></td>
<td<?php echo $style;?>><img src="pngbar.php?rating=<?php echo $row[3]?>$amp;type=progress" /></td>
<td<?php echo $style;?>><img src="pngbar.php?rating=<?php echo $row[4]?>&type=priority" /></td>
<td<?php echo $style;?>><?php echo $row[1]?>...</td>
</tr>
<?php
}
mysql_close();
?>
</table>
<?php
}
}
else
{
print("\t<th>Keywords:</th>\n");
print("\t<td><input type=\"text\" name=\"keywords\" value=\"$keywords\" size=\"100\"/></td>\n");
print("</tr>\n</table>\n");
print("<input type=\"submit\" name=\"newsearch\" value=\"Try Search\" />");
print("</form>\n");
}
emitBottom();
?>