b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (0.9.x) [ class tree: htsrv ] [ index: htsrv ] [ all elements ]

Source for file profile_update.php

Documentation is available at profile_update.php

  1. <?php
  2. /**
  3.  * This file updates the current user's profile!
  4.  *
  5.  * b2evolution - {@link http://b2evolution.net/}
  6.  * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  7.  * @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
  8.  *
  9.  * @package htsrv
  10.  */
  11.  
  12. /**
  13.  * Initialize everything:
  14.  */
  15. require_oncedirname(__FILE__'/../b2evocore/_main.php' );
  16.  
  17. // Getting GET or POST parameters:
  18. param'checkuser_id''integer''' );
  19. param'newuser_firstname''string''' );
  20. param'newuser_lastname''string''' );
  21. param'newuser_nickname''string''' );
  22. param'newuser_idmode''string''' );
  23. param'newuser_locale''string'$default_locale );
  24. param'newuser_icq''string''' );
  25. param'newuser_aim''string''' );
  26. param'newuser_msn''string''' );
  27. param'newuser_yim''string''' );
  28. param'newuser_url''string''' );
  29. param'newuser_email''string''' );
  30. param'newuser_notify''integer');
  31. param'pass1''string''' );
  32. param'pass2''string''' );
  33.  
  34. ifis_logged_in() )
  35. {    // must be logged in!
  36.     dieT_('You are not logged in.') );
  37. }
  38.  
  39. if$checkuser_id != $user_ID )
  40. {    // Can only edit your own profile
  41.     dieT_('You are not logged in under the same account you are trying to modify.') );
  42. }
  43.  
  44. if$demo_mode && ($user_login == 'demouser'))
  45. {
  46.     die'Demo mode: you can\'t edit the demouser profile!<br />[<a href="javascript:history.go(-1)">' 
  47.                 . T_('Back to profile''</a>]' );
  48. }
  49.  
  50. // checking the nickname has been typed
  51. if (empty($newuser_nickname))
  52. {
  53.     die ('<strong>' T_('ERROR''</strong>: ' T_('please enter your nickname (can be the same as your login)')
  54.                 . '<br />[<a href="javascript:history.go(-1)">' T_('Back to profile''</a>]' );
  55.     return false;
  56. }
  57.  
  58. // if the ICQ UIN has been entered, check to see if it has only numbers
  59. if (!empty($newuser_icq))
  60. {
  61.     if (!ereg("^[0-9]+$"$newuser_icq))
  62.     {
  63.         die ('<strong>' T_('ERROR''</strong>: ' T_('your ICQ UIN can only be a number, no letters allowed')
  64.                     . '<br />[<a href="javascript:history.go(-1)">' T_('Back to profile''</a>]' );
  65.         return false;
  66.     }
  67. }
  68.  
  69. // checking e-mail address
  70. if (empty($newuser_email))
  71. {
  72.     die ('<strong>' T_('ERROR''</strong>: ' T_('please type your e-mail address')
  73.                 . '<br />[<a href="javascript:history.go(-1)">' T_('Back to profile''</a>]' );
  74.     return false;
  75. }
  76. elseif (!is_email($newuser_email))
  77. {
  78.     die ('<strong>' T_('ERROR''</strong>: ' T_('the email address is invalid')
  79.                 . '<br />[<a href="javascript:history.go(-1)">' T_('Back to profile''</a>]' );
  80.     return false;
  81. }
  82.  
  83. if$error validate_url$newuser_url$comments_allowed_uri_scheme ) )
  84. {
  85.     die'<strong>' T_('ERROR''</strong>: ' T_('Supplied URL is invalid: '$error );
  86.     return false;
  87. }
  88.  
  89. if ($pass1 == '')
  90. {
  91.     if ($pass2 != '')
  92.     {
  93.         die ('<strong>' T_('ERROR''</strong>: ' T_('you typed your new password only once. Go back to type it twice.'));
  94.     }
  95.     $updatepassword '';
  96. }
  97. else
  98. {
  99.     if ($pass2 == '')
  100.     {
  101.         die ('<strong>' T_('ERROR''</strong>: ' T_('you typed your new password only once. Go back to type it twice.')
  102.                 . '<br />[<a href="javascript:history.go(-1)">' T_('Back to profile''</a>]' );
  103.     }
  104.     if ($pass1 != $pass2)
  105.     {
  106.         die ('<strong>' T_('ERROR''</strong>: ' T_('you typed two different passwords. Go back to correct that.')
  107.                 . '<br />[<a href="javascript:history.go(-1)">' T_('Back to profile''</a>]' );
  108.     }
  109.     
  110.     ifstrlen($pass1$Settings->get('user_minpwdlen') )
  111.     {
  112.         diesprintfT_('The mimimum password length is %d characters.')$Settings->get('user_minpwdlen'))
  113.                 . '<br />[<a href="javascript:history.go(-1)">' T_('Back to profile''</a>]' );
  114.     }
  115.  
  116.     $newuser_pass md5($pass1);
  117.     $updatepassword "user_pass = '$newuser_pass', ";
  118.     if!setcookie$cookie_pass$newuser_pass$cookie_expires$cookie_path$cookie_domain) )
  119.     {
  120.         printfT_('setcookie %s failed!')$cookie_pass );
  121.     }
  122. }
  123.  
  124.  
  125. $DB->query"UPDATE $tableusers 
  126.                                 SET $updatepassword
  127.                                         user_firstname= '".$DB->escape($newuser_firstname)."',
  128.                                         user_lastname= '".$DB->escape($newuser_lastname)."',
  129.                                         user_nickname= '".$DB->escape($newuser_nickname)."',
  130.                                         user_icq= '".$DB->escape($newuser_icq)."',
  131.                                         user_email= '".$DB->escape($newuser_email)."',
  132.                                         user_url= '".$DB->escape($newuser_url)."',
  133.                                         user_aim= '".$DB->escape($newuser_aim)."',
  134.                                         user_msn= '".$DB->escape($newuser_msn)."',
  135.                                         user_yim= '".$DB->escape($newuser_yim)."',
  136.                                         user_idmode= '".$DB->escape($newuser_idmode)."',
  137.                                         user_locale= '".$DB->escape($newuser_locale)."',
  138.                                         user_notify= $newuser_notify
  139.                             WHERE ID = $user_ID);
  140.  
  141. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  142. header('Last-Modified: ' gmdate('D, d M Y H:i:s'' GMT');
  143. header('Cache-Control: no-cache, must-revalidate');
  144. header('Pragma: no-cache');
  145.  
  146. param'redirect_to''string' );
  147. $location (!empty($redirect_to)) $redirect_to $_SERVER['HTTP_REFERER'];
  148. header('Refresh:0;url=' $location);
  149.  
  150. ?>

Documentation generated on Tue, 20 May 2008 01:51:57 +0200 by phpDocumentor 1.4.2