Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > Template Shares > Mods & Themes
Reply
  #1  
Old 20th November 2010, 21:54
lateam's Avatar
lateam lateam is offline
Senior Member
 
Join Date: Apr 2009
France
Posts: 40
Default Ajax Search
attention

Attention

coding in course






1. create the plugin

Plugin Name:TESTLATEAM.php

Plugin Title:Rechercher un Torrent

Plugin Content:
PHP Code:
<script src="ajaxsearch.js"></script>
<form name="form1">
<input name="keyword" onKeyUp="SendQuery(this.value)" style="WIDTH:100px" autocomplete="off">
<div align="left" class="box" id="autocomplete" style="WIDTH:200px;BACKGROUND-COLOR:#EDF3DE"></div>
</form>
<script language="JavaScript"> HideDiv("autocomplete"); </script> 
2. create root/ajaxsearch.js

PHP Code:
// AjaxSearch 0.1
// Adding Ajax-like search into your ts 5.6
// By lateam

 
var req;
 
function 
Initialize()
{
    try
    {
        
req=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(
e)
    {
        try
        {
            
req=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(
oc)
        {
            
req=null;
        }
    }
 
    if(!
req&&typeof XMLHttpRequest!="undefined")
    {
        
req = new XMLHttpRequest();
    }
 
}
function 
SendQuery(key)
{
    
Initialize();
    
    var 
url="ajaxsearch.php?s="+key;
 
    if(
req!=null)
    {
        
req.onreadystatechange Process;
        
req.open("GET"urltrue);
        
req.send(null);
 
    }
}
 
function 
Process()
{
    if (
req.readyState == 4)
    {
    
// only if "OK"
        
if (req.status == 200)
        {
            if(
req.responseText=="")
                
HideDiv("autocomplete");
            else
            {
                
ShowDiv("autocomplete");
                
document.getElementById("autocomplete").innerHTML =req.responseText;
            }
        }
        else
        {
            
document.getElementById("autocomplete").innerHTML=
                
"There was a problem retrieving data:<br>"+req.statusText;
        }
    }
}
 
function 
ShowDiv(divid)
{
   if (
document.layersdocument.layers[divid].visibility="show";
   else 
document.getElementById(divid).style.display="inline";
}
 
function 
HideDiv(divid)
{
   if (
document.layersdocument.layers[divid].visibility="hide";
   else 
document.getElementById(divid).style.display="block";
}
 
function 
BodyLoad()
{
    
HideDiv("autocomplete");
    
document.form1.keyword.focus();

2. create root/ajaxsearch.php

PHP Code:
<?
    
// AjaxSearch 0.1
    // by lateam
  
    
    
    
$config['dbhost'] = "localhost";        // Database host
    
$config['dbname'] = "xxxxxxxxx";        // Database name
    
$config['dbusername'] = "xxxxxxxx";            // Database username
    
$config['dbpass'] = "xxxxxxxxxxx";                    // Database password
    
$config['tableprefix'] = "";            // Table prefix
    
    
$config['systemtype'] = "drupal";    // valid choices are: drupal, wordpress
    
$config['maxresult'] = 10;                // Number of results to return
    
$config['maxbodylength'] = 60;            // Trimming body length to x number of characters
    
    
    
    
    
if (isset($_REQUEST['s']) && trim($_REQUEST['s'] != ""))
    {
        if (
$link mysql_connect($config['dbhost'], $config['dbusername'], $config['dbpass']))
        {
            if (
mysql_select_db($config['dbname'], $link))
            {
                switch (
strtolower($config['systemtype']))
                {
                    case 
"drupal":
                        
$storytable "torrents";
                        
$titlefield "name";
                        
$bodyfield "genre";
                        
$storyid "id";
                        
$desturl "details.php?id=--storyid--";
                        break;
                    
                    case 
"wordpress":
                        
$storytable "posts";
                        
$titlefield "post_title";
                        
$bodyfield "post_content";
                        
$storyid "ID";
                        
$desturl "?p=--storyid--";
                        break;
                    
                    default:
                        echo 
"Sorry, search is not available.";        // Oopss ..
                
}
                    
                    
                    
                
$stmt "SELECT * FROM " $config['tableprefix'] . "$storytable WHERE $titlefield LIKE '%" addslashes($_REQUEST['s']) . "%' OR $bodyfield LIKE '%" addslashes($_REQUEST['s']) . "%' LIMIT " $config['maxresult'];
                
                if (
$result mysql_query($stmt$link))
                {
                    if (
mysql_num_rows($result) > 0)
                    {
                        while (
$row mysql_fetch_array($resultMYSQL_ASSOC))
                        {
                            
// stripping images and links...
                            
$contents preg_replace("/<img(.)*>|<a (.)*>|<\/a>/i"""$row[$bodyfield]);
                            if (
strlen($contents) > $config['maxbodylength'])
                                
$contents substr($contents0$config['maxbodylength']) . " ...";
                            
$linkurl = (str_replace("--storyid--"$row[$storyid], $desturl));
                            echo 
"<p style=\"cursor: pointer;\" onclick=\"document.location='$linkurl'\"<strong>" $row[$titlefield] . "</strong> - $contents</p>";
                        }  
                    }
                    else
                        echo 
"Sorry, no record matching your search criteria...";
                }
                else
                    echo 
"Sorry, search is not available.";
            }
            else
                echo 
"Sorry, search is not available.";
        }
        else
            echo 
"Sorry, search is not available.";
    }
    else
        echo 
"<script language=\"JavaScript\">HideDiv(\"autocomplete\");</script>";
?>
Attached Thumbnails
search.png  
Reply With Quote
The Following 6 Users Say Thank You to lateam For This Useful Post:
FENIX (26th January 2013), Fynnon (22nd November 2010), Marco (23rd November 2010), mmisu120000 (22nd November 2010), nicukent (27th February 2011), PAX (5th March 2012)
  #2  
Old 21st November 2010, 23:54
lafouine022 lafouine022 is offline
Senior Member
 
Join Date: Feb 2010
P2P
Posts: 120
Default
fix charset caracter

1. in ajaxsearch.php

find:
PHP Code:
 $config['dbhost'] = "localhost";        // Database host 
replace with:
PHP Code:
header("Content-Type: text/html; charset=iso-8859-1");  
    
$config['dbhost'] = "localhost";        // Database host 
2. in browse.php

find:
PHP Code:
<form method="post" action="'.$_SERVER['SCRIPT_NAME'].'?">
            <
input type="hidden" name="do" value="search" />
            
'.$lang->browse['bykeyword'].' <input type="text" id="auto_keywords" autocomplete="off" name="keywords" size="40" value="'.(isset($keywords) ? htmlspecialchars_uni($keywords) : '').'" />
            <
script type="text/javascript">
                new 
AutoComplete(\'auto_keywords\', \'ts_ajax.php?action=autocomplete&type=torrent&field=name&keyword=\', { delay: 0.25, resultFormat: AutoComplete.Options.RESULT_FORMAT_TEXT });
            </script>
            <select name="search_type">
                <option value="t_name"'
.($search_type == 't_name' ' selected="selected"' '').'>'.$lang->browse['t_name'].'</option>
                <option value="t_description"'
.($search_type == 't_description' ' selected="selected"' '').'>'.$lang->browse['t_description'].'</option>
                <option value="t_both"'
.($search_type == 't_both' ' selected="selected"' '').'>'.$lang->browse['t_both'].'</option>
                <option value="t_uploader"'
.($search_type == 't_uploader' ' selected="selected"' '').'>'.$lang->browse['t_uploader'].'</option>
                <option value="t_genre"'
.($search_type == 't_genre' ' selected="selected"' '').'>'.$lang->browse['t_genre'].'</option>
            </select>
            '
.$lang->browse['in'].'
                '
.$catdropdown.'
            <input type="image" class="none" style="vertical-align: middle;" src="'
.$BASEURL.'/'.$pic_base_url.'torrent_search.gif" alt="'.$lang->browse['tsearch'].'" />
            </form> 
replace with:
PHP Code:
<script src="ajaxsearch.js"></script>
            <form name="form1" method="post" action="'.$_SERVER['SCRIPT_NAME'].'?">

            <input type="hidden" name="do" value="search" />

            '.$lang->browse['bykeyword'].' <input type="text" id="auto_keywords" onKeyUp="SendQuery(this.value)" autocomplete="off" name="keywords" size="40" value="'.(isset($keywords) ? htmlspecialchars_uni($keywords) : '').'" />


            <script type="text/javascript">

                new AutoComplete(\'auto_keywords\', \'ts_ajax.php?action=autocomplete&type=torrent&field=name&keyword=\', { delay: 0.25, resultFormat: AutoComplete.Options.RESULT_FORMAT_TEXT });

            </script>

            <select name="search_type">

                <option value="t_name"'.($search_type == 't_name' ? ' selected="selected"' : '').'>'.$lang->browse['t_name'].'</option>

                <option value="t_description"'.($search_type == 't_description' ? ' selected="selected"' : '').'>'.$lang->browse['t_description'].'</option>

                <option value="t_both"'.($search_type == 't_both' ? ' selected="selected"' : '').'>'.$lang->browse['t_both'].'</option>

                <option value="t_uploader"'.($search_type == 't_uploader' ? ' selected="selected"' : '').'>'.$lang->browse['t_uploader'].'</option>

                <option value="t_genre"'.($search_type == 't_genre' ? ' selected="selected"' : '').'>'.$lang->browse['t_genre'].'</option>

            </select>

            '.$lang->browse['in'].'

                '.$catdropdown.'

            <input type="image" class="none" style="vertical-align: middle;" src="'.$BASEURL.'/'.$pic_base_url.'torrent_search.gif" alt="'.$lang->browse['tsearch'].'" />
<div align="left" class="none" id="autocomplete" style="WIDTH:200px;BACKGROUND-COLOR:#ADCBE7"></div>
            </form><script language="JavaScript"> HideDiv("autocomplete"); </script> 
Reply With Quote
The Following 6 Users Say Thank You to lafouine022 For This Useful Post:
FENIX (26th January 2013), Fynnon (22nd November 2010), Marco (23rd November 2010), mmisu120000 (22nd November 2010), nicukent (27th February 2011), PAX (5th March 2012)
  #3  
Old 22nd November 2010, 09:19
mmisu120000's Avatar
mmisu120000 mmisu120000 is offline
Senior Member
 
Join Date: Jun 2009
P2P
Posts: 202
Default
Yes, guys, works like a charm!

Good job, really nice one...!
__________________
"How terrible is wisdom when it holds no benefit for the wise?" - Louis Cypher
WDW Tracker - Using heavy modified TSSE
Reply With Quote
The Following User Says Thank You to mmisu120000 For This Useful Post:
nicukent (27th February 2011)
  #4  
Old 23rd November 2010, 13:54
Marco Marco is offline
Senior Member
 
Join Date: Jun 2009
Seychelles
Posts: 327
Default
thx guys

for all searches i have sorry , search is not available ...:)
i see this is a reply error line...so please help me .
Reply With Quote
The Following User Says Thank You to Marco For This Useful Post:
nicukent (27th February 2011)
  #5  
Old 23rd November 2010, 14:36
lafouine022 lafouine022 is offline
Senior Member
 
Join Date: Feb 2010
P2P
Posts: 120
Default
1. in ajaxsearch.php

PHP Code:
$config['dbname'] = "xxxxxxxxx";        // Database name
    
$config['dbusername'] = "xxxxxxxx";            // Database username
    
$config['dbpass'] = "xxxxxxxxxxx";                    // Database password 


did you enter the field correctly allocate??
Reply With Quote
The Following User Says Thank You to lafouine022 For This Useful Post:
nicukent (27th February 2011)
  #6  
Old 23rd November 2010, 22:55
Marco Marco is offline
Senior Member
 
Join Date: Jun 2009
Seychelles
Posts: 327
Default
off course if i didn't wright well then i can't connect to DB but i haven't connection error just this .... :)


thank you :)
Reply With Quote
The Following User Says Thank You to Marco For This Useful Post:
nicukent (27th February 2011)
  #7  
Old 24th November 2010, 06:11
lafouine022 lafouine022 is offline
Senior Member
 
Join Date: Feb 2010
P2P
Posts: 120
Wink remplace Genre for seeders
oki yes sorry ^^

you have not installed GENRE MOD
so replace genre by seeders


in ajaxsearch.php

replace:
PHP Code:
switch (strtolower($config['systemtype']))
                {
                    case 
"drupal":
                        
$storytable "torrents";
                        
$titlefield "name";
                        
$bodyfield "genre";
                        
$storyid "id";
                        
$desturl "details.php?id=--storyid--";
                        break; 
with this:
PHP Code:
switch (strtolower($config['systemtype'])) 
                { 
                    case 
"drupal"
                        
$storytable "torrents"
                        
$titlefield "name"
                        
$bodyfield "seeders"
                        
$storyid "id"
                        
$desturl "details.php?id=--storyid--";
                        break; 
and replace this:
PHP Code:
 echo "<p style=\"cursor: pointer;\" onclick=\"document.location='$linkurl'\"<strong>" $row[$titlefield] . "</strong> - $contents</p>"
by this:
PHP Code:
echo "<p style=\"cursor: pointer;\" onclick=\"document.location='$linkurl'\"<font color=navy><b>" $row[$titlefield] . "</b> - $contents Seeders</font></p>"
is work :bubble:

Last edited by lafouine022; 25th November 2010 at 00:20.
Reply With Quote
The Following 4 Users Say Thank You to lafouine022 For This Useful Post:
FENIX (26th January 2013), Marco (16th October 2013), nicukent (27th February 2011), PAX (5th March 2012)
  #8  
Old 5th March 2012, 15:32
PAX's Avatar
PAX PAX is offline
Senior Member
 
Join Date: Nov 2010
P2P
Posts: 41
Default
very good mod, thanks
Reply With Quote
The Following User Says Thank You to PAX For This Useful Post:
z3ro (12th December 2013)
  #9  
Old 12th December 2013, 22:07
z3ro z3ro is offline
Senior Member
 
Join Date: Oct 2010
P2P
Posts: 121
Red face Help!
What is?

install ajax search and not works!

write torrent name and goto logo.

Help! what problem?
Reply With Quote
  #10  
Old 14th December 2013, 10:21
firefly007's Avatar
firefly007 firefly007 is offline
SUPPORT GURU
 
Join Date: Jun 2010
P2P
Posts: 721
Default
Quote:
Originally Posted by Raven View Post
What is?

install ajax search and not works!

write torrent name and goto logo.

Help! what problem?
A little lacking in info :) Could you explain what error you getting.
__________________




Please Support Majority Report


You can contact me on Skype live:phesadent.elect but please let me know first.


If you are ever need me desperately then please email me at dan.oak44@gmail.com and I will contact u within a week.


Due to free time I'm able to help interested member's with their tracker.

Please Note!
Depending on your requests I will charge you for my assistance for Tracker installs and mods.
All my mods are custom and prices will very depending on the request.
I'm able to install any tracker and mods including themes.

Please PM me

Reply With Quote
Reply

Tags
ajax , search

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 18:31. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.