Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL & ~E_NOTICE);
- define('THIS_SCRIPT', 'S_IRC');
- define('CSRF_PROTECTION', false);
- define('TABLE_PREFIX', 'vb_');
- require_once "./includes/config.php";
- $link = mysql_connect($config['MasterServer']['servername'].':'.$config['MasterServer']['port'], $config['MasterServer']['username'], $config['MasterServer']['password']);
- mysql_select_db($config['Database']['dbname']);
- $text=$_GET['t'];
- $sec=explode(" ",$text);
- $init=($sec[0]=='-i10')?10:0;
- $init=($sec[0]=='-i20')?20:$init;
- $init=($sec[0]=='-i30')?30:$init;
- $init=($sec[0]=='-i40')?40:$init;
- $init=($sec[0]=='-i50')?50:$init;
- $text=($init>0)?str_replace($sec[0],'',$text):$text;
- $sec=($init>0)?$sec[1]:$sec[0];
- $totalres=0;
- $areavalida = array(
- //'0' => 'GERAL',
- '137' => 'FILME',
- '138' => 'MUSICA',
- '139' => 'APPS',
- '140' => 'GAME',
- '181' => 'SERIE',
- '176' => 'ANIME',
- '213' => 'EBOOK',
- '141' => 'SHOW',
- '82' => 'XXX',
- '86' => 'ESPECIAL'
- );
- $camposbusca = array(
- 'up_banda',
- 'up_album',
- 'up_genero',
- 'up_disco_dados',
- 'up_musicas',
- 'up_sinopse',
- 'up_personagens',
- 'up_diretor',
- 'up_trTitulo',
- 'up_orTitulo',
- 'up_escritor',
- 'up_elenco',
- 'up_estilo',
- 'up_descricao',
- 'up_participantes',
- 'up_servidores',
- 'up_idioma',
- 'up_episodio',
- );
- function buscar($area,$chave,$inicio='0')
- {
- global $camposbusca,$totalres;
- //$db->escape_string()
- $chave = preg_replace('#"(.+)"#si', '\\1', $chave);
- $chave = str_replace(array(' ','%20'), '%', $chave);
- $chave = str_replace(array('\'','"','\\','<','>'), '', $chave);
- $porarea=($area == 'zero')?'and (find_in_set(85,f.parentlist) or find_in_set(82,f.parentlist) or find_in_set(86,f.parentlist))':'and find_in_set('.$area.',f.parentlist)';
- $limite = "limit ".$inicio.",10";
- for($x=0;$x<count($camposbusca);$x++)
- {
- $campos.=($campos)?' OR ':'';
- $campos.='u.'.$camposbusca[$x]." like '%".addslashes($chave)."%'";
- }
- $qry = "
- select
- t.title,
- t.threadid,
- t.postusername as username
- from
- ".TABLE_PREFIX."thread t,
- ".TABLE_PREFIX."forum f,
- ".TABLE_PREFIX."up_topico u
- where (t.title like '%".addslashes($chave)."%') and u.threadid = t.threadid and t.forumid = f.forumid $porarea
- order by t.dateline desc
- ";
- $qpre=mysql_query($qry);
- $totalres = mysql_num_rows($qpre);
- $consulta = mysql_query($qry.$limite) or die(mysql_error());
- if ($totalres <= 0) { //sem resultado no titulo, chama outros campos
- $qry = "
- select
- t.title,
- t.threadid,
- t.postusername as username
- from
- ".TABLE_PREFIX."thread t,
- ".TABLE_PREFIX."forum f,
- ".TABLE_PREFIX."up_topico u
- where (t.title like '%".addslashes($chave)."%' OR $campos) and u.threadid = t.threadid and t.forumid = f.forumid $porarea
- order by t.dateline desc
- ";
- $qpre=mysql_query($qry);
- $totalres = mysql_num_rows($qpre);
- $consulta = mysql_query($qry.$limite) or die(mysql_error());
- }
- while($res=mysql_fetch_array($consulta))
- {
- $treads[$res['threadid']]['title'] = $res['title'];
- $treads[$res['threadid']]['username'] = $res['username'];
- }
- return $treads;
- }
- //enviaIrc("testesss");
- //Validando a area
- foreach($areavalida as $key => $value)
- {
- if($value == strtoupper($sec))
- {
- $area = $key;
- $text = str_replace($sec,'',$text);
- }
- }
- if(!$area)
- {
- $area = 'zero';
- }
- print '<pre>';
- print (trim($text) != '')?"Palavras@".$text."\n":"";
- print "Inicio@".$init."\n";
- //Executando a busca
- $resp = buscar($area,trim($text),$init);
- if(!is_array($resp)){ print "Total Res@0\n";exit;}
- if($area != 'zero'){ print "Busca Area@".$areavalida[$area]."\n";}
- print "Total Res@".$totalres."\n";
- if(is_array($resp)) {
- foreach($resp as $threadid => $campo)
- {
- print "[titulo]".$campo['title']."[/titulo]\n";
- print "[INFO]".$threadid."^".$campo['username']."[/INFO]\n";
- }
- }
- print "
- ";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement