File: 1.13.3b/server/web/login.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008 PurplePixie Systems 6: 7: FreeNATS is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeNATS is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with FreeNATS. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: ob_start(); 24: require("include.php"); 25: $NATS->Start(); 26: 27: if ($NATS->Cfg->Get("site.auth","")=="http") // HTTP-AUTH 28: { 29: if (!isset($_SERVER['PHP_AUTH_USER'])) 30: { 31: $realm="FreeNATS ".date("Y-m-d H:i:s"); 32: header("WWW-Authenticate: Basic realm=\"".$realm."\""); 33: header("HTTP/1.0 401 Unauthorized"); 34: echo $NATS->Lang->Item("msg.loginfailed"); 35: exit(); 36: } 37: else 38: { 39: $username = $_SERVER['PHP_AUTH_USER']; 40: $password = $_SERVER['PHP_AUTH_PW']; 41: } 42: } 43: else 44: { 45: if (isset($_REQUEST['naun'])) $username=$_REQUEST['naun']; 46: else $username=""; 47: if (isset($_REQUEST['napw'])) $password=$_REQUEST['napw']; 48: else $password=""; 49: } 50: 51: if ($NATS_Session->Create($NATS->DB,$username,$password)) 52: { 53: if ( isset($_REQUEST['nala']) && ($_REQUEST['nala']!="") ) 54: setcookie("fn_lang",$_REQUEST['nala']); 55: 56: $loc="main.php"; 57: if ($NATS->Cfg->Get("site.login.nocheck",0)!="1") 58: $loc.="?check_updates=1&quiet_check=1"; 59: if (isset($_REQUEST['url'])) $loc=$_REQUEST['url']; 60: 61: if ($NATS->Cfg->Get("freenats.firstrun")=="1") $loc="welcome.php"; 62: 63: header("Location: ".$loc); 64: exit(); 65: } 66: 67: header("Location: ./?msg=2"); 68: exit(); 69: ?>