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

 

 


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


  Mostrar Mensajes
Páginas: [1]
1  Programación / PHP / Re: problema con Cookies en: 29 Octubre 2008, 05:00 am
gracias me funciono lo de $_SESSION[]  ;D

saludos
2  Programación / PHP / Re: problema con Cookies en: 28 Octubre 2008, 03:35 am
no funciona me sigue dando el mismo error

alguien puede ayudarme ?
3  Programación / PHP / problema con Cookies en: 27 Octubre 2008, 06:34 am
tengo un problema al crear una Cookie y me tira el siguiente error

Warning: Cannot modify header information - headers already sent by (output started at /login.php:9)

este es el codigo

login.php
Código
  1. <form name=login action=login.php method=post>
  2. Usuario: <input type=text name=user size=20><br>
  3. contraseña: <input type=password name=pass size=20> <input type=submit name=entrar value=conectar>
  4. </form>
  5.  
  6. <?php
  7.  
  8. $clave = sha1("123456");
  9.  
  10. if(@$_COOKIE[USER_COOKIE] == $clave)
  11. {
  12.   echo "Bienvenido";
  13.   echo "<a href='paginaprivada.php'><br><br>Go to</a>";
  14. }else{
  15.  
  16. if(@$_REQUEST['entrar']=="conectar")
  17. {
  18.  
  19. $user = $_POST['user'];
  20. $password = $_POST['pass'];
  21.  
  22. $passwordsha1 = sha1($password);
  23.  
  24. if($passwordsha1 == $clave)
  25. {  
  26.   echo "Bienvenido $user";
  27.   setcookie(@USER_COOKIE,$passwordsha1, time()+3600);
  28.   echo "<a href='paginaprivada.php'><br><br>Go to</a>";
  29. }else{
  30.   echo "<br>Contraseña incorrecta</p>";
  31. }
  32.  
  33. }
  34. }
  35. ?>

el error solo me lo da en el web hosting ya lo probe localmente y funciona bien, tambien eh probado cambiandole nombre a la cookie y igual subi al hosting un blog que utilizaba cookies y no tira ningun error entonces me fije en el codigo de el blog y veo que hace como una estructura para la cookie y no entiendo muy bien el codigo de el blog alguien me prodria explicar algo al respecto.

este es el codigo de el blog que subi para probar y no tiene ningun problema

Código
  1. <?php
  2.  
  3. function cookie_setup() {
  4.  
  5. global $fp_config;
  6.  
  7. // md5(BLOG_BASEURL);
  8.  
  9. if ( !defined('COOKIEHASH') )
  10. define('COOKIEHASH', $fp_config['general']['blogid']);
  11.  
  12. if ( !defined('USER_COOKIE') )
  13.        define('USER_COOKIE', 'fpuser_'. COOKIEHASH);
  14. if ( !defined('PASS_COOKIE') )
  15.        define('PASS_COOKIE', 'fppass_'. COOKIEHASH);
  16. if ( !defined('SESS_COOKIE') )
  17.        define('SESS_COOKIE', 'fpsess_'. COOKIEHASH);
  18.  
  19. if ( !defined('COOKIEPATH') )
  20.        define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', BLOG_BASEURL ) );
  21. if ( !defined('SITECOOKIEPATH') )
  22.        define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', BLOG_BASEURL ) );
  23. if ( !defined('COOKIE_DOMAIN') )
  24.        define('COOKIE_DOMAIN', false);
  25.  
  26.  
  27. }
  28.  
  29. if ( !function_exists('wp_get_cookie_login') ):
  30. function wp_get_cookie_login() {
  31. if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) )
  32. return false;
  33.  
  34. return array('login' => $_COOKIE[USER_COOKIE], 'password' => $_COOKIE[PASS_COOKIE]);
  35. }
  36.  
  37. endif;
  38.  
  39. function cookie_set($username, $password, $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
  40. if ( !$already_md5 )
  41. $password = md5( md5($password) ); // Double hash the password in the cookie.
  42.  
  43. if ( empty($home) )
  44. $cookiepath = COOKIEPATH;
  45. else
  46. $cookiepath = preg_replace('|https?://[^/]+|i', '', $home . '/' );
  47.  
  48. if ( empty($siteurl) ) {
  49. $sitecookiepath = SITECOOKIEPATH;
  50. $cookiehash = COOKIEHASH;
  51. } else {
  52. $sitecookiepath = preg_replace('|https?://[^/]+|i', '', $siteurl . '/' );
  53. $cookiehash = md5($siteurl);
  54. }
  55.  
  56. if ( $remember )
  57. $expire = time() + 31536000;
  58. else
  59. $expire = 0;
  60.  
  61. setcookie(USER_COOKIE, $username, $expire, $cookiepath, COOKIE_DOMAIN);
  62. setcookie(PASS_COOKIE, $password, $expire, $cookiepath, COOKIE_DOMAIN);
  63.  
  64. if ( $cookiepath != $sitecookiepath ) {
  65. setcookie(USER_COOKIE, $username, $expire, $sitecookiepath, COOKIE_DOMAIN);
  66. setcookie(PASS_COOKIE, $password, $expire, $sitecookiepath, COOKIE_DOMAIN);
  67. }
  68. }
  69.  
  70. function cookie_clear() {
  71. setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
  72. setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
  73. setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
  74. setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
  75. }
  76.  
  77.  
  78. if ( !function_exists('wp_login') ) :
  79. function wp_login($username, $password, $already_md5 = false) {
  80. global $wpdb, $error;
  81.  
  82. $username = sanitize_user($username);
  83.  
  84. if ( '' == $username )
  85. return false;
  86.  
  87. if ( '' == $password ) {
  88. $error = __('<strong>ERROR</strong>: The password field is empty.');
  89. return false;
  90. }
  91.  
  92. $login = get_userdatabylogin($username);
  93. //$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'");
  94.  
  95. if (!$login) {
  96. $error = __('<strong>ERROR</strong>: Invalid username.');
  97. return false;
  98. } else {
  99. // If the password is already_md5, it has been double hashed.
  100. // Otherwise, it is plain text.
  101. if ( ($already_md5 && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) {
  102. return true;
  103. } else {
  104. $error = __('<strong>ERROR</strong>: Incorrect password.');
  105. $pwd = '';
  106. return false;
  107. }
  108. }
  109. }
  110. endif;
  111.  
  112. if ( !function_exists('is_user_logged_in') ) :
  113. function is_user_logged_in() {
  114. $user = wp_get_current_user();
  115.  
  116. if ( $user->id == 0 )
  117. return false;
  118.  
  119. return true;
  120. }
  121. endif;
  122.  
  123. if ( !function_exists('auth_redirect') ) :
  124. function auth_redirect() {
  125. // Checks if a user is logged in, if not redirects them to the login page
  126. if ( (!empty($_COOKIE[USER_COOKIE]) &&
  127. !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) ||
  128. (empty($_COOKIE[USER_COOKIE])) ) {
  129. nocache_headers();
  130.  
  131. wp_redirect(get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
  132. exit();
  133. }
  134. }
  135. endif;
  136.  
  137.  
  138. ?>

espero me ayuden.
4  Seguridad Informática / Bugs y Exploits / Re: <-> Taller de Stack Overflows en Windows, por Rojodos en: 25 Octubre 2007, 15:00 pm
exelente tu tutorial rojodos hasta ahora solo tenia una idea muy remota de lo que se tratava stack overflows ahora me quedo clarisimo.

gracias  :xD
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines