Търсачка

C++ JAVA
Post Reply
niksdevil
Турист
Турист
Posts: 364
Joined: Sun Jan 16, 2011 7:17 pm

Търсачка

Post by niksdevil » Fri Nov 08, 2019 10:44 am

Здравейте, идеята ми е ако може да комбинира различни символи а не на ключова дума да речем Металика, да я намира по следните начини:

meталиka metalika меtalika и т.н

Ето този код ползвам :

Code: Select all

<?php
if &#40;empty&#40;$_GET&#91;'keyword'&#93;&#41;&#41; &#123;
	header&#40;"Location&#58; " . PT_Link&#40;'login'&#41;&#41;;
    exit&#40;&#41;;
&#125;
$keyword = PT_Secure&#40;$_GET&#91;'keyword'&#93;&#41;;

$list = '<div class="text-center no-content-found empty_state"><svg xmlns="http&#58;//www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-video-off"><path d="M16 16v1a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2m5.66 0H14a2 2 0 0 1 2 2v3.34l1 1L23 7v10"></path><line x1="1" y1="1" x2="23" y2="23"></line></svg>' . $lang->no_videos_found_for_now . '</div>';
$list2 = '<div class="text-center no-content-found empty_state"><svg xmlns="http&#58;//www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-video-off"><path d="M16 16v1a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2m5.66 0H14a2 2 0 0 1 2 2v3.34l1 1L23 7v10"></path><line x1="1" y1="1" x2="23" y2="23"></line></svg></div>';
$final = '';
$final2 = '';
$category = '';
$date = '';
$category_id = '';
// pagination system 
$pt->page_number = isset&#40;$_GET&#91;'page_id'&#93;&#41; && is_numeric&#40;$_GET&#91;'page_id'&#93;&#41; && $_GET&#91;'page_id'&#93; > 0 ? $_GET&#91;'page_id'&#93; &#58; 1;
$pt->limit_per_page = !empty&#40;$pt->config->videos_load_limit&#41; && is_numeric&#40;$pt->config->videos_load_limit&#41; && $pt->config->videos_load_limit > 0 ? &#40;int&#41; $pt->config->videos_load_limit &#58; 20;
$db->pageLimit = $pt->limit_per_page;
// pagination system 
if &#40;isset&#40;$_POST&#91;'category'&#93;&#41; && !empty&#40;$_POST&#91;'category'&#93;&#41;&#41; &#123;
    if &#40;is_array&#40;$_POST&#91;'category'&#93;&#41; && count&#40;$_POST&#91;'category'&#93;&#41; > 1&#41; &#123;
        $cat_id = "'".implode&#40;"','", $_POST&#91;'category'&#93;&#41;."'";
       // $cat_id = PT_Secure&#40;$cat_id&#41;;
        $category = " AND category_id IN &#40;".$cat_id."&#41; ";
    &#125;
    else&#123;
        $cat_id = PT_Secure&#40;$_POST&#91;'category'&#93;&#91;0&#93;&#41;;
        $category = " AND category_id = '".$cat_id."' ";
    &#125;
    $category_id = $cat_id;
&#125;
if &#40;isset&#40;$_POST&#91;'date'&#93;&#41; && !empty&#40;$_POST&#91;'date'&#93;&#41;&#41; &#123;
    if &#40;$_POST&#91;'date'&#93; == 'last_hour'&#41; &#123;
        $time = time&#40;&#41;-&#40;60*60&#41;;
        $date = " AND time >= ".$time." ";
    &#125;
    elseif &#40;$_POST&#91;'date'&#93; == 'today'&#41; &#123;
        $time = time&#40;&#41;-&#40;60*60*24&#41;;
        $date = " AND time >= ".$time." ";
    &#125;
    elseif &#40;$_POST&#91;'date'&#93; == 'this_week'&#41; &#123;
        $time = time&#40;&#41;-&#40;60*60*24*7&#41;;
        $date = " AND time >= ".$time." ";
    &#125;
    elseif &#40;$_POST&#91;'date'&#93; == 'this_month'&#41; &#123;
        $time = time&#40;&#41;-&#40;60*60*24*30&#41;;
        $date = " AND time >= ".$time." ";
    &#125;
    elseif &#40;$_POST&#91;'date'&#93; == 'this_year'&#41; &#123;
        $time = time&#40;&#41;-&#40;60*60*24*365&#41;;
        $date = " AND time >= ".$time." ";
    &#125;
&#125;

if &#40;$pt->config->total_videos > 1000000&#41; &#123;

    // $get_videos = $db->rawQuery&#40;"SELECT * FROM " . T_VIDEOS . " WHERE MATCH &#40;title&#41; AGAINST &#40;'$keyword'&#41; AND privacy = 0 ".$category.$date." ORDER BY id ASC LIMIT 20"&#41;;

    // pagination system 
    // $get_videos = $db->where&#40;"title LIKE '%$keyword%' AND privacy = 0  ".$category.$date&#41;->orderBy&#40;'id', 'ASC'&#41;->objectbuilder&#40;&#41;->paginate&#40;T_VIDEOS, $pt->page_number&#41;;
    $get_videos = $db->where&#40;"MATCH &#40;title&#41; AGAINST &#40;'$keyword'&#41; AND privacy = 0  ".$category.$date&#41;->orderBy&#40;'id', 'ASC'&#41;->objectbuilder&#40;&#41;->paginate&#40;T_VIDEOS, $pt->page_number&#41;;
    $pt->total_pages = $db->totalPages;
    // pagination system
&#125; else &#123;
    //$get_videos = $db->rawQuery&#40;"SELECT * FROM " . T_VIDEOS . " WHERE title LIKE '%$keyword%' AND privacy = 0 ".$category.$date." ORDER BY id ASC LIMIT 20"&#41;;
    
    // pagination system 
    $get_videos = $db->where&#40;"&#40;title LIKE '%$keyword%' OR tags LIKE '%$keyword%' OR description LIKE '%$keyword%'&#41; AND privacy = 0  ".$category.$date&#41;->orderBy&#40;'id', 'ASC'&#41;->objectbuilder&#40;&#41;->paginate&#40;T_VIDEOS, $pt->page_number&#41;;
    $pt->total_pages = $db->totalPages;
    // pagination system
&#125;
if &#40;!empty&#40;$get_videos&#41;&#41; &#123;
    $len = count&#40;$get_videos&#41;;
    foreach &#40;$get_videos as $key => $video&#41; &#123;
        $video = PT_GetVideoByID&#40;$video, 0, 0, 0&#41;;
        $pt->last_video = false;
        if &#40;$key == $len - 1&#41; &#123;
            $pt->last_video = true;
        &#125;
        $final .= PT_LoadPage&#40;'search/list', array&#40;
            'ID' => $video->id,
            'USER_DATA' => $video->owner,
            'THUMBNAIL' => $video->thumbnail,
            'URL' => $video->url,
            'TITLE' => $video->title,
            'DESC' => $video->markup_description,
            'VIEWS' => $video->views,
            'VIEWS_NUM' => number_format&#40;$video->views&#41;,
            'TIME' => $video->time_ago,
            'DURATION' => $video->duration,
            'VIDEO_ID_' => PT_Slug&#40;$video->title, $video->video_id&#41;,
            'GIF' => $video->gif
        &#41;&#41;;
    &#125;
&#125;
if &#40;empty&#40;$final&#41;&#41; &#123;
	$final = $list;
&#125;

$get_users = $db->rawQuery&#40;"SELECT * FROM " . T_USERS . " WHERE &#40;&#40;`username` LIKE '%$keyword%'&#41; OR CONCAT&#40; `first_name`,  ' ', `last_name` &#41; LIKE  '%$keyword%'&#41; ORDER BY id ASC LIMIT 50"&#41;;
if &#40;!empty&#40;$get_users&#41;&#41; &#123;
    $len = count&#40;$get_users&#41;;
    foreach &#40;$get_users as $key => $user&#41; &#123;
        $user = PT_UserData&#40;$user, array&#40;'data' => true&#41;&#41;;
        $pt->last_user = false;
        if &#40;$key == $len - 1&#41; &#123;
            $pt->last_user = true;
        &#125;
        $final2 .= PT_LoadPage&#40;'search/user-list', array&#40;
            'ID' => $user->id,
            'USER_DATA' => $user,
        &#41;&#41;;
    &#125;
&#125;
// print_r&#40;$_POST&#41;;
// exit&#40;&#41;;
if &#40;empty&#40;$final2&#41;&#41; &#123;
    $final2 = $list2;
&#125;


$pt->videos      = $get_videos;
$pt->users      = $get_users;
$pt->page        = 'search';
$pt->title       = $lang->search . ' | ' . $pt->config->title;
$pt->description = $pt->config->description;
$pt->keyword     = $pt->config->keyword;
$pt->content     = PT_LoadPage&#40;'search/content', array&#40;
    'VIDEOS' => $final,
    'USERS' => $final2,
    'KEYWORD' => $keyword,
    'CAT' => $category_id
&#41;&#41;;

User avatar
dakata__92
Web-tourist
Web-tourist
Posts: 3296
Joined: Tue Aug 02, 2011 7:24 pm
Answers: 126

Post by dakata__92 » Fri Nov 08, 2019 11:11 am

Извади ни само заявките, които ползваш! Виждам че си ги качил, но в случая са ти необходими две неща: Качествена заявка да търси в колоните на таблицата и транслитератор за преобразуване на кирилицата в латиница и обратното.

https://slovored.com/transliteration/rules.html

Post Reply