Newton 0 Denunciar post Postado Março 2, 2005 Oi Gente ! ^^É o seguinte:Peguei esse codigo fonte abaixo onde ele irá fazer uma busca interna no meu site, só que tem um problema. Pelo o que eu entendi ele esta fazendo a busca nos arquivos txt's (.txt) de onde estão os arquivos do site.Eu quero que ele faça a busca nos .html ou .php e não nos txt's, eu mudei lá onde ele faz a busca no txt e coloquel .html, mas ai dá erro : Notice: Undefined index: texto in c:\arquivos de programas\easyphp1-7\www\busca2.6\index.php on line 30eNotice: Undefined variable: arquivo2 in c:\arquivos de programas\easyphp1-7\www\busca2.6\index.php on line 46Segue o código abaixo: Index.php<html><head><title></title></head><style>.fontNormal { font-family: Verdana; font-size: 10px; color: #333333; font-weight: normal; text-decoration: none; }.fontLink { font-family: Verdana; font-size: 12px; color: #000000; font-weight: normal; text-decoration: none; }.fontLink:hover { font-family: Verdana; font-size: 12px; color: #333333; font-weight: normal; text-decoration: underline; }.inputText { font-family: Verdana; font-size: 10px; color: #333333; font-weight: normal; text-decoration: none; background-color: #F8F8F8; border: 1px solid #333333; height: 20px; width: 200px; padding: 2px; }.inputButton { font-family: Verdana; font-size: 10px; color: #000000; font-weight: normal; text-decoration: none; background-color: #F8F8F8; height: 19px; }</style><body bgcolor="#aabbee"><table align="center"> <tr> <td align="center"> <form name="form1" method="POST" action=""> <input type="text" name="texto" class="inputText"> <input type="submit" name="sb1" value="OK" class="inputButton"> </form> </td> </tr> <tr> <td height="20"></td> </tr> <tr> <td> <? // Variável que quarda // a palavra a ser buscada $texto = $_POST["texto"]; //Definindo Variáveis /* settype($texto,'string'); settype($id,'string'); settype($arquivo,'string'); settype($conteudo,'string'); settype($sentinela,'integer'); */ include("busca.php"); // Variável que guarda // o número de arquivos // contidos no array $contador = count($arquivo2); // Gera o loop exibindo // todos os arquivos em // que foram positiva a pesquisa if( $texto != "" ) { for( $i=0; $i < $contador; $i++ ) { $arquivo = "$arquivo2[$i]"; $arquivoB = "$arquivo3[$i]"; $id = fopen( $arquivo, "r" ); $conteudo = fread( $id, filesize( $arquivo ) ); // Apenas um truque para que alguns // caracteres não dê erro if( $texto == "*" || $texto == "?" || $texto == "+" ) { $texto = "\$texto"; } if( $texto == "[" || $texto == "(" ) { $texto = "çç{%ÇÇÇ"; } // Analiza a palavra inserida, procura // em todos os arquivos colocados no array // e retorna o valor if(eregi( $texto, $conteudo ) ) { echo "<a class=\"fontLink\" href=\"" . $arquivo . "\">" . eregi_replace( $texto, "<b>" . $texto . "</b>", $arquivoB ) . "</a><br>"; $sentinela = "1"; } } // Caso a palavra não exista, a // variável não assume valor algum // e é impressa a mensagem abaixo if( !$sentinela ) { echo "<h6 class=\"inputText\" align=\"center\">Desculpe <br />Essa palavra não foi encontrada</h6>"; } } ?> </td> </tr></table></body></html> busca.php<?phpif(isset($_POST['texto])){$dir = "./";$dh = opendir($dir);$x=0; while (false !== ($filename = readdir($dh))){ if (substr($filename,-4) == ".html") { $lines=file($filename); $arquivo2[$x]= $filename; $arquivo3[$x]= $lines[0]; $x++; } }}?>Espero que algume possa me ajudar...não entendo quase nada de php...to aprendendo ainda... http://forum.imasters.com.br/public/style_emoticons/default/blush.gif Compartilhar este post Link para o post Compartilhar em outros sites
lukascolette 0 Denunciar post Postado Março 2, 2005 da uma olhada aki: http://forum.wmonline.com.br/index.php?showtopic=109190 Compartilhar este post Link para o post Compartilhar em outros sites
Newton 0 Denunciar post Postado Março 2, 2005 da uma olhada aki:http://forum.wmonline.com.br/index.php?showtopic=109190 Eu tentei usar esse codigo ai , mas ele é lerdo e não consigo configurar ele... :huh: Compartilhar este post Link para o post Compartilhar em outros sites
lukascolette 0 Denunciar post Postado Março 2, 2005 kra, ele ja vem configurado tudo certinho, eh soh você mudar o diretorio q você quer q ele pesquise, SOH ISSO . E ele nao eh lerdo naum Compartilhar este post Link para o post Compartilhar em outros sites
Newton 0 Denunciar post Postado Março 3, 2005 kra, ele ja vem configurado tudo certinho, eh soh você mudar o diretorio q você quer q ele pesquise, SOH ISSO . E ele nao eh lerdo naum Consegui fazer o codigo funcionar!!! http://forum.imasters.com.br/public/style_emoticons/default/clap.gif Mas agora estou com um outro problema.... Seguinte: Quero que a busca seje exibida numa nova janela. Como eu consigo fazer isso? E outra coisa: Aparece um erro qndo aparece o resultado da busca.. Warning: file_get_contents(..//Pop/Html): failed to open stream: Permission denied in c:\arquivos de programas\easyphp1-7\www\pop propagandas\pop\buscainterna.php on line 217 O que acontece? Compartilhar este post Link para o post Compartilhar em outros sites
dr1c0 0 Denunciar post Postado Março 18, 2005 http://forum.wmonline.com.br/index.php?showtopic=109190 Copiei o código e modifiquei o que pedia. Mas tá dando um erro aqui, quando ele não acha o que foi pedido tá beleza, mas quando acha retorna um erro: Fatal error: Call to undefined function: file_get_contents() in c:\apache\htdocs\site teste\busca.php on line 233 a linha é essa: $abre = file_get_contents("$diretorio[$i]/$arquivo"); Compartilhar este post Link para o post Compartilhar em outros sites