includes/search.php
changeset 296 a21faa57e6c6
parent 294 444c34a3886b
child 318 eec2dfd2f0a3
equal deleted inserted replaced
295:53233b86e054 296:a21faa57e6c6
   389     $where_req = ( count($where_req) > 0 ) ? "{$and_clause}" . implode(" AND\n  ", $where_req) : '';
   389     $where_req = ( count($where_req) > 0 ) ? "{$and_clause}" . implode(" AND\n  ", $where_req) : '';
   390 
   390 
   391     $sql = 'SELECT ' . $concat_column . ' AS id, p.name FROM ' . table_prefix . "page_text AS t\n"
   391     $sql = 'SELECT ' . $concat_column . ' AS id, p.name FROM ' . table_prefix . "page_text AS t\n"
   392             . "  LEFT JOIN " . table_prefix . "pages AS p\n"
   392             . "  LEFT JOIN " . table_prefix . "pages AS p\n"
   393             . "    ON ( p.urlname = t.page_id AND p.namespace = t.namespace )\n"
   393             . "    ON ( p.urlname = t.page_id AND p.namespace = t.namespace )\n"
   394             . "  WHERE\n  $where_any\n  $where_req;";
   394             . "  WHERE p.visible = 1 AND (\n    $where_any\n    $where_req\n  );";
   395     if ( !($q = $db->sql_unbuffered_query($sql)) )
   395     if ( !($q = $db->sql_unbuffered_query($sql)) )
   396       $db->_die('Error is in perform_search(), includes/search.php, query 2. Parsed query dump follows:<pre>(indexable) ' . htmlspecialchars(print_r($query, true)) . '(non-indexable) ' . htmlspecialchars(print_r($query_phrase, true)) . '</pre>');
   396       $db->_die('Error is in perform_search(), includes/search.php, query 2. Parsed query dump follows:<pre>(indexable) ' . htmlspecialchars(print_r($query, true)) . '(non-indexable) ' . htmlspecialchars(print_r($query_phrase, true)) . '</pre>');
   397 
   397 
   398     if ( $row = $db->fetchrow() )
   398     if ( $row = $db->fetchrow() )
   399     {
   399     {
   461   $where_not = ( count($where_not) > 0 ) ? "$text_col NOT LIKE '%" . implode("%' AND $text_col NOT LIKE '%", $where_not) . "%'" : '';
   461   $where_not = ( count($where_not) > 0 ) ? "$text_col NOT LIKE '%" . implode("%' AND $text_col NOT LIKE '%", $where_not) . "%'" : '';
   462 
   462 
   463   $sql = 'SELECT ' . $concat_column . ' AS id, t.page_id, t.namespace, CHAR_LENGTH(t.page_text) AS page_length, t.page_text, p.name AS page_name FROM ' . table_prefix . "page_text AS t
   463   $sql = 'SELECT ' . $concat_column . ' AS id, t.page_id, t.namespace, CHAR_LENGTH(t.page_text) AS page_length, t.page_text, p.name AS page_name FROM ' . table_prefix . "page_text AS t
   464             LEFT JOIN " . table_prefix . "pages AS p
   464             LEFT JOIN " . table_prefix . "pages AS p
   465               ON ( p.urlname = t.page_id AND p.namespace = t.namespace )
   465               ON ( p.urlname = t.page_id AND p.namespace = t.namespace )
   466             WHERE $text_where $where_not;";
   466             WHERE p.visible = 1 AND ( $text_where $where_not );";
   467   if ( !($q = $db->sql_unbuffered_query($sql)) )
   467   if ( !($q = $db->sql_unbuffered_query($sql)) )
   468     $db->_die('Error is in perform_search(), includes/search.php, query 3');
   468     $db->_die('Error is in perform_search(), includes/search.php, query 3');
   469 
   469 
   470   $page_data = array();
   470   $page_data = array();
   471   if ( $row = $db->fetchrow() )
   471   if ( $row = $db->fetchrow() )
   494   // Iterate through $paths->pages and check the titles for search terms. Score accordingly.
   494   // Iterate through $paths->pages and check the titles for search terms. Score accordingly.
   495   //
   495   //
   496 
   496 
   497   foreach ( $paths->pages as $id => $page )
   497   foreach ( $paths->pages as $id => $page )
   498   {
   498   {
   499     if ( $page['namespace'] != 'Special' )
   499     if ( $page['namespace'] != 'Special' || $page['visible'] == 0 )
   500       continue;
   500       continue;
   501     if ( !is_int($id) )
   501     if ( !is_int($id) )
   502       continue;
   502       continue;
   503     $idstring = 'ns=' . $page['namespace'] . ';pid=' . $page['urlname_nons'];
   503     $idstring = 'ns=' . $page['namespace'] . ';pid=' . $page['urlname_nons'];
   504     $any = array_values(array_unique(array_merge($query['any'], $query_phrase['any'])));
   504     $any = array_values(array_unique(array_merge($query['any'], $query_phrase['any'])));