A lightweight forum engine written in PHP. Repository is now obsolete and read-only. http://www.pioder.pl/uforum.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
4.3 KiB

  1. <?php
  2. /**
  3. * @package uForum
  4. * @file register.php
  5. * @version $Id$
  6. * @copyright 2007-2010 (c) PioDer <pioder@wp.pl>
  7. * @link http://www.pioder.pl/
  8. * @license see LICENSE.txt
  9. **/
  10. define('IN_uF', true);
  11. //include files
  12. require('./config.php');
  13. require('./includes/constants.php');
  14. require('./includes/db.php');
  15. require('./includes/errors.php');
  16. //connect to database
  17. DataBase::db_connect();
  18. require('./includes/sessions.php');
  19. require('./includes/classes/class_user.php');
  20. require('./common.php');
  21. require('./includes/misc_functions.php');
  22. require('./includes/classes/class_forum.php');
  23. require('./includes/classes/class_posting.php');
  24. require('./includes/classes/class_topic.php');
  25. require('./includes/emailer.php');
  26. require('./includes/classes/class_mod.php');
  27. require('./includes/classes/secure.php');
  28. $default_lang = DefaultLang();
  29. require('./lngs/'.$default_lang.'/main.php');
  30. require('./lngs/'.$default_lang.'/email.php');
  31. $start = TimeGeneration();
  32. SessDelInvalid();
  33. SessRegister();
  34. SessDeleteOld();
  35. $default_skin = ViewSkinName();
  36. $msg='';
  37. if ($_SESSION['uid']>0)
  38. {
  39. message_forum($lng['youareexist'],'index.php');
  40. }
  41. foreach ($_POST as $name => $value)
  42. {
  43. if ($forum_config['use_censorlist'])
  44. {
  45. $_POST[$name] = Secure::UseCensorlist($value);
  46. }
  47. }
  48. $errors = false;
  49. if (isset($_POST['email']))
  50. {
  51. if (!ereg ("^.+@.+\..+$", $_POST['email']))
  52. {
  53. $errors = true;
  54. $message = $lng['invalid_email'];
  55. }
  56. if (trim($_POST['nick'])=='')
  57. {
  58. $errors = true;
  59. $message = $lng['empty_nick'];
  60. }
  61. if ($_POST['password']=='')
  62. {
  63. $errors = true;
  64. $message = $lng['empty_password'];
  65. }
  66. if ($_POST['confirmpassword']=='')
  67. {
  68. $errors = true;
  69. $message = $lng['empty_password'];
  70. }
  71. if ($_POST['valid_match']!=$_POST['valid_key'])
  72. {
  73. $errors = true;
  74. $message = $lng['key_not_valid'];
  75. }
  76. if ($_POST['password']!=$_POST['confirmpassword'])
  77. {
  78. $errors = true;
  79. $message=$lng['incorrect_password2'];
  80. }
  81. if (!$errors)
  82. {
  83. $nick = addslashes(strip_tags($_POST['nick']));
  84. $sql = "SELECT `nick` FROM `".USERS_TABLE."` WHERE `nick`='$nick'";
  85. $query = DataBase::sql_query($sql,GENERAL,'Could not obtain user information.');
  86. $result = DataBase::fetch($query);
  87. if ($nick == $result['nick'])
  88. {
  89. $errors = true;
  90. $message = $lng['user_is_exist'];
  91. }
  92. }
  93. if (!$errors)
  94. {
  95. $_POST['nick']= addslashes(strip_tags($_POST['nick']));
  96. $original_pass = addslashes($_POST['password']);
  97. $_POST['password']=md5($_POST['password']);
  98. User::CreateProfile($_POST['nick'],$_POST['password'], $_POST['email'],0,1,0,1,'','','');
  99. $stop = TimeGeneration();
  100. if ($forum_config['allow_send_email'])
  101. {
  102. SendRegisterEmail();
  103. }
  104. message_forum($lng['account_created'],'index.php');
  105. }
  106. else
  107. {
  108. $msg = './skins/'.$default_skin.'/post_error_body.tpl';
  109. }
  110. }
  111. else
  112. {
  113. $_POST['nick']='';
  114. $_POST['email']='';
  115. $_POST['interests']='';
  116. $_POST['sig']='';
  117. $_POST['avatar']='';
  118. }
  119. $match_array = Secure::generate_code();
  120. //add skin variables
  121. $skin = array(
  122. //labels profile
  123. 'lnick' => $lng['user_name'],
  124. 'lpass' => $lng['lpassw'],
  125. 'lnewpass' => $lng['new_password'],
  126. 'lcpass' => $lng['confirm_password'],
  127. 'lemail' => 'E-mail',
  128. 'lgg' => $lng['gg_number'],
  129. 'lallow_gg' => $lng['allow_gg'],
  130. 'lallow_email' => $lng['allow_email'],
  131. 'lallow_qr' => $lng['allow_qr'],
  132. 'linterests' => $lng['luinterests'],
  133. 'lsig' => $lng['sig'],
  134. 'lavaddr' => $lng['picture_adress'],
  135. 'lmatch'=> $match_array[0].' + '.$match_array[1].' = ',
  136. 'valid_key' => $match_array[2],
  137. 'lovpr' => $lng['general_settings'],
  138. 'lupr' => $lng['profile_settings'],
  139. 'lspr' => $lng['signature_settings'],
  140. 'lapr' => $lng['avatar_settings'],
  141. 'lsubmit' => $lng['save'],
  142. 'lreset' => $lng['reset'],
  143. 'no' => $lng['no'],
  144. 'yes' => $lng['yes'],
  145. 'pa_link'=>''
  146. );
  147. $_POST['allow_gg']='1';
  148. $skin = array_push_assoc($skin, GenerateHeader($lng['lregister'], '<a href="register.php" class="navigator">'.$lng['lregister']));
  149. if ($msg=='')
  150. {
  151. $msg = './skins/'.$default_skin.'/blank.tpl';
  152. }
  153. //do it!
  154. require('./skins/'.$default_skin.'/overall_header.tpl');
  155. require('./skins/'.$default_skin.'/register_body.tpl');
  156. $stop = TimeGeneration();
  157. $skin['queries'] = ShowQueries($start, $stop);
  158. require('./skins/'.$default_skin.'/overall_footer.tpl');
  159. ?>