Forum Freeglobes

Aide et support, annonces, thèmes et plugins, discussions.

Vous n'êtes pas identifié.

Annonce

Plugin Allopass amélioré: possibilité de générer des codes gratuits pour votre annuaire! Allez voir sur le site :-)

#1 20-04-2010 00:50:56

relisys
Recrue
Date d'inscription: 13-06-2008
Messages: 27

Search isn't showing what im asking

ok so i have quite a few websites with the same name at the end, ect

over 300 web sites with there ending name with "baby shop"

but when i search a name with the key words "tots" baby shop it doesn't give me a procise result  its comes up in the 3rd or 4th page

how do i change the code so it gives me a procise result instead of it been on a diffrent page

here is the code

Code:

<?php
if(isset($_REQUEST["seek"]) and !empty($_REQUEST["seek"]) and strlen($_REQUEST["seek"]) >= $CONFIG['search_minlength'])
{
    $seek = $_REQUEST["seek"];
}
else if(!isset($_REQUEST['id']) || empty($_REQUEST['id']))
{
    $seek = "";
}

if (!empty($seek))
{
    if(isUTF8($seek)) {
        $seek = utf8_decode($seek);
    }
    $seek = strip_tags($seek);
    
    $km =& get_manager("keyword");
    $lm =& get_manager("link");
    $myts =& MyTextSanitizer::getInstance();
    $re = MyRewriteEngine::getInstance();
    
    $my_url = 'index.php?do=recherche&amp;seek='.$seek;
    $start = isset($_GET['start']) ? $_GET['start'] : 0;
    $limit = 10;
    
    $recherche = strtolower($seek);

    $mots = str_replace('+', ' ', trim($recherche));
    $mots = str_replace('\'', ' ', $mots);
    $mots = str_replace('%', ' ', $mots);
    $mots = str_replace(',', ' ', $mots);
    $mots = str_replace(':', ' ', $mots);

    $tab = explode(' ' , $mots);
    $nb = count($tab);
    
    $criteriacompo = new CriteriaCompo(new Criteria('id',0,'='),'OR');

    for($i = 0; $i < $nb; $i++)
    {
        if(strlen($tab[$i]) >= $CONFIG['search_minlength'])
        {
            $criteriacompo->add(new Criteria('name',"%".$tab[$i]."%",'LIKE'),'OR');
            $criteriacompo->add(new Criteria('description',"%".$tab[$i]."%",'LIKE'),'OR');
        }
    }

    $criteriacompo2 = new CriteriaCompo($criteriacompo,'AND');
    $criteriacompo2->add(new Criteria('state',4,'='),'AND');
    
    $total_items = $lm->getCount($criteriacompo2);
    $smarty->assign('total_results',$total_items);
    
    $criteriacompo2->setOrder('DESC');
    $criteriacompo2->setSort('hits');
    $criteriacompo2->setLimit($limit);
    $criteriacompo2->setStart($start);

    // Cols to be selected
    $cols = array('id', 'name', 'url', 'description', 'pr', 'category', 'image', 'hits','vote');
    // retrieving objects
    $links =& $lm->getObjects($criteriacompo2,$cols);
    
    $total_keywords = $km->getCount();
    
    $hasresults = count($links) == 0 ? 0 : 1;
    
    if(count($links) > 0)
    {
        affichage_liens($links, $CONFIG['url_rewriting'], 1);
    }
    else
    {
        // No results
    }
    
    $smarty->assign("resultsfor",$lang['resultsfor']);
    $smarty->assign('searched_expr',$recherche);
    
    $pagenav = new PageNav($total_items, $limit, $start, $my_url);
    
    $smarty->assign('pagenav',$pagenav->renderNavNormal());
    
    if($total_keywords <= $CONFIG['max_keywords'] || $CONFIG['max_keywords'] == 0)
    {
        $criteria = new Criteria('word',$recherche,'=');
        $criteria->setLimit(1);
        $cols = array('occurence');
        $keywords =& $km->getObjects($criteria,$cols);
        
        if(count($keywords) > 0 && !isset($_COOKIE[$recherche]))
        {
            $attributes = array('occurence' => $keywords[0]->getVar('occurence')+1, 'date' => date("Y-m-d"), 'hasresults' => $hasresults);
            $km->update($criteria, $attributes);
        }
        else if(count($keywords) == 0)
        {
            $keyword = $km->create(true);
            $keyword->setVars(array('id' => '', 'word' => $recherche, 'occurence' => 1, 'date' => date("Y-m-d"), 'hasresults' => $hasresults));
            $km->insert($keyword);
        }
        
        // Count only one search per word per day per user
        @ setcookie($recherche,'1', time()+3600*24);
    }
}
else if (!isset($_POST["seek"]))
{
    $directory =& MyDirectory::getInstance();
    $directory->error301('./');
}
else
{
    $smarty->assign("message",$lang['search_moreprecise']);
}
?>

Dernière modification par relisys (20-04-2010 09:38:04)

Hors ligne

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr


BlogCounter
FosseeneProduct - annuaire mon pagerank - films x achats en lignes sexe gratuit blog buzz