PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/public_html/old/phorum/login.php

https://gitlab.com/cherian/xmec
PHP | 224 lines | 172 code | 20 blank | 32 comment | 19 complexity | 2b45b3f66f44a5ed5b96d76662b52320 MD5 | raw file
  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. require "./common.php";
  19. settype($Error, "string");
  20. //Thats for all those ppl who likes to use different colors in different forums
  21. if($f>0){
  22. $table_width=$ForumTableWidth;
  23. $table_header_color=$ForumTableHeaderColor;
  24. $table_header_font_color=$ForumTableHeaderFontColor;
  25. $table_body_color_1=$ForumTableBodyColor1;
  26. $table_body_font_color_1=$ForumTableBodyFontColor1;
  27. $nav_color=$ForumNavColor;
  28. }
  29. else{
  30. $table_width=$default_table_width;
  31. $table_header_color=$default_table_header_color;
  32. $table_header_font_color=$default_table_header_font_color;
  33. $table_body_color_1=$default_table_body_color_1;
  34. $table_body_font_color_1=$default_table_body_font_color_1;
  35. $nav_color=$default_nav_color;
  36. }
  37. if(empty($target)){
  38. if(isset($HTTP_REFERER)){
  39. $target=$HTTP_REFERER;
  40. }
  41. else{
  42. $target="$forum_url/$forum_page.$ext";
  43. }
  44. }
  45. if (!$xmec_user->isLoggedIn()) {
  46. if (!empty($lp)) {
  47. echo ' <HTML>',
  48. ' <BODY bgcolor="#FFFFFF" topmargin=0 leftmargin=0 marginheight = "0" marginwidth = "0">',
  49. ' <p><br>',
  50. 'Please login using your xmec username & password.<br>',
  51. /*
  52. 'Click <a href=', rawurlencode($target), '>here</a> to get the page, once logged in.',
  53. */
  54. '</body>';
  55. } else {
  56. echo ' <HTML>',
  57. ' <script language="JavaScript">',
  58. 'function loginpage() {',
  59. ' top.location.href="/xmec.php?target=', rawurlencode("/phorum/login.php?target=$target&lp=1"), '";',
  60. '}',
  61. '</script>',
  62. '<BODY bgcolor="#FFFFFF" topmargin=0 leftmargin=0 marginheight = "0" marginwidth = "0">',
  63. ' <p><br>',
  64. 'Please login first, using your xmec username & password to access this page.<br>',
  65. 'If you are not at the login page, click <a href=xx OnClick="JavaScript:loginpage();return false;">here</a> to get it.',
  66. '</body>';
  67. }
  68. exit();
  69. } else {
  70. header("Location: $target");
  71. exit();
  72. }
  73. // ******************************************************
  74. // ********** Nothing gets executed from here onwards..**
  75. // ******************************************************
  76. // initvar("phorum_auth");
  77. // $target=str_replace("phorum_auth=$phorum_auth", '', $target);
  78. if(isset($logout)){
  79. $SQL="update $pho_main"."_auth set sess_id='' where sess_id='$phorum_auth'";
  80. $q->query($DB, $SQL);
  81. unset($phorum_auth);
  82. SetCookie("phorum_auth",'');
  83. header("Location: $target");
  84. exit();
  85. }
  86. if(empty($forgotpass) && !empty($username) && !empty($password)){
  87. $uid=phorum_check_login($username, $password);
  88. if($uid){
  89. $sess_id=phorum_session_id($HTTP_POST_VARS['username'], $HTTP_POST_VARS["password"]);
  90. phorum_login_user($sess_id, $uid);
  91. if(!strstr($target, "?")){
  92. $target.="?f=0$GetVars";
  93. }
  94. else{
  95. $target.="$GetVars";
  96. }
  97. header("Location: $target");
  98. exit();
  99. }
  100. else{
  101. $Error=$lLoginError;
  102. }
  103. } elseif (!empty($forgotpass)) {
  104. $SQL="select username, email from $pho_main"."_auth where username='$lookup' or email='$lookup'";
  105. $q->query($DB, $SQL);
  106. $rec=$q->getrow();
  107. if(!empty($rec["username"])){
  108. $newpass=substr(md5($username.microtime()), 0, 8);
  109. $crypt_pass=md5($newpass);
  110. $SQL="update $pho_main"."_auth set password='$crypt_pass' where username='$rec[username]'";
  111. $q->query($DB, $SQL);
  112. mail($rec["email"], $lNewPassword, "$lNewPassBody:\n\n $lUserName: $rec[username]\n $lPassword: $newpass\n\n$lNewPassChange", "From: <$DefaultEmail>");
  113. $Error=$lNewPassMailed;
  114. } else {
  115. $Error=$lNewPassError;
  116. }
  117. }
  118. if(basename($PHP_SELF)=="login.$ext"){
  119. $title = " - $lLoginCaption";
  120. include phorum_get_file_name("header");
  121. }
  122. // hack
  123. $signup_page="register";
  124. //////////////////////////
  125. // START NAVIGATION //
  126. //////////////////////////
  127. $menu="";
  128. if($ActiveForums>1){
  129. addnav($menu, $lForumList, "$forum_page.$ext?f=0$GetVars");
  130. }
  131. addnav($menu, $lRegisterLink, "$signup_page.$ext?f=$f&target=$target$GetVars");
  132. $nav=getnav($menu);
  133. //////////////////////////
  134. // END NAVIGATION //
  135. //////////////////////////
  136. if($Error){
  137. echo "<p><b>$Error</b>";
  138. }
  139. ?>
  140. <form action="<?php echo "login.$ext"; ?>" method="post">
  141. <input type="hidden" name="f" value="<?php echo $f; ?>">
  142. <input type="hidden" name="target" value="<?php echo $target; ?>">
  143. <?php echo $PostVars; ?>
  144. <table cellspacing="0" cellpadding="0" border="0">
  145. <tr>
  146. <td <?php echo bgcolor($nav_color); ?>>
  147. <table cellspacing="0" cellpadding="2" border="0">
  148. <tr>
  149. <td><?php echo $nav; ?></td>
  150. </tr>
  151. </table>
  152. </td>
  153. </tr>
  154. <tr>
  155. <td <?php echo bgcolor($nav_color); ?>>
  156. <table class="PhorumListTable" cellspacing="0" cellpadding="2" border="0">
  157. <tr>
  158. <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>
  159. </tr>
  160. <tr>
  161. <td <?php echo bgcolor($table_body_color_1); ?> nowrap><font color="<?php echo $table_body_font_color_1; ?>">&nbsp;<?php echo $lUserName;?>:</font></td>
  162. <td <?php echo bgcolor($table_body_color_1); ?>><input type="Text" name="username" size="30" maxlength="50"></td>
  163. </tr>
  164. <tr>
  165. <td <?php echo bgcolor($table_body_color_1); ?> nowrap><font color="<?php echo $table_body_font_color_1; ?>">&nbsp;<?php echo $lPassword;?>:</font></td>
  166. <td <?php echo bgcolor($table_body_color_1); ?>><input type="Password" name="password" size="30" maxlength="20"></td>
  167. </tr>
  168. <tr>
  169. <td <?php echo bgcolor($table_body_color_1); ?> nowrap>&nbsp;</td>
  170. <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>
  171. </tr>
  172. </table>
  173. </td>
  174. </tr>
  175. </table>
  176. </form>
  177. <form action="<?php echo "login.$ext"; ?>" method="post">
  178. <input type="hidden" name="f" value="<?php echo $f; ?>" />
  179. <input type="hidden" name="target" value="<?php echo $target; ?>" />
  180. <input type="hidden" name="forgotpass" value="1" />
  181. <?php echo $PostVars; ?>
  182. <table cellspacing="0" cellpadding="0" border="0">
  183. <tr>
  184. <td <?php echo bgcolor($default_nav_color); ?>>
  185. <table class="PhorumListTable" width="400" cellspacing="0" cellpadding="2" border="0">
  186. <tr>
  187. <td height="21" <?php echo bgcolor($default_table_header_color); ?>><FONT color="<?php echo $default_table_header_font_color; ?>">&nbsp;<?php echo $lForgotPass; ?></font></td>
  188. </tr>
  189. <tr>
  190. <td <?php echo bgcolor($default_table_body_color_1); ?>><font color="<?php echo $default_table_body_font_color_1; ?>"><?php echo $lLostPassExplain; ?></font></td>
  191. </tr>
  192. <tr>
  193. <td align="center" <?php echo bgcolor($default_table_body_color_1); ?>><input type="Text" name="lookup" size="30" maxlength="50"> <input type="submit" value="<?php echo $lSubmit; ?>"></td>
  194. </tr>
  195. </table>
  196. </td>
  197. </tr>
  198. </table>
  199. </form>
  200. <?php
  201. if(basename($PHP_SELF)=="login.$ext"){
  202. include phorum_get_file_name("footer");
  203. }
  204. ?>