-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvia.php
More file actions
130 lines (107 loc) · 4.27 KB
/
Copy pathenvia.php
File metadata and controls
130 lines (107 loc) · 4.27 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
<?php
require_once(dirname(__FILE__) . '/Settings.php');
function reem($texto1) {
//Rememplazamos caracteres especiales latinos minusculas
$find = array('á', 'é', 'í', 'ó', 'ú', 'ñ', '\"', '€', 'ü', 'Á', 'É', 'Í', 'Ó', 'Ú', 'Ñ', 'Ü', 'ç', 'Ç', '¿', '¡');
$repl = array('á', 'é', 'í', 'ó', 'ú', 'ñ', '"', '€', 'ü', 'Á', 'É', 'Í', 'Ó', 'Ú', 'Ñ', 'Ü', 'ç', 'Ç', '¿', '¡');
$texto1 = str_replace($find, $repl, $texto1);
return $texto1;
}
function tecla2($cadena) {
// Si es una letra o numero de 1 caracter de logitud, se le añadira <div class="tecla">
// Pero si coincide con las palabras flechas,enter etc... se le añadira <img src="" />
$buscarRegex = array('/^([A-ZñÑ0-9]{1})$/i','/^(flechas|enter|control|alt|espacio|der|izq|mover|shift|letras|letrasflechas)$/i','/^([0-9]) - ([0-9])$/i');
$reemplazo = array('<div class="tecla">$1</div>','<img src="ico/$1.png" alt="tecla-$1" />', '<span class="tecla">$1</span> - <span class="tecla">$2</span>');
$mag = preg_replace($buscarRegex, $reemplazo, $cadena,-1,$contador);
// Si las sustituciones son menores a 1, significa que no se ha encontrado el patrón.
if($contador <= 6){return $mag;}else{return 'desconocida';}
}
function tecla3($texto2)
{
$buscar = (' - ');
$reem1 = ('</div> - <div class="table">');
$texto2 = str_replace($buscar, $reem1, $texto2);
return $texto2;
}
function sanear_string($string)
{
$string = trim($string);
$string = str_replace(
array('á', 'à', 'ä', 'â', 'ª', 'Á', 'À', 'Â', 'Ä'),
array('a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A'),
$string
);
$string = str_replace(
array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ê', 'Ë'),
array('e', 'e', 'e', 'e', 'E', 'E', 'E', 'E'),
$string
);
$string = str_replace(
array('í', 'ì', 'ï', 'î', 'Í', 'Ì', 'Ï', 'Î'),
array('i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'),
$string
);
$string = str_replace(
array('ó', 'ò', 'ö', 'ô', 'Ó', 'Ò', 'Ö', 'Ô'),
array('o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'),
$string
);
$string = str_replace(
array('ú', 'ù', 'ü', 'û', 'Ú', 'Ù', 'Û', 'Ü'),
array('u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'),
$string
);
$string = str_replace(
array('ñ', 'Ñ', 'ç', 'Ç'),
array('n', 'N', 'c', 'C',),
$string
);
//Esta parte se encarga de eliminar cualquier caracter extraño
$string = str_replace(
array("\\", "¨", "º", "-", "~",
"#", "@", "|", "!", "\"",
"·", "$", "%", "&", "/",
"(", ")", "?", "'", "¡",
"¿", "[", "^", "`", "]",
"+", "}", "{", "¨", "´",
">", "< ", ";", ",", ":",
".", " "),
'',
$string
);
return strtolower($string);
}
/* Por cada campo de tecla ... */
foreach($_POST['tecla'] as $tecla){
/* Le pasamos tecla2 y le agregamos a un array. */
$teclas[] = tecla2($tecla);
}
/* Lo mismo con las acciones.. */
foreach($_POST['accion'] as $accion){
$acciones[] = $accion;
}
$miniatura = $_REQUEST['miniatura'] ;
$linkjuego = $_REQUEST['link_juego'] ;
$nombre = $_REQUEST['nombre'] ;
$descripcion = $_REQUEST['descripcion'] ;
$cat = $_POST['cat'] ;
$cat2 = sanear_string($_POST['cat']);
$tipo = $_POST['tipo_de_juego'];
$teclas = serialize($teclas);
$acciones = serialize($acciones);
$ancho = $_POST['ancho'];
$alto = $_POST['alto'];
$code = $_POST['code'];
session_start();
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') {
echo "<script>alert('El c\u00f3digo es err\u00f3neo.');
window.history.back();</script>";
} else {
mysql_connect ($db_server, $db_user, $db_passwd) or die ('Error: ' . mysql_error());
mysql_select_db ($db_name);
mysql_query ("SET NAMES 'utf8'");
$query="INSERT INTO juegos (miniatura, linkjuego, nombre, descripcion, categoria, cat2, tipo, teclas, acciones, ancho, alto, code) VALUES ('$miniatura', '$linkjuego', '$nombre', '$descripcion', '$cat', '$cat2', '$tipo', '$teclas','$acciones', '$ancho', '$alto', '$code')";
mysql_query($query) or die ('Error: ' . mysql_error());
header("location:okay.html");
};
?>