PageRenderTime 2ms CodeModel.GetById 141ms app.highlight 12ms RepoModel.GetById 129ms app.codeStats 0ms

/old/phorum/login.php

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