PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/web/trunk/forum/login.php

#
PHP | 156 lines | 112 code | 18 blank | 26 comment | 13 complexity | 418dfbbca5cb0fb0ccec007e5486c691 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // //
  4. // Copyright (C) 2000 Phorum Development Team //
  5. // http://www.phorum.org //
  6. // //
  7. // This program is free software. You can redistribute it and/or modify //
  8. // it under the terms of either the current Phorum License (viewable at //
  9. // phorum.org) or the Phorum License that was distributed with this file //
  10. // //
  11. // This program is distributed in the hope that it will be useful, //
  12. // but WITHOUT ANY WARRANTY, without even the implied warranty of //
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
  14. // //
  15. // You should have received a copy of the Phorum License //
  16. // along with this program. //
  17. ////////////////////////////////////////////////////////////////////////////////
  18. // register_globals picks up a sourceforge.net 'username' cookie... *sigh*
  19. $username = $_POST['username'];
  20. require "./common.php";
  21. settype($Error, "string");
  22. //Thats for all those ppl who likes to use different colors in different forums
  23. if($f>0){
  24. $table_width=$ForumTableWidth;
  25. $table_header_color=$ForumTableHeaderColor;
  26. $table_header_font_color=$ForumTableHeaderFontColor;
  27. $table_body_color_1=$ForumTableBodyColor1;
  28. $table_body_font_color_1=$ForumTableBodyFontColor1;
  29. $nav_color=$ForumNavColor;
  30. }
  31. else{
  32. $table_width=$default_table_width;
  33. $table_header_color=$default_table_header_color;
  34. $table_header_font_color=$default_table_header_font_color;
  35. $table_body_color_1=$default_table_body_color_1;
  36. $table_body_font_color_1=$default_table_body_font_color_1;
  37. $nav_color=$default_nav_color;
  38. }
  39. if(empty($target)){
  40. if(isset($HTTP_REFERER)){
  41. $target=$HTTP_REFERER;
  42. }
  43. else{
  44. $target="$forum_url/$forum_page.$ext";
  45. }
  46. }
  47. initvar("phorum_auth");
  48. // $target=str_replace("phorum_auth=$phorum_auth", '', $target);
  49. if(isset($logout)){
  50. $SQL="update $pho_main"."_auth set sess_id='' where sess_id='$phorum_auth'";
  51. $q->query($DB, $SQL);
  52. unset($phorum_auth);
  53. SetCookie("phorum_auth",'');
  54. header("Location: $target");
  55. exit();
  56. }
  57. if(empty($forgotpass) && !empty($username) && !empty($password)){
  58. $uid=phorum_check_login($username, $password);
  59. if($uid){
  60. $sess_id=phorum_session_id($_POST['username'], $_POST["password"]);
  61. phorum_login_user($sess_id, $uid);
  62. if(!strstr($target, "?")){
  63. $target.="?f=0$GetVars";
  64. }
  65. else{
  66. $target.="$GetVars";
  67. }
  68. header("Location: $target");
  69. exit();
  70. }
  71. else{
  72. $Error=$lLoginError;
  73. }
  74. }
  75. if(basename($PHP_SELF)=="login.$ext"){
  76. $title = " - $lLoginCaption";
  77. include phorum_get_file_name("header");
  78. }
  79. // hack
  80. $signup_page="register";
  81. //////////////////////////
  82. // START NAVIGATION //
  83. //////////////////////////
  84. $menu="";
  85. if($ActiveForums>1){
  86. addnav($menu, $lForumList, "$forum_page.$ext?f=0$GetVars");
  87. }
  88. addnav($menu, $lRegisterLink, "$signup_page.$ext?f=$f&target=$target$GetVars");
  89. $nav=getnav($menu);
  90. //////////////////////////
  91. // END NAVIGATION //
  92. //////////////////////////
  93. if($Error){
  94. echo "<p><strong>$Error</strong>";
  95. }
  96. ?>
  97. <form action="<?php echo "login.$ext"; ?>" method="post">
  98. <input type="hidden" name="f" value="<?php echo $f; ?>" />
  99. <input type="hidden" name="target" value="<?php echo $target; ?>" />
  100. <?php echo $PostVars; ?>
  101. <table cellspacing="0" cellpadding="0" border="0">
  102. <tr>
  103. <td <?php echo bgcolor($nav_color); ?>>
  104. <table cellspacing="0" cellpadding="2" border="0">
  105. <tr>
  106. <td><?php echo $nav; ?></td>
  107. </tr>
  108. </table>
  109. </td>
  110. </tr>
  111. <tr>
  112. <td <?php echo bgcolor($nav_color); ?>>
  113. <table class="PhorumListTable" cellspacing="0" cellpadding="2" border="0">
  114. <tr>
  115. <td height="21" colspan="2" <?php echo bgcolor($table_header_color); ?>><FONT color="<?php echo $table_header_font_color; ?>">&nbsp;<?php echo $lLoginCaption; ?></font></td>
  116. </tr>
  117. <tr>
  118. <td <?php echo bgcolor($table_body_color_1); ?> nowrap="nowrap"><font color="<?php echo $table_body_font_color_1; ?>">&nbsp;<?php echo $lUserName;?>:</font></td>
  119. <td <?php echo bgcolor($table_body_color_1); ?>><input type="Text" name="username" size="30" maxlength="50" /></td>
  120. </tr>
  121. <tr>
  122. <td <?php echo bgcolor($table_body_color_1); ?> nowrap="nowrap"><font color="<?php echo $table_body_font_color_1; ?>">&nbsp;<?php echo $lPassword;?>:</font></td>
  123. <td <?php echo bgcolor($table_body_color_1); ?>><input type="Password" name="password" size="30" maxlength="20" /></td>
  124. </tr>
  125. <tr>
  126. <td <?php echo bgcolor($table_body_color_1); ?> nowrap="nowrap">&nbsp;</td>
  127. <td <?php echo bgcolor($table_body_color_1); ?>><input type="submit" value="<?php echo $lLogin; ?>" />&nbsp;<br /><img src="images/trans.gif" width=3 height=3 border=0></td>
  128. </tr>
  129. </table>
  130. </td>
  131. </tr>
  132. </table>
  133. </form>
  134. <?php
  135. if(basename($PHP_SELF)=="login.$ext"){
  136. include phorum_get_file_name("footer");
  137. }
  138. ?>