PageRenderTime 295ms CodeModel.GetById 160ms app.highlight 8ms RepoModel.GetById 123ms app.codeStats 0ms

/web/trunk/forum/login.php

#
PHP | 156 lines | 112 code | 18 blank | 26 comment | 13 complexity | 418dfbbca5cb0fb0ccec007e5486c691 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  // register_globals picks up a sourceforge.net 'username' cookie... *sigh*
 20  $username = $_POST['username'];
 21
 22  require "./common.php";
 23
 24  settype($Error, "string");
 25
 26  //Thats for all those ppl who likes to use different colors in different forums
 27  if($f>0){
 28    $table_width=$ForumTableWidth;
 29    $table_header_color=$ForumTableHeaderColor;
 30    $table_header_font_color=$ForumTableHeaderFontColor;
 31    $table_body_color_1=$ForumTableBodyColor1;
 32    $table_body_font_color_1=$ForumTableBodyFontColor1;
 33    $nav_color=$ForumNavColor;
 34  }
 35  else{
 36    $table_width=$default_table_width;
 37    $table_header_color=$default_table_header_color;
 38    $table_header_font_color=$default_table_header_font_color;
 39    $table_body_color_1=$default_table_body_color_1;
 40    $table_body_font_color_1=$default_table_body_font_color_1;
 41    $nav_color=$default_nav_color;
 42  }
 43
 44  if(empty($target)){
 45    if(isset($HTTP_REFERER)){
 46      $target=$HTTP_REFERER;
 47    }
 48    else{
 49      $target="$forum_url/$forum_page.$ext";
 50    }
 51  }
 52
 53  initvar("phorum_auth");
 54
 55//  $target=str_replace("phorum_auth=$phorum_auth", '', $target);
 56
 57  if(isset($logout)){
 58    $SQL="update $pho_main"."_auth set sess_id='' where sess_id='$phorum_auth'";
 59    $q->query($DB, $SQL);
 60
 61    unset($phorum_auth);
 62    SetCookie("phorum_auth",'');
 63    header("Location: $target");
 64    exit();
 65  }
 66
 67  if(empty($forgotpass) && !empty($username) && !empty($password)){
 68    $uid=phorum_check_login($username, $password);
 69    if($uid){
 70      $sess_id=phorum_session_id($_POST['username'], $_POST["password"]);
 71      phorum_login_user($sess_id, $uid);
 72      if(!strstr($target, "?")){
 73        $target.="?f=0$GetVars";
 74      }
 75      else{
 76        $target.="$GetVars";
 77      }
 78      header("Location: $target");
 79      exit();
 80    }
 81    else{
 82      $Error=$lLoginError;
 83    }
 84  }
 85
 86  if(basename($PHP_SELF)=="login.$ext"){
 87    $title = " - $lLoginCaption";
 88    include phorum_get_file_name("header");
 89  }
 90
 91  // hack
 92  $signup_page="register";
 93
 94  //////////////////////////
 95  // START NAVIGATION     //
 96  //////////////////////////
 97
 98    $menu="";
 99    if($ActiveForums>1){
100      addnav($menu, $lForumList, "$forum_page.$ext?f=0$GetVars");
101    }
102    addnav($menu, $lRegisterLink, "$signup_page.$ext?f=$f&target=$target$GetVars");
103    $nav=getnav($menu);
104
105  //////////////////////////
106  // END NAVIGATION       //
107  //////////////////////////
108
109
110  if($Error){
111    echo "<p><strong>$Error</strong>";
112  }
113?>
114<form action="<?php echo "login.$ext"; ?>" method="post">
115<input type="hidden" name="f" value="<?php echo $f; ?>" />
116<input type="hidden" name="target" value="<?php echo $target; ?>" />
117<?php echo $PostVars; ?>
118<table cellspacing="0" cellpadding="0" border="0">
119<tr>
120    <td <?php echo bgcolor($nav_color); ?>>
121      <table cellspacing="0" cellpadding="2" border="0">
122        <tr>
123          <td><?php echo $nav; ?></td>
124        </tr>
125      </table>
126    </td>
127</tr>
128<tr>
129    <td <?php echo bgcolor($nav_color); ?>>
130        <table class="PhorumListTable" cellspacing="0" cellpadding="2" border="0">
131        <tr>
132            <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>
133        </tr>
134        <tr>
135            <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>
136            <td <?php echo bgcolor($table_body_color_1); ?>><input type="Text" name="username" size="30" maxlength="50" /></td>
137        </tr>
138        <tr>
139            <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>
140            <td <?php echo bgcolor($table_body_color_1); ?>><input type="Password" name="password" size="30" maxlength="20" /></td>
141        </tr>
142        <tr>
143            <td <?php echo bgcolor($table_body_color_1); ?> nowrap="nowrap">&nbsp;</td>
144            <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>
145        </tr>
146        </table>
147    </td>
148</tr>
149</table>
150</form>
151
152<?php
153  if(basename($PHP_SELF)=="login.$ext"){
154    include phorum_get_file_name("footer");
155  }
156?>