-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
135 lines (106 loc) · 3.81 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
$pasta_arquivos = "htmls";
$pasta_temp = "temp";
include("funcoes.php");
/*se foi feito o upload*/
if (count($_POST) && count($_FILES) && isset($_FILES['novo_arquivo'])){
/*se for um aqrquivo html*/
if (eregi("(html|htm)$",$_FILES['novo_arquivo']['name'])){
/*move o aarquivo para a pasta*/
move_uploaded_file($_FILES['novo_arquivo']['tmp_name'],$pasta_arquivos . "/" . $_FILES['novo_arquivo']['name']);
}
}
/*pega a lista de arquivos html*/
$paginas = getHTMLFiles($pasta_arquivos);
/* se foi feito um submit do formulario */
if( count($_POST) && isset($_POST['enviar']) ){
/*pega a lista de stopwords*/
$stopwords = getStopWords($_POST['stopwords']);
//se existem stop words
if ( count($stopwords)){
//inclui as configuracoes do banco de dados
include("dados_banco.php");
//faz a conexao
$con = mysql_connect($host,$user,$password);
mysql_select_db($database,$con);
//limpa a base de dados
mysql_query("truncate palavras");
mysql_query("truncate paginas");
mysql_query("truncate palavras_paginas");
/*para cada pagina html em $v*/
foreach ($paginas as $v) {
/*pega o conteudo e manda o resultado para a funcao limpaTags */
$str = limpaTags( file_get_contents( $pasta_arquivos . "/" . $v) );
$sql = "select id from paginas where pagina = '$v'";
$query = mysql_query($sql,$con);
if (!mysql_numrows($query)){
mysql_query("insert into paginas (pagina) values ('$v')",$con);
$id_pagina = mysql_insert_id($con);
}else{
$d = mysql_fetch_assoc($query);
$id_pagina = $d['id'];
}
/*remove as stopwords*/
$palavras = removeStopWords($str, $stopwords,$id_pagina,$con);
//calcula o peso de cada palavra
calculaPeso($palavras,$id_pagina,$con);
}
mysql_close($con);
}else{
echo "<center style='color: red;'>Você deve informar alguma stop word!</center>";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Tópicos Especiais em Computação - Gerson - Gustavo - Cláudio - Marcus Rosa</title>
<style type="text/css">
<!--
*{
font-family: verdana;
font-size: 11px;
}
a{
color: #0000ff;
}
-->
</style>
</head>
<body>
<div align="center">Informe as STOPWORDS separadas por , ( vírgula ) </div><br />
<form method="post" enctype="multipart/form-data">
<div style="text-align: center">
<textarea name="stopwords" style="width: 300px; height: 100px;"></textarea><br />
<input type="submit" name="enviar" value="Gerar banco de dados" />
</div>
<br />
<center><b>Conteúdo da pasta HTML</b></center><br />
<table cellpadding="2" style="margin: 0px auto 0px auto">
<?php
foreach ($paginas as $v) {
echo '<tr>';
echo '<td>
<a href="ver_arquivo.php?arq='. urlencode($pasta_arquivos . "/" . $v) .'" target="_blank">' . $v . '</a>
</td>';
echo '<td>
<a href="ver_arquivo.php?arq='. urlencode($pasta_arquivos . "/" . $v) .'&ver=1" target="_blank">Ver</a>
</td>';
echo '<td><a href="remover.php?arq='. urlencode($pasta_arquivos."/".$v) .'">Remover</a></td>';
echo '</tr>';
}
?>
<tr>
<td colspan="2">
Selecione um arquivo html para fazer o upload para a pasta HTML<br /><input type="file" name="novo_arquivo" /><br /><br />
<input type="submit" name="upload" value="Realizar Upload" />
</td>
</tr>
</table>
<br />
<center><a href="ver_banco.php">Ver banco de dados</a></center><br /><br />
<center><a href="busca.php">Ir para a página de busca</a></center>
</form>
</body>
</html>