-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRespuesta.php
More file actions
130 lines (76 loc) · 2.65 KB
/
Respuesta.php
File metadata and controls
130 lines (76 loc) · 2.65 KB
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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<title>Respuesta</title>
</head>
<body>
<?php
//include './dba.php';
include './map.php'; // se utiliza cuando se quiere leer un archivo
include './map_text.php'; // se utiliza cuando se quiere leer el texto del input
include './reduce.php';
function probar($data){
$data = trim($data); // eliminar chars innecesarios
$data = stripslashes($data); // eliminar backslashs
$data = htmlspecialchars($data); // eliminar chars especiales
$data = strtolower($data);
return $data;
}
function quitar ($l){
$l = str_replace(","," ",$l);
$l = str_replace("."," ",$l);
$l = str_replace(":"," ",$l);
$l = str_replace("\""," ",$l);
$l = str_replace("("," ",$l);
$l = str_replace(")"," ",$l);
return $l;
}
$arreglo=array();
if($_POST['rad']=="write"){ // ingreso por campo de texto
$entrada=probar($_POST['texto']);
$palabra=probar($_POST['palabra']);
//llamar a la funcion map en map_text.php
$arreglo=map_text($entrada);
// aqui está el numero de ocurrencias de la palabra
$fin=$arreglo[$palabra];
if ($fin<1 ){
$fin=0;
}
}else{
if ($_POST['rad']=="upload"){ // ingreso por archivo
copy($_FILES['archivo']['tmp_name'],$_FILES['archivo']['name']);
$nombre=$_FILES['archivo']['name'];
$palabra=probar($_POST['palabra']);
//echo "la palabra es: ".$palabra;
//echo "<br>";
$fl= fopen($nombre, "r") or die("No se pudo abrir el archivo");
//llamar a la funcion map en map.php
$arreglo=map($fl);
// aqui está el numero de ocurrencias de la palabra
$fin=$arreglo[$palabra];
if ($fin<1 ){
$fin=0;
}
}
}
?>
<div class="container resp">
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<label class="text-center" id="tipotext"><h4><b>La palabra </b></h4></label>
<label class="text-center" id="pal"><h4><b>"<?php echo $palabra ?>"</b></h4></label>
<label class="text-center" id="tipotext"><h4><b>aparece un total de:</b></h4></label>
<input type="text" name="resultado" value="<?php echo $fin ?>">
<label class="text-center" id="tipotext"><h4><b> veces</b></h4></label>
</div>
</div>
</div>
</div>
</body>
</html>