1 |
dpavlin |
1.1 |
<? |
2 |
|
|
|
3 |
|
|
/* mnoGoSearch-php v.3.1.2.5 |
4 |
|
|
* for mnoGoSearch ( formely known as UdmSearch ) free web search engine |
5 |
|
|
* (C) 1999,2000 by Sergey Kartashoff <gluke@biosys.net> |
6 |
|
|
* (C) 1998-1999 by Vladas Lapinskas <lapinskas@mail.iae.lt> |
7 |
|
|
* Kir Kolyshkin <kir@sever.net> |
8 |
|
|
* UdmSearch Developers Team <devel@search.udm.net> |
9 |
|
|
* oracle7 support by Roman V. Petrov (poma@mail.ru) |
10 |
|
|
* |
11 |
|
|
* features: ispell support (db & text mode), |
12 |
|
|
* mysql , oracle (both v7 and v8) and postgresql SQL-backends |
13 |
|
|
* both in native and odbc modes support |
14 |
|
|
* crc-multi, crc, multi-dict and single-dict storage modes support |
15 |
|
|
*/ |
16 |
|
|
|
17 |
|
|
global $mnogo_output; |
18 |
|
|
|
19 |
|
|
$mnogo_output=""; |
20 |
|
|
|
21 |
|
|
$dir="./mnogo"; |
22 |
|
|
#$dir="."; |
23 |
|
|
|
24 |
|
|
require("$dir/config.inc"); |
25 |
|
|
require("$dir/init.inc"); |
26 |
|
|
require("$dir/common.inc"); |
27 |
|
|
|
28 |
|
|
require("$dir/template.inc"); |
29 |
|
|
require("$dir/db_func.inc"); |
30 |
|
|
require("$dir/ispell.inc"); |
31 |
|
|
require("$dir/parse.inc"); |
32 |
|
|
|
33 |
|
|
global $template_file; |
34 |
|
|
global $found,$np,$isnext,$ps,$tag,$ul,$ue,$self,$o,$m,$cat; |
35 |
|
|
global $dt, $dp, $dx, $dm, $dy, $dd, $db, $de, $lang; |
36 |
|
|
global $q_local,$ul_local,$ue_local,$t_local,$db_local,$de_local,$lang_local; |
37 |
|
|
|
38 |
|
|
if ($lang_content_negotiation == "yes") { |
39 |
|
|
// path to template file ($lang_content_negotiation = "yes") |
40 |
|
|
// please refer to docs on this feature before using it. |
41 |
|
|
$template_file= ereg_replace(".php.*", ".htm", basename($SCRIPT_FILENAME)); |
42 |
|
|
$template_file = "./$dir/" . $template_file; |
43 |
|
|
} else { |
44 |
|
|
// path to template file ($lang_content_negotiation = "no") |
45 |
|
|
$template_file="$dir/search.htm"; |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
// ----------------------------------------------- |
49 |
|
|
// M A I N |
50 |
|
|
// ----------------------------------------------- |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
init(); |
54 |
|
|
|
55 |
|
|
|
56 |
|
|
if (! $have_query_flag) { |
57 |
|
|
print_template('bottom'); |
58 |
|
|
drop_temp_table(0); |
59 |
|
|
return; |
60 |
|
|
} elseif ($have_query_flag && ($q=='')) { |
61 |
|
|
print_template('noquery'); |
62 |
|
|
print_template('bottom'); |
63 |
|
|
drop_temp_table(0); |
64 |
|
|
return; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
if (eregi('db',$ispellmode) || eregi('text',$ispellmode)) load_affix(); |
68 |
|
|
|
69 |
|
|
list($query_url_id,$query_url,$query_count_url_id)=last_parse($q); |
70 |
|
|
|
71 |
|
|
if (count($all_words) == 0) { |
72 |
|
|
print_template('notfound'); |
73 |
|
|
print_template('bottom'); |
74 |
|
|
drop_temp_table(0); |
75 |
|
|
track_query($query_orig,time(),0); |
76 |
|
|
return; |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
if (($dbtype == 'oracle')|| |
80 |
|
|
($dbtype == 'oracle7') || |
81 |
|
|
($dbtype == 'oracle8')) |
82 |
|
|
{ |
83 |
|
|
if($DEBUG) echo "main(): ",$query_count_url_id,"<BR><HR>"; |
84 |
|
|
|
85 |
|
|
if (!($res2=db_query($query_count_url_id))) print_error_local('Query error: '.$query_count_url_id."\n<BR>".db_error()); |
86 |
|
|
|
87 |
|
|
$row=db_fetchrow($res2); |
88 |
|
|
$found=$row[0]; |
89 |
|
|
|
90 |
|
|
db_freeresult($res2); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
if($DEBUG) echo "main(): ",$query_url_id,"<BR><HR>"; |
94 |
|
|
if (!($res=db_query($query_url_id))) print_error_local('Query error: '.$query_url_id."\n<BR>".db_error()); |
95 |
|
|
|
96 |
|
|
$from=IntVal($np)*IntVal($ps); |
97 |
|
|
$to=IntVal($np+1)*IntVal($ps); |
98 |
|
|
|
99 |
|
|
if (($dbtype == 'mysql') || |
100 |
|
|
($dbtype == 'pgsql') || |
101 |
|
|
($dbtype == '')) { |
102 |
|
|
$found=db_numrows($res); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
if($to>$found) $to=$found; |
106 |
|
|
if (($from+$ps)<$found) $isnext=1; |
107 |
|
|
$nav=make_nav($query_orig); |
108 |
|
|
|
109 |
|
|
if ($found>0) { |
110 |
|
|
print_template('restop'); |
111 |
|
|
} else { |
112 |
|
|
print_template('notfound'); |
113 |
|
|
print_template('bottom'); |
114 |
|
|
drop_temp_table(0); |
115 |
|
|
track_query($query_orig,time(),0); |
116 |
|
|
return; |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
$data_seek=db_dataseek($res,$from); |
120 |
|
|
if (! $data_seek) { |
121 |
|
|
print_template('notfound'); |
122 |
|
|
print_template('bottom'); |
123 |
|
|
drop_temp_table(0); |
124 |
|
|
track_query($query_orig,time(),0); |
125 |
|
|
return; |
126 |
|
|
} |
127 |
|
|
|
128 |
|
|
$url_id_array=array(); |
129 |
|
|
$rating_array=array(); |
130 |
|
|
|
131 |
|
|
for ($i=0; $i<$ps; $i++) { |
132 |
|
|
$row=db_fetchrow($res); |
133 |
|
|
|
134 |
|
|
if (!$row) break; |
135 |
|
|
|
136 |
|
|
$url_id_array[] = $row[0]; |
137 |
|
|
$rating_array[] = $row[1]; |
138 |
|
|
} |
139 |
|
|
|
140 |
|
|
db_freeresult($res); |
141 |
|
|
|
142 |
|
|
drop_temp_table(1); |
143 |
|
|
|
144 |
|
|
$ndoc=$from+1; |
145 |
|
|
for ($i=0; $i<count($url_id_array); $i++) { |
146 |
|
|
|
147 |
|
|
$query=ereg_replace("%URL_IN%",$url_id_array[$i],$query_url); |
148 |
|
|
$rating=$rating_array[$i]; |
149 |
|
|
|
150 |
|
|
if($DEBUG) echo "main(): ",$query,"<BR><HR>"; |
151 |
|
|
if (!($res=db_query($query))) print_error_local('Query error: '.$query."\n<BR>".db_error()); |
152 |
|
|
|
153 |
|
|
$data=db_fetchrow($res); |
154 |
|
|
db_freeresult($res); |
155 |
|
|
|
156 |
|
|
$url=$data[0]; |
157 |
|
|
$title=$data[1]; |
158 |
|
|
$title=($title) ? htmlspecialChars($title):'No title'; |
159 |
|
|
$text=ParseDocText(htmlspecialChars($data[2])); |
160 |
|
|
$contype=$data[3]; |
161 |
|
|
$docsize=$data[4]; |
162 |
|
|
$lastmod=format_lastmod($data[5]); |
163 |
|
|
$keyw=htmlspecialChars($data[6]); |
164 |
|
|
$desc=htmlspecialChars($data[7]); |
165 |
|
|
$crc=$data[8]; |
166 |
|
|
$rec_id=0+$data[9]; |
167 |
|
|
|
168 |
|
|
if ($db_format == '3.1') { |
169 |
|
|
$category=$data[10]; |
170 |
|
|
} |
171 |
|
|
|
172 |
|
|
if ((ereg("^ftp://", $url)) && |
173 |
|
|
($templates['ftpres'][0] != '')) { |
174 |
|
|
print_template('ftpres'); |
175 |
|
|
} elseif ((ereg("^https?://", $url)) && |
176 |
|
|
($templates['httpres'][0] != '')) { |
177 |
|
|
print_template('httpres'); |
178 |
|
|
} else { |
179 |
|
|
print_template('res'); |
180 |
|
|
} |
181 |
|
|
|
182 |
|
|
$ndoc++; |
183 |
|
|
} |
184 |
|
|
|
185 |
|
|
print_template('resbot'); |
186 |
|
|
print_template('bottom'); |
187 |
|
|
|
188 |
|
|
track_query($query_orig,time(),$found); |
189 |
|
|
|
190 |
|
|
if ($dbtype == 'oracle7') { |
191 |
|
|
Ora_Close($dbconn); // closing oracle7 cursor |
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
?> |