<?php /************************************************* Esse arquivo recebe o site que o usu�rio digita diretamente no site. Sistema desenvolvido por Noedir C. Filho http://www.constantweb.com.br - 2010 **************************************************/ session_start(); include_once "classes/conecta.class.php"; $via = new mysqlConn(); if ($_POST['manda'] == "sim") { $sql = "SELECT * FROM tbl_site WHERE sit_url = '{$_POST['url']}'"; $nbus = $via->totalRegistros($sql); if ($nbus < 1) { $via->setAcao("insert"); $via->setTabela("tbl_acre"); $via->setCampos("acr_url"); $via->setValores("'" . $_POST['url'] . "'"); $via->executa(); echo '<script type="text/javascript"> alert("Dados cadastrados com sucesso.\\r\\n\\r\\nSerão indexados em até 24 horas."); location.href="index.php"; </script>'; } else { echo '<script type="text/javascript"> alert("Esse site já está cadastrado no sistema.\\r\\n\\r\\nExperimente inserir um diretório."); location.href="acrescenta.php"; </script>'; }
/************************************************* Esse arquivo pega os sites cadastrados e faz a varredura para acrescentar na tabela sites. Isso � feito diariamente �s 3 da manh�. Sistema desenvolvido por Noedir C. Filho http://www.constantweb.com.br - 2010 **************************************************/ include_once "classes/conecta.class.php"; $via = new mysqlConn(); //Pega as informa��es da tabela ACRE $sql = "SELECT * FROM tbl_acre WHERE acr_indexado = 'n'"; $qr = $via->consulta($sql); set_time_limit(0); while ($sit = $qr->fetch(PDO::FETCH_ASSOC)) { $jacds = $via->totalRegistros("SELECT * FROM tbl_site WHERE sit_url = '" . $sit['acr_url'] . "'"); if ($jacds < 1) { //Verifica se possui o http:// ou https:// $conta = substr_count($sit['acr_url'], "http://"); $conta += substr_count($sit['acr_url'], "https://"); if ($conta >= 1) { //Verifica se o site existe realmente $head = get_headers($sit['acr_url']); $header = substr_count($head[0], "200"); if ($header >= 1) { //Pega o conte�do todo do site. $pega = file_get_contents($sit['acr_url']); // Armazena o conte�do em outra vari�vel $tti = $pega; //Retira algumas tags que n�o s�o necess�rios $pega = ereg_replace('<script.*</script>', '', $pega);
$dom = new DOMDocument(); while ($sit = $qr->fetch(PDO::FETCH_ASSOC)) { @$dom->loadHTML(file_get_contents($sit['acr_url'])); $tags = $dom->getElementsByTagName("a"); foreach ($tags as $tag) { $link = $tag->getAttribute('href'); if ($link != "") { echo $link . "<br>"; } $ver = substr_count($link, "http://"); $ver += substr_count($link, "https://"); if ($ver >= 1) { $head = get_headers($link); $header = substr_count($head[0], "200"); if ($header >= 1) { $check = $via->totalRegistros("SELECT * FROM tbl_acre WHERE acr_url = '{$href}'"); if ($check <= 0 && $link != "") { $via->setAcao("insert"); $via->setTabela("tbl_acre"); $via->setCampos("acr_url"); $via->setValores("'{$link}'"); $via->executa(); } else { $via->setAcao("delete"); $via->setTabela("tbl_acre"); $via->setCdg("acr_codigo = '{$sit['acr_codigo']}'"); $via->executa(); } } else { $via->setAcao("delete"); $via->setTabela("tbl_acre");