summaryrefslogtreecommitdiff
path: root/bucky2/cgi-bin/search
blob: 15a89a65dec48add6040d6e795019f583569b530 (plain)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/perl
use lib "../lib";
use Bucky;
use Data::Dumper;

my $session = new Bucky::Session;

my $query = $session->param("q");

print <<__BODY__;
Content-type: text/html
Pragma: no-cache

<html>
    <head>
    <title>bucky [SEARCH: $query]</title>
    <link rel="stylesheet" href="/css/bogart.css" type="text/css">
    <link rel="shortcut icon" href="/favicon.ico">
    <style type="text/css">
      <!--
      body { background-color: #EEEEEE; }
      -->
    </style>
    </head>

<body>

<center>
<table cellpadding=0 cellspacing=0 border=0>
  <tr>
    <td align="center" style="border: 0px;">

<div style="width: 900px; text-align: left; border: 0px; margin-bottom: 120px;">
<table cellpadding=0 cellspacing=0 border=0 style="padding: 0px margin: 0px;" width=100%>
<tr><td align=left valign=bottom style="padding: 0px 4px 0px 4px;"><span class="bigtitle">bucky's backwards binoculars</span></td></tr>
</table><table width=100% cellpadding=0 cellspacing=0 border=0 style="padding: 0px margin: 0px;">
<tr><td colspan=2 align="center">
<hr noshade color="#201010" style="padding: 0px; margin: 2px;">
</td></tr>
<tr>
<td align=left nowrap style="padding: 0px 4px 0px 4px;"><small>

<span class="lite"><a href="/cgi-bin/bucky/index">home</a></span> | <a href="/cgi-bin/bucky/post">post</a> |
<a href="/cgi-bin/bucky/import">ftp</a> |
<a href="/cgi-bin/bucky/inbox">inbox</a> |
<a href="/cgi-bin/bucky/message">message</a> |
<a href="/cgi-bin/bucky/profile?c=form">profile</a> |

<a href="/cgi-bin/bucky/logout">logout</a>
</small></td>
<td align=right nowrap style="padding: 0px 4px 0px 4px;"><small>

</small></td></tr>
<tr><td colspan=2 align="center">
<hr noshade color="#201010" style="padding: 0px; margin: 2px;">
</td></tr>
</table>
__BODY__

print <<__SEARCH_FORM__;
<center>
<table cellspacing=0 cellpadding=0 border=0 width=900>
<tr>
<td style="width: 149px;">&nbsp;</td>
<td style="padding: 10px;" align="center">
<form action="/cgi-bin/bucky/2/search" method="get" enctype="multipart/form-data">
<table cellpadding=0 cellspacing=0 border=0>
<tr><td style="text-align: center; vertical-align: middle;">
<input name="q" value="$query" maxlength=1024 style="font-size: 13px; font-family: Trebuchet MS, Helvetica, Arial, sans-serif;
                            color: #140A0A; border: 1px #140A0A solid; padding: 1px; margin: 0px 0px 0px 0px; width: 300px;">
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="submit" value="SEARCH" class="clicky" style="margin: 0px 0px 0px 0px;">
</td></tr></table>
</form>
</td>
<td style="width: 149px;">&nbsp;</td>
</tr>

__SEARCH_FORM__

if ($query)
{
my $start = $session->param("start");
my $limit = $session->param("limit");

my $search = new Bucky::Search;
my $results = $search->search($query, $start, $limit);

my $terms = $results->{'terms'};
my $r = 0;

my $z_last_start = $results->{'start'} - $results->{'limit'} + 1;
my $z_start = $results->{'start'};
my $z_limit = $results->{'limit'};
my $z_upto = $z_last_start + $z_limit - 1;
my $z_total = $results->{'total'};
my $z_next;

if ($results->{'total'} == 0)
	{
	my $z_next = "<center><big><big><big>No Results!</big></big></big></center>";
	print "<tr><td>&nbsp;<td style=\"border-top: 1px solid #b6aeab; padding: 10px;\" align=\"center\">$z_next&nbsp;</td>";
	}
else
	{
	$z_next = "<big>displaying $z_last_start-$z_upto of $z_total results ...";
	if ($z_start < $z_total)
		{
		$z_next .= " <big><a href=\"/cgi-bin/bucky/2/search?q=$query&start=$z_start&limit=$z_limit\">next page >></a><big></big>";
		}
	}
print "<tr><td>&nbsp;</td><td style=\"border-bottom: 1px solid #b6aeab; padding: 10px;\" align=\"center\">$z_next&nbsp;</td><td></td>" if $z_next;
foreach my $result (@{$results->{'results'}})
	{
	$r = $r ? 0 : 1;
	my $thread = $results->{'threads'}->{ $result->{'thread'} };
	my $comment = $results->{'comments'}->{ $result->{'comment'} };
	my $file = $results->{'files'}->{ $result->{'file'} };

	my $z_thread = $thread->{'id'};
	my $z_username = $thread->{'username'};
	my $z_title = $search->bold_terms( $thread->{'title'}, $terms);
	my $z_comment = $search->bold_snippet( $comment->{'comment'}, $terms);
	my $z_filename = $file->{'filename'};
	my $z_file = $search->bold_terms( $z_filename, $terms);
	my $z_date = scalar localtime $thread->{'createdate'};
	my $z_strength = $result->{'strength'} . "x" . $result->{'count'};
	my $z_bigs = $result->{'count'} > ( scalar(@$terms) - 3 )
			? "<big><big>" : "<big>";
	my $z_unbigs = $result->{'count'} > ( scalar(@$terms) - 3 )
			? "</big></big>" : "</big>";
	my $z_img;
	if ($file && $file->{'filename'} =~ /jpg/i)
		{
		my $filename = lc($file->{'filename'});
		$z_img = "<img src=\"/bucky/data/$z_thread/.thumb/t.$filename\">" if $filename;
		}
	elsif ($thread->{'flagged'})
		{
		my $file = $results->{'files'}->{ $thread->{'flagged'} };
		my $filename = lc($file->{'filename'});
		$z_img = "<img src=\"/bucky/data/$z_thread/.thumb/t.$filename\">" if $filename;
		}
	my $z_color = "c";
	$z_color .= $r;
	my $z_filelink = "<a href=\"/bucky/data/$z_thread/$z_filename\">$z_file</a>" if $z_file;

	print <<__RESULT__;
<tr>
<td align="right" valign="top" style="padding: 5px;">
$z_img
</td>
<td align="left" valign="top" class="$z_color" style="padding: 5px; border-style: solid; border-color: #b6aeab; border-width: 0px 1px 1px 1px;">
$z_bigs<a href="/cgi-bin/bucky/details/$z_thread"><u>$z_title</u></a>$z_unbigs<br>
<small>$z_strength</small> &nbsp; posted by <a href="/cgi-bin/bucky/profile/$z_username">$z_username</a> | $z_date<br>
<blockquote><big>$z_filelink $z_comment</big></blockquote>
</td>
</tr>

__RESULT__
#	print Dumper($result);
	}
print "<tr><td>&nbsp;</td><td style=\"padding: 10px;\" align=\"center\">$z_next&nbsp;</td><td></td>" if $z_next;
}

print <<__FOOTER__;
</td></tr></table>
</td></tr></table>

</div>

    </td>

  </tr>
</table>
</center>

</body>
</html>


__FOOTER__
1;