/[health_html]/inc/search.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /inc/search.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by ravilov, Fri Oct 5 15:10:53 2001 UTC revision 1.9 by ravilov, Sat Oct 27 16:54:50 2001 UTC
# Line 49  Line 49 
49                          $search[count($search) - 1]["logic"] = "";                          $search[count($search) - 1]["logic"] = "";
50                          $tp->assign("search", $search);                          $tp->assign("search", $search);
51                  } else {                  } else {
52                          global $field, $query;                          // Nothing.
                         $tp->assign("field", $field?$field:$def_field);  
                         $tp->assign("query", MyEscape($query, true));  
53                  }                  }
54                  if (!$stype) $stype = 0;                  if (!$stype) $stype = 0;
55                  $tp->assign("stype", $stype);                  $tp->assign("stype", $stype);
# Line 94  Line 92 
92                                          $i++;                                          $i++;
93                                  }                                  }
94                          } else {                          } else {
95                                  $q = preg_split('/\s+/', $query);                                  $qry_1 = array();
96                                  $q2 = array();                                  $qry_2 = array();
97                                  $q3 = array();                                  reset($fields);
98                                  while (list($k, $v) = each($q)) {                                  while (list($k, $v) = each($fields)) {
99                                          if (!$q[$k]) continue;                                          $field = $k;
100                                          $qq = "(UPPER(".$fields[$field]["dbname"].") LIKE '%".MyUpper($q[$k])."%')";                                          $var = "query_".$field; global $$var;
101                                          $is_q1 = false;                                          $query = $$var;
102                                          for ($i = 0; $i < count($q1_fields); $i++)                                          $q = preg_split('/\s+/', $query);
103                                                  if ($q1_fields[$i] == $field) $is_q1 = true;                                          $q2 = array();
104                                          $is_q2 = false;                                          $q3 = array();
105                                          for ($i = 0; $i < count($q2_fields); $i++)                                          while (list($k, $v) = each($q)) {
106                                                  if ($q2_fields[$i] == $field) $is_q2 = true;                                                  if (!$q[$k]) continue;
107                                          if ($is_q1) $q2[$k] = $qq;                                                  $qq = "(UPPER(".$fields[$field]["dbname"].") LIKE '%".MyUpper($q[$k])."%')";
108                                          if ($is_q2) $q3[$k] = $qq;                                                  $is_q1 = false;
109                                                    for ($i = 0; $i < count($q1_fields); $i++)
110                                                            if ($q1_fields[$i] == $field) $is_q1 = true;
111                                                    $is_q2 = false;
112                                                    for ($i = 0; $i < count($q2_fields); $i++)
113                                                            if ($q2_fields[$i] == $field) $is_q2 = true;
114                                                    if ($is_q1) $q2[$k] = $qq;
115                                                    if ($is_q2) $q3[$k] = $qq;
116                                            }
117                                            global $basic_logic;
118                                            if (count($q2) > 0) array_push($qry_1, "(".implode(" ".$basic_logic." ", $q2).")");
119                                            if (count($q3) > 0) array_push($qry_2, "(".implode(" ".$basic_logic." ", $q3).")");
120                                  }                                  }
121                                  global $basic_logic;                                  $qry_1 = implode(" AND ", $qry_1);
122                                  $qry_1 = implode(" ".$basic_logic." ", $q2);                                  $qry_2 = implode(" AND ", $qry_2);
                                 $qry_2 = implode(" ".$basic_logic." ", $q3);  
123                          }                          }
124                  }                  }
125                  $flds = array();                  $flds = array();
126                    reset($fields);
127                  while (list($k, $v) = each($fields)) {                  while (list($k, $v) = each($fields)) {
128                            $var = "query_".$v["dbname"];
129                            global $$var;
130                          array_push($flds, array(                          array_push($flds, array(
131                                  "name" => MyEscape($k, true),                                  "name" => MyEscape($k, true),
132                                  "caption" => MyEscape($v["caption"])                                  "caption" => MyEscape($v["caption"]),
133                                    "query" => MyEscape($$var)
134                          ));                          ));
135                  }                  }
136                  $tp->assign("fields", $flds);                  $tp->assign("fields", $flds);
# Line 127  Line 139 
139                  $tp->assign("section_menu", $section_menu);                  $tp->assign("section_menu", $section_menu);
140                  $tp->assign("FORM_ACTION", HTMLSpecialChars("?section=$section&section_menu={$section_menu}&stype=$stype"));                  $tp->assign("FORM_ACTION", HTMLSpecialChars("?section=$section&section_menu={$section_menu}&stype=$stype"));
141                  $form = $tp->fetch("search.tpl");                  $form = $tp->fetch("search.tpl");
                 if ($form) {  
                         global $onload;  
                         $onload .= "document.forms[1].elements[".($stype?2:1)."].focus();";  
                 }  
142                  return array($form, $qry_1, $qry_2);                  return array($form, $qry_1, $qry_2);
143          }          }
144  ?>  ?>

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.26