includes/paths.php
changeset 259 112debff64bd
parent 256 f8356d9c3481
child 261 5f1cd51bf1be
equal deleted inserted replaced
258:8be996c3740d 259:112debff64bd
   694    
   694    
   695   function fetch_page_search_resource()
   695   function fetch_page_search_resource()
   696   {
   696   {
   697     global $db, $session, $paths, $template, $plugins; // Common objects
   697     global $db, $session, $paths, $template, $plugins; // Common objects
   698     // sha1('') returns "da39a3ee5e6b4b0d3255bfef95601890afd80709"
   698     // sha1('') returns "da39a3ee5e6b4b0d3255bfef95601890afd80709"
   699     $texts = 'SELECT t.page_text, CONCAT(\'ns=\',t.namespace,\';pid=\',t.page_id) AS page_idstring, t.page_id, t.namespace FROM '.table_prefix.'page_text AS t
   699     
       
   700     $concat_column = ( ENANO_DBLAYER == 'MYSQL' ) ?
       
   701       'CONCAT(\'ns=\',t.namespace,\';pid=\',t.page_id)' :
       
   702       "'ns=' || t.namespace || ';pid=' || t.page_id";
       
   703     
       
   704     $texts = 'SELECT t.page_text, ' . $concat_column . ' AS page_idstring, t.page_id, t.namespace FROM '.table_prefix.'page_text AS t
   700                            LEFT JOIN '.table_prefix.'pages AS p
   705                            LEFT JOIN '.table_prefix.'pages AS p
   701                              ON ( t.page_id=p.urlname AND t.namespace=p.namespace )
   706                              ON ( t.page_id=p.urlname AND t.namespace=p.namespace )
   702                            WHERE p.namespace=t.namespace
   707                            WHERE p.namespace=t.namespace
   703                              AND ( p.password=\'\' OR p.password=\'da39a3ee5e6b4b0d3255bfef95601890afd80709\' )
   708                              AND ( p.password=\'\' OR p.password=\'da39a3ee5e6b4b0d3255bfef95601890afd80709\' )
   704                              AND p.visible=1;'; // Only indexes "visible" pages
   709                              AND p.visible=1;'; // Only indexes "visible" pages
   808     $db->free_result();
   813     $db->free_result();
   809     $search = new Searcher();
   814     $search = new Searcher();
   810     $search->buildIndex(Array("ns={$namespace};pid={$page_id}"=>$row['page_text'] . ' ' . $this->pages[$idstring]['name']));
   815     $search->buildIndex(Array("ns={$namespace};pid={$page_id}"=>$row['page_text'] . ' ' . $this->pages[$idstring]['name']));
   811     $new_index = $search->index;
   816     $new_index = $search->index;
   812     
   817     
   813     $keys = array_keys($search->index);
   818     if ( ENANO_DBLAYER == 'MYSQL' )
   814     foreach($keys as $i => $k)
   819     {
   815     {
   820       $keys = array_keys($search->index);
   816       $c =& $keys[$i];
   821       foreach($keys as $i => $k)
   817       $c = hexencode($c, '', '');
   822       {
   818     }
   823         $c =& $keys[$i];
   819     $keys = "word=0x" . implode ( " OR word=0x", $keys ) . "";
   824         $c = hexencode($c, '', '');
       
   825       }
       
   826       $keys = "word=0x" . implode ( " OR word=0x", $keys ) . "";
       
   827     }
       
   828     else
       
   829     {
       
   830       $keys = array_keys($search->index);
       
   831       foreach($keys as $i => $k)
       
   832       {
       
   833         $c =& $keys[$i];
       
   834         $c = $db->escape($c);
       
   835       }
       
   836       $keys = "word='" . implode ( "' OR word='", $keys ) . "'";
       
   837     }
   820     
   838     
   821     $query = $db->sql_query('SELECT word,page_names FROM '.table_prefix.'search_index WHERE '.$keys.';');
   839     $query = $db->sql_query('SELECT word,page_names FROM '.table_prefix.'search_index WHERE '.$keys.';');
   822     
   840     
   823     while($row = $db->fetchrow())
   841     while($row = $db->fetchrow())
   824     {
   842     {