File: computers-search.php3

package info (click to toggle)
irm 1.0.3-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 816 kB
  • ctags: 753
  • sloc: php: 3,440; sh: 346; makefile: 40
file content (121 lines) | stat: -rw-r--r-- 4,502 bytes parent folder | download
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
<?
#    IRM - The Information Resource Manager
#    Copyright (C) 1999 Yann Ramin
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License (in file COPYING) for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#    $Id: computers-search.php3,v 1.7 2000/03/26 23:12:04 atrus Exp $
#
################################################################################
#                                  CHANGELOG                                   #
################################################################################
#  7/22/99 - Keith Schoenefeld:	Cleaned up code, converted all IF(): to if(){. #
#  7/24/99 - Keith Schoenefeld: Added in stuff for phrasetype.  In             #
#				comptuers-index.php3 the user now specifies    #
#				whether they want to do an exact phrase search #
#				or a contains search on the field.  Now the    #
#				% sign on the mysql query is added only if the #
#				user selects contains.                         #
#  7/25/99 - Yann Ramin: Passed phrasetype to the computerListView so 	       #
#			 multi-paged list views search correctly.              #
#  7/27/99 - Yann Ramin: Added 'batch add software' link                       #
#  8/16/99 - Keith Schoenefeld:	Added mods to lab setup.                       #
################################################################################

include("../irm.inc");

AuthCheck("normal");
$db = new DB;
commonHeader("IRM Computers - Search Results");
# If phrase is only a contains search, add the % characters for the mysql query.
if ($phrasetype == "contains")
{
  $newcontains = "%$contains%";
} else
{
  $newcontains = $contains;
}

$tempquery = "SELECT * FROM computers WHERE ($field LIKE '$newcontains') ORDER BY $sort";

PRINT "Showing results where $field contains $contains in $style view 
		sorted by $sort.<br><br>";
PRINT "<table border=0 width=100%>";
PRINT "<tr>";
PRINT "<td align=center><h4><form method=post 
		action=computers-software-batch.php3><input type=hidden 
		name=query value=\"$tempquery\"><input type=submit 
		value=\"Batch Add Software with this Query\"></form>";
PRINT "</h4></td>";
if($cfg_groups == 1)
{
PRINT "<td align=center><h4><form method=post 
		action=computers-groups-batch.php3> <input type=hidden 
		name=query value=\"$tempquery\"><input type=submit 
		value=\"Setup groups with this query\"></form>";
PRINT "</h4></td>";
}
PRINT "</tr>";
PRINT "</table>";
PRINT "<hr noshade>";


if ($style == "full")
{
  $query = "SELECT * FROM computers WHERE ($field LIKE '$newcontains') 
	ORDER BY $sort";
  $result = $db->query($query);
  $i = $goto;
  $number = $db->numrows($result);
  while ($i < $number)
  {
    $ID = $db->result($result, $i, "ID");
    showComputer($ID, 0);
    if (($goto + 4 - $i) < 1)
    {
      break;
    }
    $i++;
  }
  $backgoto = $goto - 5;
  $forgoto = $goto + 5;
  PRINT "<table border=0><tr><td>";
  if ($backgoto > -1)
  {
    PRINT "<form><input type=hidden name=sort value=\"sort\">
		<input type=hidden name=field value=\"$field\">
		<input type=hidden name=phrasetype value=\"$phrasetype\">
		<input type=hidden name=contains value=\"$contains\">
		<input type=hidden name=style value=\"$style\">
		<input type=hidden name=goto value=$backgoto>
		<input type=submit value=\"Previous 5\"></form>";
  }
  PRINT "</td><td>";
  PRINT "<form><input type=hidden name=sort value=\"$sort\">
		<input type=hidden name=field value=\"$field\">
		<input type=hidden name=phrasetype value=\"$phrasetype\">
		<input type=hidden name=contains value=\"$contains\">
		<input type=hidden name=style value=\"$style\">
		<input type=hidden name=goto value=$forgoto>
		<input type=submit value=\"Next 5\"></form>";
  PRINT "</td></tr></table>";
} elseif ($style == "list")
{
  $query = "SELECT * FROM computers WHERE ($field LIKE '$newcontains') 
		ORDER BY $sort";
  computerListView($query, $sort, $phrasetype);
}
commonFooter();
?>