All pastes #634588 Raw Edit

Someone

public text v1 · immutable
#634588 ·published 2007-07-26 14:43 UTC
rendered paste body
    # Start Tag search
    if (($in{'q'}) || ($in{'tags'})) {
        $in{'tags'} = $in{'q'} if(!$in{'tags'});
        $in{'tags'} =~ s/\s+/ /g;
        $in{'tags'} =~ s/(^\s+)|(\s+$)//g;

        @tags = split(/\s/, $in{'tags'});
        @sqlargs = ();
        foreach (@tags) {
            push (@sqlargs, 'h_tags.tag=?');
        }
        $" = $in{'matchany'} ? ' AND ' : ' OR ';
        $sqlargs = "@sqlargs";

        $sql = "SELECT h_files.id, h_files.name, h_files.uid, h_files.dt as uploaddate
                  FROM h_files, h_share, h_groups, h_groups_members, h_tags
                 WHERE ($sqlargs)
                   AND h_tags.file_id=h_files.id
                   AND h_files.id = h_share.item_id
                   AND h_share.share_group = h_groups.id
                   AND h_groups.id = h_groups_members.group
                   AND h_groups_members.uid=?
                   AND h_files.uid!=?
                 UNION
                SELECT h_files.id, h_files.name, h_files.uid, h_files.dt
                  FROM h_files, h_tags
                 WHERE h_files.uid=?
                   AND ($sqlargs)
                   AND h_tags.file_id=h_files.id
                 ORDER BY uploaddate DESC
                 LIMIT 0 , 30";
        @tag_files = db_sql($sql, @tags, $se{uid}, $se{uid}, $se{uid}, @tags);

    }