"Fossies" - the Fresh Open Source Software Archive

Member "3.2.11/src/search.php" (17 Jul 2005, 8207 Bytes) of package /linux/www/old/mnogosearch-php-3.2.11.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "search.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 /*   mnoGoSearch-php v.3.2.10
    4  *   for mnoGoSearch ( formely known as UdmSearch ) free web search engine
    5  *   (C) 2001 by Sergey Kartashoff <gluke@mail.ru>,
    6  *               mnoGoSearch Developers Team <devel@mnogosearch.org>
    7  */
    8 
    9 if (!extension_loaded('mnogosearch')) {
   10     print "<b>This script requires PHP4.3.0+ with mnoGoSearch extension</b>";
   11     exit;
   12 }
   13 
   14 define("UDM_ENABLED",1);
   15 define("UDM_DISABLED",0);
   16 
   17 require('config.inc');
   18 require('common.inc');
   19 require('template.inc');
   20 
   21 require('init.inc');
   22 
   23 if ($lang_content_negotiation == 'yes') {
   24 // path to template file ($lang_content_negotiation = 'yes')
   25 // please refer to docs on this feature before using it.
   26     $template_file= preg_replace("/\.php\.*/", ".htm", basename($SCRIPT_FILENAME));
   27     $template_file = "./" . $template_file;
   28 } else {
   29 // path to template file ($lang_content_negotiation = 'no')
   30     $template_file='search.htm';
   31 }
   32 
   33 // -----------------------------------------------
   34 //  M A I N 
   35 // -----------------------------------------------
   36 
   37 
   38 if (!$cc) {
   39     init();
   40 
   41     if (! $have_query_flag) {
   42     print_template('bottom');
   43         return; 
   44     } elseif ($have_query_flag && ($q=='')) {
   45         print_template('noquery');  
   46         print_template('bottom');
   47         return;
   48     }         
   49 
   50     $res=Udm_Find($udm_agent,$q);
   51 
   52     if(!$res){
   53             print_error_local(Udm_Error($udm_agent));   
   54     } else {    
   55         $found=Udm_Get_Res_Param($res,UDM_PARAM_FOUND);
   56         $rows=Udm_Get_Res_Param($res,UDM_PARAM_NUM_ROWS);
   57     
   58     if (Udm_Api_Version() >= 30231) {
   59             $wordinfo=Udm_Get_Agent_Param_Ex($udm_agent,'W');
   60     } else {
   61         $wordinfo=Udm_Get_Res_Param($res,UDM_PARAM_WORDINFO_ALL);
   62     }
   63     
   64     $searchtime=Udm_Get_Res_Param($res,UDM_PARAM_SEARCHTIME);
   65     $first_doc=Udm_Get_Res_Param($res,UDM_PARAM_FIRST_DOC);
   66     $last_doc=Udm_Get_Res_Param($res,UDM_PARAM_LAST_DOC);
   67 
   68         if (!$found) {
   69         $ws='';
   70         if ((Udm_Api_Version() >= 30233) && ($suggest=='yes')) {
   71             $ws=Udm_Get_Agent_Param_Ex($udm_agent,'WS');
   72         }
   73 
   74             print_template('notfound');
   75             print_template('bottom');
   76             return;
   77     } 
   78 
   79         $from=IntVal($np)*IntVal($ps); 
   80     $to=IntVal($np+1)*IntVal($ps); 
   81 
   82     if($to>$found) $to=$found;
   83     if (($from+$ps)<$found) $isnext=1;
   84     $nav=make_nav($query_orig);
   85 
   86         print_template('restop');
   87 
   88     $global_doc_res=$res;
   89 
   90         for($i=0;$i<$rows;$i+=1){
   91             $excerpt_flag=0;
   92             $clonestr='';
   93 
   94             $rec_id=Udm_Get_Res_Field($res,$i,UDM_FIELD_URLID);
   95         
   96         $global_res_position=$i;
   97 
   98             if (Udm_Api_Version() >= 30207) {
   99             $origin_id=Udm_Get_Res_Field($res,$i,UDM_FIELD_ORIGINID);
  100             if ($origin_id) continue;
  101             else {
  102                 for($j=0;$j<$rows;$j+=1){
  103                     $cl_origin_id=Udm_Get_Res_Field($res,$j,UDM_FIELD_ORIGINID);
  104                     if (($cl_origin_id) &&
  105                         ($cl_origin_id == $rec_id)) {
  106                         $url=Udm_Get_Res_Field($res,$j,UDM_FIELD_URL);
  107                                 $contype=Udm_Get_Res_Field($res,$j,UDM_FIELD_CONTENT);
  108                         $docsize=Udm_Get_Res_Field($res,$j,UDM_FIELD_SIZE);
  109                         $lastmod=format_lastmod(Udm_Get_Res_Field($res,$j,UDM_FIELD_MODIFIED));
  110                         if (Udm_Api_Version() >= 30207) {
  111                             $pop_rank=Udm_Get_Res_Field($res,$i,UDM_FIELD_POP_RANK);
  112                         } else $pop_rank='';
  113                         $clonestr.=print_template('clone',0)."\n";
  114                     }
  115                 }
  116             }
  117         } 
  118         
  119             if (Udm_Api_Version() >= 30204) {
  120                 $excerpt_flag=Udm_Make_Excerpt($udm_agent, $res, $i);
  121             }
  122 
  123         $ndoc=Udm_Get_Res_Field($res,$i,UDM_FIELD_ORDER);
  124         $rating=Udm_Get_Res_Field($res,$i,UDM_FIELD_RATING);
  125                 $url=Udm_Get_Res_Field($res,$i,UDM_FIELD_URL);
  126                 $contype=Udm_Get_Res_Field($res,$i,UDM_FIELD_CONTENT);
  127         $docsize=Udm_Get_Res_Field($res,$i,UDM_FIELD_SIZE);
  128         $lastmod=format_lastmod(Udm_Get_Res_Field($res,$i,UDM_FIELD_MODIFIED));
  129 
  130             $title=Udm_Get_Res_Field($res,$i,UDM_FIELD_TITLE);   
  131         $title=($title) ? htmlspecialChars($title):basename($url);
  132 
  133         $title=ParseDocText($title);
  134         $text=ParseDocText(htmlspecialChars(Udm_Get_Res_Field($res,$i,UDM_FIELD_TEXT)));
  135         //$text=ParseDocText(htmlspecialChars(Udm_Get_Res_Field_ex($res,$i,"Body")));
  136                 $keyw=ParseDocText(htmlspecialChars(Udm_Get_Res_Field($res,$i,UDM_FIELD_KEYWORDS)));
  137         $desc=ParseDocText(htmlspecialChars(Udm_Get_Res_Field($res,$i,UDM_FIELD_DESC)));
  138         
  139         $crc=Udm_Get_Res_Field($res,$i,UDM_FIELD_CRC);          
  140         
  141         if (Udm_Api_Version() >= 30203) {
  142             $doclang=Udm_Get_Res_Field($res,$i,UDM_FIELD_LANG);
  143             $doccharset=Udm_Get_Res_Field($res,$i,UDM_FIELD_CHARSET);
  144         }
  145 
  146         if ($phpver >= 40006) {
  147             $category=Udm_Get_Res_Field($res,$i,UDM_FIELD_CATEGORY);
  148         } else {
  149             $category='';
  150         }
  151 
  152         reset($alias_arr);
  153         $save_url=$url;
  154         while(list($t_alias,$t_url)=each($alias_arr)) {
  155             $url=str_replace($t_alias,$t_url,$url);
  156         }
  157 
  158         if (Udm_Api_Version() <= 30223) {
  159             if (Udm_Api_Version() >= 30204) {
  160             if ($excerpt_flag) {
  161                 if (Udm_Api_Version() >= 30216) {
  162                     if (Udm_Get_Res_Field_Ex($res,$i,"CachedCopy")!='') {
  163                     $stored_href="$self?cc=1".
  164                              "&url=".urlencode($save_url).
  165                              "&q=".urlencode($query_orig);
  166                     }
  167                 } elseif (Udm_Api_Version() >= 30211) {
  168                     $stored_href="$storedocurl?rec_id=".Udm_Hash32($udm_agent,$save_url).
  169                                  "&DM=".urlencode($lastmod).
  170                              "&DS=$docsize".
  171                              "&L=$doclang".
  172                              "&CS=$doccharset".
  173                              "&DU=".urlencode($save_url).
  174                              "&CT=".urlencode($contype).
  175                              "&q=".urlencode($query_orig);
  176                 } else {
  177                     $stored_href="$storedocurl?rec_id=".Udm_CRC32($udm_agent,$save_url).
  178                                  "&DM=".urlencode($lastmod).
  179                              "&DS=$docsize".
  180                              "&L=$doclang".
  181                              "&CS=$doccharset".
  182                              "&DU=".urlencode($save_url).
  183                              "&CT=".urlencode($contype).
  184                              "&q=".urlencode($query_orig);
  185                     }
  186                 if ($stored_href!='') $storedstr=print_template('stored',0);
  187             } else $storedstr='';
  188             } else $storedstr='';
  189         } else {
  190             if (Udm_Get_Res_Field_Ex($res,$i,"CachedCopy")!='') {
  191             if (Udm_Get_Res_Field_Ex($res,$i,"dbnum")=='') {
  192                 $stored_href="$self?cc=1".
  193                          "&url=".urlencode($save_url).
  194                          "&q=".urlencode($query_orig);
  195             } else {
  196                 $stored_href="$self?cc=1".
  197                          "&dbnum=".Udm_Get_Res_Field_Ex($res,$i,"dbnum").
  198                          "&url=".urlencode($save_url).
  199                          "&q=".urlencode($query_orig);
  200             }
  201             $storedstr=print_template('stored',0);
  202             }
  203         }
  204 
  205         $sitelimitstr=$persite='';
  206         if ((Udm_Api_Version() >= 30207) &&
  207             ($groupbysite == 'yes')) {
  208             if (!$site) {
  209             $sitelimit_href="$PHP_SELF?$QUERY_STRING"; 
  210             $sitelimit_href=preg_replace("/\&np=\d*/",'',$sitelimit_href);
  211             $sitelimit_href.="&np=0&site=".Udm_Get_Res_Field($res,$i,UDM_FIELD_SITEID);
  212             $persite=Udm_Get_Res_Field_Ex($res,$i,"PerSite");
  213             $sitelimitstr=print_template('site_limit',0);
  214             }
  215         }
  216         
  217 
  218         if (Udm_Api_Version() >= 30207) {
  219             $pop_rank=Udm_Get_Res_Field($res,$i,UDM_FIELD_POP_RANK);
  220         } else $pop_rank='';
  221 
  222         
  223         if ((substr($url,0,6)=="ftp://") && 
  224                     ($templates['ftpres'][0] != '')) {
  225             print_template('ftpres');
  226         } elseif (((substr($url,0,7)=="http://")||(substr($url,0,8)=="https://")) && 
  227                     ($templates['httpres'][0] != '')) {
  228             print_template('httpres');
  229         } else {
  230             print_template('res');
  231         }
  232     }   
  233     $global_doc_res='';
  234     
  235         print_template('resbot');    
  236     print_template('bottom');
  237 
  238         // Free result
  239     Udm_Free_Res($res);
  240     }
  241 } else {
  242     /* show cached copy */
  243     init_cc();
  244     $res=udm_store_doc_cgi($udm_agent);
  245     
  246     $id=udm_get_agent_param_ex($udm_agent,'ID');
  247     $last_modified=udm_get_agent_param_ex($udm_agent,'Last-Modified');
  248     $content=udm_get_agent_param_ex($udm_agent,'Content-Type');
  249     $length=udm_get_agent_param_ex($udm_agent,'Content-Length');
  250     $charset=udm_get_agent_param_ex($udm_agent,'Charset');
  251     
  252     Header ("Content-Type: text/html; charset=$charset");
  253     
  254     print_template('storedoc_top');
  255     
  256     if ($res) {
  257     $document=ParseDocText(udm_get_agent_param_ex($udm_agent,'document'));
  258     print_template('storedoc');
  259     }
  260     
  261     print_template('storedoc_bottom');
  262 }
  263 
  264     Udm_Free_Agent($udm_agent);
  265 ?>