"Fossies" - the Fresh Open Source Software Archive

Member "3.2.11/src/template.inc" (17 Jul 2005, 22457 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 "template.inc" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 $templates=array();
    4 
    5 // -----------------------------------------------
    6 // load_file()
    7 // -----------------------------------------------
    8 function load_file($file){
    9     if (!($fp=fopen($file, 'r'))){
   10     echo "Can't open template file $template_file";
   11     exit_local(1);
   12     } 
   13     
   14     while(!feof($fp)) {
   15     $str.=fgets($fp, 1024);
   16     }
   17     
   18     fclose($fp);
   19 
   20     return $str;
   21 }
   22 
   23 // -----------------------------------------------
   24 // read_template()
   25 // -----------------------------------------------
   26 function read_template(){
   27     global $Randoms;
   28     global $template_file;
   29     global $templates,$dbaddr;
   30     global $ps, $np, $ul, $ul_arr, $o, $tag, $tag_arr, $m, $cat, $cat_arr, $wm, $wf;
   31     global $dt, $dp, $dx, $dm, $dy, $dd, $db, $de;
   32     global $clones,$lang,$lang_arr, $sp, $sy, $s, $resultslimit;
   33     global $affix_file, $spell_file, $spell_host;
   34     global $stopwordtable_arr, $stopwordfile_arr;
   35     global $synonym_arr, $searchd_arr;
   36     global $alias_arr,$type, $type_arr;
   37     
   38     $affix_file=array();
   39     $spell_file=array();
   40     $alias_arr=array();
   41 
   42     if (Udm_Api_Version() >= 30211) {
   43     $dbaddr=array();
   44     } else {
   45     $dbaddr='';
   46     }
   47 
   48     $names=array('top', 'bottom', 'restop', 'resbot', 'navigator',
   49          'res', 'ftpres', 'httpres', 'notfound', 'error', 'variables', 'clone',
   50                  'navleft_nop', 'navright_nop',
   51          'navleft', 'navbar1', 'navbar0', 'navright', 'noquery', 'site_limit',
   52          'storedoc_top','storedoc_bottom','storedoc','stored');
   53 
   54     $where='';
   55     
   56     if (!($fp=fopen($template_file, 'r'))){
   57     echo "Can't open template file $template_file";
   58     exit_local(1);
   59     } do {
   60     $str=fgets($fp, 1024);
   61 
   62         if (preg_match('/value="(.*)"[\s\t]+selected="\$ps"/i',$str,$param)) {
   63             if (($param[1]) == $ps) {
   64                 $str=preg_replace('/selected="\$ps"/i',"selected",$str);
   65             } else {
   66                 $str=preg_replace('/selected="\$ps"/i',"",$str);
   67             }
   68     } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$ul"/i',$str,$param)) {
   69         $found_param=0;
   70         for($i=0; $i<count($ul_arr); $i++) {
   71             $temp_ul=$ul_arr[$i];
   72                 if (($param[1]) == $temp_ul) {
   73                     $str=preg_replace('/selected="\$ul"/i',"selected",$str);
   74                     $found_param=1;
   75                     break;
   76                 }
   77             } 
   78             if (!$found_param) $str=preg_replace('/selected="\$ul"/i',"",$str);
   79     } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$type"/i',$str,$param)) {
   80         $found_param=0;
   81         for($i=0; $i<count($type_arr); $i++) {
   82             $temp_type=$type_arr[$i];
   83                 if (($param[1]) == $temp_type) {
   84                     $str=preg_replace('/selected="\$type"/i',"selected",$str);
   85                     $found_param=1;
   86                     break;
   87                 }
   88             } 
   89             if (!$found_param) $str=preg_replace('/selected="\$type"/i',"",$str);
   90         } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$lang"/i',$str,$param)) {
   91         $found_param=0;
   92         for($i=0; $i<count($lang_arr); $i++) {
   93             $temp_lang=$lang_arr[$i];
   94                 if (($param[1]) == $temp_lang) {
   95                     $str=preg_replace('/selected="\$lang"/i',"selected",$str);
   96                     $found_param=1;
   97                     break;
   98                 }
   99             } 
  100             if (!$found_param) $str=preg_replace('/selected="\$lang"/i',"",$str);
  101     } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$o"/i',$str,$param)) {
  102             if (($param[1]) == $o) {
  103                 $str=preg_replace('/selected="\$o"/i',"selected",$str);
  104             } else {
  105                 $str=preg_replace('/selected="\$o"/i',"",$str);
  106             }
  107     } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$m"/i',$str,$param)) {
  108             if (($param[1]) == $m) {
  109                 $str=preg_replace('/selected="\$m"/i',"selected",$str);
  110             } else {
  111                 $str=preg_replace('/selected="\$m"/i',"",$str);
  112             }
  113         } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$wm"/i',$str,$param)) {
  114             if (($param[1]) == $wm) {
  115                 $str=preg_replace('/selected="\$wm"/i',"selected",$str);
  116             } else {
  117                 $str=preg_replace('/selected="\$wm"/i',"",$str);
  118             }
  119         } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$s"/i',$str,$param)) {
  120             if ($param[1] == $s) {
  121                 $str=preg_replace('/selected="\$s"/i',"selected",$str);
  122             } else {
  123                 $str=preg_replace('/selected="\$s"/i',"",$str);
  124             }
  125         } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$sp"/i',$str,$param)) {
  126             if ($param[1] == $sp) {
  127                 $str=preg_replace('/selected="\$sp"/i',"selected",$str);
  128             } else {
  129                 $str=preg_replace('/selected="\$sp"/i',"",$str);
  130             }
  131         } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$sy"/i',$str,$param)) {
  132             if ($param[1] == $sy) {
  133                 $str=preg_replace('/selected="\$sy"/i',"selected",$str);
  134             } else {
  135                 $str=preg_replace('/selected="\$sy"/i',"",$str);
  136             }
  137         } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$wf"/i',$str,$param)) {
  138             if (($param[1]) == $wf) {
  139                 $str=preg_replace('/selected="\$wf"/i',"selected",$str);
  140             } else {
  141                 $str=preg_replace('/selected="\$wf"/i',"",$str);
  142             }
  143     } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$tag"/i',$str,$param)) {
  144             $found_param=0;
  145         for($i=0; $i<count($tag_arr); $i++) {
  146             $temp_tag=$tag_arr[$i];
  147                 if (($param[1]) == $temp_tag) {
  148                     $str=preg_replace('/selected="\$tag"/i',"selected",$str);
  149                     $found_param=1;
  150                     break;
  151                 }
  152             } 
  153             if (!$found_param) $str=preg_replace('/selected="\$tag"/i',"",$str);
  154     } elseif (preg_match('/type=radio[\s\t]+name="dt"[\s\t]+value="(.*)"/i',$str,$param)) {
  155             if (($param[1]) == $dt) {
  156                 $str=preg_replace("/value=\"$dt\"/i","value=\"$dt\" checked",$str);
  157             } else {                                
  158                 $str=preg_replace('/checked/i',"",$str);
  159             }
  160     } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$dp"/i',$str,$param)) {
  161             if (($param[1]) == $dp) {
  162                 $str=preg_replace('/selected="\$dp"/i',"selected",$str);
  163             } else {                                
  164                 $str=preg_replace('/selected="\$dp"/i',"",$str);
  165             }
  166     } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$dx"/i',$str,$param)) {
  167             if (($param[1]) == $dx) {
  168                 $str=preg_replace('/selected="\$dx"/i',"selected",$str);
  169             } else {                                
  170                 $str=preg_replace('/selected="\$dx"/i',"",$str);
  171             }
  172     } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$dm"/i',$str,$param)) {
  173             if (($param[1]) == $dm) {
  174                 $str=preg_replace('/selected="\$dm"/i',"selected",$str);
  175             } else {                                
  176                 $str=preg_replace('/selected="\$dm"/i',"",$str);
  177             }
  178     } elseif (preg_match('/value="(.*)"[\s\t]+selected="\$dy"/i',$str,$param)) {
  179             if (($param[1]) == $dy) {
  180                 $str=preg_replace('/selected="\$dy"/i',"selected",$str);
  181             } else {                                
  182                 $str=preg_replace('/selected="\$dy"/i',"",$str);
  183             }
  184     }
  185     
  186     if (preg_match('/\$g\((\d*)\)/i',$str,$param)) {                
  187         $str=str_replace("\$g($param[1])",substr($tag,0,strlen($tag)-$param[1]),$str);
  188     }
  189     
  190         $str=str_replace("\$dd",$dd,$str);
  191         $str=str_replace("\$dy",$dy,$str);
  192         $str=str_replace("\$dm",$dm,$str);
  193         $str=str_replace("\$db",$db,$str);
  194         $str=str_replace("\$de",$de,$str);
  195 
  196         $str=str_replace("\$ps",$ps,$str);
  197     $str=str_replace("\$pn",$ps*$np,$str);
  198         $str=str_replace("\$cat",$cat,$str);
  199 
  200         if (preg_match('/\$IF\s?\((.+)\)/i',$str,$param)) {
  201         $param[1]=trim($param[1]);
  202         $str=preg_replace('/\$IF\s?\((.+)\)/i',load_file($param[1]),$str);      
  203         }
  204 
  205     $comment_flag=0;
  206     
  207     if (substr($str, 0, 4) == "<!--") {
  208         reset($names);
  209         while ($name=current($names)){
  210             if (strstr($str, "<!--$name")){
  211             $where=$name;
  212 
  213             $templates["$where"][] = '';
  214             
  215             $comment_flag=1;
  216             break;
  217             } elseif (strstr($str, "/$name-->")) {
  218             $where='';
  219             $comment_flag=1;
  220             break;
  221             }
  222             next($names);
  223         }
  224     }
  225     
  226     if ($comment_flag) continue;
  227 
  228     if ($where=='variables') {
  229         if (ereg("^#",$str)) continue;
  230 
  231         if (preg_match("/^([^\s\t]+)[\s\t]+(.+)/",$str,$param)) {
  232                 $var=$param[1];
  233             $value=$param[2];
  234             $var=strtolower($var);
  235 
  236             $var=trim($var);
  237             $value=trim($value);                 
  238 
  239             if ($var=='affix') {
  240                if ($sp=='') $sp=1;
  241                $GLOBALS["ispellmode"]="text";
  242                if (Udm_Api_Version() < 30200) {                 
  243                     if (preg_match("/([^\s\t]+)[\s\t]+(.+)/",$value,$param)) {
  244                         $t_lang=trim($param[1]);
  245                         $file=trim($param[2]);
  246 
  247                         $affix_file[$t_lang]=$file;
  248                     } else {
  249                         print "Unsupported Affix command: Affix $value\n<br>";
  250                         exit;
  251                     }
  252                } else {
  253                     if (preg_match("/([^\s\t]+)[\s\t]+([^\s\t]+)[\s\t]+(.+)/",$value,$param)) {
  254                         $t_lang=trim($param[1]);
  255                                         $t_charset=trim($param[2]);
  256                         $file=trim($param[3]);
  257 
  258                         $affix_file[$t_lang]="$t_charset;$file";
  259                     } else {
  260                         print "Unsupported Affix command: Affix $value\n<br>";
  261                         exit;
  262                     }
  263                }
  264                     } elseif ($var=='spell') {
  265                        if ($sp=='') $sp=1;
  266                        $GLOBALS["ispellmode"]="text";
  267                        if (Udm_Api_Version() < 30200) {                 
  268                             if (preg_match("/([^\s\t]+)[\s\t]+(.+)/",$value,$param)) {
  269                         $t_lang=trim($param[1]);
  270                         $file=trim($param[2]);
  271                                         
  272                         $spell_file[$t_lang][]=$file;
  273                     } else {
  274                         print "Unsupported Spell command: Spell $value\n<br>";
  275                         exit;
  276                     }
  277                } else {
  278                             if (preg_match("/([^\s\t]+)[\s\t]+([^\s\t]+)[\s\t]+(.+)/",$value,$param)) {
  279                         $t_lang=trim($param[1]);
  280                                         $t_charset=trim($param[2]);
  281                         $file=trim($param[3]);
  282 
  283                         $spell_file[$t_lang][]="$t_charset;$file";
  284                     } else {
  285                         print "Unsupported Spell command: Spell $value\n<br>";
  286                         exit;
  287                     }
  288                }
  289             } elseif ($var=='ispellmode') {
  290                        if (preg_match("/^server[\s\t]+(.+)/i",$value,$param)) {
  291                   $spell_host=trim($param[1]);
  292                           $GLOBALS["ispellmode"]="server";
  293                } else {
  294                   $GLOBALS["$var"]="$value";
  295                }
  296             } elseif ($var=='alias') {
  297                        if (preg_match("/^([^\s]+)\s+(.+)$/i",$value,$param)) {
  298                           $alias_arr[trim($param[1])]=trim($param[2]);
  299                } else {
  300                   $GLOBALS["$var"]="$value";
  301                }
  302                     } elseif ($var=='stopwordtable') {
  303                        $stopwordtable_arr[]=$value;
  304                     } elseif ($var=='stopwordfile') {
  305                        $stopwordfile_arr[]=$value;
  306                     } elseif ($var=='synonym') {
  307                        if ($sy=='') $sy=1;
  308                        $synonym_arr[]=$value;
  309                     } elseif ($var=='searchdaddr') {
  310                        $searchd_arr[]=$value;
  311             } elseif ($var=='r') {
  312                $rand=0+substr($var,1);
  313                $frand=rand();
  314                $frand=$frand/getrandmax()*$value;
  315                $Randoms[$rand]=floor($frand);
  316             } elseif ($var=='dbaddr') {
  317                 if (Udm_Api_Version() >= 30211) {
  318                     $dbaddr[]=$value;
  319                 } else {
  320                     $dbaddr=$value;
  321             }
  322             } else {
  323                $GLOBALS["$var"]="$value";
  324             }
  325         }
  326     }
  327     else
  328     if ($where!=''){
  329         $templates["$where"][count($templates["$where"])-1] .= $str;
  330     }
  331     
  332     } while (!feof($fp));
  333 
  334     fclose($fp);
  335 }
  336 
  337 // -----------------------------------------------
  338 // res_field_callback($expr)
  339 // -----------------------------------------------
  340 function res_field_callback($expr) {
  341     global $global_doc_res, $global_res_position;
  342 
  343     return ParseDocText(htmlspecialChars(udm_get_res_field_ex($global_doc_res,$global_res_position,$expr[1])));
  344 }
  345 
  346 // -----------------------------------------------
  347 // print_template($t,$echo=1)
  348 // -----------------------------------------------
  349 function print_template($t,$echo=1){
  350     global $templates, $udm_agent;
  351     global $first_doc, $last_doc, $found, $query_orig, $error, $self;
  352     global $nav, $wordinfo, $doclang, $doccharset, $storedocurl;
  353     global $url, $ue, $o, $cat, $storedstr, $stored_href;
  354     global $clonestr, $searchtime, $persite;
  355     global $title, $rating, $desc, $contype, $lastmod, $docsize, $ndoc;
  356     global $keyw, $text, $category, $pop_rank;
  357     global $crc, $Randoms, $rec_id, $DEBUG, $id;
  358     global $lang_url_translation, $phpver, $sitelimit_href, $sitelimitstr;
  359     global $global_doc_res, $global_res_position;
  360     global $last_modified, $content, $charset, $length, $document, $url;
  361  
  362     $str=$templates["$t"][$o];
  363     if ($str == '') $str=$templates["$t"][0];
  364     
  365     $str=ereg_replace('\$f', "$first_doc", $str);
  366     $str=ereg_replace('\$l', "$last_doc", $str);
  367     $str=ereg_replace('\$t', "$found", $str);
  368     $str=ereg_replace('\$A', $self, $str);
  369 
  370     $str=ereg_replace('\$Q', HtmlSpecialChars(StripSlashes($query_orig)), $str);
  371     $str=ereg_replace('\$q', urlencode($query_orig), $str);
  372     $str=eregi_replace('\$UE', $ue, $str);
  373 
  374     $str=ereg_replace('\$E', $error, $str);
  375     $str=ereg_replace('\$W', $wordinfo, $str);
  376 
  377     $str=ereg_replace('\$V', $nav, $str);
  378 
  379     if ($lang_url_translation == 'yes') {
  380         $nolangurl = ereg_replace("\.[a-z]{2}\.[a-z]{2,4}$", "", $url);
  381         $str=ereg_replace('\$DU', $nolangurl, $str);
  382     } else {
  383         $str=ereg_replace('\$DU', $url, $str);
  384     }
  385 
  386     $str=ereg_replace('\$\(stored_href\)', $stored_href, $str);
  387     $str=ereg_replace('\$\(sitelimit_href\)', $sitelimit_href, $str);
  388 
  389     $str=ereg_replace('\$DT', $title, $str);
  390     $str=ereg_replace('\$DR', "$rating", $str);
  391     $str=ereg_replace('\$DX', $text, $str);
  392     $str=ereg_replace('\$DE', ($desc != '')?$desc:$text, $str);
  393     $str=ereg_replace('\$DC', $contype, $str);
  394     $str=ereg_replace('\$DM', $lastmod, $str);
  395     $str=ereg_replace('\$DS', "$docsize", $str);
  396     $str=ereg_replace('\$DN', "$ndoc", $str);
  397     $str=ereg_replace('\$DD', $desc, $str);
  398     $str=ereg_replace('\$DK', $keyw, $str);
  399     $str=ereg_replace('\$SearchTime', "$searchtime", $str);
  400     $str=ereg_replace('\$\(STORED\)', "$storedstr", $str);
  401     $str=ereg_replace('\$\(SITELIMIT\)', "$sitelimitstr", $str);
  402     $str=ereg_replace('\$\(Pop_Rank\)', "$pop_rank", $str);
  403     $str=ereg_replace('\$CL', "$clonestr", $str);
  404     $str=ereg_replace('\$\(PerSite\)', "$persite", $str);
  405     
  406     if ($t == 'storedoc_top') {
  407         $str=ereg_replace('\$\(ID\)', "$id", $str);
  408         $str=ereg_replace('\$\(Last-Modified\)', "$last_modified", $str);
  409         $str=ereg_replace('\$\(Content-Language\)', "$content", $str);
  410     $str=ereg_replace('\$\(Charset\)', "$charset", $str);
  411     $str=ereg_replace('\$\(Content-Length\)', "$length", $str);
  412     $str=ereg_replace('\$\(URL\)', "$url", $str);
  413     }
  414     if ($t == 'storedoc') {
  415     $str=ereg_replace('\$\(document\)', "$document", $str);
  416     }
  417 
  418     if ($phpver >= 40006) {
  419         if ((Udm_Api_Version() >= 30207) ||
  420             (Udm_Api_Version() <= 30203)){
  421             if (ereg('\$CP',$str)) {
  422                 if ($temp_cp_arr=Udm_Cat_Path($udm_agent,$cat)) {
  423                     reset($temp_cp_arr);
  424                     $temp_cp='';
  425                     for ($i=0; $i<count($temp_cp_arr); $i+=2) {
  426                         $cp_path=$temp_cp_arr[$i];
  427                         $cp_name=$temp_cp_arr[$i+1];
  428                         $temp_cp .= " &gt; <a href=\"$PHP_SELF?cat=$cp_path\">$cp_name</a> ";
  429                     }
  430                     $str=ereg_replace('\$CP', $temp_cp, $str);
  431             } else $str=ereg_replace('\$CP', '', $str);
  432             }       
  433 
  434             if (ereg('\$CS',$str)) {
  435                 if ($temp_cp_arr=Udm_Cat_List($udm_agent,$cat)) {
  436                     reset($temp_cp_arr);
  437                     $temp_cp='';
  438                         for ($i=0; $i<count($temp_cp_arr); $i+=2) {
  439                         $cp_path=$temp_cp_arr[$i];
  440                         $cp_name=$temp_cp_arr[$i+1];
  441                         $temp_cp .= "<a href=\"$PHP_SELF?cat=$cp_path\">$cp_name</a><br>";
  442                     }
  443                         $str=ereg_replace('\$CS', $temp_cp, $str);
  444             } else $str=ereg_replace('\$CS', '', $str);
  445             }       
  446 
  447             if (ereg('\$DY',$str)) {
  448                 if ($temp_cp_arr=Udm_Cat_Path($udm_agent,$category)) {
  449                     reset($temp_cp_arr);
  450                     $temp_cp='';
  451                         for ($i=0; $i<count($temp_cp_arr); $i+=2) {
  452                         $cp_path=$temp_cp_arr[$i];
  453                         $cp_name=$temp_cp_arr[$i+1];
  454                         $temp_cp .= " &gt; <a href=\"$PHP_SELF?cat=$cp_path\">$cp_name</a> ";
  455                     }
  456                         $str=ereg_replace('\$DY', $temp_cp, $str);
  457             } else $str=ereg_replace('\$DY', '', $str);
  458             }
  459     } else {
  460             $str=ereg_replace('\$CP', '', $str);
  461             $str=ereg_replace('\$CS', '', $str);
  462             $str=ereg_replace('\$DY', '', $str);
  463     }
  464     } else {
  465         $str=ereg_replace('\$CP', '', $str);
  466         $str=ereg_replace('\$CS', '', $str);
  467         $str=ereg_replace('\$DY', '', $str);
  468     }
  469 
  470     if (eregi('\$ndocs*',$str)) {
  471         $str=preg_replace('/\$ndocs?/', get_doc_count(), $str);
  472     }
  473 
  474     if ($global_doc_res) {
  475     $str=preg_replace_callback('/\$\(([\w\.\_\-\:]+)\)/', 'res_field_callback', $str);
  476     }
  477     
  478     $sub=$str;
  479     while($sub=strstr($sub,'$r')){
  480     $sub=substr($sub,2);
  481     $pos=0;
  482     $num='';
  483     
  484     while(($sub[$pos]>='0')&&($sub[$pos]<='9')){
  485         $num.=$sub[$pos++];
  486     }
  487     
  488     $str=ereg_replace('\$r'.$num, ''.$Randoms[$num], $str);
  489     }
  490     
  491     if($echo) echo $str; else return $str;
  492 }
  493 
  494 // -----------------------------------------------
  495 // make_nav($query_orig)
  496 // -----------------------------------------------
  497 function make_nav($query_orig){
  498    global $found,$np,$isnext,$ps,$tag,$ul,$ul_arr,$self,$o,$m,$cat,$cat_arr;
  499    global $dt, $dp, $dx, $dm, $dy, $dd, $db, $de, $lang, $wm, $wf, $site, $sp, $sy;
  500    global $q_local,$db_local,$de_local,$lang_arr, $tag, $tag_arr, $type, $type_arr;
  501    
  502    $temp_ul='';
  503    for($i=0; $i<count($ul_arr); $i++) {
  504     $temp_ul.="&ul=".urlencode($ul_arr[$i]);
  505    }    
  506    $temp_tag='';
  507    for($i=0; $i<count($tag_arr); $i++) {
  508     $temp_tag.="&tag=".urlencode($tag_arr[$i]);
  509    }    
  510    $temp_lang='';
  511    for($i=0; $i<count($lang_arr); $i++) {
  512     $temp_lang.="&lang=".urlencode($lang_arr[$i]);
  513    }    
  514    $temp_cat='';
  515    for($i=0; $i<count($cat_arr); $i++) {
  516     $temp_cat.="&cat=".urlencode($cat_arr[$i]);
  517    }    
  518    $temp_type='';
  519    for($i=0; $i<count($type_arr); $i++) {
  520     $temp_type.="&type=".urlencode($type_arr[$i]);
  521    }    
  522 
  523    if($np>0){
  524      $prevp=$np-1;
  525      $prev_href="$self?q=$q_local&np=$prevp&m=$m".
  526                 ($ps==20?'':"&ps=$ps").
  527                 $temp_tag.
  528                 $temp_ul.
  529                 $temp_cat.
  530                 $temp_lang.
  531                 ($site==''?'':"&site=$site").
  532         ($wm==''?'':"&wm=$wm").
  533         ($wf==''?'':"&wf=$wf").
  534                 (!$o?'':"&o=$o").
  535                 ($dt=='back'?'':"&dt=$dt").
  536                 (!$dp?'':"&dp=$dp").
  537                 (!$dx?'':"&dx=$dx").
  538                 ($dd=='01'?'':"&dd=$dd").
  539                 (!$dm?'':"&dm=$dm").
  540                 ($dy=='1970'?'':"&dy=$dy").
  541                 ($db=='01/01/1970'?'':"&db=$db_local").
  542                 ($de=='31/12/2020'?'':"&de=$de_local").
  543                 ($sp==''?'':"&sp=$sp").
  544                 ($sy==''?'':"&sy=$sy");
  545 
  546      $nav_left=print_template('navleft',0);
  547      $nav_left=ereg_replace('\$NH',"$prev_href",$nav_left);
  548    } elseif ($np==0) {
  549      $nav_left=print_template('navleft_nop',0);
  550    }
  551 
  552    if($isnext==1) {
  553      $nextp=$np+1;
  554      $next_href="$self?q=$q_local&np=$nextp&m=$m".
  555             ($ps==20?'':"&ps=$ps").
  556                 $temp_tag.
  557         $temp_ul.
  558                 $temp_cat.
  559                 $temp_lang.
  560                 ($site==''?'':"&site=$site").
  561         ($wm==''?'':"&wm=$wm").
  562         ($wf==''?'':"&wf=$wf").
  563                 (!$o?'':"&o=$o").
  564                 ($dt=='back'?'':"&dt=$dt").
  565                 (!$dp?'':"&dp=$dp").
  566                 (!$dx?'':"&dx=$dx").
  567                 ($dd=='01'?'':"&dd=$dd").
  568                 (!$dm?'':"&dm=$dm").
  569                 ($dy=='1970'?'':"&dy=$dy").
  570                 ($db=='01/01/1970'?'':"&db=$db_local").
  571                 ($de=='31/12/2020'?'':"&de=$de_local").
  572                 ($sp==''?'':"&sp=$sp").
  573                 ($sy==''?'':"&sy=$sy");
  574 
  575      $nav_right=print_template('navright',0);
  576      $nav_right=ereg_replace('\$NH',"$next_href",$nav_right);
  577    } else {
  578      $nav_right=print_template('navright_nop',0);
  579    }
  580 
  581    $nav_bar0=print_template('navbar0',0);
  582    $nav_bar1=print_template('navbar1',0);
  583 
  584    $tp=ceil($found/$ps);
  585 
  586    $cp=$np+1;
  587 
  588    if ($cp>5) {
  589       $lp=$cp-5;
  590    } else {
  591       $lp=1;
  592    }
  593 
  594    $rp=$lp+10-1;
  595    if ($rp>$tp) {
  596       $rp=$tp;
  597       $lp=$rp-10+1;
  598       if ($lp<1) $lp=1;
  599    }
  600 
  601 
  602    if ($lp!=$rp) {
  603       for ($i=$lp; $i<=$rp;$i++) {
  604          $realp=$i-1;
  605    
  606          if ($i==$cp) {
  607             $nav_bar=$nav_bar.$nav_bar0;
  608          } else {
  609             $nav_bar=$nav_bar.$nav_bar1;
  610          }
  611          
  612          $href="$self?q=$q_local&np=$realp&m=$m".
  613                 ($ps==20?'':"&ps=$ps").
  614                 $temp_tag.
  615         $temp_ul.
  616                 $temp_cat.
  617                 $temp_lang.
  618                 ($site==''?'':"&site=$site").
  619         ($wm==''?'':"&wm=$wm").
  620         ($wf==''?'':"&wf=$wf").
  621                 (!$o?'':"&o=$o").
  622                 ($dt=='back'?'':"&dt=$dt").
  623                 (!$dp?'':"&dp=$dp").
  624                 (!$dx?'':"&dx=$dx").
  625                 ($dd=='01'?'':"&dd=$dd").
  626                 (!$dm?'':"&dm=$dm").
  627                 ($dy=='1970'?'':"&dy=$dy").
  628                 ($db=='01/01/1970'?'':"&db=$db_local").
  629                 ($de=='31/12/2020'?'':"&de=$de_local").
  630                 ($sp==''?'':"&sp=$sp").
  631                 ($sy==''?'':"&sy=$sy");
  632 
  633          $nav_bar=ereg_replace('\$NP',"$i",$nav_bar);
  634          $nav_bar=ereg_replace('\$NH',"$href",$nav_bar);
  635       }
  636    
  637       $nav=print_template('navigator',0);
  638       $nav=ereg_replace('\$NL',"$nav_left",$nav);
  639       $nav=ereg_replace('\$NR',"$nav_right",$nav);
  640       $nav=ereg_replace('\$NB',"$nav_bar",$nav);
  641 
  642    } elseif ($found) {
  643       $nav=print_template('navigator',0);
  644       $nav=ereg_replace('\$NL',"$nav_left",$nav);
  645       $nav=ereg_replace('\$NR',"$nav_right",$nav);
  646       $nav=ereg_replace('\$NB',"",$nav);
  647    }
  648 
  649    return $nav;
  650 }
  651 
  652 ?>