mirror of
https://github.com/php/php-src.git
synced 2024-12-02 06:13:40 +08:00
cdf6b7e2c3
This module currently at the alpha state, but it can be used already. @- mnoGoSearch extension module initial version has been added. @ This module currently at the alpha state, but it can be used already. # For details about mnoGoSearch please refer at http://search.mnogo.ru PR: Submitted by: Reviewed by: Obtained from:
80 lines
2.2 KiB
PHP
80 lines
2.2 KiB
PHP
<html>
|
|
<body>
|
|
|
|
<form method=post>
|
|
<input type=text size=30 name=q value="<? echo $q; ?>">
|
|
<input type=submit value=" Search ! ">
|
|
</form>
|
|
|
|
<pre>
|
|
|
|
<?
|
|
if ($q=='') {
|
|
print("</pre></body></html>\n");
|
|
exit();
|
|
}
|
|
|
|
// Stage 1: allocate UdmSearch agent, set DBAddr and DBMode
|
|
// DBMode is optional, "single" by default
|
|
|
|
$udm=Udm_Alloc_Agent("mysql://udm:udm@localhost/udm/",'crc-multi');
|
|
|
|
// Stage 2: set search parameters
|
|
|
|
$page_size=10;
|
|
$page_number=0;
|
|
$search_mode=UDM_MODE_BOOL;
|
|
$first=$page_size*$page_number+1;
|
|
|
|
Udm_Set_Agent_Param($udm,UDM_PARAM_PAGE_SIZE,$page_size);
|
|
Udm_Set_Agent_Param($udm,UDM_PARAM_PAGE_NUM,$page_number);
|
|
Udm_Set_Agent_Param($udm,UDM_PARAM_SEARCH_MODE,$search_mode);
|
|
|
|
|
|
// Stage 3: perform search
|
|
|
|
$res=Udm_Find($udm,$q);
|
|
|
|
// Stage 4: display results
|
|
|
|
// Check error code
|
|
if(($errno=Udm_Errno($udm))>0){
|
|
// Display error message
|
|
printf("Error #%d: '%s'\n",$errno,Udm_Error($udm));
|
|
}else{
|
|
|
|
// Get result parameters
|
|
$total=Udm_Get_Res_Param($res,UDM_PARAM_FOUND);
|
|
$rows=Udm_Get_Res_Param($res,UDM_PARAM_NUM_ROWS);
|
|
|
|
printf("Documents %d-%d from %d total found\n\n",
|
|
$first,$first+$rows-1,$total);
|
|
|
|
// Fetch all rows
|
|
for($i=0;$i<$rows;$i++){
|
|
printf("%3d. %s\n",$first+$i,Udm_Get_Res_Field($res,$i,UDM_FIELD_URL));
|
|
printf(" CONT : %s\n",htmlspecialchars(Udm_Get_Res_Field($res,$i,UDM_FIELD_CONTENT)));
|
|
printf(" TITLE: %s\n",htmlspecialchars(Udm_Get_Res_Field($res,$i,UDM_FIELD_TITLE)));
|
|
printf(" KEYWORDS: %s\n",htmlspecialchars(Udm_Get_Res_Field($res,$i,UDM_FIELD_KEYWORDS)));
|
|
printf(" DESC: %s\n",htmlspecialchars(Udm_Get_Res_Field($res,$i,UDM_FIELD_DESC)));
|
|
printf(" TEXT: %s\n",htmlspecialchars(Udm_Get_Res_Field($res,$i,UDM_FIELD_TEXT)));
|
|
printf(" SIZE : %d\n",Udm_Get_Res_Field($res,$i,UDM_FIELD_SIZE));
|
|
printf(" MODIFIED : %s\n",Udm_Get_Res_Field($res,$i,UDM_FIELD_MODIFIED));
|
|
printf(" URLID : %d\n",Udm_Get_Res_Field($res,$i,UDM_FIELD_URLID));
|
|
printf(" SCORE : %d\n",Udm_Get_Res_Field($res,$i,UDM_FIELD_SCORE));
|
|
printf("---------\n");
|
|
}
|
|
|
|
// Free result
|
|
Udm_Free_Res($res);
|
|
}
|
|
|
|
//Stage 5: free UdmSearch agent
|
|
|
|
Udm_Free_Agent($udm);
|
|
?>
|
|
|
|
</pre>
|
|
</body>
|
|
</html>
|