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

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Temas
Páginas: [1] 2 3 4 5
1  Seguridad Informática / Nivel Web / Evitar cookie nula en php en: 18 Octubre 2009, 04:42 am
Hola, me gustaría preguntar de qué manera se puede evitar una cookie nula.

Por ejemplo, en un sitio existía un mecanismo de autenticación algo así (los nombres los he cambiado):

/adm/control.php
Código:
<?php
session_start();
if ($_SESSION['auth'] != 'YES') {
    header('Location: index.php');
}
echo 'Panel de admin';
?>

/adm/index.php
Código:
<?php
echo 'No logeado';
?>

y al acceder a /adm/control.php se va a index.php porque no está registrada la variable de sesión.
Pero si modifico el contenido de la Cookie con tamper data así:

Código:
PHPSESSID=

Se produce lo siguiente:

Código:
Warning: session_start() [function.session-start]: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in C:\sitio\adm\control.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\sitio\adm\control.php:3) in C:\sitio\adm\control.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\sitio\adm\control.php:3) in C:\sitio\adm\control.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at C:\sitio\adm\control.php:3) in C:\sitio\adm\control.php on line 5
Panel de admin

Entonces, mi pregunta es cómo evitar que session_start() se caiga ante un ataque así.

2  Programación / PHP / Ayuda con sistema de login en: 13 Octubre 2009, 22:14 pm
Hola, estoy intentando desarrollar un sistema de login en php, al parecer todo funciona bien, pero lo que no me funciona es el sistema anti session hijacking.
Quisiera saber si alguien me puede ayudar a encontrar el problema.

Para probar el csrf, una vez logueado con tamper data trato de enviar logout pero eliminando el t= Entonces dice csrf attempt.

Pero para probar session hijacking, no me funciona el tema del $fingerprint, una vez logueado, abro otra pestaña con firefox, y accedo a la url viendo el contenido exlusivo, si abro otra pestaña y accedo a la url, pero modificando el user agent, no se cae, diciendo session hijacking attempt, como que no cambia la cadena $fingerprint, y ese es el problema que tengo.

Si alguien por favor también pudiera darme sugerencias para hacer un buen sistema de login, se lo agradecería también.

Código
  1. //editado porque no estaba bueno. Abajo encuentran un código más decente.
  2.  
3  Programación / PHP / Filtro SQL Injection y Filtro XSS en: 13 Octubre 2009, 06:20 am
Aquí comparto dos funciones que hice para prevenir sql injection y xss.

El código está en base64, una vez que lo decodifican, pueden guardarlo como Filtros.php y requerirlo en su script.


Código:
PD9waHANCg0KIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjDQojIEZpbHRybyBw
YXJhIGV2aXRhciBTUUwgSW5qZWN0aW9uICMNCiMgdmVyc2lvbjogMC4xICAgICAgICAgICAgICAg
ICAgICAgIw0KIyBBdXRvcjogMHgwMzA5ICAgICAgICAgICAgICAgICAgICAjDQojIyMjIyMjIyMj
IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMNCmZ1bmN0aW9uIGFudGlTUUxJbmplY3Rpb24oJHN0
cikNCnsNCiAgICBpZiAoaXNfc3RyaW5nKCRzdHIpKSB7DQogICAgICAgICAvL2VuIHBocCA2IG1h
Z2ljIHF1b3RlcyB5YSBubyB2YW4NCiAgICAgICAgaWYgKGdldF9tYWdpY19xdW90ZXNfZ3BjKCkp
IHsNCiAgICAgICAgICAgICRzdHIgPSBzdHJpcHNsYXNoZXMoJHN0cik7DQogICAgICAgIH0NCiAg
ICAgICAgJHN0ciA9IG15c3FsX3JlYWxfZXNjYXBlX3N0cmluZygkc3RyKTsNCiAgICAgICAgJHN0
ciA9IGFkZGNzbGFzaGVzKCRzdHIsICclXycpOw0KICAgIH0NCiAgICByZXR1cm4gJHN0cjsNCn0N
Cg0KIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIw0KIyBGaWx0cm8g
cGFyYSBldml0YXIgQ3Jvc3MtU2l0ZSBTY3JpcHRpbmcgIw0KIyB2ZXJzaW9uOiAwLjEgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIw0KIyBBdXRvcjogMHgwMzA5ICAgICAgICAgICAgICAgICAg
ICAgICAgICAgIw0KIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIw0K
ZnVuY3Rpb24gYW50aUNyb3NzU2l0ZVNjcmlwdGluZygkc3RyKQ0Kew0KICAgIGlmIChpc19zdHJp
bmcoJHN0cikpIHsNCiAgICAgICAkc3RyID0gaHRtbGVudGl0aWVzKCRzdHIsIEVOVF9RVU9URVMs
ICdVVEYtOCcpOw0KICAgIH0NCiAgICByZXR1cm4gJHN0cjsNCn0NCg0KPz4=

y pueden usarlo así:

Código:
//Para consultas a base de datos:
//Si el campo id de la base de datos es string :
$id = antiSQLInjection( $_POST['id'] );
//Sino si el campo id de la base de datos es entero:
$id = (int) $_POST['id'];

$query = "select nombre from usuario where id='{$id}'";
mysql_query($query);


//Para imprimir:
echo antiCrossSiteScripting($_POST['texto']);


4  Programación / PHP / Pegar imagenes en php en: 12 Octubre 2009, 22:04 pm
Hola, tengo un pequeño problema, estoy generando imagenes de niveles de sokoban dinámicamente.

El problema es que para que en pantalla se muestre algo así:



Este es el código que genero con php:

Código
  1. <img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><br/>
  2. <img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><br/>
  3. <img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/box.gif" width="16" height="16"  /><img src="http://midominio/images/player.gif" width="16" height="16"  /><img src="http://midominio/images/box.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><br/>
  4. <img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/box.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/box.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><br/>
  5. <img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/goal.gif" width="16" height="16"  /><img src="http://midominio/images/goal.gif" width="16" height="16"  /><img src="http://midominio/images/goal.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><br/>
  6. <img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/box.gif" width="16" height="16"  /><img src="http://midominio/images/goal.gif" width="16" height="16"  /><img src="http://midominio/images/goal_box.gif" width="16" height="16"  /><img src="http://midominio/images/goal.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><br/>
  7. <img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/goal.gif" width="16" height="16"  /><img src="http://midominio/images/goal_box.gif" width="16" height="16"  /><img src="http://midominio/images/goal.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><br/>
  8. <img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/box.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><br/>
  9. <img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/box.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><br/>
  10. <img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><br/>
  11. <img src="http://midominio/images/floor.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/wall.gif" width="16" height="16"  /><img src="http://midominio/images/floor.gif" width="16" height="16"  /><br/>
  12. <br/>
  13.  

Y obviamente, el htm generado pesa mucho, por lo que tendré problemas de ancho de banda, por ejemplo, para unos 100 niveles, el htm pesa más de un mega.

Tengo pensado evitar:

width="16" height="16

y poner class="algo" y especificar el tamaño con css.

Sin embargo de todas formas, es mucho código, así es que me gustaría poder pegar todas las imagenes, ¿se puede hacer con php dinámicamente? y así generar una sola imagen para que el htm quede:

<img src="http://midominio/images/imagenGenerada.gif"  />

Si se puede, podría generar todas las imágenes, y subirlas a otro hosting, por ejemplo imageshack, así me ahorro un montón de ancho de banda.


Nota: cada cuadro de 16*16 de la imagen que muestro es una imagen, por ejemplo: wall.gif es el bloque de muralla, floor.gif es el bloque negro, etc.
5  Programación / PHP / Sugerencia login en: 7 Octubre 2009, 07:44 am
Hola, estoy recién comenzando a jugar con las sesiones, quisiera recibir por favor sugerencias sobre este script para comprender bien la lógica.
Edito: tenía un problema, pero edito, ahora me gustaría recibir sugerencias sobre cómo mejorar el script.


Le he añadido protección básica contra fijación de sesiones y cross site request forgeries.

Código
  1. <?php
  2.  
  3.  
  4.  
  5. if (!isset($_SESSION['logeado']))
  6. {
  7. if ($_POST['user'] == 'carlos' && $_POST['password'] == 'entrar')
  8. {
  9. $_SESSION['logeado'] = true;
  10. $_SESSION['token'] = md5(uniqid(rand(), TRUE));
  11. }
  12. } else if ($_POST['logout'])
  13. {
  14. if (isset($_SESSION['token']) &&
  15.         $_POST['token'] == $_SESSION['token'])
  16.     {
  17.       $_SESSION = array();
  18.     }
  19.  
  20. }
  21.  
  22. if ($_SESSION['logeado'] == true)
  23. {
  24.   echo 'Contenido exlusivo' . '<br />';
  25. }
  26.  
  27.  
  28. ?>
  29.  
  30.  
  31. <html>
  32.  
  33. <body>
  34.  
  35. <?php
  36.  
  37. if ($_SESSION['logeado'] == false)
  38. {
  39. ?>
  40.    <form method='POST' action='login.php'>
  41.    User:
  42.     <input name="user" type="text" maxlength="50" size="20" />
  43.    Password:
  44.     <input name="password" type="text" maxlength="50" size="20" />
  45.     <input name="login" type="submit" value="Login" />
  46.    </form>
  47.  
  48. <?php
  49. } else
  50. {
  51. ?>
  52.  
  53.    <form method='POST' action='login.php'>
  54.     <input name="token" type="hidden" value="<?php echo $_SESSION['token']; ?>" />
  55.     <input name="logout" type="submit" value="Logout" />
  56.    </form>
  57.  
  58. <?php
  59. }
  60. ?>
  61.  
  62. </body>
  63.  
  64. </html>
  65.  
  66.  
6  Programación / PHP / Se puede tener una configuración personalizada de php en un servidor compartido? en: 6 Octubre 2009, 06:56 am
Tengo esa duda:
¿Se puede tener una configuración personalizada de php en un servidor compartido?

Me gustaría contratar un hosting barato (compartido), pero me gustaría tener mi configuración personal de php, por ejemplo, deshabilitar las magic quotes, y establecer la conexión por defecto a la bd dentro de la configuración de php, así me evito exponer los datos de la bd innecesariamente.

Mi pregunta es si se puede.
7  Programación / Scripting / Bug batch. en: 1 Octubre 2009, 08:33 am
Yo había leído en un sitio que para asignar con el comando set es lo mismo:

Código:
set "variable=valor"

que

Código:
(set variable=valor)

Sin embargo, he encontrado un bug de cmd.exe.

Cuando cmd.exe reconoce una sola comilla dentro de paréntesis termina el archivo por lotes.

Por eso si se hace:

Código:
(")
el archivo por lotes termina.

Por eso si tenemos el siguiene código:

test.cmd
Código:
@echo off
(set var=%1)
echo.El texto se muestra.

y ejecutamos:

Código:
test.cmd "
el texto no se muestra porque el archivo por lotes concluyó antes por el bug.

Pero si hacemos:

test.cmd
Código:
@echo off
set "var=%1"
echo.El texto se muestra.

el texto si es mostrado.

Entonces no es lo mismo:
Código:
(set variable=valor)
que contiene el bug.

que:

Código:
set "variable=valor"

8  Programación / Scripting / Error reply [batch] en: 30 Septiembre 2009, 22:28 pm
Hola sin querer creo haber encontrado un problema del comando reply alias keyboard.

keyboard.com
14 bytes
Código:
:reply
(
echo.N REPLY.COM;O KEYBOARD.COM
echo.E 0000 B4 08 CD 21 3C 00 75 02 CD 21 B4 4C CD 21
echo.R CX
echo.000E
echo.W0
echo.Q
echo.
) | debug

Cuando lo ejecutan con tabla de códigos 1252 sale un mensaje:

Código:
chcp 1252
reply.com
3íÆž è®ôè&s       ítè ë Æ”œè sÚëøëù^_ZY[XÃSQRWVœèf ƒ>ð @

         - 1252,

Solución, llamar a reply.com redirigiendo salida a nul:

Código:
reply.com > nul

Creo que será necesario siempre redirigir la salida a nul para evitar posibles mensajes. :)

También, si le dan como entrada a reply nul se queda "colgado".

Código:
reply.com < nul

Alternativa a reply.com:

getkey.com de Herbert Kleebauer
137 bytes
Código:
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>getkey.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>getkey.com
echo L?p{KsUWK`LR0x>>getkey.com


9  Programación / Scripting / Respaldo towel.blinkenlights.nl en: 27 Septiembre 2009, 23:57 pm
Hace tiempo quise hacer esto, y pensé que no se podía, hacer un respaldo de la animación de star wars de towel.blinkenlights.nl

Para verla:
Código:
telnet.exe towel.blinkenlights.nl

Yo intentaba hacer:

Código:
telnet.exe towel.blinkenlights.nl > respaldo.txt

y no funcionó.

Al final, desistí, pero hoy, leyendo la ayuda del comando telnet.exe me acordé de esto y ya conseguí hacer el respaldo.

Es así:

Código
  1. telnet.exe -f respaldo.txt towel.blinkenlights.nl

De esa forma, todo lo que se ve va quedando en el archivo de texto.

Más o menos queda así:

Código:
                                           /~\
                                          |oo )
                                          _\=/_
                          ___            /  _  \
                         / ()\          //|/.\|\\
                       _|_____|_        \\ \_/  ||
                      | | === | |        \|\ /| ||
                      |_|  O  |_|        # _ _/  #
                       ||  O  ||          | | |
                       ||__*__||          | | |
                      |~ \___/ ~|         []|[]
                      /=\ /=\ /=\         | | |
      ________________[_]_[_]_[_]________/_]_[_\_________________________
                                           /~\
                                          |oo )    Did you hear that?
                                          _\=/_
                          ___            /  _  \
                         / ()\          //|/.\|\\
                       _|_____|_        \\ \_/  ||
                      | | === | |        \|\ /| ||
                      |_|  O  |_|        # _ _/ #
                       ||  O  ||          | | |
                       ||__*__||          | | |
                      |~ \___/ ~|         []|[]
                      /=\ /=\ /=\         | | |
      ________________[_]_[_]_[_]________/_]_[_\_________________________
                                           /~\
                                          |oo )
                                          _\=/_
                          ___            /  _  \
                         / ()\          //|/.\|\\
                       _|_____|_        \\ \_/  ||
                      | | === | |        \|\ /| ||
                      |_|  O  |_|        # _ _/ #
                       ||  O  ||          | | |
                       ||__*__||          | | |
                      |~ \___/ ~|         []|[]
                      /=\ /=\ /=\         | | |
      ________________[_]_[_]_[_]________/_]_[_\_________________________
                                           /~\
                                          |oo )
                                          _\=/_
                          ___         #  /  _  \
                         / ()\        \\//|/.\|\\
                       _|_____|_       \/  \_/  ||
                      | | === | |         |\ /| ||
                      |_|  O  |_|         \_ _/ #
                       ||  O  ||          | | |
                       ||__*__||          | | |
                      |~ \___/ ~|         []|[]
                      /=\ /=\ /=\         | | |
      ________________[_]_[_]_[_]________/_]_[_\_________________________
                                           /~\
                                          ( oo|    They've shut down
                                          _\=/_    the main reactor.
                          ___         #  /  _  \
                         / ()\        \\//|/.\|\\
                       _|_____|_       \/  \_/  ||
                      | | === | |         |\ /| ||
                      |_|  O  |_|         \_ _/  #
                       ||  O  ||          | | |
                       ||__*__||          | | |
                      |~ \___/ ~|         []|[]
                      /=\ /=\ /=\         | | |
      ________________[_]_[_]_[_]________/_]_[_\_________________________
                                           /~\
                                          ( oo|    They've shut down
                                          _\=/_    the main reactor.
                          ___         #  /  _  \
                         / ()\        \\//|/.\|\\
                       _|_____|_       \/  \_/  ||
                      | | === | |         |\ /| ||
                      |_|  O  |_|         \_ _/   #
                       ||  O  ||          | | |
                       ||__*__||          | | |
                      |~ \___/ ~|         []|[]
                      /=\ /=\ /=\         | | |
      ________________[_]_[_]_[_]________/_]_[_\_________________________

Sin embargo, esto genera una salida imprimible, para un verdadero respaldo se puede usar el putty y activar en Session -> Logging: All session output.
De esa forma tienen el texto con las secuencias de escape.
Por ejemplo:

Código:
                                           /~\                           
                                          |oo )         At last!         
                                          _\=/_                         
                          ___            /  _  \                         
                         / ()\          //|/.\|\\                       
                       _|_____|_       ||  \_/  ||                       
                      | | === | |      || |\ /| ||                       
                      |_|  O  |_|       # \_ _/ #                       
                       ||  O  ||          | | |                         
                       ||__*__||          | | |                         
                      |~ \___/ ~|         []|[]                         
                      /=\ /=\ /=\         | | |                         
      ________________[_]_[_]_[_]________/_]_[_\_________________________
10  Programación / PHP / Ayuda con header [solucionado] en: 25 Septiembre 2009, 06:49 am
Hola, tengo un pequeño problema y quisiera pedirles ayuda por favor para solucionarlo.

[ya lo solucioné]

Estoy escribiendo un conversor de archivos en php, para ello ya tengo listo y probado el upload y funciona bien, pero quiero que una vez comprobé que el archivo subido es correcto, proceder a la conversión y que aparezca para descargarlo, de lo contrario que muestre el mensaje de error.

este es un código con la idea, y con el problema.

Código
  1. <?php
  2.  
  3. header('Content-Type: text/plain');
  4. header('Content-Disposition: attachment; filename=' . '"' . 'convertido.txt' . '"');
  5.  
  6. ?>
  7.  
  8. <?
  9.  
  10. $archivoValido = 0;
  11.  
  12. if ($archivoValido == 1)
  13. {
  14. echo "Esto va dentro del archivo: convertido.txt";
  15. }
  16. else
  17. {
  18. // Que debo hacer para el mensaje de error en la página.?
  19. echo "Error. que esto se muestre en la pagina";
  20. }
  21.  
  22.  
  23.  
  24. ?>
  25.  

edito: al final la solución era usar un solo bloque de código php, y especificar los headers solo en la sección correspondiente. Al final queda así:

Código
  1. <?
  2.  
  3. $archivoValido = 0;
  4.  
  5. if ($archivoValido == 1)
  6. {
  7.       header('Content-Type: text/plain');
  8.        header('Content-Disposition: attachment; filename=' . '"' . 'convertido.txt' . '"');
  9. echo "Esto va dentro del archivo: convertido.txt";
  10. }
  11. else
  12. {
  13. // Que debo hacer para el mensaje de error en la página.?
  14. echo "Error. que esto se muestre en la pagina";
  15. }
  16.  
  17.  
  18.  
  19. ?>
  20.  

Páginas: [1] 2 3 4 5
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines