"Fossies" - the Fresh Open Source Software Archive

Member "3.2.11/src/init.inc" (17 Jul 2005, 17818 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) fasm source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "init.inc" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 if(isset($HTTP_GET_VARS)){
    4   while(list($var, $val)=each($HTTP_GET_VARS)){
    5     $$var=$val;
    6   }
    7 }
    8 if(isset($HTTP_POST_VARS)){
    9   while(list($var, $val)=each($HTTP_POST_VARS)){
   10     $$var=$val;
   11   }
   12 }
   13 if(isset($HTTP_COOKIE_VARS)){
   14   while(list($var, $val)=each($HTTP_COOKIE_VARS)){
   15     $$var=$val;
   16   }
   17 }
   18 if(isset($HTTP_SERVER_VARS)){
   19   while(list($var, $val)=each($HTTP_SERVER_VARS)){
   20     $$var=$val;
   21   }
   22 }
   23 
   24 $self=$PHP_SELF;
   25 
   26 if ($ps=="") $ps=20;
   27 if ($np=="") $np=0;
   28 if ($o=="") $o=0;
   29 if ($resultslimit<=0) $resultslimit=0;
   30 
   31 if ($excerptsize=="") $excerptsize=256;
   32 if ($excerptpadding=="") $excerptsize=40;
   33 
   34 if (($dt!='back') && ($dt!='er') && ($dt!='range')) $dt='';
   35 if ($dp=="") $dp=0;
   36 if (($dx!=0) && ($dx!=-1) && ($dx!=1)) $dx=0;
   37 if ($dy<1970) $dy=1970;
   38 if (($dm<0) || ($dm>11)) $dm=0;
   39 if (($dd<=0) || ($dd>31)) $dd="01";
   40 
   41 $db=urldecode($db);
   42 $de=urldecode($de);
   43 $type=urldecode($type);
   44 
   45 $url=urldecode($url);
   46 
   47 if ($db=="") $db='01/01/1970';
   48 if ($de=="") $de='31/12/2020';
   49 
   50 if ($hlbeg=="") $hlbeg='<b>';
   51 if ($hlend=="") $hlend='</b>';
   52 
   53 if ($storedocurl=="") $storedocurl='/cgi-bin/storedoc.cgi';
   54 
   55 if (isset($q)) {
   56     $q=urldecode($q);
   57         $have_query_flag=1;
   58 } else {
   59     $have_query_flag=0;
   60 }
   61 
   62 $query_orig=$q;
   63 
   64 if (isset($CHARSET_SAVED_QUERY_STRING)) {
   65     $q_local=urldecode($CHARSET_SAVED_QUERY_STRING);
   66     if (preg_match('/q=([^&]*)\&/',$q_local,$param)) {
   67         $q_local=urlencode($param[1]);
   68     } elseif (preg_match('/q=(.*)$/',$q_local,$param)) {
   69         $q_local=urlencode($param[1]);
   70     } else {
   71         $q_local=urlencode($q);
   72     }
   73     $q_string=$CHARSET_SAVED_QUERY_STRING;
   74 } else {
   75     $q_local=urlencode(Stripslashes($q));
   76     $q_string=$QUERY_STRING;
   77 }
   78 
   79 $db_local=urlencode($db);
   80 $de_local=urlencode($de);
   81 $type_local=urlencode($type);
   82 
   83 $url_local=urlencode($url);
   84 
   85 if (($MAX_NP > 0) && ($np>$MAX_NP)) $np=$MAX_NP;
   86 if (($MAX_PS > 0) && ($ps>$MAX_PS)) $ps=$MAX_PS;
   87 
   88 // -----------------------------------------------
   89 // init()
   90 // -----------------------------------------------
   91 function init(){
   92    global $q, $q_string, $query_orig, $have_query_flag, $have_spell_flag, $auto_wild;
   93    global $tag, $tag_arr, $cat, $cat_arr, $np, $ps, $lang, $lang_arr, $wm, $wf, $ul, $m;
   94    global $dt, $dp, $dx, $dm, $dd, $dy, $db, $de, $s, $resultslimit;
   95    global $trackquery, $localcharset, $browsercharset, $stopwordtable_arr, $stopwordfile_arr;
   96    global $minwordlength, $maxwordlength, $phrase, $cache;
   97    global $ispelluseprefixes, $crosswords, $ispellmode, $spell_host;
   98    global $affix_file, $spell_file, $vardir, $datadir, $sp, $sy;
   99    global $dbaddr,$dbmode,$udm_agent, $hlbeg, $hlend, $detectclones;
  100    global $phpver, $synonym_arr, $searchd_arr, $ul_arr;
  101    global $REMOTE_ADDR, $storedaddr, $type_arr, $type, $groupbysite, $site;
  102    global $excerptsize, $excerptpadding, $dateformat, $suggest;
  103    
  104    ParseQString();
  105 
  106    if (preg_match("/^(\d+)\.(\d+)\.(\d+)/",phpversion(),$param)) {
  107     $phpver=$param[1];
  108     if ($param[2] < 9) {
  109         $phpver .= "0$param[2]";
  110     } else {
  111         $phpver .= "$param[2]";
  112     }
  113         if ($param[3] < 9) {
  114         $phpver .= "0$param[3]";
  115     } else {
  116         $phpver .= "$param[3]";
  117     }
  118    } else {
  119     print "Cannot determine php version: <b>".phpversion()."</b>\n";
  120     exit;
  121    }
  122      
  123    $have_spell_flag=0;
  124 
  125    $stopwordtable_arr = array();
  126    $stopwordfile_arr  = array();
  127    $synonym_arr  = array();
  128    $searchd_arr  = array();
  129 
  130    read_template();
  131    
  132    if ($sp=='') $sp=0;
  133    if ($sy=='') $sy=0;
  134 
  135    if (Udm_Api_Version() >= 30211) {
  136     $udm_agent=Udm_Alloc_Agent_Array($dbaddr);
  137    } elseif (Udm_Api_Version() >= 30204) {
  138     $udm_agent=Udm_Alloc_Agent($dbaddr);    
  139    } else {
  140     $udm_agent=Udm_Alloc_Agent($dbaddr,$dbmode);    
  141    }
  142    
  143    Udm_Set_Agent_Param($udm_agent,UDM_PARAM_PAGE_SIZE,$ps);
  144    Udm_Set_Agent_Param($udm_agent,UDM_PARAM_PAGE_NUM,$np);
  145 
  146    $trackquery=strtolower($trackquery);
  147    if ($trackquery == 'yes') {
  148     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_TRACK_MODE,UDM_ENABLED);
  149    } else {
  150     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_TRACK_MODE,UDM_DISABLED);
  151    }
  152 
  153    $cache=strtolower($cache);
  154    if ($cache == 'yes') {
  155     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CACHE_MODE,UDM_ENABLED);
  156    } else {
  157     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CACHE_MODE,UDM_DISABLED);
  158    }
  159 
  160    $ispelluseprefixes=strtolower($ispelluseprefixes);
  161    if ($ispelluseprefixes == 'yes') {
  162     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_ISPELL_PREFIXES,UDM_ENABLED);
  163    } else {
  164     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_ISPELL_PREFIXES,UDM_DISABLED);
  165    }
  166 
  167    if (Udm_Api_Version() >= 30111) {
  168     $crosswords=strtolower($crosswords);
  169     if ($crosswords == 'yes') {
  170         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CROSS_WORDS,UDM_ENABLED);
  171     } else {
  172         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CROSS_WORDS,UDM_DISABLED);
  173     }
  174    }
  175 
  176    if ($localcharset != '') {
  177     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CHARSET,$localcharset);
  178     if (Udm_Api_Version() >= 30200) {
  179         if (!Udm_Check_Charset($udm_agent,$localcharset)) {
  180             print_template('top');
  181             flush();
  182                         print_error_local("Incorrect localcharset $localcharset");
  183         }
  184     }
  185    }
  186 
  187    if (Udm_Api_Version() >= 30200) {       
  188     if ($localcharset == '') Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CHARSET,'utf-8');
  189     if ($browsercharset != '') {
  190         if (!Udm_Check_Charset($udm_agent,$browsercharset)) {
  191             print_template('top');
  192             flush();
  193                         print_error_local("Incorrect browsercharset $browsercharset");
  194         }
  195         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_BROWSER_CHARSET,$browsercharset);
  196         Header ("Content-Type: text/html; charset=$browsercharset");
  197     } else {
  198         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_BROWSER_CHARSET,'utf-8');
  199         Header ("Content-Type: text/html; charset=utf-8");  
  200     }   
  201     if ($hlbeg == '') $hlbeg='<font color="000088"><b>';
  202         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_HLBEG,$hlbeg);
  203 
  204     if ($hlend == '') $hlend='</b></font>';
  205     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_HLEND,$hlend);     
  206    } else {
  207         $phrase=strtolower($phrase);
  208         if ($phrase == 'yes') {
  209         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_PHRASE_MODE,UDM_ENABLED);
  210         } else {
  211         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_PHRASE_MODE,UDM_DISABLED);
  212         }
  213       
  214     for ($i=0; $i < count($stopwordtable_arr); $i+=1) {
  215         if ($stopwordtable_arr[$i] != '') {
  216             Udm_Set_Agent_Param($udm_agent,UDM_PARAM_STOPTABLE,$stopwordtable_arr[$i]);
  217         }
  218     }
  219    }
  220 
  221    for ($i=0; $i < count($stopwordfile_arr); $i+=1) {
  222     if ($stopwordfile_arr[$i] != '') {
  223         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_STOPFILE,$stopwordfile_arr[$i]);
  224     }   
  225    }   
  226 
  227    if (Udm_Api_Version() >= 30203) {    
  228     if ($sy) {
  229             for ($i=0; $i < count($synonym_arr); $i+=1) {
  230         if ($synonym_arr[$i] != '') {
  231             Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SYNONYM,$synonym_arr[$i]);
  232         }
  233         }
  234     }
  235 
  236     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_QSTRING,$q_string);
  237         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_REMOTE_ADDR,$REMOTE_ADDR);
  238    }
  239    
  240    if (Udm_Api_Version() >= 30204) {    
  241     if ($have_query_flag) Udm_Set_Agent_Param($udm_agent,UDM_PARAM_QUERY,$query_orig);
  242     if ($storedaddr != '') Udm_Set_Agent_Param($udm_agent,UDM_PARAM_STORED,$storedaddr);
  243    }
  244 
  245    if (Udm_Api_Version() >= 30207) {
  246     $groupbysite=strtolower($groupbysite);
  247     if ($groupbysite == 'yes') {
  248         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_GROUPBYSITE,UDM_ENABLED);
  249     } else {
  250         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_GROUPBYSITE,UDM_DISABLED);
  251     }
  252     if ($site) Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SITEID,$site);
  253     $detectclones=strtolower($detectclones);
  254     if ($detectclones == 'yes') {
  255         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_DETECT_CLONES,UDM_ENABLED);
  256     } else {
  257         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_DETECT_CLONES,UDM_DISABLED);
  258     }
  259    }
  260    
  261    if  ($m=='any') {
  262     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_ANY);
  263    } elseif ($m=='all') {
  264     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_ALL);
  265    } elseif ($m=='bool') {
  266     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_BOOL);
  267    } elseif ($m=='phrase') {
  268     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_PHRASE);
  269    } else {
  270     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_SEARCH_MODE,UDM_MODE_ALL);
  271    }
  272 
  273    if  ($wm=='wrd') {
  274     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_WORD);
  275    } elseif ($wm=='beg') {
  276     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_BEGIN);
  277    } elseif ($wm=='end') {
  278     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_END);
  279    } elseif ($wm=='sub') {
  280     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_SUBSTR);
  281    } else {
  282     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WORD_MATCH,UDM_MATCH_WORD);
  283    }
  284 
  285    if ($minwordlength > 0) {
  286     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_MIN_WORD_LEN,$minwordlength);
  287    } else {
  288     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_MIN_WORD_LEN,1);
  289    }
  290 
  291    if ($maxwordlength > 0) {
  292     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_MAX_WORD_LEN,$maxwordlength);  
  293    } else {
  294     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_MAX_WORD_LEN,32);  
  295    }
  296    
  297    if ($phpver >= 40007) {
  298     if ($vardir != '') Udm_Set_Agent_Param($udm_agent,UDM_PARAM_VARDIR,$vardir);
  299     if ($datadir != '') Udm_Set_Agent_Param($udm_agent,UDM_PARAM_VARDIR,$datadir);
  300    }
  301 
  302    if ($wf != '') {
  303     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_WEIGHT_FACTOR,$wf);
  304    }
  305 
  306    for($i=0; $i<count($ul_arr); $i+=1) {
  307     $temp_ul=$ul_arr[$i];
  308     if ($temp_ul != '') {
  309         $auto_wild=strtolower($auto_wild);   
  310         if (($auto_wild == 'yes') || 
  311         ($auto_wild == '')) {
  312             if ((substr($temp_ul,0,7) == 'http://') ||
  313             (substr($temp_ul,0,8) == 'https://') ||
  314             (substr($temp_ul,0,7) == 'news://') ||
  315             (substr($temp_ul,0,6) == 'ftp://')) {
  316                     Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_URL,"$temp_ul%");
  317             } else {
  318                 Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_URL,"%$temp_ul%");
  319             }
  320         } else {
  321             Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_URL,$temp_ul);
  322         }
  323     }
  324    }
  325 
  326    for($i=0; $i<count($tag_arr); $i+=1) {
  327     $temp_tag=$tag_arr[$i];
  328     if ($temp_tag != '') Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_TAG,$temp_tag);
  329    }
  330 
  331    if (Udm_Api_Version() >= 30207) {    
  332     for($i=0; $i<count($type_arr); $i+=1) {
  333         $temp_type=$type_arr[$i];
  334         if ($temp_type != '') Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_TYPE,$temp_type);
  335         }
  336    }
  337 
  338 
  339    for($i=0; $i<count($cat_arr); $i+=1) {
  340     $temp_cat=$cat_arr[$i];
  341     if ($temp_cat != '') Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_CAT,$temp_cat);
  342    }
  343 
  344    for($i=0; $i<count($lang_arr); $i+=1) {
  345     $temp_lang=$lang_arr[$i];
  346     if ($temp_lang != '') Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_LANG,$temp_lang);
  347    }
  348 
  349    if (function_exists('Udm_Set_Agent_Param_Ex')) {
  350     if ($excerptsize>0) Udm_Set_Agent_Param_Ex($udm_agent,'ExcerptSize',$excerptsize);
  351     if ($excerptpadding>0) Udm_Set_Agent_Param_Ex($udm_agent,'ExcerptPadding',$excerptpadding);
  352     if ($dateformat!='') Udm_Set_Agent_Param_Ex($udm_agent,'DateFormat',$dateformat);
  353     
  354     if (Udm_Api_Version() >= 30215) {      
  355         if ($s!='') Udm_Set_Agent_Param_Ex($udm_agent,'s',$s);
  356         if ($resultslimit>0) Udm_Set_Agent_Param_Ex($udm_agent,'resultslimit',$resultslimit);
  357     }
  358 
  359     if (($dt == 'back') || 
  360         ($dt == 'er') || 
  361         ($dt == 'range')) {
  362         Udm_Set_Agent_Param_Ex($udm_agent,'dt',$dt);
  363         Udm_Set_Agent_Param_Ex($udm_agent,'dx',$dx);
  364         Udm_Set_Agent_Param_Ex($udm_agent,'dm',$dm);
  365         Udm_Set_Agent_Param_Ex($udm_agent,'dy',$dy);
  366         Udm_Set_Agent_Param_Ex($udm_agent,'dd',$dd);
  367         Udm_Set_Agent_Param_Ex($udm_agent,'dp',$dp);
  368         Udm_Set_Agent_Param_Ex($udm_agent,'db',$db);
  369         Udm_Set_Agent_Param_Ex($udm_agent,'de',$de);
  370     }
  371     
  372     $suggest=strtolower($suggest);
  373     if ($suggest=='yes') Udm_Set_Agent_Param_Ex($udm_agent,'suggest','yes');
  374    }
  375 
  376    if (($dt == 'back') && ($dp != '0')) {
  377         $recent_time=format_dp($dp);
  378         if ($recent_time != 0) {
  379             $dl=time()-$recent_time;
  380                         Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,">$dl");
  381         }
  382    } elseif ($dt=='er') {
  383         $recent_time=mktime(0,0,0,($dm+1),$dd,$dy);
  384         if ($dx == -1) {
  385                         Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,"<$recent_time");
  386         } elseif ($dx == 1) {
  387                         Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,">$recent_time");
  388         }
  389    } elseif ($dt=='range') {
  390         $begin_time=format_userdate($db);
  391         if ($begin_time) Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,">$begin_time");
  392 
  393                 $end_time=format_userdate($de);
  394         if ($end_time) Udm_Add_Search_Limit($udm_agent,UDM_LIMIT_DATE,"<$end_time");
  395    }
  396 
  397    print_template('top');
  398    flush();
  399    
  400    $ispellmode=strtolower($ispellmode);
  401    if ($ispellmode == 'db') {
  402     if (! Udm_Load_Ispell_Data($udm_agent,UDM_ISPELL_TYPE_DB,'','',1)) {
  403         print_error_local(Udm_Error($udm_agent));
  404     } else $have_spell_flag=1;
  405    } elseif ($ispellmode == 'server') {
  406     if (Udm_Api_Version() >= 30112) {
  407         if (! Udm_Load_Ispell_Data($udm_agent,UDM_ISPELL_TYPE_SERVER,$spell_host,'',1)) {
  408             print_error_local("Error loading ispell data from server $spell_host");
  409         } else $have_spell_flag=1;
  410     }
  411    } elseif (($ispellmode == 'text') && ($sp)) {
  412     reset($affix_file);
  413         while (list($t_lang,$file)=each($affix_file)) {
  414             if (Udm_Api_Version() < 30200) {       
  415                 if (! Udm_Load_Ispell_Data($udm_agent,UDM_ISPELL_TYPE_AFFIX,$t_lang,$file,0)) {
  416                     print_error_local("Error loading ispell data from file");
  417                 } else $have_spell_flag=1;
  418 
  419                 $temp=$spell_file[$t_lang];
  420                 for ($i=0; $i<count($temp); $i+=1) {
  421                     if (! Udm_Load_Ispell_Data($udm_agent,UDM_ISPELL_TYPE_SPELL,$t_lang,$temp[$i],1)) {
  422                         print_error_local("Error loading ispell data from file");
  423                     } else $have_spell_flag=1;
  424                 } 
  425             } else {
  426                 if (preg_match("/(.+)\;(.+)/",$file,$param)) {
  427                     $t_charset=trim($param[1]);
  428                     $t_file=trim($param[2]);
  429                     if (! Udm_Load_Ispell_Data($udm_agent,UDM_ISPELL_TYPE_AFFIX,$t_lang,$t_charset,$t_file,0)) {
  430                         print_error_local("Error loading ispell data from file");
  431                     } else $have_spell_flag=1;
  432                 }
  433 
  434                 $temp=$spell_file[$t_lang];
  435                 for ($i=0; $i<count($temp); $i+=1) {
  436                     if (preg_match("/(.+)\;(.+)/",$temp[$i],$param)) {
  437                         $t_charset=trim($param[1]);
  438                         $t_file=trim($param[2]);
  439                         if (! Udm_Load_Ispell_Data($udm_agent,UDM_ISPELL_TYPE_SPELL,$t_lang,$t_charset,$t_file,1)) {
  440                             print_error_local("Error loading ispell data from file");
  441                         } else $have_spell_flag=1;
  442                     } 
  443                 } 
  444             }
  445         }
  446    }
  447    
  448    if (Udm_Api_Version() >= 30215) {
  449     Udm_Parse_Query_String($udm_agent,$q_string);
  450    }
  451 }
  452 
  453 // -----------------------------------------------
  454 // init_cc()
  455 // -----------------------------------------------
  456 function init_cc(){
  457    global $q, $q_string, $query_orig, $have_query_flag, $have_spell_flag, $auto_wild;
  458    global $tag, $tag_arr, $cat, $cat_arr, $np, $ps, $lang, $lang_arr, $wm, $wf, $ul, $m;
  459    global $dt, $dp, $dx, $dm, $dd, $dy, $db, $de, $s, $resultslimit;
  460    global $trackquery, $localcharset, $browsercharset, $stopwordtable_arr, $stopwordfile_arr;
  461    global $minwordlength, $maxwordlength, $phrase, $cache;
  462    global $ispelluseprefixes, $crosswords, $ispellmode, $spell_host;
  463    global $affix_file, $spell_file, $vardir, $datadir, $sp, $sy;
  464    global $dbaddr,$dbmode,$udm_agent, $hlbeg, $hlend, $detectclones;
  465    global $phpver, $synonym_arr, $searchd_arr, $ul_arr;
  466    global $REMOTE_ADDR, $storedaddr, $type_arr, $type, $groupbysite, $site;
  467    global $excerptsize, $excerptpadding, $dateformat, $suggest;
  468    
  469    ParseQString();
  470 
  471    read_template();
  472    
  473    if (Udm_Api_Version() >= 30211) {
  474     $udm_agent=Udm_Alloc_Agent_Array($dbaddr);
  475    } elseif (Udm_Api_Version() >= 30204) {
  476     $udm_agent=Udm_Alloc_Agent($dbaddr);    
  477    } else {
  478     $udm_agent=Udm_Alloc_Agent($dbaddr,$dbmode);    
  479    }
  480    
  481    if ($localcharset != '') {
  482     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CHARSET,$localcharset);
  483     if (Udm_Api_Version() >= 30200) {
  484         if (!Udm_Check_Charset($udm_agent,$localcharset)) {
  485             print_template('top');
  486             flush();
  487                         print_error_local("Incorrect localcharset $localcharset");
  488         }
  489     }
  490    }
  491 
  492    if (Udm_Api_Version() >= 30200) {       
  493     if ($localcharset == '') Udm_Set_Agent_Param($udm_agent,UDM_PARAM_CHARSET,'utf-8');
  494     if ($browsercharset != '') {
  495         if (!Udm_Check_Charset($udm_agent,$browsercharset)) {
  496             print_template('top');
  497             flush();
  498                         print_error_local("Incorrect browsercharset $browsercharset");
  499         }
  500         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_BROWSER_CHARSET,$browsercharset);
  501         Header ("Content-Type: text/html; charset=$browsercharset");
  502     } else {
  503         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_BROWSER_CHARSET,'utf-8');
  504         Header ("Content-Type: text/html; charset=utf-8");  
  505     }   
  506     if ($hlbeg == '') $hlbeg='<font color="000088"><b>';
  507         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_HLBEG,$hlbeg);
  508 
  509     if ($hlend == '') $hlend='</b></font>';
  510     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_HLEND,$hlend);     
  511    } 
  512 
  513    if (Udm_Api_Version() >= 30203) {    
  514     Udm_Set_Agent_Param($udm_agent,UDM_PARAM_QSTRING,$q_string);
  515         Udm_Set_Agent_Param($udm_agent,UDM_PARAM_REMOTE_ADDR,$REMOTE_ADDR);
  516    }
  517    
  518    if (Udm_Api_Version() >= 30204) {    
  519     if ($have_query_flag) Udm_Set_Agent_Param($udm_agent,UDM_PARAM_QUERY,$query_orig);
  520    }
  521 
  522    if (function_exists('Udm_Set_Agent_Param_Ex')) {
  523     if ($dateformat!='') Udm_Set_Agent_Param_Ex($udm_agent,'DateFormat',$dateformat);
  524    }
  525    
  526    if (Udm_Api_Version() >= 30215) {
  527     Udm_Parse_Query_String($udm_agent,$q_string);
  528    }
  529 }
  530 
  531 ?>