elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Security Series.XSS. [Cross Site Scripting]


  Mostrar Temas
Páginas: 1 [2]
11  Programación / PHP / Laberinto en Php. en: 17 Marzo 2010, 16:21 pm
Hola como estan miren hice un post anteriormente el cual era de hacer un laberinto y poner al lobo y  caperucita. El lObo tiene que ir detras de caperucita Roja mas o menos lo tengo avanzado por el momento le s mostrare el codigo.
Y la duda con la que estoy

Código
  1. <?php
  2.  
  3. //Array que devolverá el laberinto
  4. $array = array(
  5.    array(1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),
  6.    array(1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1),
  7.    array(1,0,1,0,1,1,1,1,0,1,1,1,1,1,0,1,0,0,1,0,1,0,0,1),
  8.    array(1,0,1,0,0,0,0,1,0,1,0,0,0,0,0,1,1,0,1,1,1,0,1,1),
  9.    array(1,0,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,1),
  10.    array(1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,1,0,1,0,1,0,0,1),
  11.    array(1,1,1,0,1,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1),
  12.    array(1,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1),
  13.    array(1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,1),
  14.    array(1,0,1,0,1,0,1,1,1,1,1,1,0,1,0,1,0,0,1,0,1,0,0,1),
  15.    array(1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,1,1),
  16.    array(1,0,1,0,1,0,1,1,1,1,1,0,1,1,0,0,0,1,0,0,1,0,0,1),
  17.    array(1,0,0,0,1,0,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1,0,1,1),
  18.    array(1,0,1,0,0,0,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1),
  19.    array(1,0,1,1,1,0,0,1,0,0,1,0,0,1,0,1,1,1,1,0,1,1,0,1),
  20.    array(1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1),
  21.    array(1,1,1,0,1,1,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,1),
  22.    array(1,0,1,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,1,0,1,0,1),
  23.    array(1,0,1,0,1,0,1,1,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,1),
  24.    array(1,0,0,0,1,0,0,1,0,0,1,0,1,0,1,0,0,0,1,1,0,0,0,1),
  25.    array(1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,1,0,0,1,1,1,0,1),
  26.    array(1,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1),
  27.    array(1,0,1,0,1,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,1),
  28.    array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
  29. );
  30.  
  31. /*
  32. Esta función ubica aleatoriamente (o a través del parámetro $p)
  33. la caperusita en el laberinto. Además, guarda estas posiciones en las
  34. variables $qx y $qy
  35. */
  36. function caperusita(&$array,$p = NULL)
  37. {
  38.    global $qx,$qy;
  39.    if(isset($p) && strlen($p) >= 3) {
  40.        $p = explode(',',$p);
  41.        $t[1] = $p[0];
  42.        $t[0] = $p[1];
  43.    } else {
  44.        $d=count($array);
  45.        $t[0]=rand(0,($d-1));
  46.        $t[1]=rand(0,($d-1));    
  47.    }
  48.    if($array[$t[0]][$t[1]] == 0 && isset($array[$t[0]][$t[1]])) {
  49.        $array[$t[0]][$t[1]] = 2;
  50.        $qx = $t[1];
  51.        $qy = $t[0];
  52.        return TRUE;
  53.    } else {
  54.        return caperusita($array);
  55.    }
  56. }


La duda con la que estoy es como poder hacer el laberinto de manera randomica.
osea la forma.

Código
  1. //Array que devolverá el laberinto
  2. $array = array(
  3.    array(1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),
  4.    array(1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1),
  5.    array(1,0,1,0,1,1,1,1,0,1,1,1,1,1,0,1,0,0,1,0,1,0,0,1),
  6.    array(1,0,1,0,0,0,0,1,0,1,0,0,0,0,0,1,1,0,1,1,1,0,1,1),
  7.    array(1,0,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,1),
  8.    array(1,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,1,0,1,0,1,0,0,1),
  9.    array(1,1,1,0,1,0,0,1,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1),
  10.    array(1,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1),
  11.    array(1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,1),
  12.    array(1,0,1,0,1,0,1,1,1,1,1,1,0,1,0,1,0,0,1,0,1,0,0,1),
  13.    array(1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,1,1),
  14.    array(1,0,1,0,1,0,1,1,1,1,1,0,1,1,0,0,0,1,0,0,1,0,0,1),
  15.    array(1,0,0,0,1,0,0,0,0,0,1,0,0,1,0,1,1,1,1,1,1,0,1,1),
  16.    array(1,0,1,0,0,0,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1),
  17.    array(1,0,1,1,1,0,0,1,0,0,1,0,0,1,0,1,1,1,1,0,1,1,0,1),
  18.    array(1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1),
  19.    array(1,1,1,0,1,1,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,1),
  20.    array(1,0,1,0,1,0,0,0,0,1,1,0,1,0,1,0,1,0,1,1,0,1,0,1),
  21.    array(1,0,1,0,1,0,1,1,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,1),
  22.    array(1,0,0,0,1,0,0,1,0,0,1,0,1,0,1,0,0,0,1,1,0,0,0,1),
  23.    array(1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,1,0,0,1,1,1,0,1),
  24.    array(1,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1),
  25.    array(1,0,1,0,1,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,1),
  26.    array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
  27. );


La funcion de la caperucita sera casi la misma a la del lobo, lo que quiero es poder darle la opcion a que el lobo lo biusqye de manera propia si n necesirdad de intervencion del usuario ...
12  Programación / Programación Visual Basic / Nuevo proyecto !!!! Me colaboran en: 14 Marzo 2010, 00:00 am
Hola como les va muchachos miren estoy volviendo nuevamente a lo que es visual basic y se me ocurrio hacer un laberinto con un personaje x el cual estoy por ver la idea es de poder darle al personaje lo dificil viene a continuacion lo cual no me ubico la idea es de crearle el laberinto dandole un a matriz n * n la cual nosotros la damos, y de crear los obstaculos del laberinto darle un inicio y un final ....
13  Programación / PHP / Micro Tutorial Tratamiento de imagenes en Php en: 27 Noviembre 2009, 15:55 pm
Hola bueno miren queria darles essta ayuda a todos los que trabajan con imagenes le di el nombre de microTutorial por que es mi primero y si tienes fallas me avisas porfavor soy principiante:

NOTA: La informacion la saque de toda parte asi que es un codigo Mixtura (Me refiero que ES CODIGO sacado de varios source)

TRATAMIENTO DE LA IMAGEN
Primero tenemos que aprender a tratar a la imagen con esta pagina lo que hacemos es redimensionar el tamaño y ajustarlo.

Nombre de la pagina img.inc.php

Código
  1. <?php
  2. //TRATAMIENTO DE IMAGENES
  3. //====================================
  4.  
  5. class somaImagen{
  6. var $imagen_recurso; var $imagen_salida;
  7. var $imagen_recurso_ancho; var $imagen_salida_ancho;
  8. var $imagen_recurso_alto; var $imagen_salida_alto;
  9. var $imagen_recurso_desde_x = 0; var $imagen_salida_desde_x = 0;
  10. var $imagen_recurso_desde_y = 0; var $imagen_salida_desde_y = 0;
  11. var $escala; var $imagen_imprimible;
  12. var $rango_menor = 1;
  13. var $rango_mayor = 1000;
  14.  
  15. function validarMedida($valor){
  16. if ($valor>=($this->rango_menor) and $valor<$this->rango_mayor){
  17. return $valor;
  18. }else{
  19. if($valor <= ($this->rango_menor-1) ){return ($this->rango_menor); }
  20. if($valor>= $this->rango_mayor ){return $this->rango_mayor ; }
  21. }
  22. }
  23.  
  24. function crearImagen($imagen){
  25. $this->imagen_recurso = $imagen;
  26. $this->imagen_salida = imagecreatefromjpeg($this->imagen_recurso);
  27. $this->imagen_recurso_ancho = imagesx($this->imagen_salida);
  28. $this->imagen_recurso_alto = imagesy($this->imagen_salida);
  29. }
  30.  
  31.  
  32. function crearSalida($ancho,$alto){
  33. $this->imagen_salida_ancho = $ancho;
  34. $this->imagen_salida_alto = $alto;
  35. $this->imagen_imprimible = imagecreatetruecolor($this->imagen_salida_ancho,$this->imagen_salida_alto);
  36. $this->imagen_imprimible,
  37. $this->imagen_salida,
  38. $this->imagen_recurso_desde_x,
  39. $this->imagen_recurso_desde_y,
  40. $this->imagen_salida_desde_x,
  41. $this->imagen_salida_desde_y,
  42. $this->imagen_salida_ancho,
  43. $this->imagen_salida_alto,
  44. $this->imagen_recurso_ancho,
  45. $this->imagen_recurso_alto
  46. );
  47. imagejpeg($this->imagen_imprimible, NULL,100);
  48. imagedestroy($this->imagen_imprimible);
  49. }
  50.  
  51. function Cuadro($lados,$imagen){
  52. $lados=$this->validarMedida($lados);
  53. $this->crearImagen($imagen);
  54. if ( $this->imagen_recurso_ancho>= $this->imagen_recurso_alto )
  55. {$this->escala=$lados/$this->imagen_recurso_ancho;}
  56.            else
  57. {$this->escala=$lados/$this->imagen_recurso_alto;}
  58. $this->crearSalida($this->imagen_recurso_ancho * $this->escala , $this->imagen_recurso_alto * $this->escala);
  59. }
  60.  
  61. function AnchoMax($ancho,$imagen){
  62. $ancho=$this->validarMedida($ancho);
  63. $this->crearImagen($imagen);
  64. $this->escala=$ancho/$this->imagen_recurso_ancho;
  65. $this->crearSalida($this->imagen_recurso_ancho * $this->escala , $this->imagen_recurso_alto * $this->escala);
  66. }
  67.  
  68.  
  69. function AltoMax($alto,$imagen){
  70. $alto=$this->validarMedida($alto);
  71. $this->crearImagen($imagen);
  72. $this->escala=$alto/$this->imagen_recurso_alto;
  73. $this->crearSalida($this->imagen_recurso_ancho * $this->escala , $this->imagen_recurso_alto * $this->escala);
  74. }
  75.  
  76. function Encuadrar($medida,$imagen,$alineacion){
  77. $medida=$this->validarMedida($medida);
  78. $this->crearImagen($imagen);
  79. if ( $this->imagen_recurso_ancho <= $this->imagen_recurso_alto ){
  80. $this->escala = $this->imagen_salida_ancho/$this->imagen_recurso_ancho;
  81. if($alineacion!=0){
  82. if($alineacion==1){
  83. $this->imagen_salida_desde_y=($this->imagen_recurso_alto-$this->imagen_recurso_ancho);
  84. }
  85. if($alineacion==2){
  86. $this->imagen_salida_desde_y=($this->imagen_recurso_alto-$this->imagen_recurso_ancho)/2;
  87. }
  88. }
  89. $this->imagen_recurso_alto = $this->imagen_recurso_ancho;
  90. }else {
  91. $this->escala = $this->imagen_salida_alto/$this->imagen_recurso_alto;
  92. if($alineacion!=0){
  93. if($alineacion==1){
  94. $this->imagen_salida_desde_x=($this->imagen_recurso_ancho-$this->imagen_recurso_alto);
  95. }
  96. if($alineacion==2){
  97. $this->imagen_salida_desde_x=($this->imagen_recurso_ancho-$this->imagen_recurso_alto)/2;
  98. }
  99. }
  100. $this->imagen_recurso_ancho = $this->imagen_recurso_alto;
  101. }
  102. $this->crearSalida($medida,$medida);
  103. }
  104. }
  105. ?>

14  Programación / PHP / Duda con el manejo de Programacion a wEB en: 27 Noviembre 2009, 15:23 pm
Hola miren estoy con un severo problema yo aprendi a programar en php de una manera autodidacta aprendiendo de mis errores y mejoras.
Ahora toy con una gran duda me indicaron algunos que mi programacion es estructurada otros dinamica, y al final no se aver si alguien me indica de los muchachos que tienen mas experiencia.
Aqui esta mi codigo de mi pagina Principal.

NOTA:
La pagina que estoy desarrollando es de venta online implementando el carrito de compras


Código
  1. <?php
  2. // Configuration
  3. require_once('config.php');
  4.  
  5. // Install
  6. if (!defined('HTTP_SERVER')) {
  7. header('Location: install/index.php');
  8. }
  9.  
  10. // Startup
  11. require_once(DIR_SYSTEM . 'startup.php');
  12.  
  13. // Load the application classes
  14. require_once(DIR_SYSTEM . 'library/customer.php');
  15. require_once(DIR_SYSTEM . 'library/currency.php');
  16. require_once(DIR_SYSTEM . 'library/tax.php');
  17. require_once(DIR_SYSTEM . 'library/weight.php');
  18. require_once(DIR_SYSTEM . 'library/measurement.php');
  19. require_once(DIR_SYSTEM . 'library/cart.php');
  20.  
  21. // Loader
  22. $loader = new Loader();
  23. Registry::set('load', $loader);
  24.  
  25. // Config
  26. $config = new Config();
  27. Registry::set('config', $config);
  28.  
  29. // Database
  30. $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
  31. Registry::set('db', $db);
  32.  
  33. // Settings
  34. $query = $db->query("SELECT * FROM " . DB_PREFIX . "setting");
  35.  
  36. foreach ($query->rows as $setting) {
  37. $config->set($setting['key'], $setting['value']);
  38. }
  39.  
  40. $log = new Logger($config->get('config_error_filename'));
  41. Registry::set('log', $log);
  42.  
  43. // Error Handler
  44. function error_handler($errno, $errstr, $errfile, $errline) {
  45. global $config, $log;
  46.  
  47. switch ($errno) {
  48. case E_NOTICE:
  49. case E_USER_NOTICE:
  50. $error = "Notice";
  51. break;
  52. case E_WARNING:
  53. case E_USER_WARNING:
  54. $error = "Warning";
  55. break;
  56. case E_ERROR:
  57. case E_USER_ERROR:
  58. $error = "Fatal Error";
  59. break;
  60. default:
  61. $error = "Unknown";
  62. break;
  63. }
  64.  
  65.    if ($config->get('config_error_display')) {
  66.        echo '<b>' . $error . '</b>: ' . $errstr . ' in <b>' . $errfile . '</b> on line <b>' . $errline . '</b>';
  67. }
  68.  
  69. if ($config->get('config_error_log')) {
  70. $log->write('PHP ' . $error . ':  ' . $errstr . ' in ' . $errfile . ' on line ' . $errline);
  71. }
  72.  
  73. return TRUE;
  74. }
  75.  
  76. // set to the user defined error handler
  77. set_error_handler('error_handler');
  78.  
  79. // Request
  80. $request = new Request();
  81. Registry::set('request', $request);
  82.  
  83. // Response
  84. $response = new Response();
  85. $response->addHeader('Content-Type', 'text/html; charset=utf-8');
  86. Registry::set('response', $response);
  87.  
  88. // Cache
  89. Registry::set('cache', new Cache());
  90.  
  91. // Url
  92. Registry::set('url', new Url());
  93.  
  94. // Session
  95. $session = new Session();
  96. Registry::set('session', $session);
  97.  
  98. // Document
  99. Registry::set('document', new Document());
  100.  
  101. // Language
  102. $language = new Language();
  103. Registry::set('language', $language);
  104.  
  105. // Customer
  106. Registry::set('customer', new Customer());
  107.  
  108. // Currency
  109. Registry::set('currency', new Currency());
  110.  
  111. // Tax
  112. Registry::set('tax', new Tax());
  113.  
  114. // Weight
  115. Registry::set('weight', new Weight());
  116.  
  117. // Weight
  118. Registry::set('measurement', new Measurement());
  119.  
  120. // Cart
  121. Registry::set('cart', new Cart());
  122.  
  123. // Front Controller
  124. $controller = new Front();
  125.  
  126. // SEO URL's
  127. $controller->addPreAction(new Router('common/seo_url'));
  128.  
  129. // Router
  130. if (isset($request->get['route'])) {
  131. $action = new Router($request->get['route']);
  132. } else {
  133. $action = new Router('common/home');
  134. }
  135.  
  136. // Dispatch
  137. $controller->dispatch($action, new Router('error/not_found'));
  138.  
  139. // Output
  140. $response->output();
  141. ?>
15  Programación / PHP / Dar permisos a los usuarios en login en: 21 Noviembre 2009, 20:20 pm
Bueno mi duda es en dar ciertos permisos especiales a los usuariosm el admin y lo usuarios registrados no se si me pueden colaborar gracias


Código:
session_start();  if (!isset($_SESSION['logeado'])){	if ($_POST['user'] == 'carlos' && $_POST['password'] == 'entrar')	{		session_regenerate_id();		$_SESSION['logeado'] = true;		$_SESSION['token'] = md5(uniqid(rand(), TRUE));			}} else if ($_POST['logout']){	if (isset($_SESSION['token']) &&        	$_POST['token'] == $_SESSION['token'])    	{      		$_SESSION = array();   		session_destroy();    	} } if ($_SESSION['logeado'] == true){   	echo 'Contenido exlusivo' . '<br />';}  ?>  <html> <body> <?php if ($_SESSION['logeado'] == false){?>    <form method='POST' action='login.php'>    User:    	<input name="user" type="text" maxlength="50" size="20" />    Password:    	<input name="password" type="text" maxlength="50" size="20" />    	<input name="login" type="submit" value="Login" />    </form> <?php } else{?>     <form method='POST' action='login.php'>    	<input name="token" type="hidden" value="<?php echo $_SESSION['token']; ?>" />    	<input name="logout" type="submit" value="Logout" />    </form> <?php}?> </body> </html> 


Bueno como hago para enlazar en mi base de datos y me funcione
la tabla se llama usuarios
y tiene los siguientes campos
id
nombre
password
Nivel: dos nivel administrador y usuario normal
16  Foros Generales / Sugerencias y dudas sobre el Foro / Nueva sección de Programacion en: 11 Noviembre 2009, 02:08 am
Hola como estan miren no se si se puede abrir un nuevo sub-foro dentro de lo que es programacion general el sub-foro seria relativo a lo que es Haskell una humilde sugerencia :laugh: :¬¬ :xD
17  Programación / PHP / Login con Php Y ajax en: 9 Noviembre 2009, 03:19 am
Hola como estan queria ver si me pueden colaborar porfavor
con un pequeño formulario en ajax que es de login la idea la tengo pero lo que me falta es el codigo php para la verificacion y validacion del usuario y la contraseña para dar privilegios
Páginas: 1 [2]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines