Example #1
0
function search_downloads($items, $conn)
{
    global $set, $db, $apx, $user;
    require_once BASEDIR . getmodulepath('downloads') . 'functions.php';
    //Suchstring generieren
    $tagmatches = downloads_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 text LIKE '%" . addslashes_like($item) . "%' OR author LIKE '%" . addslashes_like($item) . "%' ) ";
    }
    $searchstring = implode($conn, $search);
    //Downloads durchsuchen
    $data = $db->fetch("SELECT id,title FROM " . PRE . "_downloads WHERE ( searchable='1' AND '" . time() . "' BETWEEN starttime AND endtime " . section_filter() . " AND ( " . $searchstring . " ) ) ORDER BY addtime DESC");
    if (count($data)) {
        foreach ($data as $res) {
            ++$i;
            $result[$i]['TITLE'] = $res['title'];
            $result[$i]['LINK'] = mklink('downloads.php?id=' . $res['id'], 'downloads,id' . $res['id'] . urlformat($res['title']) . '.html');
        }
    }
    return $result;
}
Example #2
0
                 }
                 $tabledata[$i]['RATING'] = $rate->display();
                 $tabledata[$i]['RATING_VOTES'] = $rate->count();
                 $tabledata[$i]['DISPLAY_RATING'] = 1;
             }
         }
     }
     $apx->tmpl->assign('DOWNLOAD', $tabledata);
     $apx->tmpl->parse('search_result');
 } else {
     $where = '';
     //Suchbegriffe
     if ($_REQUEST['item']) {
         $items = array();
         $it = explode(' ', preg_replace('#[ ]{2,}#', ' ', trim($_REQUEST['item'])));
         $tagmatches = downloads_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 ';
         }