Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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)$/i');
- $reemplazo = array('<div class="tecla">$1</div>','<img src="ico/$1.png" alt="tecla-$1" />');
- $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 >= 1){return $mag;}else{return 'desconocida';}
- }
- 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 = reem($accion);
- }
- $miniatura = $_REQUEST['miniatura'] ;
- $linkjuego = $_REQUEST['linkjuego'] ;
- $nombre = reem($_REQUEST['nombre']) ;
- $descripcion = reem($_REQUEST['descripcion']) ;
- $cat = reem($_POST['cat']) ;
- $cat2 = sanear_string($_POST['cat']);
- $tipo = $_POST['tipo_de_juego'];
- $teclas = serialize($teclas);
- $acciones = serialize($acciones);
- mysql_connect ($db_server, $db_user, $db_passwd) or die ('Error: ' . mysql_error());
- mysql_select_db ($db_name);
- $query="INSERT INTO juegos (miniatura, linkjuego, nombre, descripcion, categoria, cat2, tipo, teclas, acciones) VALUES ('$miniatura', '$linkjuego', '$nombre', '$descripcion', '$cat', '$cat2', '$tipo', '$teclas','$acciones')";
- mysql_query($query) or die ('Error: ' . mysql_error());
- header("location:okay.html")
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement