Example #1
0
function search_news($items, $conn)
{
    global $set, $db, $apx, $user;
    require_once BASEDIR . getmodulepath('news') . 'functions.php';
    //Suchstring generieren
    $tagmatches = news_match_tags($items);
    foreach ($items as $item) {
        $tagmatch = array_shift($tagmatches);
        $search[] = " ( " . iif($tagmatch, " id IN (" . implode(',', $tagmatch) . ") OR ") . " title LIKE '%" . addslashes_like($item) . "%' OR subtitle LIKE '%" . addslashes_like($item) . "%' OR teaser LIKE '%" . addslashes_like($item) . "%' OR text LIKE '%" . addslashes_like($item) . "%' ) ";
    }
    $searchstring = implode($conn, $search);
    //Ergebnisse
    $data = $db->fetch("SELECT id,title,subtitle FROM " . PRE . "_news WHERE ( searchable='1' AND '" . time() . "' BETWEEN starttime AND endtime " . section_filter() . " AND ( " . $searchstring . " ) ) ORDER BY starttime DESC");
    if (count($data)) {
        foreach ($data as $res) {
            ++$i;
            $link = mklink('news.php?id=' . $res['id'], 'news,id' . $res['id'] . urlformat($res['title']) . '.html');
            $result[$i]['TITLE'] = strip_tags($res['title']) . iif($res['subtitle'], ' - ' . strip_tags($res['subtitle']));
            $result[$i]['LINK'] = $link;
        }
    }
    return $result;
}
Example #2
0
             }
             $tabledata[$i]['RATING'] = $rate->display();
             $tabledata[$i]['RATING_VOTES'] = $rate->count();
             $tabledata[$i]['DISPLAY_RATING'] = 1;
         }
         $laststamp = date('Y/m/d', $res['starttime'] - TIMEDIFF);
     }
     $apx->tmpl->assign('NEWS', $tabledata);
     $apx->tmpl->parse('search_result');
 } else {
     $where = '';
     //Suchbegriffe
     if ($_REQUEST['item']) {
         $items = array();
         $it = explode(' ', preg_replace('#[ ]{2,}#', ' ', trim($_REQUEST['item'])));
         $tagmatches = news_match_tags($it);
         foreach ($it as $item) {
             if (trim($item)) {
                 $string = preg_replace('#[\\s_-]+#', '[^0-9a-zA-Z]*', $item);
                 if (preg_match('#^[0-9a-zA-Z]+$#', $string)) {
                     $items[] = " LIKE '%" . addslashes_like($string) . "%' ";
                 } else {
                     $items[] = " REGEXP '" . addslashes($string) . "' ";
                 }
             }
         }
         if ($_REQUEST['conn'] == 'or') {
             $conn = ' OR ';
         } else {
             $conn = ' AND ';
         }