/[LeafOK_CVS]/fenglin/bbs/search_article_v2.php
ViewVC logotype

Diff of /fenglin/bbs/search_article_v2.php

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

Revision 1.2 by sysadm, Wed Jan 21 09:42:27 2026 UTC Revision 1.5 by sysadm, Thu Jan 22 01:50:40 2026 UTC
# Line 68  Line 68 
68                  mysqli_free_result($rs);                  mysqli_free_result($rs);
69          }          }
70    
71            if (!in_array($rpp, $BBS_list_rpp_options))
72            {
73                    $rpp = $BBS_list_rpp_options[0];
74            }
75    
76            if ($page <= 0)
77            {
78                    $page = 1;
79            }
80    
81          // Initialize Solr client          // Initialize Solr client
82          $solr_client = new SolrClient($solr_options);          $solr_client = new SolrClient($solr_options);
83    
84          $query_str = "" .          $query_str = "" .
85                  ($sid_list == "(-1)" ? "" : "SectionId:($sid_list) AND ") .                  ($sid_list == "(-1)" ? "" : "SectionId:($sid_list) AND ") .
86                  ($reply ? "" : "TopicId:0 AND ") .                  ($reply ? "" : "TopicId:0 AND ") .
87                    ($uid == 0 ? "" : "PostUserId:($uid) AND ") .
88                  ($username == "" ? "" : "PostUserName:($username) AND ") .                  ($username == "" ? "" : "PostUserName:($username) AND ") .
89                  ($nickname == "" ? "" : "PostUserNickName:($nickname) AND ") .                  ($nickname == "" ? "" : "PostUserNickName:($nickname) AND ") .
90                  ($ex == 1 ? "Excerption:1 AND " : "") .                  ($ex == 1 ? "Excerption:1 AND " : "") .
91                  ($original ? "Eransship:0 AND " : "") .                  ($original ? "Transship:0 AND " : "") .
92                  "PostDateTime:[" . $begin_dt->setTimezone(new DateTimeZone("UTC"))->format("Y-m-d\T00:00:00\Z") . " TO " .                  "PostDateTime:[" . $begin_dt->setTimezone(new DateTimeZone("UTC"))->format("Y-m-d\T00:00:00\Z") . " TO " .
93                          $end_dt->setTimezone(new DateTimeZone("UTC"))->format("Y-m-d\T23:59:59\Z") . "] AND " .                          $end_dt->setTimezone(new DateTimeZone("UTC"))->format("Y-m-d\T23:59:59\Z") . "] AND " .
94                  ($title == "" ? "" : "ArticleTitle:($title) AND ") .                  ($title == "" ? "" : "ArticleTitle:($title) AND ") .
# Line 89  Line 100 
100          $solr_query->setQuery($query_str);          $solr_query->setQuery($query_str);
101          $solr_query->addField("ArticleId");          $solr_query->addField("ArticleId");
102          $solr_query->addSortField("PostDateTime", SolrQuery::ORDER_DESC);          $solr_query->addSortField("PostDateTime", SolrQuery::ORDER_DESC);
103            $solr_query->setStart(($page - 1) * $rpp);
104            $solr_query->setRows($rpp);
105          try          try
106          {          {
107                  $solr_res = $solr_client->query($solr_query);                  $solr_res = $solr_client->query($solr_query);
# Line 112  Line 125 
125    
126          $toa = $solr_obj->response->numFound;          $toa = $solr_obj->response->numFound;
127    
         unset($solr_query);  
   
         if (!in_array($rpp, $BBS_list_rpp_options))  
         {  
                 $rpp = $BBS_list_rpp_options[0];  
         }  
   
128          $page_total = ceil($toa / $rpp);          $page_total = ceil($toa / $rpp);
         if ($page > $page_total)  
         {  
                 $page = $page_total;  
         }  
   
         if ($page <= 0)  
         {  
                 $page = 1;  
         }  
129    
130          // Fill up result data          // Fill up result data
131          $result_set["data"] = array(          $result_set["data"] = array(
# Line 154  Line 151 
151                  "articles" => array(),                  "articles" => array(),
152          );          );
153    
         // Query article IDs  
         $solr_query = new SolrQuery();  
         $solr_query->setQuery($query_str);  
         $solr_query->addField("ArticleId");  
         $solr_query->addSortField("PostDateTime", SolrQuery::ORDER_DESC);  
         $solr_query->setStart(($page - 1) * $rpp);  
         $solr_query->setRows($rpp);  
         try  
         {  
                 $solr_res = $solr_client->query($solr_query);  
         }  
         catch (Exception $e)  
         {  
                 $result_set["return"]["code"] = -3;  
                 $result_set["return"]["message"] = "Solr query error";  
   
                 exit(json_encode($result_set));  
         }  
         $solr_obj = $solr_res->getResponse();  
   
         if ($solr_obj->responseHeader->status != 0)  
         {  
                 $result_set["return"]["code"] = -3;  
                 $result_set["return"]["message"] = "Solr query error: " . $solr_obj->responseHeader->status;  
   
                 exit(json_encode($result_set));  
         }  
   
         // print_r($solr_obj);  
         // exit();  
   
154          $aid_list = "-1";          $aid_list = "-1";
155    
156          if ($solr_obj->response->docs !== false)          if ($solr_obj->response->docs !== false)
# Line 195  Line 161 
161                  }                  }
162          }          }
163    
164            unset($solr_res);
165          unset($solr_query);          unset($solr_query);
166          unset($solr_client);          unset($solr_client);
167    


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1