vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.8 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=235)
-   -   Add-On Releases - [YUI] Live Search (https://vborg.vbsupport.ru/showthread.php?t=204517)

star88 03-24-2009 07:59 AM

Thanks Max for this update
unfortunatly, because non-english characters don't return any result I can't use this great mod on my site.

rmxs 03-24-2009 08:29 AM

Yes max must fix this error (old version was ok :( )

mad@Max 03-24-2009 10:47 AM

With which the old version of hack it work?

fukdawrld 03-24-2009 11:04 AM

Quote:

Originally Posted by mad@Max (Post 1774744)
This is intended:) On my forums search work on all browsers.

You mean its intended to have to click outside the box to pull up results?

rmxs 03-24-2009 02:20 PM

Works with version 1.3
with ajax_search.php

here is the content of this file

Code:

<?php
/*
Live Search v1.3
Writed by: coderphp (https://vborg.vbsupport.ru/member.php?u=174485)
Modify by: mad@Max (https://vborg.vbsupport.ru/member.php?u=209608)
*/
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'ajax_search');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array('global');

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

function utf8_to_win($string){
for ($c=0;$c<strlen($string);$c++){
$i=ord($string[$c]);
if ($i <= 127) @$out .= $string[$c];
if (@$byte2){
$new_c2=($c1&3)*64+($i&63);
$new_c1=($c1>>2)&5;
$new_i=$new_c1*256+$new_c2;
if ($new_i==1025){
$out_i=168;
} else {
if ($new_i==1105){
$out_i=184;
} else {
$out_i=$new_i-848;
}
}
@$out .= chr($out_i);
$byte2 = false;
}
if (($i>>5)==6) {
$c1 = $i;
$byte2 = true;
}
}
return $out;
}

$query = addslashes(trim($_GET['query']));
// if you use cp1251 collation your tables, uncomment below strings
//if (is_browser('opera')){
//  $query = utf8_to_win ($query);
//}
if($query AND $_SERVER['HTTP_REFERER'])
{
    foreach ($vbulletin->userinfo['forumpermissions'] AS $forumid => $fperms)
    {
        if (!($fperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($fperms & $vbulletin->bf_ugp_forumpermissions['cansearch']) OR !verify_forum_password($forumid, $forum['password'], false) OR !($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['indexposts']))
        {
            $excludelist .= ",$forumid";
        }
        else if ((!$vbulletin->GPC['titleonly'] OR $vbulletin->GPC['showposts']) AND !($fperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']))
        {    // exclude forums that have canview but no canviewthreads if this is a post search
            $excludelist .= ",$forumid";
        }
    }

    $results = $db->query_read("SELECT * FROM ". TABLE_PREFIX ."thread WHERE `title` LIKE '%$query%' AND `". TABLE_PREFIX ."thread`.`forumid` NOT IN (0 $excludelist) LIMIT 50");
    if ($db->num_rows($results)> 0)
    {
    while($result = $db->fetch_array($results))
    {
        $trimtitle = 45;
        $lsfid = $result['forumid'];
        $lsttitle = $result['title'];
        $lsalt = $lsttitle;
        if ($trimtitle > 0 && strlen($lsttitle) > $trimtitle)
        { $lsttitle = fetch_trimmed_title($lsttitle, $trimtitle); }
        $lsttitle = preg_replace('/\<[a-zA-Z0-9 \&lt;\<\>\&gt;\:\;\"\'\,\.\?\/\~\`\!\@\#\$\%\^\&\*\(\)\_\-\+\=]*\>/', '', $lsttitle);
//        $lsttitle = preg_replace("#(".$query.")#si", "<span style=\"color: #ff0000; font-weight: bold;\">\\1</span>", $lsttitle);
        $lsttitle = preg_replace("#(".$query.")#si", "<span class=\"highlight\">\\1</span>", $lsttitle);
        $lstid = $result['threadid'];
        $lsftitle = $db->query_first("SELECT title FROM ". TABLE_PREFIX ."forum WHERE forumid = $lsfid LIMIT 1");
        $lsfname = $lsftitle['title'];
        echo "<div style=\"float:left;\"><a href=\"".$vboptions[bburl]."/Vb/showthread.php?t=".$lstid."\" title=\"".$lsalt."\">".$lsttitle."</a></div><div style=\"float:right;\"><a href=\"".$vboptions[bburl]."/Vb/forumdisplay.php?f=".$lsfid."\"><font color=\"#666666\">".$lsfname."</font></a></div><br />";
    }
    }else{
    echo "<div align=\"center\">" . $vbphrase[ls_no_results] . "</div>";
    }
}
?>

I dont have the product and i have unistall it from vb to install this one.

i think here is the tip...
function utf8_to_win($string){
for ($c=0;$c<strlen($string);$c++){
$i=ord($string[$c]);
.............................

mad@Max 03-24-2009 02:26 PM

This function convert utf to windows-1251(cp1251)...

rmxs 03-24-2009 05:05 PM

Quote:

Originally Posted by mad@Max (Post 1775859)
This function convert utf to windows-1251(cp1251)...

Yes i know byt with the old work with non english and with new no. :|
you have try to include this on new version?

mad@Max 03-24-2009 08:11 PM

Version 2.0.4
Previously was a problem that, if after a certain time to begin a search, it will not bring any results. Now the problem is solved (i hope) by using $vbulletin->GPC.

mad@Max 03-24-2009 08:19 PM

rmxs, i can, but I do not know if this will work for all. But you can do this for yourself:
Replace this
PHP Code:

    if (function_exists('iconv'))
    {
        
$query = @iconv('UTF-8'$stylevar['charset'], $query);
    }else
    {
        
$query $query;
    } 

With
PHP Code:

        function utf8_to_win($string)
        {
            for (
$c 0$c strlen($string); $c++)
            {
                
$i ord($string[$c]);
                if (
$i <= 127)
                    @
$out .= $string[$c];
                if (@
$byte2)
                {
                    
$new_c2 = ($c1 3) * 64 + ($i 63);
                    
$new_c1 = ($c1 >> 2) & 5;
                    
$new_i $new_c1 256 $new_c2;
                    if (
$new_i == 1025)
                    {
                        
$out_i 168;
                    } else
                    {
                        if (
$new_i == 1105)
                        {
                            
$out_i 184;
                        } else
                        {
                            
$out_i $new_i 848;
                        }
                    }
                    @
$out .= chr($out_i);
                    
$byte2 false;
                }
                if ((
$i >> 5) == 6)
                {
                    
$c1 $i;
                    
$byte2 true;
                }
            }
            return 
$out;
        }
        
$query utf8_to_win($query); 


rmxs 03-24-2009 08:30 PM

Now this version works without any change :)


All times are GMT. The time now is 05:34 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01871 seconds
  • Memory Usage 1,773KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete