PageRenderTime 630ms CodeModel.GetById 513ms app.highlight 12ms RepoModel.GetById 101ms app.codeStats 0ms

/public_html/phorum/login.php

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