Jlog PHP Cross Reference Blogging Systems

Source: /search.php - 94 lines - 3744 bytes - Summary - Text - Print

   1  <?php
   2   require('.'.DIRECTORY_SEPARATOR.'personal'.DIRECTORY_SEPARATOR.'settings.inc.php');
   3  
   4   $c['meta']['robots']       = "noindex, follow";
   5   $c['meta']['title'] = $l['content_search_header'];
   6   $c['main'] = "<h2 class='search'>".$l['content_search_header']."</h2>";
   7  
   8   $searchstring = strip($_GET['q']);
   9  
  10      $c['main'] .= '     <form id="searchform" action="'.JLOG_PATH.'/search.php">
  11        <p><input class="userdata" type="text" name="q" size="30" value="'.htmlspecialchars($searchstring, ENT_QUOTES).'" />
  12           <input class="send" type="submit" value="'.$l['content_search'].'" /></p>
  13       </form>
  14       <script type="text/javascript">jlog_searchpage = true;</script>
  15  ';
  16  
  17  if(!empty($searchstring)) {
  18  
  19   $sql_searchstring = escape_for_mysql($searchstring);
  20  
  21   $sql = "
  22                  SELECT
  23                      id,
  24                      url,
  25                      UNIX_TIMESTAMP(date) AS date_url,
  26                      0 AS comment_id,
  27                      topic,
  28                      UNIX_TIMESTAMP(date) AS date,
  29                      keywords,
  30                      teaser,
  31                      section,
  32                      comments,
  33                      MATCH ( topic, keywords, teaser, content ) AGAINST ('".$sql_searchstring."') AS scoring
  34                  FROM ".JLOG_DB_CONTENT."
  35                  WHERE
  36                    MATCH ( topic, keywords, teaser, content ) AGAINST ( '".$sql_searchstring."' )
  37  
  38                  UNION
  39                  SELECT
  40                      ".JLOG_DB_COMMENTS.".reference AS id,
  41                      ".JLOG_DB_CONTENT.".url AS url,
  42                      UNIX_TIMESTAMP(".JLOG_DB_CONTENT.".date) AS date_url,
  43                      ".JLOG_DB_COMMENTS.".id AS comment_id,
  44                      name AS topic,
  45                      UNIX_TIMESTAMP(".JLOG_DB_COMMENTS.".date) AS date,
  46                      'comment_keywords' AS keywords,
  47                      ".JLOG_DB_COMMENTS.".content AS teaser,
  48                      'comment',
  49                      2,
  50                      MATCH(name, city, email, homepage, ".JLOG_DB_COMMENTS.".content) AGAINST ('".$sql_searchstring."') AS scoring
  51                  FROM ".JLOG_DB_COMMENTS.", ".JLOG_DB_CONTENT."
  52                  WHERE
  53                    MATCH ( name, city, email, homepage, ".JLOG_DB_COMMENTS.".content ) AGAINST ( '".$sql_searchstring."' )
  54                    AND ".JLOG_DB_COMMENTS.".reference = ".JLOG_DB_CONTENT.".id
  55                    AND ".JLOG_DB_COMMENTS.".type = ''
  56  
  57                  ORDER BY scoring desc
  58                  LIMIT 40;";
  59  
  60  
  61       $search = new Query($sql);
  62       if($search->error()) {
  63          echo "<pre>\n";
  64          echo $search->getError();
  65          echo "</pre>\n";
  66          die();
  67       }
  68  
  69      if($search->numRows() < 1) {
  70          $c['main'] .= "<p>".$l['content_nothing_found']."</p>";
  71      }
  72      else {
  73          $cc = count_comments();
  74          $c['main'] .= "<ul class='search'>\n";
  75          while( $data = $search->fetch() ) {
  76              $c['main'] .= " <li>";
  77              if($data['comment_id'] == 0) $c['main'] .= do_teaser($data, $cc, '<h3>', '</h3>');
  78              else {
  79                  $data['url'] = $data['url'].'#c'.$data['comment_id'];
  80                  if(empty($data['topic'])) $data['topic'] = $l['comments_anonym'];
  81                  $data['topic'] = $l['comments_by'].": ".$data['topic'];
  82      
  83                  list($data['teaser']) = explode('|*|JLOG_BREAK|*|', wordwrap(str_replace("\n", ' ', html_entity_decode(strip_tags($bbcomments->parse(trim($data['teaser']))))), 300, ' ...|*|JLOG_BREAK|*|'));
  84      
  85                  $c['main'] .= do_teaser($data, 0, '<h4>', '</h4>');
  86              }
  87              $c['main'] .= " </li>\n";
  88          }
  89          $c['main'] .= "</ul>\n";
  90      }
  91  }
  92  require (JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'do_template.php');
  93  echo $body;
  94  ?>

title

Description

title

Description

title

Description

title

title

Body