Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.22 KB | None | 0 0
  1. <?php
  2.         error_reporting(E_ALL & ~E_NOTICE);
  3.         define('THIS_SCRIPT', 'S_IRC');
  4.         define('CSRF_PROTECTION', false);
  5.         define('TABLE_PREFIX', 'vb_');
  6.        
  7.         require_once "./includes/config.php";
  8.         $link = mysql_connect($config['MasterServer']['servername'].':'.$config['MasterServer']['port'], $config['MasterServer']['username'], $config['MasterServer']['password']);
  9.         mysql_select_db($config['Database']['dbname']);    
  10.        
  11.         $text=$_GET['t'];
  12.         $sec=explode(" ",$text);
  13.         $init=($sec[0]=='-i10')?10:0;
  14.         $init=($sec[0]=='-i20')?20:$init;
  15.         $init=($sec[0]=='-i30')?30:$init;
  16.         $init=($sec[0]=='-i40')?40:$init;
  17.         $init=($sec[0]=='-i50')?50:$init;
  18.         $text=($init>0)?str_replace($sec[0],'',$text):$text;
  19.         $sec=($init>0)?$sec[1]:$sec[0];
  20.         $totalres=0;
  21.  
  22.         $areavalida = array(
  23.             //'0' => 'GERAL',
  24.             '137' => 'FILME',
  25.             '138' => 'MUSICA',
  26.             '139' => 'APPS',
  27.             '140' => 'GAME',
  28.             '181' => 'SERIE',
  29.             '176' => 'ANIME',
  30.             '213' => 'EBOOK',
  31.             '141' => 'SHOW',
  32.             '82' => 'XXX',
  33.             '86' => 'ESPECIAL'
  34.         );
  35.         $camposbusca = array(
  36.             'up_banda',
  37.             'up_album',
  38.             'up_genero',
  39.             'up_disco_dados',
  40.             'up_musicas',
  41.             'up_sinopse',
  42.             'up_personagens',
  43.             'up_diretor',
  44.             'up_trTitulo',
  45.             'up_orTitulo',
  46.             'up_escritor',
  47.             'up_elenco',
  48.             'up_estilo',
  49.             'up_descricao',
  50.             'up_participantes',
  51.             'up_servidores',
  52.             'up_idioma',
  53.             'up_episodio',
  54.         );
  55.         function buscar($area,$chave,$inicio='0')
  56.         {
  57.                 global $camposbusca,$totalres;
  58.                 //$db->escape_string()
  59.                 $chave = preg_replace('#"(.+)"#si', '\\1', $chave);
  60.                 $chave = str_replace(array(' ','%20'), '%', $chave);
  61.                 $chave = str_replace(array('\'','"','\\','<','>'), '', $chave);
  62.                 $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)';
  63.                 $limite = "limit ".$inicio.",10";
  64.                 for($x=0;$x<count($camposbusca);$x++)
  65.                 {
  66.                     $campos.=($campos)?' OR ':'';
  67.                     $campos.='u.'.$camposbusca[$x]." like '%".addslashes($chave)."%'";
  68.                 }
  69.                 $qry = "
  70.                         select
  71.                         t.title,
  72.                         t.threadid,
  73.                         t.postusername as username
  74.                            from
  75.                               ".TABLE_PREFIX."thread t,
  76.                               ".TABLE_PREFIX."forum f,
  77.                               ".TABLE_PREFIX."up_topico u
  78.                        
  79.                         where (t.title like '%".addslashes($chave)."%') and u.threadid = t.threadid and t.forumid = f.forumid $porarea
  80.                         order by t.dateline desc
  81.                 ";
  82.                 $qpre=mysql_query($qry);
  83.                 $totalres = mysql_num_rows($qpre);
  84.                 $consulta = mysql_query($qry.$limite) or die(mysql_error());
  85.                
  86.                 if ($totalres <= 0) { //sem resultado no titulo, chama outros campos
  87.                     $qry = "
  88.                             select
  89.                             t.title,
  90.                             t.threadid,
  91.                             t.postusername as username
  92.                                from
  93.                                   ".TABLE_PREFIX."thread t,
  94.                                   ".TABLE_PREFIX."forum f,
  95.                                   ".TABLE_PREFIX."up_topico u
  96.                            
  97.                             where (t.title like '%".addslashes($chave)."%' OR $campos) and u.threadid = t.threadid and t.forumid = f.forumid $porarea
  98.                             order by t.dateline desc
  99.                     ";
  100.                     $qpre=mysql_query($qry);
  101.                     $totalres = mysql_num_rows($qpre);
  102.                     $consulta = mysql_query($qry.$limite) or die(mysql_error());
  103.                 }
  104.                 while($res=mysql_fetch_array($consulta))
  105.                 {
  106.                     $treads[$res['threadid']]['title'] = $res['title'];
  107.                     $treads[$res['threadid']]['username'] = $res['username'];
  108.                 }
  109.                
  110.                 return $treads;
  111.         }
  112.         //enviaIrc("testesss");
  113.        
  114.         //Validando a area
  115.         foreach($areavalida as $key => $value)
  116.         {
  117.             if($value == strtoupper($sec))
  118.             {
  119.                 $area = $key;
  120.                 $text = str_replace($sec,'',$text);
  121.             }
  122.         }
  123.         if(!$area)
  124.         {
  125.             $area = 'zero';
  126.         }
  127.         print '<pre>';
  128.         print (trim($text) != '')?"Palavras@".$text."\n":"";
  129.         print "Inicio@".$init."\n";
  130.         //Executando a busca
  131.         $resp = buscar($area,trim($text),$init);
  132.         if(!is_array($resp)){ print "Total Res@0\n";exit;}
  133.         if($area != 'zero'){ print "Busca Area@".$areavalida[$area]."\n";}
  134.        
  135.         print "Total Res@".$totalres."\n";
  136.         if(is_array($resp)) {
  137.             foreach($resp as $threadid => $campo)
  138.             {
  139.                 print "[titulo]".$campo['title']."[/titulo]\n";
  140.                 print "[INFO]".$threadid."^".$campo['username']."[/INFO]\n";
  141.             }
  142.         }
  143.         print "
  144.         ";
  145. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement