includes/paths.php
changeset 304 e2cb5f1432c8
parent 279 8acd77a6c19d
parent 292 b3cfaf0a505c
child 313 854eecfada20
equal deleted inserted replaced
280:dc08c70ca550 304:e2cb5f1432c8
   116     foreach ( $code as $cmd )
   116     foreach ( $code as $cmd )
   117     {
   117     {
   118       eval($cmd);
   118       eval($cmd);
   119     }
   119     }
   120     
   120     
   121     $e = $db->sql_query('SELECT name,urlname,namespace,special,visible,comments_on,protected,delvotes,delvote_ips,wiki_mode,password FROM '.table_prefix.'pages ORDER BY name;');
   121     $e = $db->sql_query('SELECT name,urlname,namespace,special,visible,comments_on,protected,delvotes,' . "\n"
       
   122                         . '  delvote_ips,wiki_mode,password FROM '.table_prefix.'pages ORDER BY name;');
   122     if( !$e )
   123     if( !$e )
   123     {
   124     {
   124       $db->_die('The error seems to have occured while selecting the page information. File: includes/paths.php; line: '.__LINE__);
   125       $db->_die('The error seems to have occured while selecting the page information. File: includes/paths.php; line: '.__LINE__);
   125     }
   126     }
   126     while($r = $db->fetchrow())
   127     while($r = $db->fetchrow())
   679     return $texts;
   680     return $texts;
   680   }
   681   }
   681   
   682   
   682   /**
   683   /**
   683    * Rebuilds the search index
   684    * Rebuilds the search index
       
   685    * @param bool If true, prints out status messages
   684    */
   686    */
   685    
   687    
   686   function rebuild_search_index()
   688   function rebuild_search_index($verbose = false)
   687   {
   689   {
   688     global $db, $session, $paths, $template, $plugins; // Common objects
   690     global $db, $session, $paths, $template, $plugins; // Common objects
   689     $search = new Searcher();
   691     $search = new Searcher();
       
   692     if ( $verbose )
       
   693     {
       
   694       echo '<p>';
       
   695     }
   690     $texts = Array();
   696     $texts = Array();
   691     $textq = $db->sql_unbuffered_query($this->fetch_page_search_resource());
   697     $textq = $db->sql_unbuffered_query($this->fetch_page_search_resource());
   692     if(!$textq) $db->_die('');
   698     if(!$textq) $db->_die('');
   693     while($row = $db->fetchrow())
   699     while($row = $db->fetchrow())
   694     {
   700     {
       
   701       if ( $verbose )
       
   702       {
       
   703         ob_start();
       
   704         echo "Indexing page " . $this->nslist[$row['namespace']] . sanitize_page_id($row['page_id']) . "<br />";
       
   705         ob_flush();
       
   706         while (@ob_end_flush());
       
   707         flush();
       
   708       }
   695       if ( isset($this->nslist[$row['namespace']]) )
   709       if ( isset($this->nslist[$row['namespace']]) )
   696       {
   710       {
   697         $idstring = $this->nslist[$row['namespace']] . sanitize_page_id($row['page_id']);
   711         $idstring = $this->nslist[$row['namespace']] . sanitize_page_id($row['page_id']);
   698         if ( isset($this->pages[$idstring]) )
   712         if ( isset($this->pages[$idstring]) )
   699         {
   713         {
   708       {
   722       {
   709         $page = array('name' => dirtify_page_id($row['page_id']));
   723         $page = array('name' => dirtify_page_id($row['page_id']));
   710       }
   724       }
   711       $texts[(string)$row['page_idstring']] = $row['page_text'] . ' ' . $page['name'];
   725       $texts[(string)$row['page_idstring']] = $row['page_text'] . ' ' . $page['name'];
   712     }
   726     }
       
   727     if ( $verbose )
       
   728     {
       
   729       ob_start();
       
   730       echo "Calculating word list...";
       
   731       ob_flush();
       
   732       while (@ob_end_flush());
       
   733       flush();
       
   734     }
   713     $search->buildIndex($texts);
   735     $search->buildIndex($texts);
       
   736     if ( $verbose )
       
   737     {
       
   738       echo '</p>';
       
   739     }
   714     // echo '<pre>'.print_r($search->index, true).'</pre>';
   740     // echo '<pre>'.print_r($search->index, true).'</pre>';
   715     // return;
   741     // return;
   716     $q = $db->sql_query('DELETE FROM '.table_prefix.'search_index');
   742     $q = $db->sql_query('DELETE FROM '.table_prefix.'search_index');
   717     if(!$q) return false;
   743     if(!$q) return false;
   718     $secs = Array();
   744     $secs = Array();